Avoid static linking conflicts with libblkid
PATCH 1/1 Avoid static linking conflicts with libblkid
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.
Signed-off-by Alyssa Ross <[email protected]>
---
If this is too clever we could also just rename the function without a macro, but I thought it would be confusing if callers had to remember that this one function needs a bch_ prefix but none of the others do.
c_src/tools-util.h | 2 ++ 1 file changed, 2 insertions(+)
c_src/tools-util.h +2 -0
@@ -174,6 +174,8 @@ struct fiemap_extent fiemap_iter_next(struct fiemap_iter *);char *strcmp_prefix (char *,const char *); +/* Avoid conflicts with libblkid's crc32 function in static builds */ +#define crc32c bch_crc32cu32 crc32c (u32 ,const void *,size_t );char *dev_to_name (dev_t );
base-commit: b34d1341919c4edd3251c7f69c2588acd1196d71
Signature · 1 line
2.45.2
Kent Overstreet
AppliedQuoted 7 lines · Alyssa Ross
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
Quoted 5 lines
Work around this by avoiding a known name collision with a function in libblkid.
Applied