Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -7057,6 +7057,8 @@ def fsycl_help_EQ : Joined<["-"], "fsycl-help=">, Flags<[NoXarchOption]>,
def fsycl_help : Flag<["-"], "fsycl-help">, Alias<fsycl_help_EQ>,
Flags<[NoXarchOption]>, AliasArgs<["all"]>,
HelpText<"Emit help information from all of the offline compilation tools">;
def fsycl_libdevice_path_EQ : Joined<["-"], "fsycl-libdevice-path=">,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this option scrutinized by the Options Working Group? Naming wise, this should closer match existing options. Something like -fsycl-device-lib-path=

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it wasn't. Tbf I wasn't really aware the working group existed, I went with -fsycl-libdevice-path because it's similar to -fsycl-libspirv-path, but I'm happy to change it as you deem necessary, is there any other reviewer we could ping in this PR to get their opinion? Or how should I go about submitting this to the Options Working Group?

Copy link
Contributor

@mdtoguchi mdtoguchi Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PietroGhg, you can check internal wiki for more information. This should get enough eyes on the new option name.

Visibility<[ClangOption, CLOption, DXCOption, CC1Option]>, HelpText<"Path to libdevice library">;
def fsycl_libspirv_path_EQ : Joined<["-"], "fsycl-libspirv-path=">,
HelpText<"Path to libspirv library">;
def fno_sycl_libspirv : Flag<["-"], "fno-sycl-libspirv">,
Expand Down
13 changes: 11 additions & 2 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5745,7 +5745,7 @@ class OffloadingActionBuilder final {
SYCLDeviceLibLinked = addSYCLDeviceLibs(
TC, SYCLDeviceLibs, UseAOTLink,
C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment(),
IsSYCLNativeCPU, NativeCPULib, BoundArch);
IsSYCLNativeCPU, NativeCPULib, BoundArch, Args);
}
JobAction *LinkSYCLLibs =
C.MakeAction<LinkJobAction>(SYCLDeviceLibs, types::TY_LLVM_BC);
Expand Down Expand Up @@ -6030,9 +6030,18 @@ class OffloadingActionBuilder final {

bool addSYCLDeviceLibs(const ToolChain *TC, ActionList &DeviceLinkObjects,
bool isSpirvAOT, bool isMSVCEnv, bool isNativeCPU,
Action *&NativeCPULib, const char *BoundArch) {
Action *&NativeCPULib, const char *BoundArch,
DerivedArgList &Args) {
int NumOfDeviceLibLinked = 0;
SmallVector<SmallString<128>, 4> LibLocCandidates;
if (Args.hasArg(options::OPT_fsycl_libdevice_path_EQ)) {
auto ProvidedPath =
Args.getLastArgValue(options::OPT_fsycl_libdevice_path_EQ).str();
if (llvm::sys::fs::exists(ProvidedPath)) {
SmallString<128> ProvidedPathSS(ProvidedPath);
LibLocCandidates.push_back(ProvidedPathSS);
}
}
SYCLInstallation.getSYCLDeviceLibPath(LibLocCandidates);

SmallVector<std::string, 8> DeviceLibraries;
Expand Down
Empty file.
7 changes: 7 additions & 0 deletions clang/test/Driver/sycl-native-cpu-fsycl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,10 @@
//CHECK_BINDINGS_MULTI_TU:# "{{.*}}" - "SYCL post link", inputs: ["[[LINK2]].bc"], output: "[[POSTL:.*]].table"
//CHECK_BINDINGS_MULTI_TU:# "{{.*}}" - "offload wrapper", inputs: ["[[POSTL]].table"], output: "[[WRAP:.*]].o"
//CHECK_BINDINGS_MULTI_TU:# "{{.*}}" - "{{.*}}::Linker", inputs: ["[[FILE1HOST]].o", "[[FILE2HOST]].o", "[[KERNELO]].o", "[[WRAP]].o"], output: "{{.*}}"

// check that -fsycl-libdevice-path is used correctly
// RUN: %clangxx -ccc-print-phases -std=c++11 -fsycl -fsycl-targets=native_cpu \
// RUN: -fno-sycl-device-lib=all -fsycl-libdevice-path=%S/Inputs/SYCL %s 2>&1 | FileCheck %s

// CHECK: [[LIBNATIVECPU:[0-9]*]]: input, "{{.*}}Inputs/SYCL/libsycl-nativecpu_utils.bc", ir, (device-sycl)
// CHECK-NEXT: linker, {{{.*}}, [[LIBNATIVECPU]]}, ir, (device-sycl)
Loading