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

Python bindings issue when building with static libraries #1159

Open
agarny opened this issue Apr 28, 2023 · 2 comments
Open

Python bindings issue when building with static libraries #1159

agarny opened this issue Apr 28, 2023 · 2 comments

Comments

@agarny
Copy link
Contributor

agarny commented Apr 28, 2023

I am on macOS and I have everything set up to build Python bindings and it all works as expected if I do:

mkdir build
cd build
cmake -G Ninja ..
ninja

However, if I ask for a static version of libCellML to be built then I am getting various linking issues:

mkdir build
cd build
cmake -G Ninja .. -DBUILD_SHARED=OFF
ninja
...
FAILED: src/bindings/python/libcellml/_enums.so
: && /opt/homebrew/opt/llvm/bin/clang++ -g -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14 -bundle -Wl,-headerpad_max_install_names -undefined dynamic_lookup -o src/bindings/python/libcellml/_enums.so src/bindings/python/CMakeFiles/enums.dir/swig_intermediaries/enumsPYTHON_wrap.cxx.o  -Wl,-rpath,@loader_path/.  src/libcellmld.a  /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/lib/libz.tbd  /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/lib/libxml2.tbd  /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/lib/libz.tbd  /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/lib/libxml2.tbd  src/libcellml_debug_utilitiesd.a && :
ld: illegal text reloc in '___llvm_profile_runtime_user' (from src/libcellmld.a(enums.cpp.o)) to '___llvm_profile_runtime' for architecture arm64
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
[90/256] Linking CXX shared module src/bindings/python/libcellml/_analyserequationast.so
FAILED: src/bindings/python/libcellml/_analyserequationast.so
: && /opt/homebrew/opt/llvm/bin/clang++ -g -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14 -bundle -Wl,-headerpad_max_install_names -undefined dynamic_lookup -o src/bindings/python/libcellml/_analyserequationast.so src/bindings/python/CMakeFiles/analyserequationast.dir/swig_intermediaries/analyserequationastPYTHON_wrap.cxx.o  -Wl,-rpath,@loader_path/.  src/libcellmld.a  /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/lib/libz.tbd  /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/lib/libxml2.tbd  /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/lib/libz.tbd  /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/lib/libxml2.tbd  src/libcellml_debug_utilitiesd.a && :
ld: illegal text reloc in '___llvm_profile_runtime_user' (from src/libcellmld.a(analyserequationast.cpp.o)) to '___llvm_profile_runtime' for architecture arm64
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
[92/256] Linking CXX shared module src/bindings/python/libcellml/_analyser.so
FAILED: src/bindings/python/libcellml/_analyser.so
: && /opt/homebrew/opt/llvm/bin/clang++ -g -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14 -bundle -Wl,-headerpad_max_install_names -undefined dynamic_lookup -o src/bindings/python/libcellml/_analyser.so src/bindings/python/CMakeFiles/analyser.dir/swig_intermediaries/analyserPYTHON_wrap.cxx.o  -Wl,-rpath,@loader_path/.  src/libcellmld.a  /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/lib/libz.tbd  /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/lib/libxml2.tbd  /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/lib/libz.tbd  /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/lib/libxml2.tbd  src/libcellml_debug_utilitiesd.a && :
ld: illegal text reloc in '___llvm_profile_runtime_user' (from src/libcellmld.a(analyser.cpp.o)) to '___llvm_profile_runtime' for architecture arm64
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
[102/256] Building CXX object src/bindings/python/CMakeFil...del.dir/swig_intermediaries/analysermodelPYTHON_wrap.cxx.o
ninja: build stopped: subcommand failed.
@hsorby
Copy link
Contributor

hsorby commented Apr 29, 2023

It doesn't make sense to build the python bindings with a static libCellML library. I'm not sure on this but Windows in the past hasn't been a fan of allocating from one dll and deallocating from another.

@agarny
Copy link
Contributor Author

agarny commented May 2, 2023

It doesn't make sense to build the python bindings with a static libCellML library. I'm not sure on this but Windows in the past hasn't been a fan of allocating from one dll and deallocating from another.

Then, shouldn't we have one of those Configuration confusion messages like we have?

Also, FWIW, libOpenCOR's Python bindings are built off a static version of libOpenCOR. :)

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