Skip to content

Commit b3484c7

Browse files
committed
[SYCL][Driver] Fix output options behavior for -fsycl-link on Windows
When specifying output options with -fsycl-link -fintelfpga on Windows, the named output is not used. This is due to the output type for -fsycl-link being an archive type not being recognized when generating output file names. Also address a problem seen where use of /Fo was using that name for the intermediate unbundling step. Signed-off-by: Michael D Toguchi <[email protected]>
1 parent 284d7d2 commit b3484c7

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5527,9 +5527,11 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
55275527
if ((!AtTopLevel && !isSaveTempsEnabled() &&
55285528
(!C.getArgs().hasArg(options::OPT__SLASH_Fo) ||
55295529
// FIXME - The use of /Fo is limited when offloading is enabled. When
5530-
// compiling to exe use of /Fo does not produce the named obj
5530+
// compiling to exe use of /Fo does not produce the named obj. We also
5531+
// should not use the named output when performing unbundling.
55315532
(C.getArgs().hasArg(options::OPT__SLASH_Fo) &&
55325533
(!JA.isOffloading(Action::OFK_None) ||
5534+
isa<OffloadUnbundlingJobAction>(JA) ||
55335535
JA.getOffloadingHostActiveKinds() > Action::OFK_Host)))) ||
55345536
CCGenDiagnostics) {
55355537
StringRef Name = llvm::sys::path::filename(BaseInput);
@@ -5567,7 +5569,8 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
55675569
// Determine what the derived output name should be.
55685570
const char *NamedOutput;
55695571

5570-
if ((JA.getType() == types::TY_Object || JA.getType() == types::TY_LTO_BC) &&
5572+
if ((JA.getType() == types::TY_Object || JA.getType() == types::TY_LTO_BC ||
5573+
JA.getType() == types::TY_Archive) &&
55715574
C.getArgs().hasArg(options::OPT__SLASH_Fo, options::OPT__SLASH_o)) {
55725575
// The /Fo or /o flag decides the object filename.
55735576
StringRef Val =

clang/test/Driver/sycl-offload-intelfpga.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,33 @@
1616

1717
/// -fintelfpga -fsycl-link tests
1818
// RUN: touch %t.o
19-
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -fsycl-link %t.o 2>&1 \
19+
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -fsycl-link %t.o -o libfoo.a 2>&1 \
2020
// RUN: | FileCheck -check-prefixes=CHK-FPGA-LINK,CHK-FPGA-EARLY %s
21-
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -fsycl-link=early %t.o 2>&1 \
21+
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -fsycl-link=early %t.o -o libfoo.a 2>&1 \
2222
// RUN: | FileCheck -check-prefixes=CHK-FPGA-LINK,CHK-FPGA-EARLY %s
23-
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -fsycl-link=image %t.o 2>&1 \
23+
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -fsycl-link=image %t.o -o libfoo.a 2>&1 \
2424
// RUN: | FileCheck -check-prefixes=CHK-FPGA-LINK,CHK-FPGA-IMAGE %s
2525
// CHK-FPGA-LINK-NOT: clang-offload-bundler{{.*}} "-check-section"
2626
// CHK-FPGA-LINK: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64_fpga-unknown-unknown-sycldevice" "-inputs=[[INPUT:.+\.o]]" "-outputs=[[OUTPUT1:.+\.o]]" "-unbundle"
27+
// CHK-FPGA-LINK-NOT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64_fpga-unknown-unknown-sycldevice" {{.*}} "-outputs=libfoo.a" "-unbundle"
2728
// CHK-FPGA-LINK: llvm-link{{.*}} "[[OUTPUT1]]" "-o" "[[OUTPUT2:.+\.bc]]"
2829
// CHK-FPGA-LINK: llvm-spirv{{.*}} "-o" "[[OUTPUT3:.+\.spv]]" "-spirv-max-version=1.1" "-spirv-ext=+all" "[[OUTPUT2]]"
2930
// CHK-FPGA-EARLY: aoc{{.*}} "-o" "[[OUTPUT4:.+\.aocr]]" "[[OUTPUT3]]" "-sycl" "-rtl"
3031
// CHK-FPGA-IMAGE: aoc{{.*}} "-o" "[[OUTPUT5:.+\.aocx]]" "[[OUTPUT3]]" "-sycl"
31-
// CHK-FPGA-LINK: {{lib|llvm-ar}}{{.*}} "[[INPUT]]"
32+
// CHK-FPGA-LINK: llvm-ar{{.*}} "cr" "libfoo.a" "[[INPUT]]"
3233

3334
/// -fintelfpga -fsycl-link clang-cl specific
3435
// RUN: touch %t.obj
35-
// RUN: %clang_cl -### -fsycl -fintelfpga -fsycl-link %t.obj 2>&1 \
36+
// RUN: %clang_cl -### -fsycl -fintelfpga -fsycl-link %t.obj -Folibfoo.lib 2>&1 \
37+
// RUN: | FileCheck -check-prefixes=CHK-FPGA-LINK-WIN %s
38+
// RUN: %clang_cl -### -fsycl -fintelfpga -fsycl-link %t.obj -o libfoo.lib 2>&1 \
3639
// RUN: | FileCheck -check-prefixes=CHK-FPGA-LINK-WIN %s
3740
// CHK-FPGA-LINK-WIN: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64_fpga-unknown-unknown-sycldevice{{.*}}" "-inputs=[[INPUT:.+\.obj]]" "-outputs=[[OUTPUT1:.+\.obj]]" "-unbundle"
41+
// CHK-FPGA-LINK-WIN-NOT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64_fpga-unknown-unknown-sycldevice{{.*}}" {{.*}} "-outputs=libfoo.lib" "-unbundle"
3842
// CHK-FPGA-LINK-WIN: llvm-link{{.*}} "[[OUTPUT1]]" "-o" "[[OUTPUT2:.+\.bc]]"
3943
// CHK-FPGA-LINK-WIN: llvm-spirv{{.*}} "-o" "[[OUTPUT3:.+\.spv]]" "-spirv-max-version=1.1" "-spirv-ext=+all" "[[OUTPUT2]]"
4044
// CHK-FPGA-LINK-WIN: aoc{{.*}} "-o" "[[OUTPUT5:.+\.aocr]]" "[[OUTPUT3]]" "-sycl" "-rtl"
41-
// CHK-FPGA-LINK-WIN: lib.exe{{.*}} "[[INPUT]]"
42-
45+
// CHK-FPGA-LINK-WIN: lib.exe{{.*}} "[[INPUT]]" {{.*}} "-OUT:libfoo.lib"
4346

4447
/// Check -fintelfpga -fsycl-link with an FPGA archive
4548
// Create the dummy archive

0 commit comments

Comments
 (0)