diff options
authorDimitry Andric <dim@FreeBSD.org>2022-12-05 17:20:32 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-12-05 17:26:02 +0000
commit42cfe5c18c235a5e8d95bb89060db0f09f43c7b2 (patch)
parenta1f596a64c2631ca50a091bd987524dd143db7f4 (diff)
databases/db5: Add <stddef.h> to conftest.cpp for TLS check
During an exp-run for llvm 15 (see bug 265425), it turned out that databases/db5 failed to build with clang 15. This is caused by db5's configure script attempting to detect TLS but encountering internal compiler errors while compiling its test cases, and then concluding TLS does not work at all: ... checking whether C++ supports the wstring class... checking for thread local storage (TLS) class... none ... in config.log it shows what is happening: configure:19128: checking for thread local storage (TLS) class configure:19164: c++ -c -O2 -pipe -Wall -Wextra -fstack-protector-strong -fno-strict-aliasing -D_THREAD_SAFE conftest.cpp >&5 conftest.cpp:30:72: error: use of undeclared identifier 'NULL' template<typename T> __thread T* TLSClass<T>::tlsvar = NULL; ^ Assertion failed: (!isValueDependent() && "Expression evaluator can't be called on a dependent expression."), function isConstantInitializer, file /usr/src/contrib/llvm-project/clang/lib/AST/Expr.cpp, line 3184. PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: c++ -c -O2 -pipe -Wall -Wextra -fstack-protector-strong -fno-strict-aliasing -D_THREAD_SAFE conftest.cpp 1. conftest.cpp:30:76: current parser token ';' #0 0x00000000053fec51 PrintStackTrace #/usr/src/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:569:13 #1 0x00000000053fcf35 RunSignalHandlers #/usr/src/contrib/llvm-project/llvm/lib/Support/Signals.cpp:104:18 #2 0x00000000053a591e HandleCrash #/usr/src/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:76:5 #3 0x00000000053a5ae3 CrashRecoverySignalHandler #/usr/src/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:0:51 #4 0x0000000006a1b05e handle_signal #/usr/src/lib/libthr/thread/thr_sig.c:0:3 c++: error: clang frontend command failed with exit code 134 (use -v to see invocation) Interestingly enough this compilation error with a fatal crash exists for a very long time, even back to clang 10 and earlier! But for various reasons the configure script has always ignored these errors and found some workaround way to enable TLS anyway. For now the problem can be fixed by including <stddef.h> at the top of conftest.cpp, which will allow the TLS test to succeed normally, without crashing, and the correct result will then be: configure:19128: checking for thread local storage (TLS) class configure:19165: c++ -c -O2 -pipe -Wall -Wextra -fstack-protector-strong -fno-strict-aliasing -D_THREAD_SAFE conftest.cpp >&5 conftest.cpp:33:35: warning: unused variable 'x' [-Wunused-variable] static __thread int x = 0; ^ 1 warning generated. configure:19165: $? = 0 configure:19220: result: modifier PR: 267156 Approved by: maintainer timeout (>1 month) MFH: 2022Q4
2 files changed, 9 insertions, 1 deletions
diff --git a/databases/db5/Makefile b/databases/db5/Makefile
index 6480caea579c..29597687220b 100644
--- a/databases/db5/Makefile
+++ b/databases/db5/Makefile
@@ -1,6 +1,6 @@
CATEGORIES= databases java
MASTER_SITES= https://download.oracle.com/berkeley-db/
diff --git a/databases/db5/files/patch-dist_configure b/databases/db5/files/patch-dist_configure
index 830bc1f487ef..1243a1117aaf 100644
--- a/databases/db5/files/patch-dist_configure
+++ b/databases/db5/files/patch-dist_configure
@@ -13,3 +13,11 @@
+@@ -19144,6 +19144,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+ test -z "$ax_tls_defn_keyword" && continue
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
++#include <stddef.h>
+ template <typename T>class TLSClass {
+ public: static $ax_tls_decl_keyword T *tlsvar;
+ };