[clang] [Clang] Add clang driver option -fpartition-static-data-sections (PR #124991)

Mingming Liu via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 6 14:00:15 PST 2026


================
@@ -6182,6 +6182,42 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
     }
   }
 
+  if (Arg *A =
+          Args.getLastArg(options::OPT_fpartition_static_data_sections,
+                          options::OPT_fno_partition_static_data_sections)) {
+    if (!A->getOption().matches(
+            options::OPT_fno_partition_static_data_sections)) {
+      // This codegen pass is only available on x86 and AArch64 ELF targets.
+      if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF()) {
+        A->render(Args, CmdArgs);
+        // Turn on -memprof-annotate-static-data-prefix.
----------------
mingmingl-llvm wrote:

> Instead we can say something like "For maximum effectiveness, use LLD and pass the -Wl,-z,-keep-data-section-prefix flag"

I can add this in the doc as well.

https://github.com/llvm/llvm-project/pull/124991


More information about the cfe-commits mailing list