This is an archive of the discontinued LLVM Phabricator instance.

[SPIR-V] Add linking of separate translation units using spirv-link
ClosedPublic

Authored by Anastasia on Dec 24 2021, 3:49 AM.

Details

Summary

Add support of linking files compiled into SPIR-V object files using spirv-link (https://github.com/KhronosGroup/SPIRV-Tools#linker).

Examples:

clang --target=spirv64 test1.cl test2.cl
clang  --target=spirv64 test1.cl -o test1.o
clang  --target=spirv64 test1.o test2.cl -o test_app.out

This will work independently from the SPIR-V generation method (via an external tool or an internal backend) and will apply to either approach that is being used.

Diff Detail

Event Timeline

Anastasia created this revision.Dec 24 2021, 3:49 AM
Anastasia requested review of this revision.Dec 24 2021, 3:49 AM
Anastasia edited the summary of this revision. (Show Details)Dec 24 2021, 3:56 AM
Anastasia edited the summary of this revision. (Show Details)Dec 24 2021, 4:06 AM
svenvh accepted this revision.Jan 10 2022, 4:50 AM

LGTM. I made some minor comments, that can be fixed before committing.

clang/docs/UsersManual.rst
3602

(or: "+the spirv-link linker")

3604
clang/lib/Driver/ToolChains/SPIRV.cpp
78

Indentation seems to be slightly off? Can be fixed on commit.

This revision is now accepted and ready to land.Jan 10 2022, 4:50 AM
This revision was landed with ongoing or failed builds.Jan 11 2022, 5:15 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJan 11 2022, 5:15 AM
aganea added a subscriber: aganea.Jan 11 2022, 9:00 AM
aganea added inline comments.
clang/test/Driver/spirv-toolchain.cl
71

Hello @Anastasia, this line fails on my machine. It works with `// SPLINK: spirv-link{{.*}} [[SPV1]] [[SPV2]] "-o" "a.out"
`

See output with the error:

FAIL: Clang :: Driver/spirv-toolchain.cl (579 of 81682)
******************** TEST 'Clang :: Driver/spirv-toolchain.cl' FAILED ********************
Script:
--
: 'RUN: at line 2';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv64 -x cl -c D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPV64 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 3';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv64 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPV64 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 4';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv64 -x ir -c D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPV64 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 5';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv64 -x clcpp -c D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPV64 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 6';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv64 -x c -c D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPV64 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 12';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv32 -x cl -c D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPV32 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 13';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv32 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPV32 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 14';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv32 -x ir -c D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPV32 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 15';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv32 -x clcpp -c D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPV32 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 16';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv32 -x c -c D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPV32 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 24';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv64 -x cl -S D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPT64 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 25';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv64 -x ir -S D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPT64 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 26';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv64 -x clcpp -c D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPV64 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 27';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv64 -x c -S D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPT64 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 33';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv32 -x cl -S D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPT32 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 34';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv32 -x ir -S D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPT32 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 35';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv32 -x clcpp -c D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPV32 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 36';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv32 -x c -S D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPT32 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 44';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv64 -x assembler -c D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=ASM D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 45';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv32 -x assembler -c D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=ASM D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 50';   d:\git\llvm-project\release\bin\clang.exe -### --target=spirv64 -x cl -c D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl --save-temps 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=TMP D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
: 'RUN: at line 63';   d:\git\llvm-project\release\bin\clang.exe -### -target spirv64 D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl 2>&1 | d:\git\llvm-project\release\bin\filecheck.exe --check-prefix=SPLINK D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl
--
Exit Code: 1

Command Output (stdout):
--
$ ":" "RUN: at line 2"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv64" "-x" "cl" "-c" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPV64" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 3"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv64" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPV64" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 4"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv64" "-x" "ir" "-c" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPV64" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 5"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv64" "-x" "clcpp" "-c" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPV64" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 6"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv64" "-x" "c" "-c" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPV64" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 12"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv32" "-x" "cl" "-c" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPV32" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 13"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv32" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPV32" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 14"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv32" "-x" "ir" "-c" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPV32" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 15"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv32" "-x" "clcpp" "-c" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPV32" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 16"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv32" "-x" "c" "-c" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPV32" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 24"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv64" "-x" "cl" "-S" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPT64" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 25"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv64" "-x" "ir" "-S" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPT64" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 26"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv64" "-x" "clcpp" "-c" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPV64" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 27"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv64" "-x" "c" "-S" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPT64" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 33"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv32" "-x" "cl" "-S" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPT32" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 34"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv32" "-x" "ir" "-S" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPT32" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 35"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv32" "-x" "clcpp" "-c" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPV32" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 36"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv32" "-x" "c" "-S" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPT32" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 44"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv64" "-x" "assembler" "-c" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=ASM" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 45"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv32" "-x" "assembler" "-c" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=ASM" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 50"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "--target=spirv64" "-x" "cl" "-c" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl" "--save-temps"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=TMP" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ ":" "RUN: at line 63"
$ "d:\git\llvm-project\release\bin\clang.exe" "-###" "-target" "spirv64" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
$ "d:\git\llvm-project\release\bin\filecheck.exe" "--check-prefix=SPLINK" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
# command stderr:
D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl:71:12: error: SPLINK: expected string not found in input
// SPLINK: {{"spirv-link.*"}} [[SPV1]] [[SPV2]] "-o" "a.out"
           ^
<stdin>:8:160: note: scanning from here
 "llvm-spirv" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-3443c4.bc" "-o" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-0aa22f.o"
                                                                                                                                                               ^
<stdin>:8:160: note: with "SPV1" equal to "\"C:\\\\\\\\Users\\\\\\\\ALEXAN~1\\\\\\\\AppData\\\\\\\\Local\\\\\\\\Temp\\\\\\\\spirv-toolchain-ab01cc\\.o\""
 "llvm-spirv" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-3443c4.bc" "-o" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-0aa22f.o"
                                                                                                                                                               ^
<stdin>:8:160: note: with "SPV2" equal to "\"C:\\\\\\\\Users\\\\\\\\ALEXAN~1\\\\\\\\AppData\\\\\\\\Local\\\\\\\\Temp\\\\\\\\spirv-toolchain-0aa22f\\.o\""
 "llvm-spirv" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-3443c4.bc" "-o" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-0aa22f.o"
                                                                                                                                                               ^
<stdin>:9:187: note: possible intended match here
 "c:\\scoop\\user\\apps\\vulkan\\current\\bin\\spirv-link.exe" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-ab01cc.o" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-0aa22f.o" "-o" "a.out"
                                                                                                                                                                                          ^

Input file: <stdin>
Check file: D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: clang version 14.0.0 (https://github.com/llvm/llvm-project.git be7dbd674cb0cec2558e054c39be0eb098a99394)
            2: Target: spirv64
            3: Thread model: posix
            4: InstalledDir: d:\git\llvm-project\release\bin
            5:  "d:\\git\\llvm-project\\release\\bin\\clang.exe" "-cc1" "-triple" "spirv64" "-Wspir-compat" "-emit-llvm-bc" "-emit-llvm-uselists" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "spirv-toolchain.cl" "-mrelocation-model" "static" "-mframe-pointer=all" "-ffp-contract=on" "-fno-rounding-math" "-fno-verbose-asm" "-mconstructor-aliases" "-debugger-tuning=gdb" "-fcoverage-compilation-dir=D:\\git\\llvm-project\\release\\tools\\clang\\test\\Driver" "-resource-dir" "d:\\git\\llvm-project\\release\\lib\\clang\\14.0.0" "-fdebug-compilation-dir=D:\\git\\llvm-project\\release\\tools\\clang\\test\\Driver" "-ferror-limit" "19" "-finclude-default-header" "-fdeclare-opencl-builtins" "-fgnuc-version=4.2.1" "-fno-threadsafe-statics" "-o" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-84db8e.bc" "-x" "cl" "D:\\git\\llvm-project\\clang\\test\\Driver\\spirv-toolchain.cl"
            6:  "llvm-spirv" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-84db8e.bc" "-o" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-ab01cc.o"
            7:  "d:\\git\\llvm-project\\release\\bin\\clang.exe" "-cc1" "-triple" "spirv64" "-Wspir-compat" "-emit-llvm-bc" "-emit-llvm-uselists" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "spirv-toolchain.cl" "-mrelocation-model" "static" "-mframe-pointer=all" "-ffp-contract=on" "-fno-rounding-math" "-fno-verbose-asm" "-mconstructor-aliases" "-debugger-tuning=gdb" "-fcoverage-compilation-dir=D:\\git\\llvm-project\\release\\tools\\clang\\test\\Driver" "-resource-dir" "d:\\git\\llvm-project\\release\\lib\\clang\\14.0.0" "-fdebug-compilation-dir=D:\\git\\llvm-project\\release\\tools\\clang\\test\\Driver" "-ferror-limit" "19" "-finclude-default-header" "-fdeclare-opencl-builtins" "-fgnuc-version=4.2.1" "-fno-threadsafe-statics" "-o" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-3443c4.bc" "-x" "cl" "D:\\git\\llvm-project\\clang\\test\\Driver\\spirv-toolchain.cl"
            8:  "llvm-spirv" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-3443c4.bc" "-o" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-0aa22f.o"
check:71'0                                                                                                                                                                    X error: no match found
check:71'1                                                                                                                                                                      with "SPV1" equal to "\"C:\\\\\\\\Users\\\\\\\\ALEXAN~1\\\\\\\\AppData\\\\\\\\Local\\\\\\\\Temp\\\\\\\\spirv-toolchain-ab01cc\\.o\""
check:71'2                                                                                                                                                                      with "SPV2" equal to "\"C:\\\\\\\\Users\\\\\\\\ALEXAN~1\\\\\\\\AppData\\\\\\\\Local\\\\\\\\Temp\\\\\\\\spirv-toolchain-0aa22f\\.o\""
            9:  "c:\\scoop\\user\\apps\\vulkan\\current\\bin\\spirv-link.exe" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-ab01cc.o" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-0aa22f.o" "-o" "a.out"
check:71'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:71'3                                                                                                                                                                                               ?                              possible intended match
>>>>>>

error: command failed with exit status: 1

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
********************
Failed Tests (1):
  Clang :: Driver/spirv-toolchain.cl

If I just run that command:

D:\git\llvm-project> "d:\git\llvm-project\release\bin\clang.exe" "-###" "-target" "spirv64" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl" "D:\git\llvm-project\clang\test\Driver\spirv-toolchain.cl"
clang version 14.0.0 (https://github.com/llvm/llvm-project.git be7dbd674cb0cec2558e054c39be0eb098a99394)
Target: spirv64
Thread model: posix
InstalledDir: d:\git\llvm-project\release\bin
 "d:\\git\\llvm-project\\release\\bin\\clang.exe" "-cc1" "-triple" "spirv64" "-Wspir-compat" "-emit-llvm-bc" "-emit-llvm-uselists" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "spirv-toolchain.cl" "-mrelocation-model" "static" "-mframe-pointer=all" "-ffp-contract=on" "-fno-rounding-math" "-fno-verbose-asm" "-mconstructor-aliases" "-debugger-tuning=gdb" "-fcoverage-compilation-dir=D:\\git\\llvm-project" "-resource-dir" "d:\\git\\llvm-project\\release\\lib\\clang\\14.0.0" "-fdebug-compilation-dir=D:\\git\\llvm-project" "-ferror-limit" "19" "-fmessage-length=167" "-finclude-default-header" "-fdeclare-opencl-builtins" "-fgnuc-version=4.2.1" "-fno-threadsafe-statics" "-fcolor-diagnostics" "-o" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-6356aa.bc" "-x" "cl" "D:\\git\\llvm-project\\clang\\test\\Driver\\spirv-toolchain.cl"
 "llvm-spirv" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-6356aa.bc" "-o" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-0c9f09.o"
 "d:\\git\\llvm-project\\release\\bin\\clang.exe" "-cc1" "-triple" "spirv64" "-Wspir-compat" "-emit-llvm-bc" "-emit-llvm-uselists" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "spirv-toolchain.cl" "-mrelocation-model" "static" "-mframe-pointer=all" "-ffp-contract=on" "-fno-rounding-math" "-fno-verbose-asm" "-mconstructor-aliases" "-debugger-tuning=gdb" "-fcoverage-compilation-dir=D:\\git\\llvm-project" "-resource-dir" "d:\\git\\llvm-project\\release\\lib\\clang\\14.0.0" "-fdebug-compilation-dir=D:\\git\\llvm-project" "-ferror-limit" "19" "-fmessage-length=167" "-finclude-default-header" "-fdeclare-opencl-builtins" "-fgnuc-version=4.2.1" "-fno-threadsafe-statics" "-fcolor-diagnostics" "-o" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-1794d3.bc" "-x" "cl" "D:\\git\\llvm-project\\clang\\test\\Driver\\spirv-toolchain.cl"
 "llvm-spirv" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-1794d3.bc" "-o" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-facf65.o"
 "C:\\Scoop\\user\\apps\\vulkan\\current\\Bin\\spirv-link.exe" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-0c9f09.o" "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\spirv-toolchain-facf65.o" "-o" "a.out"
svenvh added inline comments.Jan 11 2022, 9:02 AM
clang/test/Driver/spirv-toolchain.cl
71

I have just committed a fix for that: 4b14fc6fe5a7 ("[SPIR-V] Drop double quote from test pattern", 2022-01-11)

aganea added inline comments.Jan 11 2022, 9:04 AM
clang/test/Driver/spirv-toolchain.cl
71

Great, thanks!

bader added a subscriber: bader.Jan 24 2022, 6:20 AM
bader added inline comments.
clang/docs/UsersManual.rst
3602

@Anastasia, sorry for late feedback.
I think being able to link SPIR-V modules is a great feature, but I have a concerns regarding spirv-link tool.
The documentation says that the linker tool is still under development and from our experience this tool had issues blocking us from using it for SYCL mode. The last time new features were added to this tool is almost 4 year ago.
Do you know if there are any plans for to finish the development and if ? Are you aware of any "real-world usages" of this tool? Have you tried to use it for SPIR-V module produced from C++ (e.g. C++ for OpenCL)?
I think supporting SPIR-V extensions like SPV_KHR_linkonce_odr is quite important for code size and JIT compilation time reduction. As this extension was ratified recently, I suppose spirv-link doesn't support it yet.

Anastasia added inline comments.Aug 31 2022, 2:40 PM
clang/docs/UsersManual.rst
3602

Hi Alexey,

Sorry for the late reply. Do you have any other suggestions about the tools that can be used for linking SPIR-V binaries?

I am not in contact with the maintainers but it is an open-source project so I imagine contributions to enhance or improve functionality should be welcome... unless you have other experiences?

Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2022, 2:40 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
bader added inline comments.Sep 5 2022, 4:25 AM
clang/docs/UsersManual.rst
3602

Do you have any other suggestions about the tools that can be used for linking SPIR-V binaries?

I'm unaware of other tools for SPIR-V binaries linking. To link SPIR-V binaries in our toolchain, we translate them to/from LLVM IR to link LLVM IR.

I am not in contact with the maintainers but it is an open-source project so I imagine contributions to enhance or improve functionality should be welcome... unless you have other experiences?

I talked to the maintainers (but it was quite long time ago) and they told me that there are no active contributors to this tool.