Closed domenkozar closed 11 months ago
I don't have an M1 to test this with. It seems like something's going awry with the C++ exceptions tests.
This can be fixed with GHC patch https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7247 and then using -fcompact-unwind
.
Or, as "summarized" by https://github.com/NixOS/nixpkgs/pull/152037
Probably all GHC + C++ executables should use this flag, but I'm not 100% sure the ecosystem is ready for it. Hence a flag instead of an unconditional change in GHC behavior.
https://github.com/hasktorch/hasktorch/issues/631#issuecomment-1685155167
When I tested Apple Silicon, ghc-928 throws the error of uncaught exception
, but ghc-946 does not throw it.
The test uses ghc directly. It does not depend on inline-c-cpp.
It seems that it depends on ghc version.
@junjihashimoto -fcompact-unwind
is the default behavior since 9.4, so that makes sense. For 9.2 you can specify -fcompact-unwind
. Earlier versions are unaware that compact unwind data is required nowadays and still instruct the toolchain to remove compact unwind data.
Nixpkgs will do the right thing for you if you use that.
@roberth Thank you for your kind reply! The PR is great. It should be merged. In my case, the option(-fcompat-unwind) works.
% nix-shell -p haskell.compiler.ghc928
$ make
ghc -o a.out test.hs main.cpp -optl='-Wl,-keep_dwarf_unwind' -lc++
[1 of 1] Compiling Main ( test.hs, test.o )
Linking a.out ...
./a.out
12
libc++abi: terminating with uncaught exception of type std::logic_error: THIS FAILS!
make: *** [Makefile:3: all] Abort trap: 6
$ ghc -o a.out test.hs main.cpp -optl='-Wl,-keep_dwarf_unwind' -fcompact-unwind -lc++
Linking a.out ...
$ ./a.out
12
0
CI is necessary for 3 generations of stackage, intel and Apple. Would you like me to setup GHA?
Sure, go ahead.
The patch of -fcompact-unwind
is merged. Thanks all!