Skip to content

Commit

Permalink
[Clang] Respect -L options when compiling directly for AMDGPU
Browse files Browse the repository at this point in the history
The AMDGPU linker is `lld`, which has full support for standard features
like static libraries. Previously the AMDGPU toolchain did not forward
`-L` arguments so we could not tell it where to find certain libraries.
This patch simply forwards it like the other toolchains.

Reviewed By: yaxunl, MaskRay

Differential Revision: https://reviews.llvm.org/D150013
  • Loading branch information
jhuber6 committed May 11, 2023
1 parent 3d4eed0 commit 027aeec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,11 @@ void tools::AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
Args.AddAllArgValues(CmdArgs, options::OPT_Zlinker_input);

// LIBRARY_PATH are included before user inputs and only supported on native
// toolchains.
// toolchains. Otherwise only add the '-L' arguments requested by the user.
if (!TC.isCrossCompiling())
addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
else
Args.AddAllArgs(CmdArgs, options::OPT_L);

for (const auto &II : Inputs) {
// If the current tool chain refers to an OpenMP offloading host, we
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Driver/amdgpu-toolchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
// DWARF_VER: "-dwarf-version=5"

// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
// RUN: -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=LTO %s
// RUN: -L. -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=LTO %s
// LTO: clang{{.*}} "-flto=full"{{.*}}"-fconvergent-functions"
// LTO: ld.lld{{.*}}-plugin-opt=mcpu=gfx906
// LTO: ld.lld{{.*}}"-L."{{.*}}"-plugin-opt=mcpu=gfx906"

0 comments on commit 027aeec

Please sign in to comment.