[clang] [llvm] [Clang][AIX] Add -mloadtime-comment-vars flag to preserve identifying variables (PR #187986)

Hubert Tong via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 25 07:05:17 PDT 2026


================
@@ -6873,6 +6873,100 @@ When ``#pragma comment(copyright, ...)`` appears in a C++20 module interface
 unit, the copyright string is embedded only in the object file compiled from
 that interface unit. Importing TUs do not re-emit the string.
 
+Preserving Identifying Variables with -mloadtime-comment-vars
+--------------------------------------------------------------
+
+The ``-mloadtime-comment-vars=`` flag accepts a comma-separated list of
+global variable names that should be preserved in the final object file as
+loadtime identifying strings. This is an AIX-specific feature; on other
+targets the compiler emits a warning and the flag is not forwarded to
+``-cc1``.
+
+This flag complements ``#pragma comment(copyright, ...)`` for codebases that
+already use the traditional UNIX convention of embedding identifying strings
+directly in source variables rather than via a pragma.
+
+Syntax:
+
+.. code-block:: console
+
+  -mloadtime-comment-vars=<var1>[,<var2>,...]
+
+Name matching:
+
+Names are matched against the variable's **mangled IR symbol name** — the
+name as it appears in the object file.
----------------
hubert-reinterpretcast wrote:

People can "Google" this.
```suggestion
Names are matched against the variable's mangled name.
```

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


More information about the cfe-commits mailing list