-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add @[Linkage("value")]
annotation (applies to fun
)
#15426
base: master
Are you sure you want to change the base?
Add @[Linkage("value")]
annotation (applies to fun
)
#15426
Conversation
The annotation can be specified on fun definitions (with a body). Incidently it can also be specified to extern fun in lib declarations (without a body) in which case LLVM may only accept a few values (external, weak). The linkage is only set during codegen when `--single-module` is set, since otherwise it would prevent any module from calling funs that are always declared in the `main` module.
It would be nice to have a spec for this. This should be quite trivial: Build a binary which includes a fun with |
I added a spec that checks if the linkage as been correctly set on the LLVM bitcode. That only tests the intended behavior, not that the linked binary behaves as expected, but it avoids having to find alternatives to |
Declares a new compiler annotation,
Linkage
, that may take one of the following values:"external"
—the symbol is referenced in the object file and is visible to all symbols from all object files (this is the default)."internal"
—the symbol will be referenced in the object file, but is only visible to symbols within that object only.The annotation can only be specified on
fun
definitions (with a body). Incidentally it can also be specified to externfun
inlib
declarations (without a body), though the only value accepted by LLVM will beexternal
and a few other values (not implemented).I chose to limit the possible values, and not expose all values from
LLVM::Linkage
. We should have a proper discussion about adding more. For example we might consider theweak
value in a future development, but we'll need to correctly define what we mean with "weak" linkage (there are multiple definitions).Related to #921