fpco / inline-c

284 stars 51 forks source link

Test failures on Apple Silicon #127

Closed domenkozar closed 11 months ago

domenkozar commented 3 years ago
these derivations will be built:
  /nix/store/5y7sy3wqnqk06gd12p6bmp0vmxpm2nrx-inline-c-cpp-0.4.0.3.drv
waiting for locks or build slots...
building '/nix/store/5y7sy3wqnqk06gd12p6bmp0vmxpm2nrx-inline-c-cpp-0.4.0.3.drv'...
setupCompilerEnvironmentPhase
Build with /nix/store/m7njrg10v1mn89mqmjlwpdks9f9w3n2g-ghc-8.10.6.
unpacking sources
unpacking source archive /nix/store/88m8c6w1x9xni09y2fvi2czg04zfxhk5-inline-c-cpp-0.4.0.3.tar.gz
source root is inline-c-cpp-0.4.0.3
setting SOURCE_DATE_EPOCH to timestamp 1610995240 of file inline-c-cpp-0.4.0.3/inline-c-cpp.cabal
patching sources
compileBuildDriverPhase
setupCompileFlags: -package-db=/private/tmp/nix-build-inline-c-cpp-0.4.0.3.drv-0/setup-package.conf.d -j4 -threaded -rtsopts
[1 of 1] Compiling Main             ( Setup.hs, /private/tmp/nix-build-inline-c-cpp-0.4.0.3.drv-0/Main.o )
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
Linking Setup ...
updateAutotoolsGnuConfigScriptsPhase
configuring
configureFlags: --verbose --prefix=/nix/store/4nwbl2ifihqirabqcfmzn7m6z3mf2mhz-inline-c-cpp-0.4.0.3 --libdir=$prefix/lib/$compiler --libsubdir=$abi/$libname --docdir=/nix/store/2qxpxck5h0gl5lfg64ig1k2j11f6plcm-inline-c-cpp-0.4.0.3-doc/share/doc/inline-c-cpp-0.4.0.3 --with-gcc=clang --package-db=/private/tmp/nix-build-inline-c-cpp-0.4.0.3.drv-0/package.conf.d --ghc-options=-j4 --disable-split-objs --disable-library-profiling --disable-profiling --enable-shared --disable-coverage --enable-static --disable-executable-dynamic --enable-tests --disable-benchmarks --enable-library-vanilla --disable-library-for-ghci --extra-include-dirs=/nix/store/bsimh33mww300hcm1rj106ci02g0yvrd-libcxx-11.1.0-dev/include --extra-lib-dirs=/nix/store/f5nirjav817bv6wrqdqrxvy6g0ffs1vp-libcxx-11.1.0/lib --extra-include-dirs=/nix/store/303904q0nr7mv5qrdgmacd9hy5ws6c20-libcxxabi-11.1.0-dev/include --extra-lib-dirs=/nix/store/q65iy5a3jz4g10igwd0fch381cy37bb5-libcxxabi-11.1.0/lib --extra-lib-dirs=/nix/store/mz7i1ga12cb9zfpc29mq0782cfi449qf-compiler-rt-libc-11.1.0/lib --extra-lib-dirs=/nix/store/1998f6nswbff17vc97w62dvv8b131dak-ncurses-6.2/lib --extra-lib-dirs=/nix/store/mi7r8azivrjpi8m0yr84bbv6iip6702x-libffi-3.4.2/lib --extra-lib-dirs=/nix/store/zrj85hlkkfc3ifw87rvmmp15h83rayf2-gmp-6.2.1/lib --extra-include-dirs=/nix/store/imir2phxjscnyw7mnxzlv41wn9mhcw4j-libiconv-50/include --extra-lib-dirs=/nix/store/imir2phxjscnyw7mnxzlv41wn9mhcw4j-libiconv-50/lib --extra-framework-dirs=/nix/store/z54k7h2y1hcshfvgzb86lvb62s9x85nd-apple-framework-CoreFoundation-11.0.0/Library/Frameworks --extra-include-dirs=/nix/store/wxjwrich12j8zd7j33vr2zgk0c2y4mhy-libobjc-11.0.0/include --extra-lib-dirs=/nix/store/wxjwrich12j8zd7j33vr2zgk0c2y4mhy-libobjc-11.0.0/lib
Using Parsec parser
Configuring inline-c-cpp-0.4.0.3...
Flags chosen: std-vector-example=False
Dependency base >=4.7 && <5: using base-4.14.3.0
Dependency containers -any: using containers-0.6.5.1
Dependency inline-c >=0.9.0.0: using inline-c-0.9.1.5
Dependency safe-exceptions -any: using safe-exceptions-0.1.7.2
Dependency template-haskell -any: using template-haskell-2.16.0.0
Dependency base ==4.*: using base-4.14.3.0
Dependency containers -any: using containers-0.6.5.1
Dependency hspec -any: using hspec-2.7.10
Dependency inline-c -any: using inline-c-0.9.1.5
Dependency inline-c-cpp -any: using inline-c-cpp-0.4.0.3
Dependency safe-exceptions -any: using safe-exceptions-0.1.7.2
Dependency template-haskell -any: using template-haskell-2.16.0.0
Dependency vector -any: using vector-0.12.3.0
Source component graph:
    component lib
    component test:tests dependency lib
Configured component graph:
    component inline-c-cpp-0.4.0.3-A1Kz6vjoZAuIl4y8UdP5tB
        include base-4.14.3.0
        include containers-0.6.5.1
        include inline-c-0.9.1.5-AoXdJmx2DKD6JtbxHNTuqR
        include safe-exceptions-0.1.7.2-CO9bWjTaWu2CNZLbcWkM5F
        include template-haskell-2.16.0.0
    component inline-c-cpp-0.4.0.3-EcdfWSEtGUbH27lsRWFBtt-tests
        include base-4.14.3.0
        include containers-0.6.5.1
        include hspec-2.7.10-9kZZjX0DQR793Uvv1TKEpm
        include inline-c-0.9.1.5-AoXdJmx2DKD6JtbxHNTuqR
        include inline-c-cpp-0.4.0.3-A1Kz6vjoZAuIl4y8UdP5tB
        include safe-exceptions-0.1.7.2-CO9bWjTaWu2CNZLbcWkM5F
        include template-haskell-2.16.0.0
        include vector-0.12.3.0-BKW5RhsuKxHHdCukdcCkz7
Linked component graph:
    unit inline-c-cpp-0.4.0.3-A1Kz6vjoZAuIl4y8UdP5tB
        include base-4.14.3.0
        include containers-0.6.5.1
        include inline-c-0.9.1.5-AoXdJmx2DKD6JtbxHNTuqR
        include safe-exceptions-0.1.7.2-CO9bWjTaWu2CNZLbcWkM5F
        include template-haskell-2.16.0.0
        Language.C.Inline.Cpp=inline-c-cpp-0.4.0.3-A1Kz6vjoZAuIl4y8UdP5tB:Language.C.Inline.Cpp,Language.C.Inline.Cpp.Exceptions=inline-c-cpp-0.4.0.3-A1Kz6vjoZAuIl4y8UdP5tB:Language.C.Inline.Cpp.Exceptions
    unit inline-c-cpp-0.4.0.3-EcdfWSEtGUbH27lsRWFBtt-tests
        include base-4.14.3.0
        include containers-0.6.5.1
        include hspec-2.7.10-9kZZjX0DQR793Uvv1TKEpm
        include inline-c-0.9.1.5-AoXdJmx2DKD6JtbxHNTuqR
        include inline-c-cpp-0.4.0.3-A1Kz6vjoZAuIl4y8UdP5tB
        include safe-exceptions-0.1.7.2-CO9bWjTaWu2CNZLbcWkM5F
        include template-haskell-2.16.0.0
        include vector-0.12.3.0-BKW5RhsuKxHHdCukdcCkz7
Ready component graph:
    definite inline-c-cpp-0.4.0.3-A1Kz6vjoZAuIl4y8UdP5tB
        depends base-4.14.3.0
        depends containers-0.6.5.1
        depends inline-c-0.9.1.5-AoXdJmx2DKD6JtbxHNTuqR
        depends safe-exceptions-0.1.7.2-CO9bWjTaWu2CNZLbcWkM5F
        depends template-haskell-2.16.0.0
    definite inline-c-cpp-0.4.0.3-EcdfWSEtGUbH27lsRWFBtt-tests
        depends base-4.14.3.0
        depends containers-0.6.5.1
        depends hspec-2.7.10-9kZZjX0DQR793Uvv1TKEpm
        depends inline-c-0.9.1.5-AoXdJmx2DKD6JtbxHNTuqR
        depends inline-c-cpp-0.4.0.3-A1Kz6vjoZAuIl4y8UdP5tB
        depends safe-exceptions-0.1.7.2-CO9bWjTaWu2CNZLbcWkM5F
        depends template-haskell-2.16.0.0
        depends vector-0.12.3.0-BKW5RhsuKxHHdCukdcCkz7
Using Cabal-3.2.1.0 compiled by ghc-8.10
Using compiler: ghc-8.10.6
Using install prefix:
/nix/store/4nwbl2ifihqirabqcfmzn7m6z3mf2mhz-inline-c-cpp-0.4.0.3
Executables installed in:
/nix/store/4nwbl2ifihqirabqcfmzn7m6z3mf2mhz-inline-c-cpp-0.4.0.3/bin
Libraries installed in:
/nix/store/4nwbl2ifihqirabqcfmzn7m6z3mf2mhz-inline-c-cpp-0.4.0.3/lib/ghc-8.10.6/aarch64-osx-ghc-8.10.6/inline-c-cpp-0.4.0.3-A1Kz6vjoZAuIl4y8UdP5tB
Dynamic Libraries installed in:
/nix/store/4nwbl2ifihqirabqcfmzn7m6z3mf2mhz-inline-c-cpp-0.4.0.3/lib/ghc-8.10.6/aarch64-osx-ghc-8.10.6
Private executables installed in:
/nix/store/4nwbl2ifihqirabqcfmzn7m6z3mf2mhz-inline-c-cpp-0.4.0.3/libexec/aarch64-osx-ghc-8.10.6/inline-c-cpp-0.4.0.3
Data files installed in:
/nix/store/4nwbl2ifihqirabqcfmzn7m6z3mf2mhz-inline-c-cpp-0.4.0.3/share/aarch64-osx-ghc-8.10.6/inline-c-cpp-0.4.0.3
Documentation installed in:
/nix/store/2qxpxck5h0gl5lfg64ig1k2j11f6plcm-inline-c-cpp-0.4.0.3-doc/share/doc/inline-c-cpp-0.4.0.3
Configuration files installed in:
/nix/store/4nwbl2ifihqirabqcfmzn7m6z3mf2mhz-inline-c-cpp-0.4.0.3/etc
No alex found
Using ar found on system at:
/nix/store/fn10hhcprz2sjfx0ps5657k24kb7inj8-cctools-binutils-darwin-949.0.1/bin/ar
No c2hs found
No cpphs found
No doctest found
Using gcc version 11.1.0 given by user at:
/nix/store/id1jfmdc8h3xrxvbz8rhsab7jpwd4y45-clang-wrapper-11.1.0/bin/clang
Using ghc version 8.10.6 found on system at:
/nix/store/m7njrg10v1mn89mqmjlwpdks9f9w3n2g-ghc-8.10.6/bin/ghc
Using ghc-pkg version 8.10.6 found on system at:
/nix/store/m7njrg10v1mn89mqmjlwpdks9f9w3n2g-ghc-8.10.6/bin/ghc-pkg
No ghcjs found
No ghcjs-pkg found
No greencard found
Using haddock version 2.24.2 found on system at:
/nix/store/m7njrg10v1mn89mqmjlwpdks9f9w3n2g-ghc-8.10.6/bin/haddock
No happy found
Using haskell-suite found on system at: haskell-suite-dummy-location
Using haskell-suite-pkg found on system at: haskell-suite-pkg-dummy-location
No hmake found
Using hpc version 0.68 found on system at:
/nix/store/m7njrg10v1mn89mqmjlwpdks9f9w3n2g-ghc-8.10.6/bin/hpc
Using hsc2hs version 0.68.7 found on system at:
/nix/store/m7njrg10v1mn89mqmjlwpdks9f9w3n2g-ghc-8.10.6/bin/hsc2hs
Using hscolour version 1.24 found on system at:
/nix/store/ab3k6kf3j5sbmwjgvkgiaj29sxz7nsrx-hscolour-1.24.4/bin/HsColour
No jhc found
Using ld found on system at:
/nix/store/4jbmi4qkwa0g0316ri73iw8ksc4pl150-cctools-binutils-darwin-wrapper-949.0.1/bin/ld
No pkg-config found
Using runghc version 8.10.6 found on system at:
/nix/store/m7njrg10v1mn89mqmjlwpdks9f9w3n2g-ghc-8.10.6/bin/runghc
Using strip found on system at:
/nix/store/id1jfmdc8h3xrxvbz8rhsab7jpwd4y45-clang-wrapper-11.1.0/bin/strip
Using tar found on system at:
/nix/store/2rkvd2ddbs89xhfhjcac7yi9mjf9ra2p-gnutar-1.34/bin/tar
No uhc found
building
Preprocessing library for inline-c-cpp-0.4.0.3..
Building library for inline-c-cpp-0.4.0.3..
[1 of 2] Compiling Language.C.Inline.Cpp ( src/Language/C/Inline/Cpp.hs, dist/build/Language/C/Inline/Cpp.o, dist/build/Language/C/Inline/Cpp.dyn_o )

src/Language/C/Inline/Cpp.hs:11:1: warning: [-Wunused-imports]
    The import of ‘Data.Monoid’ is redundant
      except perhaps to import instances from ‘Data.Monoid’
    To import instances alone, use: import Data.Monoid()
   |
11 | import           Data.Monoid ((<>), mempty)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
[2 of 2] Compiling Language.C.Inline.Cpp.Exceptions ( src/Language/C/Inline/Cpp/Exceptions.hs, dist/build/Language/C/Inline/Cpp/Exceptions.o, dist/build/Language/C/Inline/Cpp/Exceptions.dyn_o )
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
ld: warning: /nix/store/imir2phxjscnyw7mnxzlv41wn9mhcw4j-libiconv-50/lib/libiconv.dylib, ignoring unexpected dylib file
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
ld: warning: /nix/store/imir2phxjscnyw7mnxzlv41wn9mhcw4j-libiconv-50/lib/libiconv.dylib, ignoring unexpected dylib file
Preprocessing test suite 'tests' for inline-c-cpp-0.4.0.3..
Building test suite 'tests' for inline-c-cpp-0.4.0.3..
[1 of 2] Compiling StdVector        ( test/StdVector.hs, dist/build/tests/tests-tmp/StdVector.o, dist/build/tests/tests-tmp/StdVector.dyn_o )
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
[2 of 2] Compiling Main             ( test/tests.hs, dist/build/tests/tests-tmp/Main.o, dist/build/tests/tests-tmp/Main.dyn_o )

<no location info>: warning: [-Wmissed-extra-shared-lib]
    dlopen(libstdc++.dylib, 5): image not found
    It's OK if you don't want to use symbols from it directly.
    (the package DLL is loaded by the system linker
     which manages dependencies by itself).
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
ld: warning: /nix/store/imir2phxjscnyw7mnxzlv41wn9mhcw4j-libiconv-50/lib/libiconv.dylib, ignoring unexpected dylib file
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
'apple-a7' is not a recognized processor for this target (ignoring processor)
ld: warning: /nix/store/imir2phxjscnyw7mnxzlv41wn9mhcw4j-libiconv-50/lib/libiconv.dylib, ignoring unexpected dylib file
Linking dist/build/tests/tests ...
running tests
Running 1 test suites...
Test suite tests: RUNNING...
Hello, world!3
3
100
1
libc++abi: terminating with uncaught exception of type std::runtime_error: C++ error message
Test suite tests: FAIL
Test suite logged to: dist/test/inline-c-cpp-0.4.0.3-tests.log
0 of 1 test suites (0 of 1 test cases) passed.
builder for '/nix/store/5y7sy3wqnqk06gd12p6bmp0vmxpm2nrx-inline-c-cpp-0.4.0.3.drv' failed with exit code 1
error: build of '/nix/store/5y7sy3wqnqk06gd12p6bmp0vmxpm2nrx-inline-c-cpp-0.4.0.3.drv' failed
bitonic commented 3 years ago

I don't have an M1 to test this with. It seems like something's going awry with the C++ exceptions tests.

roberth commented 2 years ago

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.

junjihashimoto commented 1 year ago

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.

roberth commented 1 year ago

@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.

131 can fix it for 9.2, but that hasn't been merged because we're currently without CI. I don't have time to configure GHA for it.

Nixpkgs will do the right thing for you if you use that.

junjihashimoto commented 1 year ago

@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
junjihashimoto commented 1 year ago

CI is necessary for 3 generations of stackage, intel and Apple. Would you like me to setup GHA?

roberth commented 1 year ago

Sure, go ahead.

junjihashimoto commented 11 months ago

The patch of -fcompact-unwind is merged. Thanks all!