According to https://eel.is/c++draft/cpp.predefined#2.6, __STDCPP_THREADS__ is a predefined macro.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
390 ms | linux > HWAddressSanitizer-x86_64.TestCases::sizes.cpp |
Event Timeline
clang/include/clang/Frontend/FrontendOptions.h | ||
---|---|---|
307 | This doesn't seem to fit with the other frontend options. This seems more like a language option. See the existing PosixThreads langopt. If you add a langopt, you should be able to remove the option from CodeGenOptions, since codegen can check language options. |
clang/test/CXX/cpp/cpp.predefined/p2.cpp | ||
---|---|---|
1 ↗ | (On Diff #306724) | Let's expand on this:
Pass an extra macro def on the command line to control the preprocessor test expectations similar to p1.cpp |
clang/test/CXX/cpp/cpp.predefined/p2.cpp | ||
---|---|---|
1 ↗ | (On Diff #306724) | I found split-file is handy to separate different test expectations. |
Hi, it seems that p2.cpp is failing on our production builder (https://luci-milo.appspot.com/p/fuchsia/builders/prod/clang-linux-x64/b8862835022166171808):
FAIL: Clang :: CXX/cpp/cpp.predefined/p2.cpp (1210 of 26900) ******************** TEST 'Clang :: CXX/cpp/cpp.predefined/p2.cpp' FAILED ******************** Script: -- : 'RUN: at line 1'; split-file /b/s/w/ir/x/w/llvm-project/clang/test/CXX/cpp/cpp.predefined/p2.cpp /b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/tools/clang/test/CXX/cpp/cpp.predefined/Output/p2.cpp.tmp.dir : 'RUN: at line 2'; /b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/bin/clang -cc1 -internal-isystem /b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/lib/clang/12.0.0/include -nostdsysteminc -verify /b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/tools/clang/test/CXX/cpp/cpp.predefined/Output/p2.cpp.tmp.dir/defined.cpp : 'RUN: at line 3'; /b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/bin/clang -cc1 -internal-isystem /b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/lib/clang/12.0.0/include -nostdsysteminc -verify -mthread-model posix /b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/tools/clang/test/CXX/cpp/cpp.predefined/Output/p2.cpp.tmp.dir/defined.cpp : 'RUN: at line 4'; /b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/bin/clang -cc1 -internal-isystem /b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/lib/clang/12.0.0/include -nostdsysteminc -verify -mthread-model single /b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/tools/clang/test/CXX/cpp/cpp.predefined/Output/p2.cpp.tmp.dir/not-defined.cpp : 'RUN: at line 5'; /b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/bin/clang -cc1 -internal-isystem /b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/lib/clang/12.0.0/include -nostdsysteminc -verify -x c /b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/tools/clang/test/CXX/cpp/cpp.predefined/Output/p2.cpp.tmp.dir/not-defined.cpp -- Exit Code: 127 Command Output (stderr): -- /b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/tools/clang/test/CXX/cpp/cpp.predefined/Output/p2.cpp.script: line 1: split-file: command not found -- ******************** Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. ******************** Failed Tests (1): Clang :: CXX/cpp/cpp.predefined/p2.cpp
This can be reproduced if you run clang tests before building llvm tools (running check-clang without running check-llvm). Should split-file be used here in the first place since it's an llvm tool? If so, should there be a way to force check-clang to build split-file before running tests?
Looks like _LIBCPP_HAS_NO_THREADS is being set for libcxxabi, and the build now fails with this change:
llvm-project/libcxxabi/../libcxx/include/__config:1172:2: error: _LIBCPP_HAS_NO_THREADS cannot be set when STDCPP_THREADS is set
Indeed: LIBCXX_ENABLE_THREADS is off by default.
@zequanwu, what's your take on this... which part of the system needs to adapt?
If we believe the standard says that the compiler is supposed to set __STDCPP_THREADS__, then I think the libc++ #error needs to be adjusted. libcxxabi, or any other client, should be able to define _LIBCPP_HAS_NO_THREADS, and it should work, even if the compiler thinks they are allowed.
So, we could remove the checking for if __STDCPP_THREADS__ and _LIBCPP_HAS_NO_THREADS are both set. And let libcxx adds flag -mthread-model single to use single thread (but this is compiler specific flag, might need a better solution).
Yes, and I think we also need to audit to see if there is any code in libc++ that checks __STDCPP_THREADS__. Actually, I went ahead and did that. It like no other code checks it, so we're probably OK to remove the libc++ check.
It's worth noting that this change will prevent users of older libc++ versions from disabling thread support with new clang. I think that's probably OK.
This doesn't seem to fit with the other frontend options. This seems more like a language option. See the existing PosixThreads langopt.
If you add a langopt, you should be able to remove the option from CodeGenOptions, since codegen can check language options.