Skip to content

Commit 1b47b92

Browse files
authored
[Driver][SYCL] Improve object file recognition processing with linker args (#4552)
When processing linker arguments, we need to be sure that any items like -rpath DIR are not processed as a file. Add a check to not recognize DIR as an object as it is a directory.
1 parent 1ce8442 commit 1b47b92

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7781,6 +7781,8 @@ bool clang::driver::isOptimizationLevelFast(const ArgList &Args) {
77817781
}
77827782

77837783
bool clang::driver::isObjectFile(std::string FileName) {
7784+
if (llvm::sys::fs::is_directory(FileName))
7785+
return false;
77847786
if (!llvm::sys::path::has_extension(FileName))
77857787
// Any file with no extension should be considered an Object. Take into
77867788
// account -lsomelib library filenames.

clang/test/Driver/sycl-offload.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,14 @@
112112
// RUN: | FileCheck -check-prefixes=SYCL_TARGET_OPT_AOT %s
113113
// SYCL_TARGET_OPT_AOT-NOT: error: cannot deduce implicit triple value for '-Xsycl-target-backend'
114114
// SYCL_TARGET_OPT_AOT: {{opencl-aot|ocloc|aoc}}{{.*}} "-DFOO"
115+
116+
/// Do not process directories when checking for default sections in fat objs
117+
// RUN: %clangxx -### -Wl,-rpath,%S -fsycl -fsycl-targets=spir64_x86_64 %t_empty.o %s 2>&1 \
118+
// RUN: | FileCheck -check-prefix NO_DIR_CHECK %s
119+
// RUN: %clangxx -### -Xlinker -rpath -Xlinker %S -fsycl -fsycl-targets=spir64_fpga %t_empty.o %s 2>&1 \
120+
// RUN: | FileCheck -check-prefix NO_DIR_CHECK %s
121+
// RUN: %clangxx -### -Wl,-rpath,%S -fsycl -fsycl-targets=spir64_gen %t_empty.o %s 2>&1 \
122+
// RUN: | FileCheck -check-prefix NO_DIR_CHECK %s
123+
// RUN: %clangxx -### -Wl,-rpath,%S -fsycl -fintelfpga %t_empty.o %s 2>&1 \
124+
// RUN: | FileCheck -check-prefix NO_DIR_CHECK %s
125+
// NO_DIR_CHECK-NOT: clang-offload-bundler: error: '{{.*}}': Is a directory

0 commit comments

Comments
 (0)