[PATCH] D144505: [Clang] Add options in LTO mode when cross compiling for AMDGPU

Joseph Huber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 22 08:10:19 PST 2023


jhuber6 added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:545
+    addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0],
+                  C.getDriver().getLTOMode() == LTOK_Thin);
   CmdArgs.push_back("-shared");
----------------
JonChesterfield wrote:
> What's the test against OK_Thin for? ThinLTO is a thing but I don't know if it exists (/works) on amdgpu, is this that?
AMDGPU's linker is `lld` so it works "in theory". But in practice, separate linking of object files isn't fully supported by the ABI. So I consider it a "your mileage may vary" scenario. FWIW, it functioned properly with my experimental libc setup
```
$ cat main.cpp
int foo();

int main() {
  return foo();
}
$ cat foo.cpp
int foo() { return 3; }
$ clang++ crt1.o main.cpp foo.cpp --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -Wl,-plugin-opt=mcpu=gfx1030 -nogpulib -o image -flto=thin
$ amdhsa_loader image; echo $?
3
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144505/new/

https://reviews.llvm.org/D144505



More information about the cfe-commits mailing list