Skip to content

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

@ntorresalberto

Description

@ntorresalberto

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions