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

Build failure: Linking error with libdart_ffi.so (relocation R_X86_64_32S) #3898

Open
ntorresalberto opened this issue Jan 24, 2025 · 7 comments · Fixed by #3904
Open

Build failure: Linking error with libdart_ffi.so (relocation R_X86_64_32S) #3898

ntorresalberto opened this issue Jan 24, 2025 · 7 comments · Fixed by #3904

Comments

@ntorresalberto
Copy link
Contributor

While building Multipass, the build process fails during the linking stage with the following error:

[ 56%] Linking CXX static library libcommands.a
[ 56%] Built target commands
[ 56%] Building CXX object src/client/cli/formatter/CMakeFiles/formatter.dir/csv_formatter.cpp.o
[ 56%] Building CXX object src/client/cli/formatter/CMakeFiles/formatter.dir/format_utils.cpp.o
[ 56%] Building CXX object src/client/cli/formatter/CMakeFiles/formatter.dir/json_formatter.cpp.o
[ 57%] Building CXX object src/client/cli/formatter/CMakeFiles/formatter.dir/table_formatter.cpp.o
[ 57%] Building CXX object src/client/cli/formatter/CMakeFiles/formatter.dir/yaml_formatter.cpp.o
[ 57%] Linking CXX static library libformatter.a
[ 57%] Built target formatter
[ 57%] Building CXX object src/client/cli/CMakeFiles/client.dir/argparser.cpp.o
[ 58%] Building CXX object src/client/cli/CMakeFiles/client.dir/client.cpp.o
[ 58%] Linking CXX static library libclient.a
[ 58%] Built target client
[ 58%] Building CXX object src/client/cli/CMakeFiles/multipass.dir/main.cpp.o
[ 58%] Linking CXX executable ../../../bin/multipass
[ 58%] Built target multipass
[ 58%] Building CXX object src/client/gui/CMakeFiles/dart_ffi.dir/ffi/dart_ffi.cpp.o
[ 58%] Linking CXX shared library ../../../lib/libdart_ffi.so
/usr/bin/ld: ../../../3rd-party/xz-decoder/libxz-embedded.a(xz_crc32.c.o): relocation R_X86_64_32S against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [src/client/gui/CMakeFiles/dart_ffi.dir/build.make:216: lib/libdart_ffi.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:2349: src/client/gui/CMakeFiles/dart_ffi.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

Environment

OS: Fedora 41
Compiler: Clang 19.1.5
CMake Version: 3.30.5
Multipass Version: main

Solution

I can provide a seemingly harmless one-line PR to add the -fPIC flag when compiling libxz-embedded, which should resolve this issue without impacting other parts of the build. Let me know if that would be helpful

@ricab
Copy link
Collaborator

ricab commented Jan 27, 2025

Interesting, I wonder why we don't see this 🤔 Do you have a recipe I could use to try to reproduce?

@ntorresalberto
Copy link
Contributor Author

Yes, sorry.
I was just following the build steps and this happens on the make call.
I suspect it could be related to me using Fedora 41?
I had some troubles finding the equivalent dependencies, though I think I got them all.
Here's the ld version just in case, as it's mentioned in the log error:

$ ld --version
GNU ld version 2.43.1-5.fc41

@ricab
Copy link
Collaborator

ricab commented Jan 27, 2025

Thanks. I had tried that, but couldn't find anything for libapparmor so gave up. How did you fulfill that one?

@ntorresalberto
Copy link
Contributor Author

I googled a bit and found the Terra repository: https://discussion.fedoraproject.org/t/howto-install-fyra-labs-terra-repository-on-traditional-and-atomic-fedora/124522

Seemed serious and open enough to consider it.
They provide an apparmor-devel package.

@ntorresalberto
Copy link
Contributor Author

ntorresalberto commented Jan 27, 2025

Just FYI, the current compilation issue was solved for me when I added:

set_property(TARGET xz-embedded PROPERTY POSITION_INDEPENDENT_CODE ON)

to multipass/3rd-party/xz-decoder/CMakeLists.txt (which basically adds -fPIC to the target).

I'd be happy to make a PR if you think it's worth it.

@ricab
Copy link
Collaborator

ricab commented Jan 27, 2025

Hi @ntorresalberto, OK I just reproduced this. I am not sure why this doesn't affect our usual builds... Anyway, that would be a welcome change, thanks!

@ntorresalberto
Copy link
Contributor Author

done! 😃

github-merge-queue bot pushed a commit that referenced this issue Feb 3, 2025
Fix #3898 by adding -fPIC to xz-embedded [clone]
giuliazanchi pushed a commit to giuliazanchi/multipass that referenced this issue Feb 5, 2025
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

Successfully merging a pull request may close this issue.

2 participants