AnyarInc / Ascent

A fast and flexible C++ simulation engine and differential equation solver.
Apache License 2.0
123 stars 15 forks source link

Undefined symbols for architecture x86_64: "std::uncaught_exceptions()" #26

Closed barracuda156 closed 1 year ago

barracuda156 commented 1 year ago

On several versions of macOS x86_64 the build fails at linking:

[100%] Linking CXX executable ascent_test
cd /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_math_ascent/ascent/work/build/unit_tests && /opt/local/bin/cmake -E cmake_link_script CMakeFiles/ascent_test.dir/link.txt --verbose=ON
/opt/local/bin/clang++-mp-15 -pipe -Os -DNDEBUG -I/opt/local/include -stdlib=libc++ -arch x86_64 -mmacosx-version-min=10.10 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -L/opt/local/lib -Wl,-headerpad_max_install_names CMakeFiles/ascent_test.dir/src/main.cpp.o -o ascent_test  -Wl,-rpath,/opt/local/lib 
Undefined symbols for architecture x86_64:
  "std::uncaught_exceptions()", referenced from:
      Catch::ScopedMessage::~ScopedMessage() in main.cpp.o
      Catch::uncaught_exceptions() in main.cpp.o
      Catch::Capturer::~Capturer() in main.cpp.o
      Catch::Section::~Section() in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

On aarch64 it fails like this:

In file included from /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_math_ascent/ascent/work/Ascent-0.7.0/unit_tests/src/main.cpp:189:
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_math_ascent/ascent/work/Ascent-0.7.0/catch2/catch.hpp:8205:13: error: unrecognized instruction mnemonic, did you mean: bit, cnt, hint, ins, not?
            CATCH_BREAK_INTO_DEBUGGER();
            ^
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_math_ascent/ascent/work/Ascent-0.7.0/catch2/catch.hpp:7916:83: note: expanded from macro 'CATCH_BREAK_INTO_DEBUGGER'
        #define CATCH_BREAK_INTO_DEBUGGER() []{ if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } }()
                                                                                  ^
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_math_ascent/ascent/work/Ascent-0.7.0/catch2/catch.hpp:7881:34: note: expanded from macro 'CATCH_TRAP'
    #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
                                 ^
<inline asm>:1:2: note: instantiated into assembly here
        int $3
        ^
1 error generated.

See details here: https://ports.macports.org/port/ascent/details

mwalcott3 commented 1 year ago

Most likely catch2 dev dependency just needs to be upgraded.

The linking issue may be related to https://github.com/catchorg/Catch2/issues/1218. If upgrading doesn't work we can use CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS

aarch64 failing is somewhat odd because it looks like it includes the fix https://github.com/catchorg/Catch2/issues/1127 for that and not should be using __asm__("int $3\n" : : ) . I know @stephenberry has an arm macbook so he should be able to test out if upgrading catch2 fixes this and if not why is not using the correct define for CATCH_TRAP on that platform.

stephenberry commented 1 year ago

@barracuda156

I think the problem should now be fixed. Let me know if you still run into errors.

The unit test framework has been changed to boost ut.

stephenberry commented 1 year ago

@barracuda156 FYI the master branch has been changed to main

barracuda156 commented 1 year ago

I think the problem should now be fixed. Let me know if you still run into errors.

@stephenberry Thank you! Let me try.

barracuda156 commented 1 year ago

Most likely catch2 dev dependency just needs to be upgraded.

Not relevant anymore, AFAIU, but there was no dependency declared, and CMake configure did not check for catch2 being available (otherwise it would have failed earlier, during configure itself). Since Macports build bots run every build from scratch, if something is not declared as dependency, it will not be present.

barracuda156 commented 1 year ago

@stephenberry All looks good locally:

--->  Testing ascent
Executing:  cd "/opt/local/var/macports/build/_opt_PPCRosettaPorts_math_ascent/ascent/work/build" && ctest test 
Test project /opt/local/var/macports/build/_opt_PPCRosettaPorts_math_ascent/ascent/work/build
    Start 1: ascent_test
1/1 Test #1: ascent_test ......................   Passed    0.09 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) =   0.11 sec

I will open a PR to Macports now, and once it gets merged, will update on build status across all macOS versions.

stephenberry commented 1 year ago

Excellent, thank you!

barracuda156 commented 1 year ago

Excellent, thank you!

@stephenberry Thank you for working on this!

barracuda156 commented 1 year ago

@barracuda156

I think the problem should now be fixed. Let me know if you still run into errors.

@stephenberry @mwalcott3

Errors differ now (and perhaps some systems that were broken initially are now fixed), so it is not yet fully fixed. I opened a separate issue: https://github.com/AnyarInc/Ascent/issues/28