config_host.mk.in | 1 + configure.ac | 5 +++++ external/firebird/UnpackedTarball_firebird.mk | 1 + external/firebird/sanitizer-rtti.patch | 11 +++++++++++ external/firebird/sanitizer.patch | 9 --------- 5 files changed, 18 insertions(+), 9 deletions(-)
New commits: commit 6e1026cacada6056f2be6b74baf426c984305867 Author: Stephan Bergmann <[email protected]> AuthorDate: Fri Feb 7 10:33:44 2025 +0100 Commit: Stephan Bergmann <[email protected]> CommitDate: Fri Feb 7 11:38:12 2025 +0100 external/firebird: Avoid ODR violation issues from sanitizer builds My local ASan/UBSan builds of d37c60c5e2b793c0934d431e59c8cb3ff1a170b6 "external/firebird: Drop -fno-rtti from sanitizer builds" against LLVM 21 trunk had been fine, but <https://ci.libreoffice.org/job/lo_ubsan/3459/> against lode's LLVM 12.0.1 started to fail with > ==3374322==ERROR: AddressSanitizer: odr-violation (0x0000007af7a0): > [1] size=16 'typeinfo for Firebird::Exception' /home/tdf/lode/jenkins/workspace/lo_ubsan/workdir/UnpackedTarball/firebird/src/common/fb_exception.cpp > [2] size=16 'typeinfo for Firebird::Exception' /home/tdf/lode/jenkins/workspace/lo_ubsan/workdir/UnpackedTarball/firebird/src/common/fb_exception.cpp > These globals were registered at these points: > [1]: > #0 0x440738 in __asan_register_globals.part.0 /home/tdf/lode/packages/llvm-llvmorg-12.0.1.src/compiler-rt/lib/asan/asan_globals.cpp:360:3 > #1 0x68237b in asan.module_ctor (/workdir/UnpackedTarball/firebird/gen/Debug/firebird/bin/isql+0x68237b) > > [2]: > #0 0x440738 in __asan_register_globals.part.0 /home/tdf/lode/packages/llvm-llvmorg-12.0.1.src/compiler-rt/lib/asan/asan_globals.cpp:360:3 > #1 0x7f5ccdec01ab in asan.module_ctor (/workdir/UnpackedTarball/firebird/gen/Debug/firebird/lib/libfbclient.so.2+0x9b41ab) What appears to make a difference there is <https://github.com/llvm/llvm-project/commit/1ada819c237bf724e6eaa1c82b2742e3eb57a5d5> "[asan] Default to -fsanitize-address-use-odr-indicator for non-Windows", first appearing in LLVM 16: My local ASan/UBSan LLVM 21 trunk build, which builds external/firebird fine, has > 0000000000ee5166 B __odr_asan_gen__ZTIN8Firebird9ExceptionE > 000000000045b960 D _ZTIN8Firebird9ExceptionE in workdir/UnpackedTarball/firebird/gen/Debug/firebird/bin/isql and > 0000000000e49920 b __odr_asan_gen__ZTIN8Firebird9ExceptionE > 0000000000b9d100 D _ZTIN8Firebird9ExceptionE in workdir/UnpackedTarball/firebird/gen/Debug/firebird/lib/libfbclient.so.2, but when I rebuild it with -fno-sanitize-address-use-odr-indicator, it has only > 000000000045bbc0 D _ZTIN8Firebird9ExceptionE in workdir/UnpackedTarball/firebird/gen/Debug/firebird/bin/isql and only > 0000000000b9d1c0 D _ZTIN8Firebird9ExceptionE in workdir/UnpackedTarball/firebird/gen/Debug/firebird/lib/libfbclient.so.2, and fails the same way as <https://ci.libreoffice.org/job/lo_ubsan/3459/>. So make the "Drop -fno-rtti" patch depend on Clang >= 16 (recorded, for simplicity, with a bespoke new CLANG_16 config_host.mk variable). Change-Id: I70a8ce8eb535265d592d470718d6b3a6765d5bcd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181235 Reviewed-by: Stephan Bergmann <[email protected]> Tested-by: Jenkins diff --git a/config_host.mk.in b/config_host.mk.in index 41aa4f801165..aa3b67e910d4 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -71,6 +71,7 @@ export CCACHE_DEPEND_MODE=@CCACHE_DEPEND_MODE@ export CDR_CFLAGS=$(gb_SPACE)@CDR_CFLAGS@ export CDR_LIBS=$(gb_SPACE)@CDR_LIBS@ @x_CFLAGS@ export CFLAGS=@CFLAGS@ +export CLANG_16=@CLANG_16@ export CLANG_USE_LD=@CLANG_USE_LD@ export CLANGDIR=@CLANGDIR@ export CLANGLIBDIR=@CLANGLIBDIR@ diff --git a/configure.ac b/configure.ac index 59d83e1230ea..67cf30a8046a 100644 --- a/configure.ac +++ b/configure.ac @@ -4704,6 +4704,7 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ AC_SUBST(COM_IS_CLANG) CLANGVER= +CLANG_16= if test "$COM_IS_CLANG" = TRUE; then AC_MSG_CHECKING([whether Clang is new enough]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ @@ -4732,10 +4733,14 @@ if test "$COM_IS_CLANG" = TRUE; then else AC_MSG_ERROR(["$CLANG_FULL_VERSION" is too old or unrecognized, must be at least Clang 12]) fi + if test "$CLANGVER" -ge 160000; then + CLANG_16=TRUE + fi AC_DEFINE_UNQUOTED(CLANG_VERSION,$CLANGVER) AC_DEFINE_UNQUOTED(CLANG_FULL_VERSION,$CLANG_FULL_VERSION) fi fi +AC_SUBST(CLANG_16) SHOWINCLUDES_PREFIX= if test "$_os" = WINNT; then diff --git a/external/firebird/UnpackedTarball_firebird.mk b/external/firebird/UnpackedTarball_firebird.mk index 821b167650d5..79e1da16daee 100644 --- a/external/firebird/UnpackedTarball_firebird.mk +++ b/external/firebird/UnpackedTarball_firebird.mk @@ -79,6 +79,7 @@ endif ifneq ($(filter -fsanitize=%,$(CC)),) $(eval $(call gb_UnpackedTarball_add_patches,firebird, \ external/firebird/sanitizer.patch \ + $(if $(CLANG_16),external/firebird/sanitizer-rtti.patch) \ )) endif diff --git a/external/firebird/sanitizer-rtti.patch b/external/firebird/sanitizer-rtti.patch new file mode 100644 index 000000000000..37a0686d9d2d --- /dev/null +++ b/external/firebird/sanitizer-rtti.patch @@ -0,0 +1,11 @@ +--- builds/posix/make.defaults ++++ builds/posix/make.defaults +@@ -102,7 +102,7 @@ + #____________________________________________________________________________ + + # Firebird needs no RTTI +-RTTI_FLAG:= -fno-rtti ++RTTI_FLAG:= + + # If this is defined then we use special rules useful for developers only + IsDeveloper = @DEVEL_FLG@ diff --git a/external/firebird/sanitizer.patch b/external/firebird/sanitizer.patch index 8f2a1e54df53..3707b5bf54af 100644 --- a/external/firebird/sanitizer.patch +++ b/external/firebird/sanitizer.patch @@ -21,15 +21,6 @@ +_ZTI* --- builds/posix/make.defaults +++ builds/posix/make.defaults -@@ -102,7 +102,7 @@ - #____________________________________________________________________________ - - # Firebird needs no RTTI --RTTI_FLAG:= -fno-rtti -+RTTI_FLAG:= - - # If this is defined then we use special rules useful for developers only - IsDeveloper = @DEVEL_FLG@ @@ -252,7 +252,7 @@ # LINKER OPTIONS #
