Skip to content

Commit 812b982

Browse files
authored
[HIP] Fix compression arguments being passed to linker wrapper (#151591)
Summary: The new driver's behavior forwards all unrecognized command line arguments to the host linker. It only knew `--compress` so when `-compress` was passed it didn't forward it correctly. This patch changes the spelling because multi word arguments should have two dashes.
1 parent 48ea3e4 commit 812b982

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3014,12 +3014,12 @@ void tools::addOffloadCompressArgs(const llvm::opt::ArgList &TCArgs,
30143014
llvm::opt::ArgStringList &CmdArgs) {
30153015
if (TCArgs.hasFlag(options::OPT_offload_compress,
30163016
options::OPT_no_offload_compress, false))
3017-
CmdArgs.push_back("-compress");
3017+
CmdArgs.push_back("--compress");
30183018
if (TCArgs.hasArg(options::OPT_v))
3019-
CmdArgs.push_back("-verbose");
3019+
CmdArgs.push_back("--verbose");
30203020
if (auto *Arg = TCArgs.getLastArg(options::OPT_offload_compression_level_EQ))
30213021
CmdArgs.push_back(
3022-
TCArgs.MakeArgString(Twine("-compression-level=") + Arg->getValue()));
3022+
TCArgs.MakeArgString(Twine("--compression-level=") + Arg->getValue()));
30233023
}
30243024

30253025
void tools::addMCModel(const Driver &D, const llvm::opt::ArgList &Args,

clang/test/Driver/hip-offload-compress-zlib.hip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
// CHECK: clang-offload-bundler{{.*}} -type=bc
1616
// CHECK-SAME: -targets={{.*}}hip-amdgcn-amd-amdhsa-unknown-gfx1100,hip-amdgcn-amd-amdhsa-unknown-gfx1101
17-
// CHECK-SAME: -compress -verbose -compression-level=9
17+
// CHECK-SAME: --compress --verbose --compression-level=9
1818
// CHECK: Compressed bundle format
1919

2020
// Test uncompress of bundled bitcode.
@@ -41,4 +41,4 @@
4141

4242
// CO: clang-offload-bundler{{.*}} "-type=o"
4343
// CO-SAME: -targets={{.*}}hipv4-amdgcn-amd-amdhsa--gfx1100,hipv4-amdgcn-amd-amdhsa--gfx1101
44-
// CO-SAME: "-compress" "-verbose"
44+
// CO-SAME: "--compress" "--verbose"

clang/test/Driver/hip-offload-compress-zstd.hip

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
// CHECK: clang-offload-bundler{{.*}} -type=bc
1616
// CHECK-SAME: -targets={{.*}}hip-amdgcn-amd-amdhsa-unknown-gfx1100,hip-amdgcn-amd-amdhsa-unknown-gfx1101
17-
// CHECK-SAME: -compress -verbose -compression-level=9
17+
// CHECK-SAME: --compress --verbose --compression-level=9
1818
// CHECK: Compressed bundle format
1919

2020
// Test uncompress of bundled bitcode.
@@ -41,4 +41,16 @@
4141

4242
// CO: clang-offload-bundler{{.*}} "-type=o"
4343
// CO-SAME: -targets={{.*}}hipv4-amdgcn-amd-amdhsa--gfx1100,hipv4-amdgcn-amd-amdhsa--gfx1101
44-
// CO-SAME: "-compress" "-verbose"
44+
// CO-SAME: "--compress" "--verbose"
45+
46+
// RUN: rm -rf %t.bc
47+
// RUN: %clang -### -v --target=x86_64-linux-gnu \
48+
// RUN: -x hip --offload-arch=gfx1100 --offload-arch=gfx1101 \
49+
// RUN: --offload-new-driver -fgpu-rdc -nogpuinc -nogpulib \
50+
// RUN: %S/Inputs/hip_multiple_inputs/a.cu \
51+
// RUN: --offload-compress --offload-compression-level=9 \
52+
// RUN: --gpu-bundle-output \
53+
// RUN: -o %t.bc \
54+
// RUN: 2>&1 | FileCheck %s --check-prefix=NEWDRIVER
55+
56+
// NEWDRIVER: clang-linker-wrapper{{.*}}"--compress" "--verbose" "--compression-level=9"

0 commit comments

Comments
 (0)