[Bug 267156] databases/db5: fix build with clang 15

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 17 Oct 2022 18:39:16 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267156

            Bug ID: 267156
           Summary: databases/db5: fix build with clang 15
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: ports-bugs@FreeBSD.org
          Reporter: dim@FreeBSD.org

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
/share/dim/src/freebsd/llvm-15-update/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
/share/dim/src/freebsd/llvm-15-update/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:569:13
#1 0x00000000053fcf35 RunSignalHandlers
/share/dim/src/freebsd/llvm-15-update/contrib/llvm-project/llvm/lib/Support/Signals.cpp:104:18
#2 0x00000000053a591e HandleCrash
/share/dim/src/freebsd/llvm-15-update/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:76:5
#3 0x00000000053a5ae3 CrashRecoverySignalHandler
/share/dim/src/freebsd/llvm-15-update/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:0:51
#4 0x0000000006a1b05e handle_signal
/share/dim/src/freebsd/llvm-15-update/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

-- 
You are receiving this mail because:
You are the assignee for the bug.