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

Can not link statically to libblkid.a #311

Closed
Nanderty opened this issue Jul 6, 2024 · 0 comments
Closed

Can not link statically to libblkid.a #311

Nanderty opened this issue Jul 6, 2024 · 0 comments

Comments

@Nanderty
Copy link

Nanderty commented Jul 6, 2024

Trying to statically link bcachefs-tools to libblkid.a results in the following:

error: linking with `x86_64-pc-linux-gnu-gcc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/18/bin:/usr/lib/llvm/17/bin:/etc/eselect/wine/bin:/opt/texlive/2024/bin/x86_64-linux/:/opt/ULWGL:/opt/npm/" VSLANG="1033" "x86_64-pc-linux-gnu-gcc" "-m64" "/tmp/rustcd7rKwS/symbols.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.00.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.01.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.02.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.03.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.04.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.05.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.06.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.07.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.08.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.09.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.10.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.11.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.12.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.13.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.14.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.bcachefs.9ebece77aa65d6ff-cgu.15.rcgu.o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e.3rn9u56d6c1br7j6.rcgu.o" "-Wl,--as-needed" "-L" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps" "-L" "." "-L" "/usr/lib64" "-L" "/usr/lib64" "-L" "/usr/lib64" "-L" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,--whole-archive" "-lbcachefs" "-Wl,--no-whole-archive" "-lurcu" "-lblkid" "-luuid" "-lsodium" "-lz" "-llz4" "-lzstd" "-Wl,-Bdynamic" "-ludev" "-Wl,-Bstatic" "-lkeyutils" "-laio" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/librpassword-ccfdd0e65c0d3f46.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/librtoolbox-33943486b8d4c8c4.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libudev-85796aff61f7dfb9.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/liblibudev_sys-d56592d5c0cef955.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libstrum-2bf3ab74dbc0ab1f.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/liberrno-cc32df8d254e035c.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/liblibc-9fc715d760caf7b8.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libzeroize-149ed9b6d7d77730.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libeither-ead1a66cf28c4a3c.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libcolored-2c5a319cfeec9287.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/liblazy_static-da1e20d618c18f47.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/liblog-7fd7b6c1b40e5bc6.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libbch_bindgen-5b91aceebd7bd614.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libuuid-6e2cacbbf1cf451e.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libanyhow-cbd19378ec0faa52.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libbitflags-31ef73f2be0abcdc.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libbyteorder-134c59375c0e5e26.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libmemoffset-b418c9b8d772e598.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libbitfield-5e62c3698dfd0b62.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libclap_complete-218a0226d2d95ec8.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libclap-08c62e13eefb5791.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libclap_builder-b2a6358c9708def1.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libterminal_size-bedec782858e3b62.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/librustix-9d525b5bd60761e4.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libbitflags-315c90933016954d.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/liblinux_raw_sys-e1aad1109bb24990.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libstrsim-9a43d14de7aab33b.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libanstream-d2f1c105b53b51ee.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libanstyle_query-d239106657f2b6f7.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libcolorchoice-176ba2d651e5485f.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libanstyle_parse-2699eb17d0b66781.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libutf8parse-d0c9de0dfd0b54bd.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libclap_lex-b2a401821c782c71.rlib" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/libanstyle-c50ac9dede2a7ed8.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-67c26cb1beb053f2.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-78ed579cf0d63ff5.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-5bca8deeffa26476.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-8ce44df8e7ed1c2e.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-372c57af4a2a548e.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-837a63cb350a3665.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-4ebf2c35084728b7.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-c584bf51fdbcee42.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-e939613d4d8496b4.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-44a331beb9d77904.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-9dc38b643e6f14ec.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-f2b26cf559f2e21d.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-43e8a4ab7b8bc0e2.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-3b19c5882e26257a.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-501cc06aee89a83a.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-c1f9c42bdb0c7fa4.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-9aceca49c90f4972.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-b3aac605ddb8b199.rlib" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-57b8a60aeb7be089.rlib" "-Wl,-Bdynamic" "-ludev" "-lurcu-common" "-lurcu" "-lkeyutils" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/usr/lib/rust/1.77.1/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/Nanderty/misc/bcachefs-tools-1.9.1/target/release/deps/bcachefs-6a722de2b5cba46e" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs"
  = note: /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib64/libblkid.a(libcommon_la-crc32c.o): in function `crc32c':
          (.text+0x0): multiple definition of `crc32c'; ./libbcachefs.a(tools-util.o):/home/Nanderty/misc/bcachefs-tools-1.9.1/c_src/tools-util.c:481: first defined here
          collect2: error: ld returned 1 exit status
          

error: could not compile `bcachefs-tools` (bin "bcachefs") due to 1 previous error
make: *** [Makefile:179: bcachefs] Error 101
koverstreet pushed a commit that referenced this issue Oct 12, 2024
When static linking, it's not possible to have two functions with the
same name in different libraries:

	= note: /nix/store/s2cjhni3s6shh0n35ay1hpj8d85k44qk-x86_64-unknown-linux-musl-binutils-2.43.1/bin/x86_64-unknown-linux-musl-ld: /nix/store/zwid05lzfy46k32xljb2alh0gq7ys58a-util-linux-minimal-static-x86_64-unknown-linux-musl-2.39.4-lib/lib/libblkid.a(libcommon_la-crc32c.o): in function `crc32c':
	        (.text+0x0): multiple definition of `crc32c'; ./libbcachefs.a(tools-util.o):/build/source/c_src/tools-util.c:484: first defined here
	        collect2: error: ld returned 1 exit status

Work around this by avoiding a known name collision with a function in
libblkid.

Closes: #311
Signed-off-by: Alyssa Ross <[email protected]>
Signed-off-by: Kent Overstreet <[email protected]>
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

1 participant