[PATCH] D73307: Unique Names for Functions with Internal Linkage
Sriraman Tallam via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 8 19:01:21 PDT 2020
tmsriram added a comment.
We just noticed an issue with alias attribute and this option. Here is the code that exposes the problem:
alias_global.c
static int foo;
extern int bar __attribute__((alias("foo")))
$ clang -c alias_global.c -funique-internal-linkage-names
alias_global.c:4:31: error: alias must point to a defined variable or function
extern int bar __attribute__((alias("foo")));
This happens because bar is aliased to "foo" and not "foo.<md5sum>".
I would like to know your thoughts on this? Here is what I think. alias attribute is a bit special in that the symbol name must be given carefully, for instance the mangled name if it is a C++ compile and the actual name for a C compile. Even without the option, the same error will happen if a C++ compiler was used on this code. So, in some sense, alias attribute requires the user to know what symbol name to expect. -funique-internal-linkage-names can be treated as just an additional extension of this where the user must append the md5 hash of the module, which can be computed independently with:
$ echo -n alias_global.c | md5sum
So, I suggest we leave it as it is and add to the documentation that this needs to be kept in mind.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73307/new/
https://reviews.llvm.org/D73307
More information about the cfe-commits
mailing list