Open DoDoENT opened 2 years ago
Interesting, since this happens with Android too it seems likely to be an upstream bug in llvm. Do you have local/desktop build you could try with tip-of-tree llvm and thisLTO to confirm this?
Do you have local/desktop build you could try with tip-of-tree llvm and thinLTO to confirm this?
I can try with desktop build using upstream LLVM 13, but I guess that emscripten uses more recent version of LLVM.
I can try building the tip-of-tree LLVM, but not this week (it takes quite a time to build it on my machine...).
Great. I think it would be interesting to see if LLVM 13 has this issue. Do you happen to know what version of llvm is shipped in Android NDK r23?
I'm guessing you can't test with older versions of emscripten because we had other issues that prevented you running a thinLTO build?
Great. I think it would be interesting to see if LLVM 13 has this issue. Do you happen to know what version of llvm is shipped in Android NDK r23?
r23 is based on LLVM 12. But so is Xcode 13, which (at least for Intel Mac) builds the same code correctly using ThinLTO (haven't tested iOS and M1 mac build yet).
I'm guessing you can't test with older versions of emscripten because we had other issues that prevented you running a thinLTO build?
Correct, see this issue and this issue (for the second one I still haven't tested with thinLTO, but I since it's a binaryen issue, it's probably present).
Note that by using full LTO I don't get crash (neither on emscripten nor with Android NDK), but the linking time is rather long - this is why I'm experimenting with ThinLTO in the first place, after a suggestion by Danila Kutenin (@danlark1) from this CppCon talk.
Same crash also on LLVM 13 linux.
My guess is that it's somehow lld-related, since it works on Mac, where ld64 is used instead of lld.
Interestingly, if I put -flto
on files that define symbols for which instruction selection triggers the crash above, I can get Android and Linux build to work (most of the files are still under ThinLTO, which gives good compilation times - only several files are under monolithic LTO regime).
Unfortunately, on emscripten, this causes a different crash - this time in parser (?!?). However, I believe that this is something 2.0.33-related, as the same file could be normally parsed and compiled with 2.0.31 (the last emscripten that I can successfully use, but only with monolithic LTO).
The parser stack trace is (unfortunately I'm not at liberty of sharing the source code, even in preprocessed form):
Assertion failed: ((D.hasGlobalStorage() || (D.hasLocalStorage() && CGF.getContext().getLangOpts().OpenCLCPlusPlus)) && "VarDecl must have global or local (in the case of OpenCL) storage!"), function EmitDeclInit, file /opt/s/w/ir/cache/builder/emscripten-releases/llvm-project/clang/lib/CodeGen/CGDeclCXX.cpp, line 33.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /Users/dodo/.conan/data/emsdk_installer/2.0.33/microblink/stable/package/743cf0321be3152777da4d05247a66d1552e70a2/upstream/bin/clang++ -target wasm32-unknown-emscripten -fignore-exceptions -D__EMSCRIPTEN_major__=2 -D__EMSCRIPTEN_minor__=0 -D__EMSCRIPTEN_tiny__=33 -D_LIBCPP_ABI_VERSION=2 -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/SDL --sysroot=/Users/dodo/.conan/data/emsdk_installer/2.0.33/microblink/stable/package/743cf0321be3152777da4d05247a66d1552e70a2/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/compat -DALL_KEYS -DALL_SYMMETRIC_KEYS -DBOOST_NO_EXCEPTIONS -DBOOST_NO_RTTI -DBOOST_SWEATER_EXACT_WORKER_SELECTION=1 -DBOOST_SWEATER_SPIN_BEFORE_SUSPENSION=0 -DBOOST_SWEATER_USE_CALLER_THREAD=1 -DEIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS=16 -DEIGEN_CMAKE_INCLUDED -DEIGEN_DEFAULT_DENSE_INDEX_TYPE=std::int32_t -DEIGEN_DEFAULT_TO_ROW_MAJOR -DEIGEN_FAST_MATH -DEIGEN_MAX_STATIC_ALIGN_BYTES=16 -DEIGEN_MPL2_ONLY -DEIGEN_NO_AUTOMATIC_RESIZING -DEIGEN_STACK_ALLOCATION_LIMIT=0 -DENABLE_RESULT_SIGNATURE -DLOG_LEVEL=0 -DMB_ACCELERATE_Multithreaded=2 -DMB_ACCELERATE_Off=0 -DMB_ACCELERATE_Singlethreaded=1 -DMB_NN_API_BUILD=1 -DMB_NN_DLL=1 -DMB_NN_XNNPACK=1 -DMB_NOEXCEPT_EXCEPT_BADALLOC=TNUN_NOEXCEPT_EXCEPT_BADALLOC -DMB_USE_ACCELERATE=MB_ACCELERATE_Off -DNN_ALIGNED_MODELS -DNN_GRAPH_PER_LAYER_DEBUGGING=1 -DNN_MODEL_DEFAULT_ALIGNMENT=8 -DNN_MODEL_EXTENSION=.strop -DNN_USE_PROTECTION=1 -DNN_WINOGRAD=1 -DPRODUCT_ID=MB::Protection::Product::MicroBlinkCore -DPROTECT -DTNUN_MALLOC_OVERCOMMIT=TNUN_OVERCOMMIT_Partial -DTNUN_NOEXCEPT_EXCEPT_BADALLOC= -DTNUN_OVERCOMMIT_Disabled=0 -DTNUN_OVERCOMMIT_Full=2 -DTNUN_OVERCOMMIT_Partial=1 -DU_EXPORT= -DuECC_SUPPORTS_secp160r1=0 -DuECC_SUPPORTS_secp192r1=0 -DuECC_SUPPORTS_secp224r1=0 -DuECC_SUPPORTS_secp256r1=0 -DuECC_SUPPORTS_secp521r1=0 -I/Users/dodo/Work/Microblink/core-neural-network/NeuralNetwork/Source -I/Users/dodo/Work/Microblink/core-neural-network/NeuralNetwork/Include -I/Users/dodo/Work/Microblink/core-neural-network/NNUtils/Source -I/Users/dodo/Work/Microblink/core-neural-network/NNUtils/Include -I/Users/dodo/Work/Microblink/core-neural-network/MemoryMonitor/Source -I/Users/dodo/Work/Microblink/core-neural-network/MemoryMonitor/Include -isystem /Users/dodo/.conan/data/Eigen/3.3.9.2/microblink/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /Users/dodo/.conan/data/Eigen/3.3.9.2/microblink/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/unsupported -isystem /Users/dodo/.conan/data/CoreUtils/8.0.0/microblink/stable/package/743b1eac71af9dee88f7488b9a5a8fbf426c52d6/include -isystem /Users/dodo/.conan/data/CMakeBuild/17.0.0/nenad/testing/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /Users/dodo/.conan/data/LogAndTimer/2.1.8/microblink/stable/package/1b68a1022ab7ea21b45aebba237fa0b2cf6bc967/include -isystem /Users/dodo/.conan/data/Boost/1.75.1/microblink/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /Users/dodo/.conan/data/ConfigEx/1.0.4/microblink/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /Users/dodo/.conan/data/Functionoid/3.0.5/microblink/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /Users/dodo/.conan/data/Pimpl/1.0.3/microblink/stable/package/5a2681c47898ec950d41f4e071da2bbe213d4d2d/include -isystem /Users/dodo/.conan/data/RapidJSON/1.1.5/microblink/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /Users/dodo/.conan/data/UTFCpp/3.1.1/microblink/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /Users/dodo/.conan/data/Sweater/10.1.0/microblink/stable/package/3a523ed3a17bb295e44bd8f47da137f5aff3f596/include -isystem /Users/dodo/.conan/data/cpuinfo/3.0.4/microblink/stable/package/018b01f29ee14620abcb123d984bf08e23e5007b/include -isystem /Users/dodo/.conan/data/ConcurrentQueue/3.0.2/microblink/stable/package/12895d81e42ab236ed6e3b6c1cbda7b1120b44cb/include -isystem /Users/dodo/.conan/data/Err/1.1.4/microblink/stable/package/12895d81e42ab236ed6e3b6c1cbda7b1120b44cb/include -isystem /Users/dodo/.conan/data/OpenCV/4.5.3.1/microblink/stable/package/5201d8ac0e988aa9006addf923417b891578f6d6/include -isystem /Users/dodo/.conan/data/MMap/0.3.1/microblink/stable/package/295bf22980c266f264805adb55ba01c37880f102/include -isystem /Users/dodo/.conan/data/icu/69.1.4/microblink/stable/package/c66be85e85fe0ae3ac63cdf045f1f794e6ba2c58/include -isystem /Users/dodo/.conan/data/range-v3/0.10.0/microblink/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /Users/dodo/.conan/data/Obfuscation/0.1.1/microblink/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /Users/dodo/.conan/data/Hash/8.0.3/microblink/stable/package/f452476940c585d877838cdfd918971803cbd5c7/include -isystem /Users/dodo/.conan/data/VersionAndPaths/2.2.0/microblink/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /Users/dodo/.conan/data/XNNPACK/20210616.1/microblink/stable/package/6a3e709b599442a83a4ea350c7afef2851910adc/include -isystem /Users/dodo/.conan/data/Protection/10.0.2/microblink/stable/package/5c09109a8ebbea11c7065510543c852e9db56984/include -isystem /Users/dodo/.conan/data/MicroECC/2.0.1/microblink/stable/package/97ef2861601bf6968459f53ddb9fa6c664c84a27/include -O3 -DNDEBUG -fvisibility-inlines-hidden -fstrict-aliasing -fstrict-enums -fvisibility=hidden -fvisibility-inlines-hidden -fPIC -std=gnu++2a -Wheader-guard -fdiagnostics-color -fenable-matrix -fno-PIC -mmutable-globals -mbulk-memory -mnontrapping-fptoint -msign-ext -msimd128 -fomit-frame-pointer -ffunction-sections -fmerge-all-constants -fno-stack-protector -DNDEBUG -fno-unwind-tables -fno-asynchronous-unwind-tables -flto=thin -fno-exceptions -fno-rtti -fno-threadsafe-statics -ffast-math -ffp-contract=fast -Wall -Wextra -Wstrict-aliasing -Wdocumentation -Werror -Wno-error=deprecated-declarations -Wno-error=#warnings -Wno-error=unknown-attributes -Wno-unused-command-line-argument -include/Users/dodo/.conan/data/CMakeBuild/17.0.0/nenad/testing/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/banned.h -O3 -fvectorize -fslp-vectorize -funroll-loops -Wno-sign-compare -std=gnu++20 -flto -MD -MT CMakeFiles/NeuralNetwork.dir/NeuralNetwork/Source/Math/biased_matmul.cpp.o -MF CMakeFiles/NeuralNetwork.dir/NeuralNetwork/Source/Math/biased_matmul.cpp.o.d -c -pthread /Users/dodo/Work/Microblink/core-neural-network/NeuralNetwork/Source/Math/biased_matmul.cpp -o CMakeFiles/NeuralNetwork.dir/NeuralNetwork/Source/Math/biased_matmul.cpp.o
1. /Users/dodo/Work/Microblink/core-neural-network/NeuralNetwork/Source/Math/biased_matmul.cpp:1362:148: current parser token ';'
2. /Users/dodo/Work/Microblink/core-neural-network/NeuralNetwork/Source/Math/biased_matmul.cpp:28:1: parsing namespace 'MB'
3. /Users/dodo/Work/Microblink/core-neural-network/NeuralNetwork/Source/Math/biased_matmul.cpp:31:1: parsing namespace 'MB::Math'
4. /Users/dodo/Work/Microblink/core-neural-network/NeuralNetwork/Source/Math/biased_matmul.cpp:1322:6: instantiating function definition 'MB::Math::biased_matmul_st_block<MB::Math::Postprocessing::NOP>'
5. /Users/dodo/Work/Microblink/core-neural-network/NeuralNetwork/Source/Math/biased_matmul.cpp:1322:6: LLVM IR generation of declaration 'MB::Math::biased_matmul_st_block'
6. /Users/dodo/Work/Microblink/core-neural-network/NeuralNetwork/Source/Math/biased_matmul.cpp:1322:6: Generating code for declaration 'MB::Math::biased_matmul_st_block'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 libLLVM.dylib 0x0000000115f6e0db llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 43
1 libLLVM.dylib 0x0000000115f6cea8 llvm::sys::RunSignalHandlers() + 248
2 libLLVM.dylib 0x0000000115f6d510 llvm::sys::CleanupOnSignal(unsigned long) + 208
3 libLLVM.dylib 0x0000000115e8048a (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) + 106
4 libLLVM.dylib 0x0000000115e8067e CrashRecoverySignalHandler(int) + 110
5 libsystem_platform.dylib 0x00007ff8074e7e2d _sigtramp + 29
6 libsystem_platform.dylib 0x00007ff7b44f6948 _sigtramp + 18446744072317102904
7 libsystem_c.dylib 0x00007ff80741ed10 abort + 123
8 libsystem_c.dylib 0x00007ff80741e0be err + 0
9 libclang-cpp.dylib 0x000000011033f64a clang::CodeGen::CodeGenFunction::EmitCXXGlobalVarDeclInit(clang::VarDecl const&, llvm::Constant*, bool) + 3178
10 libclang-cpp.dylib 0x00000001105c8c43 (anonymous namespace)::ItaniumCXXABI::EmitGuardedInit(clang::CodeGen::CodeGenFunction&, clang::VarDecl const&, llvm::GlobalVariable*, bool) + 2563
11 libclang-cpp.dylib 0x000000011033285d clang::CodeGen::CodeGenFunction::AddInitializerToStaticVarDecl(clang::VarDecl const&, llvm::GlobalVariable*) + 701
12 libclang-cpp.dylib 0x00000001103310cf clang::CodeGen::CodeGenFunction::EmitStaticVarDecl(clang::VarDecl const&, llvm::GlobalValue::LinkageTypes) + 255
13 libclang-cpp.dylib 0x00000001103341e7 clang::CodeGen::CodeGenFunction::EmitAutoVarAlloca(clang::VarDecl const&) + 855
14 libclang-cpp.dylib 0x0000000110330df5 clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) + 293
15 libclang-cpp.dylib 0x0000000110330801 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) + 369
16 libclang-cpp.dylib 0x00000001104c23eb clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) + 155
17 libclang-cpp.dylib 0x00000001104b6cd2 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) + 594
18 libclang-cpp.dylib 0x00000001104b5be4 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) + 164
19 libclang-cpp.dylib 0x00000001104c34c0 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) + 512
20 libclang-cpp.dylib 0x0000000110526e4e clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 1630
21 libclang-cpp.dylib 0x000000011054603e clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) + 446
22 libclang-cpp.dylib 0x000000011053e978 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) + 488
23 libclang-cpp.dylib 0x0000000110542c95 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) + 1237
24 libclang-cpp.dylib 0x000000011054a5eb clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 2603
25 libclang-cpp.dylib 0x00000001105e9ddf (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) + 159
26 libclang-cpp.dylib 0x0000000110518c15 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) + 181
27 libclang-cpp.dylib 0x0000000110130b5f clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) + 2911
28 libclang-cpp.dylib 0x000000010ffe8038 clang::Sema::ActOnExplicitInstantiation(clang::Scope*, clang::SourceLocation, clang::SourceLocation, clang::Declarator&) + 5080
29 libclang-cpp.dylib 0x000000010f13b36c clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) + 412
30 libclang-cpp.dylib 0x000000010f13c9f9 clang::Parser::ParseDeclarationAfterDeclarator(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&) + 105
31 libclang-cpp.dylib 0x000000010f1ff444 clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) + 2628
32 libclang-cpp.dylib 0x000000010f1fd305 clang::Parser::ParseExplicitInstantiation(clang::DeclaratorContext, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) + 181
33 libclang-cpp.dylib 0x000000010f1fd17a clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) + 282
34 libclang-cpp.dylib 0x000000010f130ea6 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributesWithRange&, clang::SourceLocation*) + 726
35 libclang-cpp.dylib 0x000000010f21268f clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) + 175
36 libclang-cpp.dylib 0x000000010f155601 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) + 209
37 libclang-cpp.dylib 0x000000010f154f8a clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) + 7386
38 libclang-cpp.dylib 0x000000010f130f22 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributesWithRange&, clang::SourceLocation*) + 850
39 libclang-cpp.dylib 0x000000010f21268f clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) + 175
40 libclang-cpp.dylib 0x000000010f155601 clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo, 4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) + 209
41 libclang-cpp.dylib 0x000000010f154f8a clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) + 7386
42 libclang-cpp.dylib 0x000000010f130f22 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributesWithRange&, clang::SourceLocation*) + 850
43 libclang-cpp.dylib 0x000000010f21268f clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) + 175
44 libclang-cpp.dylib 0x000000010f210c28 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) + 1176
45 libclang-cpp.dylib 0x000000010f1191ad clang::ParseAST(clang::Sema&, bool, bool) + 749
46 libclang-cpp.dylib 0x0000000110b297e3 clang::FrontendAction::Execute() + 99
47 libclang-cpp.dylib 0x0000000110aa407f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 831
48 libclang-cpp.dylib 0x0000000110bae26c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 540
49 clang-14 0x000000010ba0817e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 1438
50 clang-14 0x000000010ba05ddb ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) + 283
51 libclang-cpp.dylib 0x000000011075b027 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >*, bool*) const::$_1>(long) + 23
52 libLLVM.dylib 0x0000000115e8039c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 236
53 libclang-cpp.dylib 0x000000011075aa91 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >*, bool*) const + 305
54 libclang-cpp.dylib 0x0000000110725926 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const + 726
55 libclang-cpp.dylib 0x0000000110725d5d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__2::pair<int, clang::driver::Command const*> >&) const + 125
56 libclang-cpp.dylib 0x000000011073f01c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__2::pair<int, clang::driver::Command const*> >&) + 396
57 clang-14 0x000000010ba053f4 main + 10868
58 dyld 0x000000011a2b14fe start + 462
One difference with emscripten is that we also do LTO of the all the system libraries too. Can you try disabling that to see if that makes the problem go away.
(To do this you would need to modity get_base_cflags
in tools/system_libs.py
and remove the flags += ['-flto=' + settings.LTO]
line and then run emcc --clear-cache
).. when the cache rebuilds the system libs should be non-LTO
I can try that next week but I don't have high hopes that it will help as the same crash also happens on Android NDK where the system libraries are not built with -flto
(I've built them manually for our case, but kept the possibility to use the default ones just in case a client requires us to link an ABI-compatible system lib).
I've tried both using default system NDK libs and my own (that are built with LTO) and a crash happened in both cases.
Same crash also on LLVM 13 Linux.
My guess is that it's somehow lld-related since it works on Mac, where ld64 is used instead of lld.
I also plan to test using gold instead of LLD next week. I have a hunch that this is LLD-related because both Xcode 13 and Android NDK r23 are built from similar commits. My assumption is based on the bug that we encountered on both NDK r23 and Xcode 13, which is, ironically, also LTO-related. Furthermore, the files on which I had to put -flto
to work around this issue, as described above, are also heavy users of clang's builtin matrix support.
🤔, maybe those two bugs are somehow related.
Have a nice weekend!
Unfortunately, on emscripten, this causes a different crash - this time in parser (?!?). However, I believe that this is something 2.0.33-related, as the same file could be normally parsed and compiled with 2.0.31 (the last emscripten that I can successfully use, but only with monolithic LTO).
I've reported this as a new issue and I've been successful in creating a repro case for that.
I also plan to test using gold instead of LLD next week. I have a hunch that this is LLD-related because both Xcode 13 and Android NDK r23 are built from similar commits
The hunch was wrong - I get the same crash also when using gold 😞 (tested on Linux since NDK dropped support for gold and emscripten never had it (AFAIK)).
Just found this on Twitter - it's got a very similar stack trace to ours and it's reported here (crash in DAG legalizer).
I'm experimenting with using ThinLTO instead of monolithic LTO for my builds. However, when building my code with ThinLTO enabled, I get the following crash:
Unfortunately, I don't have the minimum reproducible case at the moment and the crash happens with proprietary code that I'm not at liberty to share. I hope the stack trace will be enough for you to determine the cause of the crash.
Emscripten version: 2.0.33 Host: Mac OS Monterey
Note: The exact same crash happens also with Android NDK r23