-
Notifications
You must be signed in to change notification settings - Fork 829
[SYCL] Add option forwarding from clang-linker-wrapper tool to clang-sycl-linker #21958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
srividya-sundaram
wants to merge
6
commits into
intel:sycl
Choose a base branch
from
srividya-sundaram:clw-to-csl
base: sycl
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+286
−13
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
20f67e1
Only have option forwarding and test changes.
srividya-sundaram 0b40efc
Check option forwarding to CSL.
srividya-sundaram f5327ea
Fix clang format.
srividya-sundaram 50fddb1
Migrate to uint16_t ActiveOffloadKindMask and update test.
srividya-sundaram 92df82d
Address review comments.
srividya-sundaram 550602e
Merge branch 'sycl' into clw-to-csl
srividya-sundaram File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // Test that clang-linker-wrapper correctly invokes clang-sycl-linker when --use-clang-sycl-linker is enabled | ||
| // | ||
| // REQUIRES: spirv-registered-target | ||
| // | ||
| // Create SYCL offload object file | ||
| // RUN: %clangxx -fsycl --offload-new-driver -fsycl-targets=spir64-unknown-unknown -c %s -o %t.o | ||
| // | ||
| // Test that clang-sycl-linker is invoked with basic options | ||
| // RUN: clang-linker-wrapper --dry-run --use-clang-sycl-linker \ | ||
| // RUN: --linker-path=/usr/bin/ld --host-triple=x86_64-unknown-linux-gnu \ | ||
| // RUN: %t.o -o %t.out 2>&1 \ | ||
| // RUN: | FileCheck %s --check-prefix=CHECK-BASIC | ||
| // CHECK-BASIC: clang{{.*}}-fsycl --sycl-link | ||
| // CHECK-BASIC-SAME: -Xlinker --triple=spir64-unknown-unknown | ||
| // | ||
| // Test that --save-temps is forwarded | ||
| // RUN: clang-linker-wrapper --dry-run --use-clang-sycl-linker --save-temps \ | ||
| // RUN: --linker-path=/usr/bin/ld --host-triple=x86_64-unknown-linux-gnu \ | ||
| // RUN: %t.o -o %t.out 2>&1 \ | ||
| // RUN: | FileCheck %s --check-prefix=CHECK-SAVE-TEMPS | ||
| // CHECK-SAVE-TEMPS: clang{{.*}}-fsycl --sycl-link | ||
| // CHECK-SAVE-TEMPS-SAME: -Xlinker --save-temps | ||
| // | ||
| // Test that device compiler options are forwarded | ||
| // RUN: clang-linker-wrapper --dry-run --use-clang-sycl-linker \ | ||
| // RUN: --linker-path=/usr/bin/ld --host-triple=x86_64-unknown-linux-gnu \ | ||
| // RUN: --device-compiler=sycl:spir64-unknown-unknown=-my-backend-opt \ | ||
| // RUN: %t.o -o %t.out 2>&1 \ | ||
| // RUN: | FileCheck %s --check-prefix=CHECK-DEVICE-COMPILER | ||
| // CHECK-DEVICE-COMPILER: clang{{.*}}-fsycl --sycl-link | ||
| // CHECK-DEVICE-COMPILER-SAME: -Xlinker --device-compiler=sycl:spir64-unknown-unknown=-my-backend-opt | ||
| // | ||
| // Test that device linker options are forwarded | ||
| // RUN: clang-linker-wrapper --dry-run --use-clang-sycl-linker \ | ||
| // RUN: --linker-path=/usr/bin/ld --host-triple=x86_64-unknown-linux-gnu \ | ||
| // RUN: --device-linker=sycl:spir64-unknown-unknown=-my-linker-opt \ | ||
| // RUN: %t.o -o %t.out 2>&1 \ | ||
| // RUN: | FileCheck %s --check-prefix=CHECK-DEVICE-LINKER | ||
| // CHECK-DEVICE-LINKER: clang{{.*}}-fsycl --sycl-link | ||
| // CHECK-DEVICE-LINKER-SAME: -Xlinker --device-linker=sycl:spir64-unknown-unknown=-my-linker-opt | ||
|
|
||
| int foo() { return 42; } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| // Tests that clang driver correctly forwards options to clang-linker-wrapper | ||
| // for SYCL offload compilation. | ||
| // | ||
| // REQUIRES: spirv-registered-target | ||
| // | ||
| // RUN: %clangxx -fsycl --offload-new-driver -fsycl-targets=spir64-unknown-unknown -c %s -o %t_1.o | ||
| // RUN: %clangxx -fsycl --offload-new-driver -fsycl-targets=spir64-unknown-unknown -c %s -o %t_2.o | ||
| // | ||
| // Test that --use-clang-sycl-linker is not passed by default. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver -fsycl-targets=spir64-unknown-unknown \ | ||
| // RUN: %t_1.o 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT | ||
| // CHECK-DEFAULT: clang-linker-wrapper | ||
| // CHECK-DEFAULT-NOT: "--use-clang-sycl-linker" | ||
| // | ||
| // Test that driver options are correctly passed through clang-linker-wrapper. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver -fsycl-targets=spir64-unknown-unknown \ | ||
| // RUN: -Xsycl-target-backend=spir64-unknown-unknown "-backend-opt" \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-BACKEND-OPT | ||
| // CHECK-BACKEND-OPT: clang-linker-wrapper{{.*}} "--device-compiler=sycl:spir64-unknown-unknown=-backend-opt" | ||
| // | ||
| // Test multiple backend options. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver -fsycl-targets=spir64-unknown-unknown \ | ||
| // RUN: -Xsycl-target-backend=spir64-unknown-unknown "-opt1 -opt2" \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-MULTI-OPTS | ||
| // CHECK-MULTI-OPTS: clang-linker-wrapper{{.*}} "--device-compiler=sycl:spir64-unknown-unknown=-opt1 -opt2" | ||
| // | ||
| // Test linker options are forwarded. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver -fsycl-targets=spir64-unknown-unknown \ | ||
| // RUN: -Xsycl-target-linker=spir64-unknown-unknown "-linker-opt" \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-LINKER-OPT | ||
| // CHECK-LINKER-OPT: clang-linker-wrapper{{.*}} "--device-linker=sycl:spir64-unknown-unknown=-linker-opt" | ||
| // | ||
| // Test both backend and linker options together. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver -fsycl-targets=spir64-unknown-unknown \ | ||
| // RUN: -Xsycl-target-backend=spir64-unknown-unknown "-backend-opt" \ | ||
| // RUN: -Xsycl-target-linker=spir64-unknown-unknown "-linker-opt" \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-BOTH-OPTS | ||
| // CHECK-BOTH-OPTS: clang-linker-wrapper{{.*}} "--device-compiler=sycl:spir64-unknown-unknown=-backend-opt" | ||
| // CHECK-BOTH-OPTS-SAME: "--device-linker=sycl:spir64-unknown-unknown=-linker-opt" | ||
| // | ||
| // Test AOT GPU with backend options. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver -fsycl-targets=spir64_gen-unknown-unknown \ | ||
| // RUN: -Xsycl-target-backend=spir64_gen "-device pvc" \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-AOT-GPU | ||
| // CHECK-AOT-GPU: clang-linker-wrapper{{.*}} "--device-compiler=sycl:spir64_gen-unknown-unknown=-device pvc" | ||
| // | ||
| // Test AOT CPU with backend options. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver -fsycl-targets=spir64_x86_64-unknown-unknown \ | ||
| // RUN: -Xsycl-target-backend=spir64_x86_64 "-march=skylake" \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-AOT-CPU | ||
| // CHECK-AOT-CPU: clang-linker-wrapper{{.*}} "--device-compiler=sycl:spir64_x86_64-unknown-unknown=-march=skylake" | ||
| // | ||
| // Test multi-target with target-specific options (both in same invocation). | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver \ | ||
| // RUN: -fsycl-targets=spir64_gen-unknown-unknown,spir64_x86_64-unknown-unknown \ | ||
| // RUN: -Xsycl-target-backend=spir64_gen "-device pvc" \ | ||
| // RUN: -Xsycl-target-backend=spir64_x86_64 "-march=skylake" \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-MULTI-TARGET | ||
| // CHECK-MULTI-TARGET: clang-linker-wrapper{{.*}} "--device-compiler=sycl:spir64_gen-unknown-unknown=-device pvc" | ||
| // CHECK-MULTI-TARGET-SAME: "--device-compiler=sycl:spir64_x86_64-unknown-unknown=-march=skylake" | ||
| // | ||
| // Test that --use-clang-sycl-linker flag is properly forwarded. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver -fsycl-targets=spir64-unknown-unknown \ | ||
| // RUN: -Xlinker --use-clang-sycl-linker \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-USE-CSL | ||
| // CHECK-USE-CSL: clang-linker-wrapper{{.*}} "--use-clang-sycl-linker" | ||
| // | ||
| // Test that backend options are forwarded when using clang-sycl-linker. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver -fsycl-targets=spir64-unknown-unknown \ | ||
| // RUN: -Xlinker --use-clang-sycl-linker \ | ||
| // RUN: -Xsycl-target-backend=spir64-unknown-unknown "-backend-opt" \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-CSL-BACKEND | ||
| // CHECK-CSL-BACKEND: clang-linker-wrapper{{.*}} "--device-compiler=sycl:spir64-unknown-unknown=-backend-opt"{{.*}} "--use-clang-sycl-linker" | ||
| // | ||
| // Test that linker options are forwarded when using clang-sycl-linker. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver -fsycl-targets=spir64-unknown-unknown \ | ||
| // RUN: -Xlinker --use-clang-sycl-linker \ | ||
| // RUN: -Xsycl-target-linker=spir64-unknown-unknown "-linker-opt" \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-CSL-LINKER | ||
| // CHECK-CSL-LINKER: clang-linker-wrapper{{.*}} "--device-linker=sycl:spir64-unknown-unknown=-linker-opt"{{.*}} "--use-clang-sycl-linker" | ||
| // | ||
| // Test that both backend and linker options work together with clang-sycl-linker. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver -fsycl-targets=spir64-unknown-unknown \ | ||
| // RUN: -Xlinker --use-clang-sycl-linker \ | ||
| // RUN: -Xsycl-target-backend=spir64-unknown-unknown "-backend-opt" \ | ||
| // RUN: -Xsycl-target-linker=spir64-unknown-unknown "-linker-opt" \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-CSL-BOTH | ||
| // CHECK-CSL-BOTH: clang-linker-wrapper{{.*}} "--device-compiler=sycl:spir64-unknown-unknown=-backend-opt"{{.*}} "--device-linker=sycl:spir64-unknown-unknown=-linker-opt"{{.*}} "--use-clang-sycl-linker" | ||
| // | ||
| // Test AOT GPU with clang-sycl-linker. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver -fsycl-targets=spir64_gen-unknown-unknown \ | ||
| // RUN: -Xlinker --use-clang-sycl-linker \ | ||
| // RUN: -Xsycl-target-backend=spir64_gen "-device pvc" \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-CSL-AOT-GPU | ||
| // CHECK-CSL-AOT-GPU: clang-linker-wrapper{{.*}} "--device-compiler=sycl:spir64_gen-unknown-unknown=-device pvc"{{.*}} "--use-clang-sycl-linker" | ||
| // | ||
| // Test AOT CPU with clang-sycl-linker. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver -fsycl-targets=spir64_x86_64-unknown-unknown \ | ||
| // RUN: -Xlinker --use-clang-sycl-linker \ | ||
| // RUN: -Xsycl-target-backend=spir64_x86_64 "-march=skylake" \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-CSL-AOT-CPU | ||
| // CHECK-CSL-AOT-CPU: clang-linker-wrapper{{.*}} "--device-compiler=sycl:spir64_x86_64-unknown-unknown=-march=skylake"{{.*}} "--use-clang-sycl-linker" | ||
| // | ||
| // Test multi-target with clang-sycl-linker. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver \ | ||
| // RUN: -fsycl-targets=spir64_gen-unknown-unknown,spir64_x86_64-unknown-unknown \ | ||
| // RUN: -Xlinker --use-clang-sycl-linker \ | ||
| // RUN: -Xsycl-target-backend=spir64_gen "-device pvc" \ | ||
| // RUN: -Xsycl-target-backend=spir64_x86_64 "-march=skylake" \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-CSL-MULTI | ||
| // CHECK-CSL-MULTI: clang-linker-wrapper{{.*}} "--device-compiler=sycl:spir64_gen-unknown-unknown=-device pvc"{{.*}} "--device-compiler=sycl:spir64_x86_64-unknown-unknown=-march=skylake"{{.*}} "--use-clang-sycl-linker" | ||
| // | ||
| // Test that --save-temps is forwarded when using clang-sycl-linker. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver -fsycl-targets=spir64-unknown-unknown \ | ||
| // RUN: -Xlinker --use-clang-sycl-linker -Xlinker --save-temps \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-CSL-SAVE-TEMPS | ||
| // CHECK-CSL-SAVE-TEMPS: clang-linker-wrapper{{.*}} "--use-clang-sycl-linker"{{.*}} "--save-temps" | ||
| // | ||
| // Test that --dry-run is forwarded when using clang-sycl-linker. | ||
| // RUN: %clangxx -### -fsycl --offload-new-driver -fsycl-targets=spir64-unknown-unknown \ | ||
| // RUN: -Xlinker --use-clang-sycl-linker -Xlinker --dry-run \ | ||
| // RUN: %t_1.o %t_2.o 2>&1 | FileCheck %s --check-prefix=CHECK-CSL-DRY | ||
| // CHECK-CSL-DRY: clang-linker-wrapper{{.*}} "--use-clang-sycl-linker"{{.*}} "--dry-run" | ||
|
|
||
| int foo() { return 42; } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test looks similiar to the one I see in community: https://github.com/llvm/llvm-project/blob/main/clang/test/Driver/linker-wrapper.c
Other similar tests that are programming-model or target specific:
https://github.com/llvm/llvm-project/blob/main/clang/test/Driver/linker-wrapper-hip-amdgcnspirv.c
https://github.com/llvm/llvm-project/blob/e721580311e3988e767ec3aaa06bce025f72ff7e/clang/test/Driver/hipspv-toolchain.hip#L55
Do you think it would be possible to add test like you wrote here to community first aligned with naming and style? (like
linker-wrapper-sycl.cpp), and then add modifications in downstream on top of what is in upstream?I want to minimize our back-and-forth between downstream and community and submit to community first if that makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--use-clang-sycl-linkeris a temporary downstream-only transition flag and won't be upstreamed.The test is specifically for
--use-clang-sycl-linker's behavior (dispatching toclang -fsycl --sycl-link), so there's no meaningful upstream test to write at this point.Once we complete the migration and remove
--use-clang-sycl-linker, I can submit an upstream SYCL test for (CLW invoking clang + fsycl + --sycl-link) that aligns with community naming standards.