Skip to content

Commit

Permalink
[Linkerwrapper] Make -Xoffload-linker pass directly to clang
Browse files Browse the repository at this point in the history
Summary:
We provide `-Xoffload-linker` to pass arguments directly to the link
step. Currently this uses `-Wl,` implicitly which prevents us from using
clang options that we otherwise could make use of. This patch removes
that implicit behavior as users can just as easiliy pass
`-Xoffload-linker -Wl,-foo` if needed.
  • Loading branch information
jhuber6 committed Dec 11, 2023
1 parent 97efd8a commit ef23bba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions clang/test/Driver/linker-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@
// RUN: --linker-path=/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: clang{{.*}}--target=amdgcn-amd-amdhsa{{.*}}-Wl,a
// LINKER-ARGS: clang{{.*}}--target=nvptx64-nvidia-cuda{{.*}}-Wl,a -Wl,b
// LINKER-ARGS: clang{{.*}}--target=amdgcn-amd-amdhsa{{.*}}a
// LINKER-ARGS: clang{{.*}}--target=nvptx64-nvidia-cuda{{.*}}a b

// RUN: not clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu -ldummy \
// RUN: --linker-path=/usr/bin/ld --device-linker=a --device-linker=nvptx64-nvidia-cuda=b -- \
Expand Down
2 changes: 1 addition & 1 deletion clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args) {
std::back_inserter(CmdArgs));

for (StringRef Arg : Args.getAllArgValues(OPT_linker_arg_EQ))
CmdArgs.push_back(Args.MakeArgString("-Wl," + Arg));
CmdArgs.push_back(Args.MakeArgString(Arg));

for (StringRef Arg : Args.getAllArgValues(OPT_builtin_bitcode_EQ)) {
if (llvm::Triple(Arg.split('=').first) == Triple)
Expand Down

0 comments on commit ef23bba

Please sign in to comment.