Skip to content

Commit 81db69d

Browse files
committed
Drop -foutput-file-base, use -dumpdir
1 parent 25381a2 commit 81db69d

File tree

7 files changed

+82
-89
lines changed

7 files changed

+82
-89
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5895,11 +5895,6 @@ def o : JoinedOrSeparate<["-"], "o">,
58955895
Visibility<[ClangOption, CC1Option, CC1AsOption, FC1Option, FlangOption]>,
58965896
HelpText<"Write output to <file>">, MetaVarName<"<file>">,
58975897
MarshallingInfoString<FrontendOpts<"OutputFile">>;
5898-
def foutput_file_base : Joined<["-"], "foutput-file-base=">,
5899-
Flags<[NoXarchOption, HelpHidden]>,
5900-
Visibility<[ClangOption]>,
5901-
HelpText<"Name extra output files after <base> not the main output file">,
5902-
MetaVarName<"<base>">;
59035898
def object_file_name_EQ : Joined<["-"], "object-file-name=">,
59045899
Visibility<[ClangOption, CC1Option, CC1AsOption, CLOption, DXCOption]>,
59055900
HelpText<"Set the output <file> for debug infos">, MetaVarName<"<file>">,

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,22 @@ static void renderRemarksOptions(const ArgList &Args, ArgStringList &CmdArgs,
294294
Format = A->getValue();
295295

296296
SmallString<128> F;
297-
if (const Arg *A = Args.getLastArg(options::OPT_foptimization_record_file_EQ))
297+
if (const Arg *A =
298+
Args.getLastArg(options::OPT_foptimization_record_file_EQ)) {
298299
F = A->getValue();
299-
else if (const Arg *A = Args.getLastArg(options::OPT_foutput_file_base))
300+
F += ".";
301+
} else if (const Arg *A = Args.getLastArg(options::OPT_dumpdir)) {
300302
F = A->getValue();
301-
else if (Output.isFilename())
303+
} else if (Output.isFilename()) {
302304
F = Output.getFilename();
305+
F += ".";
306+
}
303307

304308
assert(!F.empty() && "Cannot determine remarks output name.");
305309
// Append "opt.ld.<format>" to the end of the file name.
306310
CmdArgs.push_back(Args.MakeArgString(Twine(PluginOptPrefix) +
307-
"opt-remarks-filename=" + F +
308-
".opt.ld." + Format));
311+
"opt-remarks-filename=" + F + "opt.ld." +
312+
Format));
309313

310314
if (const Arg *A =
311315
Args.getLastArg(options::OPT_foptimization_record_passes_EQ))
@@ -1069,13 +1073,15 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
10691073
}
10701074

10711075
if (Args.hasArg(options::OPT_gsplit_dwarf)) {
1072-
StringRef F;
1073-
if (const Arg *A = Args.getLastArg(options::OPT_foutput_file_base))
1076+
SmallString<128> F;
1077+
if (const Arg *A = Args.getLastArg(options::OPT_dumpdir)) {
10741078
F = A->getValue();
1075-
else
1079+
} else {
10761080
F = Output.getFilename();
1081+
F += "_";
1082+
}
10771083
CmdArgs.push_back(
1078-
Args.MakeArgString(Twine(PluginOptPrefix) + "dwo_dir=" + F + "_dwo"));
1084+
Args.MakeArgString(Twine(PluginOptPrefix) + "dwo_dir=" + F + "dwo"));
10791085
}
10801086

10811087
if (IsThinLTO && !IsOSAIX)
@@ -1338,9 +1344,6 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
13381344
for (auto A : Args.getAllArgValues(options::OPT_Xthinlto_distributor_EQ))
13391345
CmdArgs.push_back(Args.MakeArgString("--thinlto-distributor-arg=" + A));
13401346
}
1341-
1342-
// clang-linker-wrapper adds this without checking if it is needed.
1343-
Args.ClaimAllArgs(options::OPT_foutput_file_base);
13441347
}
13451348

13461349
void tools::addOpenMPRuntimeLibraryPath(const ToolChain &TC,

clang/test/Driver/linker-wrapper-libs.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ int bar() { return weak; }
4848
// RUN: --linker-path=/usr/bin/ld %t.a %t.o -o a.out 2>&1 \
4949
// RUN: | FileCheck %s --check-prefix=LIBRARY-RESOLVES
5050

51-
// LIBRARY-RESOLVES: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.o {{.*}}.o
52-
// LIBRARY-RESOLVES: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx1030 {{.*}}.o {{.*}}.o
51+
// LIBRARY-RESOLVES: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.o {{.*}}.o
52+
// LIBRARY-RESOLVES: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=amdgcn-amd-amdhsa -mcpu=gfx1030 {{.*}}.o {{.*}}.o
5353

5454
//
5555
// Check that we extract a static library that defines a global visibile to the
@@ -72,8 +72,8 @@ int bar() { return weak; }
7272
// RUN: --linker-path=/usr/bin/ld %t.a %t.o -o a.out 2>&1 \
7373
// RUN: | FileCheck %s --check-prefix=LIBRARY-GLOBAL
7474

75-
// LIBRARY-GLOBAL: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.o {{.*}}.o
76-
// LIBRARY-GLOBAL: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx1030 {{.*}}.o {{.*}}.o
75+
// LIBRARY-GLOBAL: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.o {{.*}}.o
76+
// LIBRARY-GLOBAL: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=amdgcn-amd-amdhsa -mcpu=gfx1030 {{.*}}.o {{.*}}.o
7777

7878
//
7979
// Check that we do not extract a global symbol if the source file was not
@@ -95,8 +95,8 @@ int bar() { return weak; }
9595
// RUN: --linker-path=/usr/bin/ld %t.o %t.a -o a.out 2>&1 \
9696
// RUN: | FileCheck %s --check-prefix=LIBRARY-GLOBAL-NONE
9797

98-
// LIBRARY-GLOBAL-NONE-NOT: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx1030 {{.*}}.o {{.*}}.o
99-
// LIBRARY-GLOBAL-NONE-NOT: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.o {{.*}}.o
98+
// LIBRARY-GLOBAL-NONE-NOT: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=amdgcn-amd-amdhsa -mcpu=gfx1030 {{.*}}.o {{.*}}.o
99+
// LIBRARY-GLOBAL-NONE-NOT: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.o {{.*}}.o
100100

101101
//
102102
// Check that we do not extract an external weak symbol.
@@ -116,9 +116,9 @@ int bar() { return weak; }
116116
// RUN: --linker-path=/usr/bin/ld %t.o %t.a -o a.out 2>&1 \
117117
// RUN: | FileCheck %s --check-prefix=LIBRARY-WEAK
118118

119-
// LIBRARY-WEAK: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70
119+
// LIBRARY-WEAK: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=nvptx64-nvidia-cuda -march=sm_70
120120
// LIBRARY-WEAK-NOT: {{.*}}.o {{.*}}.o
121-
// LIBRARY-WEAK: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx1030
121+
// LIBRARY-WEAK: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=amdgcn-amd-amdhsa -mcpu=gfx1030
122122

123123
//
124124
// Check that we do not extract an unneeded hidden symbol.
@@ -138,9 +138,9 @@ int bar() { return weak; }
138138
// RUN: --linker-path=/usr/bin/ld %t.o %t.a -o a.out 2>&1 \
139139
// RUN: | FileCheck %s --check-prefix=LIBRARY-HIDDEN
140140

141-
// LIBRARY-HIDDEN: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70
141+
// LIBRARY-HIDDEN: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=nvptx64-nvidia-cuda -march=sm_70
142142
// LIBRARY-HIDDEN-NOT: {{.*}}.o {{.*}}.o
143-
// LIBRARY-HIDDEN: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx1030
143+
// LIBRARY-HIDDEN: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=amdgcn-amd-amdhsa -mcpu=gfx1030
144144

145145
//
146146
// Check that we do not extract a static library that defines a global visibile
@@ -161,9 +161,9 @@ int bar() { return weak; }
161161
// RUN: --linker-path=/usr/bin/ld %t.o %t.a %t.a -o a.out 2>&1 \
162162
// RUN: | FileCheck %s --check-prefix=LIBRARY-GLOBAL-DEFINED
163163

164-
// LIBRARY-GLOBAL-DEFINED: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.o {{.*}}.o
164+
// LIBRARY-GLOBAL-DEFINED: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.o {{.*}}.o
165165
// LIBRARY-GLOBAL-DEFINED-NOT: {{.*}}gfx1030{{.*}}.o
166-
// LIBRARY-GLOBAL-DEFINED: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx1030 {{.*}}.o {{.*}}.o
166+
// LIBRARY-GLOBAL-DEFINED: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=amdgcn-amd-amdhsa -mcpu=gfx1030 {{.*}}.o {{.*}}.o
167167

168168
//
169169
// Check that we can use --[no-]whole-archive to control extraction.
@@ -185,7 +185,7 @@ int bar() { return weak; }
185185
// RUN: --linker-path=/usr/bin/ld %t.o --whole-archive %t.a -o a.out 2>&1 \
186186
// RUN: | FileCheck %s --check-prefix=LIBRARY-WHOLE-ARCHIVE
187187

188-
// LIBRARY-WHOLE-ARCHIVE: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.o {{.*}}.o
189-
// LIBRARY-WHOLE-ARCHIVE: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx1030 {{.*}}.o {{.*}}.o
190-
// LIBRARY-WHOLE-ARCHIVE: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_52 {{.*}}.o
191-
// LIBRARY-WHOLE-ARCHIVE: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx90a {{.*}}.o
188+
// LIBRARY-WHOLE-ARCHIVE: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.o {{.*}}.o
189+
// LIBRARY-WHOLE-ARCHIVE: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=amdgcn-amd-amdhsa -mcpu=gfx1030 {{.*}}.o {{.*}}.o
190+
// LIBRARY-WHOLE-ARCHIVE: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=nvptx64-nvidia-cuda -march=sm_52 {{.*}}.o
191+
// LIBRARY-WHOLE-ARCHIVE: clang{{.*}} -o {{.*}}.img -dumpdir {{.*}}.img. --target=amdgcn-amd-amdhsa -mcpu=gfx90a {{.*}}.o

clang/test/Driver/linker-wrapper.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ __attribute__((visibility("protected"), used)) int x;
2222
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
2323
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=NVPTX-LINK
2424

25-
// NVPTX-LINK: clang{{.*}} -o {{.*}}.img -foutput-file-base=a.out.nvptx64.sm_70.img --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.o {{.*}}.o
25+
// NVPTX-LINK: clang{{.*}} -o {{.*}}.img -dumpdir a.out.nvptx64.sm_70.img. --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.o {{.*}}.o
2626

2727
// RUN: clang-offload-packager -o %t.out \
2828
// RUN: --image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
@@ -40,7 +40,7 @@ __attribute__((visibility("protected"), used)) int x;
4040
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
4141
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=AMDGPU-LINK
4242

43-
// AMDGPU-LINK: clang{{.*}} -o {{.*}}.img -foutput-file-base=a.out.amdgcn.gfx908.img --target=amdgcn-amd-amdhsa -mcpu=gfx908 -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
43+
// AMDGPU-LINK: clang{{.*}} -o {{.*}}.img -dumpdir a.out.amdgcn.gfx908.img. --target=amdgcn-amd-amdhsa -mcpu=gfx908 -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
4444

4545
// RUN: clang-offload-packager -o %t.out \
4646
// RUN: --image=file=%t.amdgpu.bc,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx1030 \
@@ -57,7 +57,7 @@ __attribute__((visibility("protected"), used)) int x;
5757
// RUN: not clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
5858
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=SPIRV-LINK
5959

60-
// SPIRV-LINK: clang{{.*}} -o {{.*}}.img -foutput-file-base=a.out.spirv64..img --target=spirv64-unknown-unknown {{.*}}.o --sycl-link -Xlinker -triple=spirv64-unknown-unknown -Xlinker -arch=
60+
// SPIRV-LINK: clang{{.*}} -o {{.*}}.img -dumpdir a.out.spirv64..img. --target=spirv64-unknown-unknown {{.*}}.o --sycl-link -Xlinker -triple=spirv64-unknown-unknown -Xlinker -arch=
6161

6262
// RUN: clang-offload-packager -o %t.out \
6363
// RUN: --image=file=%t.elf.o,kind=openmp,triple=x86_64-unknown-linux-gnu \
@@ -68,7 +68,7 @@ __attribute__((visibility("protected"), used)) int x;
6868
// RUN: --linker-path=/usr/bin/ld.lld --whole-archive %t.a --no-whole-archive \
6969
// RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CPU-LINK
7070

71-
// CPU-LINK: clang{{.*}} -o {{.*}}.img -foutput-file-base=a.out.x86_64..img --target=x86_64-unknown-linux-gnu -Wl,--no-undefined {{.*}}.o {{.*}}.o -Wl,-Bsymbolic -shared -Wl,--whole-archive {{.*}}.a -Wl,--no-whole-archive
71+
// CPU-LINK: clang{{.*}} -o {{.*}}.img -dumpdir a.out.x86_64..img. --target=x86_64-unknown-linux-gnu -Wl,--no-undefined {{.*}}.o {{.*}}.o -Wl,-Bsymbolic -shared -Wl,--whole-archive {{.*}}.a -Wl,--no-whole-archive
7272

7373
// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o
7474
// RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu -mllvm -openmp-opt-disable \
@@ -100,8 +100,8 @@ __attribute__((visibility("protected"), used)) int x;
100100
// RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu \
101101
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CUDA
102102

103-
// CUDA: clang{{.*}} -o [[IMG_SM70:.+]] -foutput-file-base=a.out.nvptx64.sm_70.img --target=nvptx64-nvidia-cuda -march=sm_70
104-
// CUDA: clang{{.*}} -o [[IMG_SM52:.+]] -foutput-file-base=a.out.nvptx64.sm_52.img --target=nvptx64-nvidia-cuda -march=sm_52
103+
// CUDA: clang{{.*}} -o [[IMG_SM70:.+]] -dumpdir a.out.nvptx64.sm_70.img. --target=nvptx64-nvidia-cuda -march=sm_70
104+
// CUDA: clang{{.*}} -o [[IMG_SM52:.+]] -dumpdir a.out.nvptx64.sm_52.img. --target=nvptx64-nvidia-cuda -march=sm_52
105105
// CUDA: fatbinary{{.*}}-64 --create {{.*}}.fatbin --image=profile=sm_70,file=[[IMG_SM70]] --image=profile=sm_52,file=[[IMG_SM52]]
106106
// CUDA: usr/bin/ld{{.*}} {{.*}}.openmp.image.{{.*}}.o {{.*}}.cuda.image.{{.*}}.o
107107

@@ -127,8 +127,8 @@ __attribute__((visibility("protected"), used)) int x;
127127
// RUN: --compress --compression-level=6 \
128128
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=HIP
129129

130-
// HIP: clang{{.*}} -o [[IMG_GFX90A:.+]] -foutput-file-base=a.out.amdgcn.gfx90a.img --target=amdgcn-amd-amdhsa -mcpu=gfx90a
131-
// HIP: clang{{.*}} -o [[IMG_GFX908:.+]] -foutput-file-base=a.out.amdgcn.gfx908.img --target=amdgcn-amd-amdhsa -mcpu=gfx908
130+
// HIP: clang{{.*}} -o [[IMG_GFX90A:.+]] -dumpdir a.out.amdgcn.gfx90a.img. --target=amdgcn-amd-amdhsa -mcpu=gfx90a
131+
// HIP: clang{{.*}} -o [[IMG_GFX908:.+]] -dumpdir a.out.amdgcn.gfx908.img. --target=amdgcn-amd-amdhsa -mcpu=gfx908
132132
// HIP: clang-offload-bundler{{.*}}-type=o -bundle-align=4096 -compress -compression-level=6 -targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa--gfx90a,hip-amdgcn-amd-amdhsa--gfx908 -input={{/dev/null|NUL}} -input=[[IMG_GFX90A]] -input=[[IMG_GFX908]] -output={{.*}}.hipfb
133133

134134
// RUN: clang-offload-packager -o %t.out \
@@ -157,7 +157,7 @@ __attribute__((visibility("protected"), used)) int x;
157157
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run --clang-backend \
158158
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CLANG-BACKEND
159159

160-
// CLANG-BACKEND: clang{{.*}} -o {{.*}}.img -foutput-file-base=a.out.amdgcn.gfx908.img --target=amdgcn-amd-amdhsa -mcpu=gfx908 -flto -Wl,--no-undefined {{.*}}.o
160+
// CLANG-BACKEND: clang{{.*}} -o {{.*}}.img -dumpdir a.out.amdgcn.gfx908.img. --target=amdgcn-amd-amdhsa -mcpu=gfx908 -flto -Wl,--no-undefined {{.*}}.o
161161

162162
// RUN: clang-offload-packager -o %t.out \
163163
// RUN: --image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
@@ -180,8 +180,8 @@ __attribute__((visibility("protected"), used)) int x;
180180
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
181181
// RUN: --linker-path=/usr/bin/ld %t-on.o %t-off.o %t.a -o a.out 2>&1 | FileCheck %s --check-prefix=AMD-TARGET-ID
182182

183-
// AMD-TARGET-ID: clang{{.*}} -o {{.*}}.img -foutput-file-base=a.out.amdgcn.gfx90a:xnack+.img --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack+ -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
184-
// AMD-TARGET-ID: clang{{.*}} -o {{.*}}.img -foutput-file-base=a.out.amdgcn.gfx90a:xnack-.img --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack- -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
183+
// AMD-TARGET-ID: clang{{.*}} -o {{.*}}.img -dumpdir a.out.amdgcn.gfx90a:xnack+.img. --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack+ -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
184+
// AMD-TARGET-ID: clang{{.*}} -o {{.*}}.img -dumpdir a.out.amdgcn.gfx90a:xnack-.img. --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack- -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
185185

186186
// RUN: clang-offload-packager -o %t-lib.out \
187187
// RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=generic
@@ -196,8 +196,8 @@ __attribute__((visibility("protected"), used)) int x;
196196
// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
197197
// RUN: --linker-path=/usr/bin/ld %t1.o %t2.o %t.a -o a.out 2>&1 | FileCheck %s --check-prefix=ARCH-ALL
198198

199-
// ARCH-ALL: clang{{.*}} -o {{.*}}.img -foutput-file-base=a.out.amdgcn.gfx90a.img --target=amdgcn-amd-amdhsa -mcpu=gfx90a -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
200-
// ARCH-ALL: clang{{.*}} -o {{.*}}.img -foutput-file-base=a.out.amdgcn.gfx908.img --target=amdgcn-amd-amdhsa -mcpu=gfx908 -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
199+
// ARCH-ALL: clang{{.*}} -o {{.*}}.img -dumpdir a.out.amdgcn.gfx90a.img. --target=amdgcn-amd-amdhsa -mcpu=gfx90a -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
200+
// ARCH-ALL: clang{{.*}} -o {{.*}}.img -dumpdir a.out.amdgcn.gfx908.img. --target=amdgcn-amd-amdhsa -mcpu=gfx908 -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o
201201

202202
// RUN: clang-offload-packager -o %t.out \
203203
// RUN: --image=file=%t.elf.o,kind=openmp,triple=x86_64-unknown-linux-gnu \
@@ -207,7 +207,7 @@ __attribute__((visibility("protected"), used)) int x;
207207
// RUN: --linker-path=/usr/bin/ld.lld -r %t.o \
208208
// RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=RELOCATABLE-LINK
209209

210-
// RELOCATABLE-LINK: clang{{.*}} -o {{.*}}.img -foutput-file-base=a.out.x86_64..img --target=x86_64-unknown-linux-gnu
210+
// RELOCATABLE-LINK: clang{{.*}} -o {{.*}}.img -dumpdir a.out.x86_64..img. --target=x86_64-unknown-linux-gnu
211211
// RELOCATABLE-LINK: /usr/bin/ld.lld{{.*}}-r
212212
// RELOCATABLE-LINK: llvm-objcopy{{.*}}a.out --remove-section .llvm.offloading
213213

@@ -219,7 +219,7 @@ __attribute__((visibility("protected"), used)) int x;
219219
// RUN: --linker-path=/usr/bin/ld.lld -r %t.o \
220220
// RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=RELOCATABLE-LINK-HIP
221221

222-
// RELOCATABLE-LINK-HIP: clang{{.*}} -o {{.*}}.img -foutput-file-base=a.out.amdgcn.gfx90a.img --target=amdgcn-amd-amdhsa
222+
// RELOCATABLE-LINK-HIP: clang{{.*}} -o {{.*}}.img -dumpdir a.out.amdgcn.gfx90a.img. --target=amdgcn-amd-amdhsa
223223
// RELOCATABLE-LINK-HIP: clang-offload-bundler{{.*}} -type=o -bundle-align=4096 -targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa--gfx90a -input={{/dev/null|NUL}} -input={{.*}} -output={{.*}}
224224
// RELOCATABLE-LINK-HIP: /usr/bin/ld.lld{{.*}}-r
225225
// RELOCATABLE-LINK-HIP: llvm-objcopy{{.*}}a.out --remove-section .llvm.offloading
@@ -233,7 +233,7 @@ __attribute__((visibility("protected"), used)) int x;
233233
// RUN: --linker-path=/usr/bin/ld.lld -r %t.o \
234234
// RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=RELOCATABLE-LINK-CUDA
235235

236-
// RELOCATABLE-LINK-CUDA: clang{{.*}} -o {{.*}}.img -foutput-file-base=a.out.nvptx64.sm_89.img --target=nvptx64-nvidia-cuda
236+
// RELOCATABLE-LINK-CUDA: clang{{.*}} -o {{.*}}.img -dumpdir a.out.nvptx64.sm_89.img. --target=nvptx64-nvidia-cuda
237237
// RELOCATABLE-LINK-CUDA: fatbinary{{.*}} -64 --create {{.*}}.fatbin --image=profile=sm_89,file={{.*}}.img
238238
// RELOCATABLE-LINK-CUDA: /usr/bin/ld.lld{{.*}}-r
239239
// RELOCATABLE-LINK-CUDA: llvm-objcopy{{.*}}a.out --remove-section .llvm.offloading

clang/test/Driver/lto-dwo.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
// Confirm that -gsplit-dwarf=DIR is passed to linker
22

3-
// RUN: %clang --target=x86_64-unknown-linux -### %s -flto=thin -gsplit-dwarf -o a.out 2> %t
3+
// DEFINE: %{RUN-ELF} = %clang --target=x86_64-unknown-linux -### %s \
4+
// DEFINE: -flto=thin -gsplit-dwarf
5+
6+
// RUN: %{RUN-ELF} -o a.out 2> %t
47
// RUN: FileCheck -check-prefix=CHECK-LINK-ELF-DWO-DIR-DEFAULT < %t %s
58
// RUN: %clang_cl --target=x86_64-unknown-windows-msvc -### -fuse-ld=lld -flto -gsplit-dwarf -o a.out -- %s 2> %t
69
// RUN: FileCheck -check-prefix=CHECK-LINK-COFF-DWO-DIR-DEFAULT < %t %s
710
//
8-
// CHECK-LINK-ELF-DWO-DIR-DEFAULT: "-plugin-opt=dwo_dir=a.out_dwo"
11+
// CHECK-LINK-ELF-DWO-DIR-DEFAULT: "-plugin-opt=dwo_dir=a.out-dwo"
912
// CHECK-LINK-COFF-DWO-DIR-DEFAULT: "/dwodir:a.out_dwo"
13+
14+
// Check -dumpdir effect on -gsplit-dwarf.
15+
//
16+
// DEFINE: %{RUN-DUMPDIR} = %{RUN-ELF} -dumpdir /dir/file.ext
17+
//
18+
// RUN: %{RUN-ELF} 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O
19+
// RUN: %{RUN-ELF} -o FOO 2>&1 | FileCheck %s -check-prefix=CHECK-O
20+
// RUN: %{RUN-DUMPDIR} 2>&1 | FileCheck %s -check-prefix=CHECK-DUMPDIR
21+
// RUN: %{RUN-DUMPDIR} -o FOO 2>&1 | FileCheck %s -check-prefix=CHECK-DUMPDIR
22+
//
23+
// CHECK-NO-O: "-plugin-opt=dwo_dir=a-dwo"
24+
// CHECK-O: "-plugin-opt=dwo_dir=FOO-dwo"
25+
// CHECK-DUMPDIR: "-plugin-opt=dwo_dir=/dir/file.extdwo"

0 commit comments

Comments
 (0)