Skip to content

Commit

Permalink
Issue 4596 - Build with clang/lld fails when LTO enabled
Browse files Browse the repository at this point in the history
Bug Description:
Build with clang/lld fails with undefined reference error.
```
ld.lld: error: ./.libs/libslapd.so: undefined reference to __rust_probestack [--no-allow-shlib-undefined]
ld.lld: error: ./.libs/libslapd.so: undefined reference to __muloti4 [--no-allow-shlib-undefined]
```

Fix Description:
* Disabled GCC security flags when building with clang.
* lld by default uses xxhash for build ids, which is too small for rpm
(it requires it between 16 and 64 bytes in size), use sha1 instead.
* Switch debug CFLAGS and LDFLAGS to use DWARF4 instead of DWARF5.
* Disable LTO for clang rpm build.

Fixes: 389ds#4596

Reviewed by: ???
  • Loading branch information
vashirov committed Nov 1, 2024
1 parent ab8b96a commit 0e11219
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ NQBUILDNUM := $(subst \,,$(subst $(QUOTE),,$(BUILDNUM)))
DEBUG_DEFINES = @debug_defs@
DEBUG_CFLAGS = @debug_cflags@
DEBUG_CXXFLAGS = @debug_cxxflags@
GCCSEC_CFLAGS = @gccsec_cflags@
if CLANG_ENABLE
ASAN_CFLAGS = @asan_cflags@
else
Expand All @@ -32,6 +31,7 @@ ASAN_CFLAGS = @asan_cflags@ -lasan
else
ASAN_CFLAGS = @asan_cflags@
endif
GCCSEC_CFLAGS = @gccsec_cflags@
endif
MSAN_CFLAGS = @msan_cflags@
TSAN_CFLAGS = @tsan_cflags@
Expand Down Expand Up @@ -77,7 +77,7 @@ endif

if CLANG_ENABLE
CLANG_ON = 1
CLANG_LDFLAGS = -latomic -fuse-ld=lld
CLANG_LDFLAGS = -latomic -fuse-ld=lld -Wl,--build-id=sha1
EXPORT_LDFLAGS =
else
CLANG_ON = 0
Expand Down
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], [Enable debug features (de
AC_MSG_RESULT($enable_debug)
if test "$enable_debug" = yes ; then
debug_defs="-DDEBUG -DMCC_DEBUG"
debug_cflags="-g3 -ggdb -gdwarf-5 -O0"
debug_cxxflags="-g3 -ggdb -gdwarf-5 -O0"
debug_cflags="-g3 -ggdb -gdwarf-4 -O0"
debug_cxxflags="-g3 -ggdb -gdwarf-4 -O0"
debug_rust_defs="-C debuginfo=2 -Z macro-backtrace"
cargo_defs=""
rust_target_dir="debug"
Expand Down Expand Up @@ -252,7 +252,7 @@ AC_ARG_ENABLE(profiling, AS_HELP_STRING([--enable-profiling], [Enable gcov profi
[], [ enable_profiling=no ])
AC_MSG_RESULT($enable_profiling)
if test "$enable_profiling" = yes ; then
profiling_defs="-fprofile-arcs -ftest-coverage -g3 -ggdb -gdwarf-5 -O0"
profiling_defs="-fprofile-arcs -ftest-coverage -g3 -ggdb -gdwarf-4 -O0"
profiling_links="-lgcov --coverage"
else
profiling_defs=""
Expand Down
2 changes: 1 addition & 1 deletion rpm/389-ds-base.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

%if %{with clang}
%global toolchain clang
%global _missing_build_ids_terminate_build 0
%global _lto_cflags %nil
%endif

# Build cockpit plugin
Expand Down

0 comments on commit 0e11219

Please sign in to comment.