Skip to content

Commit 3438a48

Browse files
mdtoguchibader
authored andcommitted
[SYCL][Driver] file.lib files are not under consideration for unbundling
On windows, passing file.lib on the command line was triggering the use of the unbundler. Use of -foffload-static-lib is the way to pass libraries to use for unbundling. We key off of the file name extension to determine if an object should be unbundled. We need to do an explicit check for 'lib' with the filename object check as there are some type lookups which rely on 'lib' being an object Signed-off-by: Michael D Toguchi <michael.d.toguchi@intel.com>
1 parent 49bde1f commit 3438a48

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5845,8 +5845,12 @@ bool clang::driver::isOptimizationLevelFast(const ArgList &Args) {
58455845
}
58465846

58475847
bool clang::driver::isObjectFile(std::string FileName) {
5848-
return (llvm::sys::path::has_extension(FileName) &&
5849-
types::lookupTypeForExtension(
5850-
llvm::sys::path::extension(FileName).drop_front()) ==
5851-
types::TY_Object);
5848+
if (llvm::sys::path::has_extension(FileName)) {
5849+
std::string Ext(llvm::sys::path::extension(FileName).drop_front());
5850+
// We cannot rely on lookupTypeForExtension solely as that has 'lib'
5851+
// marked as an object.
5852+
return (Ext != "lib" &&
5853+
types::lookupTypeForExtension(Ext) == types::TY_Object);
5854+
}
5855+
return false;
58525856
}

clang/test/Driver/sycl-offload.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,5 +583,14 @@
583583
// FO-CHECK: clang{{.*}} "-include" "[[HEADER]]" {{.*}} "-o" "[[OUTPUT2:.+\.obj]]"
584584
// FO-CHECK: clang-offload-bundler{{.*}} "-outputs=somefile.obj" "-inputs=[[OUTPUT1]],[[OUTPUT2]]"
585585

586+
/// passing of a library should not trigger the unbundler
587+
// RUN: touch %t.a
588+
// RUN: touch %t.lib
589+
// RUN: %clang -ccc-print-phases -fsycl %t.a %s 2>&1 \
590+
// RUN: | FileCheck -check-prefix=LIB-UNBUNDLE-CHECK %s
591+
// RUN: %clang_cl -ccc-print-phases -fsycl %t.lib %s 2>&1 \
592+
// RUN: | FileCheck -check-prefix=LIB-UNBUNDLE-CHECK %s
593+
// LIB-UNBUNDLE-CHECK-NOT: clang-offload-unbundler
594+
586595
// TODO: SYCL specific fail - analyze and enable
587596
// XFAIL: windows-msvc

0 commit comments

Comments
 (0)