-
-
Notifications
You must be signed in to change notification settings - Fork 470
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
MOLD removes GCC's offload symbols when linking #1190
Comments
Do I need an Nvidia card to reproduce the issue? I spin up Ubuntu 23.04 docker image, installed the compiler with |
Yes — if you want to reproduce the run-time result. No — to see the issue as there inspecting the resulting binaries for the symbols — or looking at GCC's lto-plugin/lto-plugin.c either in the debugger or compiling it with some some printf debugging (separate compilation should be possible). Namely, if you have the GOMP_offload_register_ver@GOMP_4.5 symbol in the binary, it is okay, if not, there os no offloading. Offloading (in GCC, I think also in LLVM, but I mightbe wrong) piggybacks on the LTO, using special sections like ".gnu.offload_lto_.opts" to store the data. That's primarily handled via the LDPT_REGISTER_CLAIM_FILE_HOOK or LDPT_REGISTER_CLAIM_FILE_HOOK_V2 hook. Namely, in the above linked linker plugin, claim_file_handler_v2 checks on one hand for normal LTO sections but also for files that contain offload sections. The former are claimed", the latter only remembered. Once done, in all_symbols_read_handler, GCC's LTO wrapper is called if either files have been claimed (normal host side LTO) or offload data has been found or both. My impression is that GCC's LTO plugin is never called and therefore cannot do the offloading code generation. Possibly, there is a check in MOLD that there is an LTO section, but for GCC offloading, also a ckeck for some offloading section is needed. The linker plugin itself only checks for ".gnu.offload_lto_.opts" (There are more but those are then handled by the LTO compiler itself.) For the LTO handling in GCC and the section names, see also https://gcc.gnu.org/wiki/Offloading#Address_mapping_tables I hope that helps. Thanks! |
(For LLVM, seemingly ".llvm.offloading" is used according to https://clang.llvm.org/docs/OffloadingDesign.html#linking-target-device-code — but I think they don't use linker plugins, but I have not digested LLVM's workflow.) |
Does compiling and linking with
|
Could you try again with the above commit? |
That's with a GCC compiler with enabled offload support.
For instance:
When using:
And then running:
The MOLD version lacks the following symbol:
And, hence, it fails here (I do have an Nvidia card for offloading):
The text was updated successfully, but these errors were encountered: