================
@@ -6510,6 +6510,98 @@ 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
+mangled 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. Names are matched against each
+variable's mangled name, and unrecognised names are silently ignored.
+
+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:
+
+```console
+-mloadtime-comment-vars=<var1>[,<var2>,...]
+```
+
+In C, variable names are not mangled, so the mangled name is identical to the
source
+identifier (for example, `sccsid`). In C++, the mangled name follows the
+Itanium C++ ABI, so a namespace-scoped or class-scoped variable must be named
+using its mangled form:
+
+```c++
+namespace N { char sccsid[] = "@(#) MyApp Version 1.0"; } // N::sccsid ->
_ZN1N6sccsidE
+const char *App::version = "@(#) Built 2026-06-25"; // App::version ->
_ZN3App7versionE
+```
+
+```console
+-mloadtime-comment-vars=_ZN1N6sccsidE,_ZN3App7versionE
+```
+
+Valid variable types:
+
+A variable named in the list must meet all of these conditions to be
+preserved:
+
+- It must be defined at file, namespace, or class scope (a function-local
+ `static` variable is not supported).
+- Its type must be a character pointer (`char *`, `const char *`) or a
+ character array (`char[]`, `const char[]`).
----------------
tonykuttai wrote:
Done. The element type is now restricted to plain char via canonical-type
matching (`hasSameUnqualifiedType` with `Context.CharTy`), so signed char,
unsigned char, and the wide/Unicode character types don't match. A listed
variable of such a type is silently ignored, same as any other non-matching
type.
https://github.com/llvm/llvm-project/pull/187986
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits