Skip to content

Conversation

@cor3ntin
Copy link
Contributor

@cor3ntin cor3ntin commented Jun 5, 2025

The language of side seems fairly stable.
Setting the feature test macro will ease implementation in standard libraries.

The language of side seems fairly stable.
Setting the feature test macro will ease implementation in
standard libraries.
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jun 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 5, 2025

@llvm/pr-subscribers-clang

Author: Corentin Jabot (cor3ntin)

Changes

The language of side seems fairly stable.
Setting the feature test macro will ease implementation in standard libraries.


Full diff: https://github.com/llvm/llvm-project/pull/142936.diff

3 Files Affected:

  • (modified) clang/lib/Frontend/InitPreprocessor.cpp (+1-1)
  • (modified) clang/test/Lexer/cxx-features.cpp (+4)
  • (modified) clang/www/cxx_status.html (+1-6)
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index 69a91eef6aedb..ef1a508a96c35 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -773,7 +773,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts,
   Builder.defineMacro("__cpp_pack_indexing", "202311L");
   Builder.defineMacro("__cpp_deleted_function", "202403L");
   Builder.defineMacro("__cpp_variadic_friend", "202403L");
-  // Builder.defineMacro("__cpp_trivial_relocatability", "202502L");
+  Builder.defineMacro("__cpp_trivial_relocatability", "202502L");
 
   if (LangOpts.Char8)
     Builder.defineMacro("__cpp_char8_t", "202207L");
diff --git a/clang/test/Lexer/cxx-features.cpp b/clang/test/Lexer/cxx-features.cpp
index 8c1867d5c7365..ced5bcaf0db16 100644
--- a/clang/test/Lexer/cxx-features.cpp
+++ b/clang/test/Lexer/cxx-features.cpp
@@ -49,6 +49,10 @@
 #error "wrong value for __cpp_placeholder_variables"
 #endif
 
+#if check(trivial_relocatability, 202502, 202502, 202502, 202502, 202502, 202502, 202502)
+#error "wrong value for __cpp_trivial_relocatability"
+#endif
+
 // --- C++23 features ---
 
 #if check(auto_cast, 0, 0, 0, 0, 0, 202110, 202110)
diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index dff57689e84b9..cbcf462970b7f 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -280,12 +280,7 @@ <h2 id="cxx26">C++2c implementation status</h2>
  <tr>
   <td>Trivial Relocatability</pre></td>
   <td><a href="https://wg21.link/P2786">P2786R13</a></td>
-  <td class="partial" align="center">
-    <details>
-      <summary>Clang 21 (Partial)</summary>
-      The feature test macro (<code>__cpp_trivial_relocatability</code>) has not yet been set.
-    </details>
-  </td>
+  <td class="unreleased" align="center">Clang 21</td>
  </tr>
  <tr>
   <td><pre>#embed</pre></td>

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been in the tree for less than a month and we've not had a release out to the public with it yet, right? That seems a bit premature if we were waiting for some user experience before flipping the switch. I don't have a good intuition for how much use these facilities have gotten so far.

If @ldionne thinks this makes his life (or other standard libraries) easier though, it maybe be reasonable.

@EricWF
Copy link
Member

EricWF commented Jun 10, 2025

I'm OK with this, but @ldionne should be the one to approve.

@cor3ntin
Copy link
Contributor Author

cor3ntin commented Jun 12, 2025

@EricWF we decided to hold off (we keep finding minor issues so it needs more backing) - can you use either the major clang version or __has_builtin as a discriminant for the time being?

@EricWF
Copy link
Member

EricWF commented Jul 7, 2025

@cor3ntin I think Apple Clang still complicates version detection, and we can't use __has_builtin, because that's returned true for version of Clang where it's "broken" from libc++'s perspective.

I don't think @ldionne would feel comfortable shipping actual libc++ changes if the compiler doesn't feel comfortable with it's own implementation.

@cor3ntin
Copy link
Contributor Author

cor3ntin commented Jul 8, 2025

@cor3ntin I think Apple Clang still complicates version detection, and we can't use __has_builtin, because that's returned true for versions of Clang where it's "broken" from libc++'s perspective.

__builtin_is_cpp_trivially_relocatable is new in 21, it was never shipped (in either Clang or AppleClang), nor is it "broken", so it should be a suitable test

The reason clang is not setting the FTM in 21 is out of an abundance of caution, and because we found some minor bugs in the past couple of months, but it is certainly usable and doesn't have more bugs than other new features :)

@cor3ntin
Copy link
Contributor Author

@erichkeane any objection merging that ?

@erichkeane
Copy link
Collaborator

@erichkeane any objection merging that ?

Go for it, I haven't seen any churn on this in months, and it is the beginning of the cycle. No better time!

@cor3ntin cor3ntin merged commit 73cfd45 into llvm:main Sep 12, 2025
13 checks passed
@cor3ntin cor3ntin deleted the corentin/trivial_reloc_ftm branch September 12, 2025 06:05
@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 12, 2025

LLVM Buildbot has detected a new failure on builder lldb-x86_64-debian running on lldb-x86_64-debian while building clang at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/162/builds/30969

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: linux/aarch64/gcs/TestAArch64LinuxGCS.py (878 of 3190)
PASS: lldb-api :: lang/cpp/pointer_to_member_type_depending_on_parent_size/TestPointerToMemberTypeDependingOnParentSize.py (879 of 3190)
UNSUPPORTED: lldb-api :: functionalities/ubsan/user-expression/TestUbsanUserExpression.py (880 of 3190)
PASS: lldb-shell :: Commands/command-disassemble-cpu-features.yaml (881 of 3190)
UNSUPPORTED: lldb-api :: functionalities/tsan/cpp_global_location/TestTsanCPPGlobalLocation.py (882 of 3190)
UNSUPPORTED: lldb-api :: functionalities/fork/concurrent_vfork/TestConcurrentVFork.py (883 of 3190)
UNSUPPORTED: lldb-api :: functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py (884 of 3190)
PASS: lldb-api :: commands/target/anon-struct/TestTargetVarAnonStruct.py (885 of 3190)
PASS: lldb-shell :: SymbolFile/NativePDB/incomplete-tag-type.test (886 of 3190)
UNRESOLVED: lldb-api :: functionalities/postmortem/netbsd-core/TestNetBSDCore.py (887 of 3190)
******************** TEST 'lldb-api :: functionalities/postmortem/netbsd-core/TestNetBSDCore.py' FAILED ********************
Script:
--
/usr/bin/python3 /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./lib --env LLVM_INCLUDE_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/include --env LLVM_TOOLS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --arch x86_64 --build-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex --lldb-module-cache-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/lldb --compiler /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/clang --dsymutil /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/worker/2.0.1/lldb-x86_64-debian/build/./bin --lldb-obj-root /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb --lldb-libs-dir /home/worker/2.0.1/lldb-x86_64-debian/build/./lib --cmake-build-type Release -t /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/functionalities/postmortem/netbsd-core -p TestNetBSDCore.py
--
Exit Code: -11

Command Output (stdout):
--
lldb version 22.0.0git (https://github.com/llvm/llvm-project.git revision 73cfd45e3401b18730e283b8a13e21fb85de3a38)
  clang revision 73cfd45e3401b18730e283b8a13e21fb85de3a38
  llvm revision 73cfd45e3401b18730e283b8a13e21fb85de3a38
Skipping the following test categories: ['libc++', 'msvcstl', 'dsym', 'gmodules', 'debugserver', 'objc']

--
Command Output (stderr):
--
Change dir to: /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/functionalities/postmortem/netbsd-core
runCmd: settings clear --all

output: 

runCmd: settings set symbols.enable-external-lookup false

output: 

runCmd: settings set target.inherit-tcc true

output: 

runCmd: settings set target.disable-aslr false

output: 

runCmd: settings set target.detach-on-error false

output: 

runCmd: settings set target.auto-apply-fixits false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants