jhuber6 created this revision.
jhuber6 added reviewers: arsenm, JonChesterfield, saiislam, yaxunl.
Herald added subscribers: kosarev, t-tye, tpr, dstuttard, kzhuravl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.
We use LLD to perform AMDGPU linking. This linker accepts some arguments
through the `-plugin-opt` facilities. These options match what `Clang`
will output when given the same input.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D128923
Files:
clang/test/Driver/linker-wrapper.c
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===================================================================
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -8,9 +8,9 @@
//
// This tool works as a wrapper over a linking job. This tool is used to create
// linked device images for offloading. It scans the linker's input for
embedded
-// device offloading data stored in sections `.llvm.offloading.<triple>.<arch>`
-// and extracts it as a temporary file. The extracted device files will then be
-// passed to a device linking job to create a final device image.
+// device offloading data stored in sections `.llvm.offloading` and extracts it
+// as a temporary file. The extracted device files will then be passed to a
+// device linking job to create a final device image.
//
//===---------------------------------------------------------------------===//
@@ -573,6 +573,7 @@
"out");
if (!TempFileOrErr)
return TempFileOrErr.takeError();
+ std::string ArchArg = ("-plugin-opt=mcpu=" + Arch).str();
SmallVector<StringRef, 16> CmdArgs;
CmdArgs.push_back(*LLDPath);
@@ -580,6 +581,8 @@
CmdArgs.push_back("gnu");
CmdArgs.push_back("--no-undefined");
CmdArgs.push_back("-shared");
+ CmdArgs.push_back("-plugin-opt=-amdgpu-internalize-symbols");
+ CmdArgs.push_back(ArchArg);
CmdArgs.push_back("-o");
CmdArgs.push_back(*TempFileOrErr);
Index: clang/test/Driver/linker-wrapper.c
===================================================================
--- clang/test/Driver/linker-wrapper.c
+++ clang/test/Driver/linker-wrapper.c
@@ -18,7 +18,7 @@
// RUN: clang-linker-wrapper --host-triple x86_64-unknown-linux-gnu --dry-run
-linker-path \
// RUN: /usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s
--check-prefix=AMDGPU_LINK
-// AMDGPU_LINK: lld{{.*}}-flavor gnu --no-undefined -shared -o {{.*}}.out
{{.*}}.o {{.*}}.o
+// AMDGPU_LINK: lld{{.*}}-flavor gnu --no-undefined -shared
-plugin-opt=-amdgpu-internalize-symbols -plugin-opt=mcpu=gfx908 -o {{.*}}.out
{{.*}}.o {{.*}}.o
// RUN: clang-offload-packager -o %t.out \
// RUN:
--image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=x86_64-unknown-linux-gnu \
@@ -90,7 +90,7 @@
// RUN: /usr/bin/ld --device-linker=a --device-linker=nvptx64-nvidia-cuda=b
-- \
// RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=LINKER_ARGS
-// LINKER_ARGS: lld{{.*}}-flavor gnu --no-undefined -shared -o {{.*}}.out
{{.*}}.o a
+// LINKER_ARGS: lld{{.*}}-flavor gnu --no-undefined -shared
-plugin-opt=-amdgpu-internalize-symbols -plugin-opt=mcpu=gfx908 -o {{.*}}.out
{{.*}}.o a
// LINKER_ARGS: nvlink{{.*}}-m64 -o {{.*}}.out -arch sm_70 {{.*}}.o a b
// RUN: clang-offload-packager -o %t-lib.out \
Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===================================================================
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -8,9 +8,9 @@
//
// This tool works as a wrapper over a linking job. This tool is used to create
// linked device images for offloading. It scans the linker's input for embedded
-// device offloading data stored in sections `.llvm.offloading.<triple>.<arch>`
-// and extracts it as a temporary file. The extracted device files will then be
-// passed to a device linking job to create a final device image.
+// device offloading data stored in sections `.llvm.offloading` and extracts it
+// as a temporary file. The extracted device files will then be passed to a
+// device linking job to create a final device image.
//
//===---------------------------------------------------------------------===//
@@ -573,6 +573,7 @@
"out");
if (!TempFileOrErr)
return TempFileOrErr.takeError();
+ std::string ArchArg = ("-plugin-opt=mcpu=" + Arch).str();
SmallVector<StringRef, 16> CmdArgs;
CmdArgs.push_back(*LLDPath);
@@ -580,6 +581,8 @@
CmdArgs.push_back("gnu");
CmdArgs.push_back("--no-undefined");
CmdArgs.push_back("-shared");
+ CmdArgs.push_back("-plugin-opt=-amdgpu-internalize-symbols");
+ CmdArgs.push_back(ArchArg);
CmdArgs.push_back("-o");
CmdArgs.push_back(*TempFileOrErr);
Index: clang/test/Driver/linker-wrapper.c
===================================================================
--- clang/test/Driver/linker-wrapper.c
+++ clang/test/Driver/linker-wrapper.c
@@ -18,7 +18,7 @@
// RUN: clang-linker-wrapper --host-triple x86_64-unknown-linux-gnu --dry-run -linker-path \
// RUN: /usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=AMDGPU_LINK
-// AMDGPU_LINK: lld{{.*}}-flavor gnu --no-undefined -shared -o {{.*}}.out {{.*}}.o {{.*}}.o
+// AMDGPU_LINK: lld{{.*}}-flavor gnu --no-undefined -shared -plugin-opt=-amdgpu-internalize-symbols -plugin-opt=mcpu=gfx908 -o {{.*}}.out {{.*}}.o {{.*}}.o
// RUN: clang-offload-packager -o %t.out \
// RUN: --image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=x86_64-unknown-linux-gnu \
@@ -90,7 +90,7 @@
// RUN: /usr/bin/ld --device-linker=a --device-linker=nvptx64-nvidia-cuda=b -- \
// RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=LINKER_ARGS
-// LINKER_ARGS: lld{{.*}}-flavor gnu --no-undefined -shared -o {{.*}}.out {{.*}}.o a
+// LINKER_ARGS: lld{{.*}}-flavor gnu --no-undefined -shared -plugin-opt=-amdgpu-internalize-symbols -plugin-opt=mcpu=gfx908 -o {{.*}}.out {{.*}}.o a
// LINKER_ARGS: nvlink{{.*}}-m64 -o {{.*}}.out -arch sm_70 {{.*}}.o a b
// RUN: clang-offload-packager -o %t-lib.out \
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits