Skip to content
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

Failed to compile project with -fwasm-exceptions that uses objc exceptions #23376

Open
Frityet opened this issue Jan 12, 2025 · 2 comments
Open
Assignees

Comments

@Frityet
Copy link

Frityet commented Jan 12, 2025

Please include the following in your bug report:

Version of emscripten/emsdk:
Please include the output emcc -v here

frityet@fritpc:~/objfw-1.2.3$ emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.74 (1092ec30a3fb1d46b1782ff1b4db5094d3d06ae5)
clang version 20.0.0git (https:/github.com/llvm/llvm-project 322eb1a92e6d4266184060346616fa0dbe39e731)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /emsdk/upstream/bin

(This is the latest, as of 25-01-12, version of the emscripten docker image)

Failing command line in full:
If this is compile or link-time failure please include the full failing command
along with its entire output.

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -mno-bulk-memory -mno-bulk-memory-opt -mno-nontrapping-fptoint -mllvm -combiner-global-alias-analysis=false -mllvm -wasm-enable-sjlj -mllvm -disable-lsr --sysroot=/emsdk/upstream/emscripten/cache/sysroot -DEMSCRIPTEN -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -fwasm-exceptions -Wall -fexceptions -fobjc-exceptions -funwind-tables -fconstant-string-class=OFConstantString -std=gnu11 -pipe -fno-common -Xclang -fno-constant-cfstrings -Wsign-compare -Wshadow -Wshorten-64-to-32 -Wundeclared-selector -Wsemicolon-before-method-body -Wobjc-missing-property-synthesis -Wmissing-method-return-type -Xclang -fobjc-runtime=objfw -Xclang -fblocks -Wwrite-strings -Wpointer-arith -Wcast-align -Wunreachable-code -Wdocumentation -pedantic -D_GNU_SOURCE -DOF_COMPILING_OBJFW -I. -I.. -I../.. -I../runtime -MD -MF OFAllocFailedException.dep -c OFAllocFailedException.m -o OFAllocFailedException.o
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'OFAllocFailedException.m'.
4.	Running pass 'WebAssembly Instruction Selection' on function '@_i_OFAllocFailedException__init'
#0 0x000055a2e4dfa888 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/emsdk/upstream/bin/clang+0x2ec6888)
#1 0x000055a2e4df7bee llvm::sys::RunSignalHandlers() (/emsdk/upstream/bin/clang+0x2ec3bee)
#2 0x000055a2e4df9adf llvm::sys::CleanupOnSignal(unsigned long) (/emsdk/upstream/bin/clang+0x2ec5adf)
#3 0x000055a2e4d5bac9 (/emsdk/upstream/bin/clang+0x2e27ac9)
#4 0x00007fec74242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x000055a2e61721b9 (/emsdk/upstream/bin/clang+0x423e1b9)
clang: error: clang frontend command failed with exit code 133 (use -v to see invocation)
clang version 20.0.0git (https:/github.com/llvm/llvm-project 322eb1a92e6d4266184060346616fa0dbe39e731)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /emsdk/upstream/bin
clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/OFAllocFailedException-198e1c.m
clang: note: diagnostic msg: /tmp/OFAllocFailedException-198e1c.sh
clang: note: diagnostic msg:

********************

/tmp/OFAllocFailedException-198e1c.m: https://gist.github.com/Frityet/e37e28716f1e579acb77d829223d6817
/tmp/OFAllocFailedException-198e1c.sh:

# Crash reproducer for clang version 20.0.0git (https:/github.com/llvm/llvm-project 322eb1a92e6d4266184060346616fa0dbe39e731)
# Driver args: "-target" "wasm32-unknown-emscripten" "-mno-bulk-memory" "-mno-bulk-memory-opt" "-mno-nontrapping-fptoint" "-mllvm" "-combiner-global-alias-analysis=false" "-mllvm" "-wasm-enable-sjlj" "-mllvm" "-disable-lsr" "--sysroot=/emsdk/upstream/emscripten/cache/sysroot" "-D" "EMSCRIPTEN" "-Werror=implicit-function-declaration" "-Xclang" "-iwithsysroot/include/fakesdl" "-Xclang" "-iwithsysroot/include/compat" "-fwasm-exceptions" "-Wall" "-fexceptions" "-fobjc-exceptions" "-funwind-tables" "-fconstant-string-class=OFConstantString" "-std=gnu11" "-pipe" "-fno-common" "-Xclang" "-fno-constant-cfstrings" "-Wsign-compare" "-Wshadow" "-Wshorten-64-to-32" "-Wundeclared-selector" "-Wsemicolon-before-method-body" "-Wobjc-missing-property-synthesis" "-Wmissing-method-return-type" "-Xclang" "-fobjc-runtime=objfw" "-Xclang" "-fblocks" "-Wwrite-strings" "-Wpointer-arith" "-Wcast-align" "-Wunreachable-code" "-Wdocumentation" "-pedantic" "-D" "_GNU_SOURCE" "-D" "OF_COMPILING_OBJFW" "-I" "." "-I" ".." "-I" "../.." "-I" "../runtime" "-MD" "-MF" "OFAllocFailedException.dep" "-c" "OFAllocFailedException.m" "-o" "OFAllocFailedException.o"
# Original command:  "/emsdk/upstream/bin/clang-20" "-cc1" "-triple" "wasm32-unknown-emscripten" "-emit-obj" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "OFAllocFailedException.m" "-mrelocation-model" "static" "-mframe-pointer=none" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=1" "-target-feature" "+exception-handling" "-mllvm" "-wasm-enable-eh" "-target-feature" "+multivalue" "-target-feature" "+reference-types" "-target-feature" "+exception-handling" "-exception-model=wasm" "-target-feature" "+multivalue" "-target-feature" "+reference-types" "-target-cpu" "generic" "-target-feature" "-bulk-memory" "-target-feature" "-bulk-memory-opt" "-target-feature" "-nontrapping-fptoint" "-fvisibility=hidden" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/home/frityet/Boxes/emscripten/objfw-1.2.3/src/exceptions" "-fcoverage-compilation-dir=/home/frityet/Boxes/emscripten/objfw-1.2.3/src/exceptions" "-resource-dir" "/emsdk/upstream/lib/clang/20" "-dependency-file" "OFAllocFailedException.dep" "-MT" "OFAllocFailedException.o" "-sys-header-deps" "-D" "EMSCRIPTEN" "-D" "_GNU_SOURCE" "-D" "OF_COMPILING_OBJFW" "-I" "." "-I" ".." "-I" "../.." "-I" "../runtime" "-isysroot" "/emsdk/upstream/emscripten/cache/sysroot" "-internal-isystem" "/emsdk/upstream/lib/clang/20/include" "-internal-isystem" "/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten" "-internal-isystem" "/emsdk/upstream/emscripten/cache/sysroot/include" "-Werror=implicit-function-declaration" "-Wall" "-Wsign-compare" "-Wshadow" "-Wshorten-64-to-32" "-Wundeclared-selector" "-Wsemicolon-before-method-body" "-Wobjc-missing-property-synthesis" "-Wmissing-method-return-type" "-Wwrite-strings" "-Wpointer-arith" "-Wcast-align" "-Wunreachable-code" "-Wdocumentation" "-pedantic" "-std=gnu11" "-fconst-strings" "-fconstant-string-class" "OFConstantString" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fobjc-runtime=gnustep" "-fobjc-encode-cxx-class-template-spec" "-fobjc-exceptions" "-fexceptions" "-exception-model=wasm" "-fcolor-diagnostics" "-iwithsysroot/include/fakesdl" "-iwithsysroot/include/compat" "-fno-constant-cfstrings" "-fobjc-runtime=objfw" "-fblocks" "-mllvm" "-combiner-global-alias-analysis=false" "-mllvm" "-wasm-enable-sjlj" "-mllvm" "-disable-lsr" "-o" "OFAllocFailedException.o" "-x" "objective-c" "OFAllocFailedException.m"
 "/emsdk/upstream/bin/clang-20" "-cc1" "-triple" "wasm32-unknown-emscripten" "-emit-obj" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "OFAllocFailedException.m" "-mrelocation-model" "static" "-mframe-pointer=none" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=1" "-target-feature" "+exception-handling" "-mllvm" "-wasm-enable-eh" "-target-feature" "+multivalue" "-target-feature" "+reference-types" "-target-feature" "+exception-handling" "-exception-model=wasm" "-target-feature" "+multivalue" "-target-feature" "+reference-types" "-target-cpu" "generic" "-target-feature" "-bulk-memory" "-target-feature" "-bulk-memory-opt" "-target-feature" "-nontrapping-fptoint" "-fvisibility=hidden" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/home/frityet/Boxes/emscripten/objfw-1.2.3/src/exceptions" "-fcoverage-compilation-dir=/home/frityet/Boxes/emscripten/objfw-1.2.3/src/exceptions" "-sys-header-deps" "-D" "EMSCRIPTEN" "-D" "_GNU_SOURCE" "-D" "OF_COMPILING_OBJFW" "-Werror=implicit-function-declaration" "-Wall" "-Wsign-compare" "-Wshadow" "-Wshorten-64-to-32" "-Wundeclared-selector" "-Wsemicolon-before-method-body" "-Wobjc-missing-property-synthesis" "-Wmissing-method-return-type" "-Wwrite-strings" "-Wpointer-arith" "-Wcast-align" "-Wunreachable-code" "-Wdocumentation" "-pedantic" "-std=gnu11" "-fconst-strings" "-fconstant-string-class" "OFConstantString" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fobjc-runtime=gnustep" "-fobjc-encode-cxx-class-template-spec" "-fobjc-exceptions" "-fexceptions" "-exception-model=wasm" "-fcolor-diagnostics" "-iwithsysroot/include/fakesdl" "-iwithsysroot/include/compat" "-fno-constant-cfstrings" "-fobjc-runtime=objfw" "-fblocks" "-mllvm" "-combiner-global-alias-analysis=false" "-mllvm" "-wasm-enable-sjlj" "-mllvm" "-disable-lsr" "-x" "objective-c" "OFAllocFailedException-198e1c.m"

Same result also occurs with emscripten running on macOS 13

❯ sw_vers
ProductName:		macOS
ProductVersion:		13.6.7
BuildVersion:		22G720
❯ emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.74-git
clang version 20.0.0git
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /usr/local/Cellar/emscripten/3.1.74/libexec/llvm/bin
@Frityet
Copy link
Author

Frityet commented Jan 12, 2025

Not sure if this is a proper LLVM issue or a LLVM issue caused by emscripten, so I will put it here for now and move it later if it is

@Frityet Frityet changed the title Failed to compile project that uses Objective-C exceptions Failed to compile project with -fwasm-exceptions that uses objc exceptions Jan 12, 2025
@Frityet
Copy link
Author

Frityet commented Jan 12, 2025

Ok it seems this is an LLVM issue, where the compiler crashes when -fwasm-exceptions is used when there is a @try block in objective C, I will make a new issue there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants