Building fails with builtin_llvm=OFF
due to unintend libbsd linking
#12152
Labels
builtin_llvm=OFF
due to unintend libbsd linking
#12152
Describe the bug
Building master (+ fix for #12151) with
builtin_llvm=OFF
results in this build error:Digging a bit deeper with the
-Wl,--verbose
linker flag:So the issue is that the system
libLLVM-13.so.1
links againstlibbsd.so.0
, which definesstrlcat
as a global symbol. Sincerootcling_impl
also defines this symbol as global, there is an unresolved conflict.Expected behavior
Tbh I'm not sure how this should be fixed.
Clearly by default there is no
strlcat
et al on linux by default, but there is libbsd and this should be checked somwhere. Currently this check is in core/foundation/inc/ROOT/RConfig.hxx:248-276 and only takes into account the operating system.Check with
__has_include
ifbsd/string.h
exists on other unixes might be a way to do it, but I would have no clue how to do the proper linking. Also it doesn't fix the issue if libbsd is introduced in a downstream project using ROOT.Alternatively, I think the "better" solution is to add a
link_libbsd
build option (disabled by default ofc). If enabled, it adds-lbsd
to the public link flags ofClib
and sets some compile flag likeHAS_STRLCPY_VIA_LIBBSD
(in addition toHAS_STRLCPY
) that triggers the inclusion of bsd/string.h in clib/inc/strlcpy.h in the#else
case of#ifndef HAS_STRLCPY
.To Reproduce
git master,
builtin_llvm=OFF
, #12151 fixed via${CLING_BINARY_DIR}
instead of${LLVM_BINARY_DIR}
Setup
master, Debian Sid, LLVM 13.0.1-11, gcc 12.2.0-3
Additional context
The text was updated successfully, but these errors were encountered: