-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSVC Compiler 19.22.xxxxx generates invalid code which leads to inability to build libuserland #3024
Comments
going to put this here for posterity:
|
Can it be related to the optimizations? In radare2 we met with memmove optimization bug: https://developercommunity.visualstudio.com/content/problem/583227/vs-2019-cl-1921277022-memmove-instrinsic-optimizat.html |
Based on @XVilka's link, that could very well be our issue. Microsoft has acknowledged the bug and so eventually Azure will be updated with a patched MSVC. Until then I am testing the MinSizeRel workaround. |
The CI is using MinSizeRel to work around this issue. Thanks @mikdusan. I'm not actually able to reproduce it locally. Let's keep this issue open until the fix is widely available. |
I investigated this with
at The root cause is that building the global builtin function table corrupts memory while adding entries. They will then later not be available when trying to access them. The bug only occurs with CMake's set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
${CMAKE_CURRENT_SOURCE_DIR}/cxx_flag_overrides.cmake) if(MSVC)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob2 /D NDEBUG")
endif() Building target So I launched it via the debugger. Now, while running The disasm is create_builtin_fn(g, BuiltinFnIdErrorReturnTrace, "errorReturnTrace", 0);
00007FF625EE5219 lea edx,[r14+28h]
00007FF625EE521D lea ecx,[rdx-27h]
00007FF625EE5220 call qword ptr [__imp_calloc (07FF62C995030h)]
00007FF625EE5226 mov rsi,rax
00007FF625EE5229 test rax,rax
00007FF625EE522C je define_builtin_fns+2999h (07FF625EE5B59h)
00007FF625EE5232 lea rbx,[rax+8]
00007FF625EE5236 mov qword ptr [rbp+28h],rax
00007FF625EE523A mov rcx,rbx
00007FF625EE523D lea r8d,[r14+10h]
00007FF625EE5241 lea rdx,[string "errorReturnTrace" (07FF62A907A28h)]
00007FF625EE5248 call buf_init_from_mem (07FF625EDCE10h)
00007FF625EE524D lea r8,[rbp+28h]
00007FF625EE5251 mov qword ptr [rbp+30h],rbx
00007FF625EE5255 lea rdx,[rbp+30h]
00007FF625EE5259 mov rcx,rdi
00007FF625EE525C mov dword ptr [rax],65h
00007FF625EE5262 mov qword ptr [rax+20h],r14
00007FF625EE5266 call HashMap<Buf * __ptr64,BuiltinFnEntry * __ptr64,&buf_hash,&buf_eql_buf>::put (07FF625DA17F2h) This is basically If you look at the asm generated for the previous builtins, the part after the call to I'm pretty sure this is a codegen bug, but maybe not the one linked above. An easy workaround is to surround one of these two functions with |
Tested this again with
and
(Ob3 is a new flag in VS 2019) on compilers |
Something odd here. At my last update I tested I speculated that maybe this issue can be resolved by rebuilding LLVM with new compiler. Unfortunately I ran into difficulties rebuilding LLVM on my system and left that unresolved. Are you using your own LLVM dependency? update: |
This issue no longer plagues us since we use the wasm kernel for building from source rather than C++ code. |
Related to #2740
With the upgrade from 19.21 (VS 2017) to 19.22, Microsoft seems to have broken something related to our FNV hash implementation. Building libuserland leads to this error:
invalid builtin function: 'hasDecl'
The workaround is to use VS 2017 or build tools older than 19.22.
The text was updated successfully, but these errors were encountered: