Skip to content

Commit 3159db5

Browse files
authored
[Driver][SYCL] Update archive creation with -fsycl-link for FPGA (#7325)
When generating archives using -fsycl-link=early|image, any associated generated objects and device binaries are added to the archive for later processing. Archives can also be used in this manner, but creating the archives with 'cr' would just add the archive to the final generated archive, which does not allow the final archive to be used for host linking. Update the archive generation by using 'cqL' for llvm-ar, as that allows for any archives that are pulled in to be added via the contents instead of the archives themselves.
1 parent c02e5a0 commit 3159db5

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,11 @@ void tools::gnutools::Linker::constructLLVMARCommand(
349349
Compilation &C, const JobAction &JA, const InputInfo &Output,
350350
const InputInfoList &Input, const ArgList &Args) const {
351351
ArgStringList CmdArgs;
352-
CmdArgs.push_back("cr");
352+
// Use 'cqL' to create the archive. This allows for any fat archives that
353+
// are passed on the command line to be added via contents instead of the
354+
// full archive. Any usage of the generated archive will then have full
355+
// access to resolve any dependencies.
356+
CmdArgs.push_back("cqL");
353357
const char *OutputFilename = Output.getFilename();
354358
if (llvm::sys::fs::exists(OutputFilename)) {
355359
C.getDriver().Diag(clang::diag::warn_drv_existing_archive_append)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
// CHK-FPGA-EARLY: clang-offload-wrapper{{.*}} "-host" "x86_64-unknown-linux-gnu" "-o" "[[WRAPOUTHOST:.+\.bc]]" "-kind=host"
2727
// CHK-FPGA-EARLY-NOT: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-O2"
2828
// CHK-FPGA-EARLY: "-o" "[[OBJOUT:.+\.o]]" {{.*}} "[[WRAPOUTHOST]]"
29-
// CHK-FPGA-EARLY: llvm-ar{{.*}} "cr" "libfoo.a" "[[OBJOUT]]" "[[OBJOUTDEV]]"
30-
// CHK-FPGA-IMAGE: llvm-ar{{.*}} "cr" "libfoo.a" "[[INPUT]]" "[[OBJOUTDEV]]"
29+
// CHK-FPGA-EARLY: llvm-ar{{.*}} "cqL" "libfoo.a" "[[OBJOUT]]" "[[OBJOUTDEV]]"
30+
// CHK-FPGA-IMAGE: llvm-ar{{.*}} "cqL" "libfoo.a" "[[INPUT]]" "[[OBJOUTDEV]]"
3131

3232
/// -fintelfpga -fsycl-link clang-cl specific
3333
// RUN: touch %t.obj
@@ -71,7 +71,7 @@
7171
// CHK-FPGA-LINK-LIB-EARLY: clang-offload-wrapper{{.*}} "-host=x86_64-unknown-linux-gnu" "-target=fpga_aocr_emu-intel-unknown" "-kind=sycl" "-batch" "[[OUTPUT4]]"
7272
// CHK-FPGA-LINK-LIB: llc{{.*}} "-filetype=obj" "-o" "[[OUTPUT5:.+\.o]]"
7373
// CHK-FPGA-LINK-LIB: clang-offload-bundler{{.*}} "-type=aoo" "-targets=host-x86_64-unknown-linux-gnu" "-input=[[INPUT]]" "-output=[[OUTPUT1:.+\.txt]]" "-unbundle"
74-
// CHK-FPGA-LINK-LIB-IMAGE: llvm-ar{{.*}} "cr" {{.*}} "@[[OUTPUT1]]"
74+
// CHK-FPGA-LINK-LIB-IMAGE: llvm-ar{{.*}} "cqL" {{.*}} "@[[OUTPUT1]]"
7575

7676
/// Check the warning's emission for conflicting emulation/hardware
7777
// RUN: touch %t-aocr.a

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@
8383
// CHK-FPGA-EARLY: clang-offload-wrapper{{.*}} "-host" "x86_64-unknown-linux-gnu" "-o" "[[WRAPOUTHOST:.+\.bc]]" "-kind=host"
8484
// CHK-FPGA-EARLY-NOT: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-O2"
8585
// CHK-FPGA-EARLY: "-o" "[[OBJOUT:.+\.o]]" {{.*}} "[[WRAPOUTHOST]]"
86-
// CHK-FPGA-EARLY: llvm-ar{{.*}} "cr" "libfoo.a" "[[OBJOUT]]" "[[OBJOUTDEV]]"
87-
// CHK-FPGA-IMAGE: llvm-ar{{.*}} "cr" "libfoo.a" "[[INPUT]]" "[[OBJOUTDEV]]"
86+
// CHK-FPGA-EARLY: llvm-ar{{.*}} "cqL" "libfoo.a" "[[OBJOUT]]" "[[OBJOUTDEV]]"
87+
// CHK-FPGA-IMAGE: llvm-ar{{.*}} "cqL" "libfoo.a" "[[INPUT]]" "[[OBJOUTDEV]]"
8888

8989
// Output designation should not be used for unbundling step
9090
// RUN: touch %t.o
@@ -140,7 +140,7 @@
140140
// CHK-FPGA-LINK-LIB-EARLY: clang-offload-wrapper{{.*}} "-host=x86_64-unknown-linux-gnu" "-target=fpga_aocr-intel-unknown" "-kind=sycl" "-batch" "[[OUTPUT4]]"
141141
// CHK-FPGA-LINK-LIB: llc{{.*}} "-filetype=obj" "-o" "[[OUTPUT5:.+\.o]]"
142142
// CHK-FPGA-LINK-LIB: clang-offload-bundler{{.*}} "-type=aoo" "-targets=host-x86_64-unknown-linux-gnu" "-input=[[INPUT]]" "-output=[[OUTPUT1:.+\.txt]]" "-unbundle"
143-
// CHK-FPGA-LINK-LIB-IMAGE: llvm-ar{{.*}} "cr" {{.*}} "@[[OUTPUT1]]"
143+
// CHK-FPGA-LINK-LIB-IMAGE: llvm-ar{{.*}} "cqL" {{.*}} "@[[OUTPUT1]]"
144144

145145
/// Check the warning's emission for -fsycl-link's appending behavior
146146
// RUN: touch dummy.a
@@ -157,7 +157,7 @@
157157
// RUN: | FileCheck -check-prefixes=CHK-SYCL-LINK-LIN -DINPUTSRC=a %s
158158
// RUN: %clang_cl -### -fsycl -fintelfpga -fsycl-link %t_dir/dummy_file.cpp 2>&1 \
159159
// RUN: | FileCheck -check-prefixes=CHK-SYCL-LINK-WIN -DINPUTSRC=a %s
160-
// CHK-SYCL-LINK-LIN: llvm-ar{{.*}} "cr" "[[INPUTSRC]].a"
160+
// CHK-SYCL-LINK-LIN: llvm-ar{{.*}} "cqL" "[[INPUTSRC]].a"
161161
// CHK-SYCL-LINK-WIN: lib.exe{{.*}} "-OUT:[[INPUTSRC]].a"
162162

163163
/// -fintelfpga with AOCR library and additional object

0 commit comments

Comments
 (0)