Skip to content

Commit 79467e6

Browse files
committed
replace the extension with the right functions
1 parent 30a9d9d commit 79467e6

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

clang/lib/Driver/ToolChains/ZOS.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,10 @@ void zos::Linker::ConstructJob(Compilation &C, const JobAction &JA,
153153
StringRef OutputName = Output.getFilename();
154154
// Strip away the last file suffix in presence from output name and add
155155
// a new .x suffix.
156-
size_t Suffix = OutputName.find_last_of('.');
157-
const char *SideDeckName =
158-
Args.MakeArgString(OutputName.substr(0, Suffix) + ".x");
156+
SmallString<128> SideDeckName = OutputName;
157+
llvm::sys::path::replace_extension(SideDeckName, "x");
159158
CmdArgs.push_back("-x");
160-
CmdArgs.push_back(SideDeckName);
159+
CmdArgs.push_back(Args.MakeArgString(SideDeckName));
161160
} else {
162161
// We need to direct side file to /dev/null to suppress linker warning when
163162
// the object file contains exported symbols, and -shared or

clang/test/Driver/zos-ld-sidedeck.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Try using various forms of output file name to see what side deck file name looks like
2+
// RUN: %clang -### --shared --target=s390x-ibm-zos %s -o foo.out 2>&1 \
3+
// RUN: | FileCheck --check-prefix=SD-BASE %s
4+
// RUN: %clang -### --shared --target=s390x-ibm-zos %s -o foo 2>&1 \
5+
// RUN: | FileCheck --check-prefix=SD-BASE %s
6+
// SD-BASE: "-x" "foo.x"
7+
8+
// RUN: %clang -### --shared --target=s390x-ibm-zos %s -o lib/foo.out 2>&1 \
9+
// RUN: | FileCheck --check-prefix=SD-SUBDIR %s
10+
// RUN: %clang -### --shared --target=s390x-ibm-zos %s -o lib/foo 2>&1 \
11+
// RUN: | FileCheck --check-prefix=SD-SUBDIR %s
12+
// SD-SUBDIR: "-x" "lib/foo.x"
13+
14+
15+
// RUN: %clang -### --shared --target=s390x-ibm-zos %s -o ../lib/foo.out 2>&1 \
16+
// RUN: | FileCheck --check-prefix=SD-REL %s
17+
// RUN: %clang -### --shared --target=s390x-ibm-zos %s -o ../lib/foo 2>&1 \
18+
// RUN: | FileCheck --check-prefix=SD-REL %s
19+
// SD-REL: "-x" "../lib/foo.x"

0 commit comments

Comments
 (0)