Skip to content

Commit

Permalink
Add windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzEeKkAa committed Jun 5, 2024
1 parent 1640965 commit 9927e4b
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 24 deletions.
13 changes: 13 additions & 0 deletions recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
echo on

cmake %CMAKE_ARGS% ^
-G "Ninja" ^
-DLLVM_DIR=%LIBRARY_PREFIX%\cmake\llvm ^
-DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
-DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=%LIBRARY_PREFIX% ^
-S . -B ./build
if %ERRORLEVEL% neq 0 exit 1

cmake --build ./build
if %ERRORLEVEL% neq 0 exit 1
10 changes: 10 additions & 0 deletions recipe/install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
echo on

cmake --install ./build --prefix %LIBRARY_PREFIX%
if %ERRORLEVEL% neq 0 exit 1

move %LIBRARY_BIN%\llvm-spirv.exe %LIBRARY_BIN%\llvm-spirv-%MAJOR_VERSION%.exe
if %ERRORLEVEL% neq 0 exit 1

mklink /h %LIBRARY_BIN%\llvm-spirv.exe %LIBRARY_BIN%\llvm-spirv-%MAJOR_VERSION%.exe
if %ERRORLEVEL% neq 0 exit 1
68 changes: 44 additions & 24 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{% else %}
{% set abi_version = version.split('.')[0] %}
{% endif %}
{% set library = "Library/" if win else "" %}

package:
name: llvm-spirv-split
Expand All @@ -16,23 +17,25 @@ package:
source:
url: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/v{{ version.replace("_", "-") }}.tar.gz
sha256: 78a770eff24d5ffe2798479845adec4b909cbf058ddc55830ea00fa7d2c1698a
patches:
- patches/0001-Work-around-a-bug-in-the-llvm-config.patch # [win]

build:
number: 0
skip: true # [not unix]

requirements:
build:
- {{ stdlib('c') }}
- {{ compiler('cxx') }}
- cmake
- make
- ninja # [win]
- make # [not win]
- pkg-config
host:
- llvmdev {{ llvm_version }}.*
- llvm {{ llvm_version }}.*
- spirv-headers
- spirv-tools
- spirv-tools # [not win]
- zlib

outputs:
Expand All @@ -42,6 +45,7 @@ outputs:
ignore_run_exports_from:
- zlib
- spirv-tools
skip: true # [win]
files:
- lib/libLLVMSPIRVLib.{{ abi_version }}.dylib # [osx]
- lib/libLLVMSPIRVLib.so.{{ abi_version }} # [linux]
Expand All @@ -68,18 +72,22 @@ outputs:
- test -f ${PREFIX}/lib/libLLVMSPIRVLib.so.{{ abi_version }} # [linux]

- name: libllvmspirv
script: install.sh
script: install.sh # [not win]
script: install.bat # [win]
build:
run_exports:
- {{ pin_subpackage("libllvmspirv" ~ major) }}
ignore_run_exports_from:
- zlib
- spirv-tools
- spirv-tools # [not win]
script_env:
- MAJOR_VERSION={{ major }} # [win]
files:
- lib/libLLVMSPIRVLib.dylib # [osx]
- lib/libLLVMSPIRVLib.so # [linux]
- lib/pkgconfig/LLVMSPIRVLib.pc
- include/LLVMSPIRVLib/
- lib/libLLVMSPIRVLib.dylib # [osx]
- lib/libLLVMSPIRVLib.so # [linux]
- {{ library }}lib/LLVMSPIRVLib.lib # [win]
- {{ library }}lib/pkgconfig/LLVMSPIRVLib.pc
- {{ library }}include/LLVMSPIRVLib/
requirements:
build:
- {{ stdlib('c') }}
Expand All @@ -92,23 +100,28 @@ outputs:
- llvm {{ llvm_version }}.*
- zlib
- spirv-headers
- spirv-tools
- {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }}
- spirv-tools # [not win]
- {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }} # [not win]
run:
- {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }}
- {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }} # [not win]
run_constrained:
- llvmdev {{ llvm_version }}.*
test:
commands:
- test -f ${PREFIX}/lib/libLLVMSPIRVLib${SHLIB_EXT}
- test -f ${PREFIX}/lib/libLLVMSPIRVLib${SHLIB_EXT} # [not win]
- if not exist "%LIBRARY_LIB%"\\LLVMSPIRVLib.lib exit 1 # [win]

- name: llvm-spirv-{{ major }}
script: install.sh
script: install.sh # [not win]
script: install.bat # [win]
build:
ignore_run_exports_from:
- zlib
script_env:
- MAJOR_VERSION={{ major }} # [win]
files:
- bin/llvm-spirv-{{ major }}
- bin/llvm-spirv-{{ major }} # [not win]
- {{ library }}bin/llvm-spirv-{{ major }}.exe # [win]
requirements:
build:
- {{ stdlib('c') }}
Expand All @@ -121,22 +134,28 @@ outputs:
- llvm {{ llvm_version }}.*
- zlib
- spirv-headers
- spirv-tools
- {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }}
- spirv-tools # [not win]
- {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }} # [not win]
run:
- {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }}
- {{ pin_subpackage("libllvmspirv" ~ major, exact=True) }} # [not win]
test:
commands:
- ${PREFIX}/bin/llvm-spirv-{{ major }} -help
- ${PREFIX}/bin/llvm-spirv-{{ major }} -help # [not win]
- '%LIBRARY_BIN%\\llvm-spirv-{{ major }}.exe -help' # [win]
- llvm-spirv-{{ major }} -help

- name: llvm-spirv
script: install.sh
script: install.sh # [not win]
script: install.bat # [win]
build:
ignore_run_exports_from:
- zlib
- spirv-tools
- spirv-tools # [not win]
script_env:
- MAJOR_VERSION={{ major }} # [win]
files:
- bin/llvm-spirv
- bin/llvm-spirv # [not win]
- {{ library }}bin/llvm-spirv.exe # [win]
requirements:
build:
- {{ stdlib('c') }}
Expand All @@ -149,13 +168,14 @@ outputs:
- llvm {{ llvm_version }}.*
- zlib
- spirv-headers
- spirv-tools
- spirv-tools # [not win]
- {{ pin_subpackage("llvm-spirv-" ~ major, exact=True) }}
run:
- {{ pin_subpackage("llvm-spirv-" ~ major, exact=True) }}
test:
commands:
- ${PREFIX}/bin/llvm-spirv -help
- ${PREFIX}/bin/llvm-spirv -help # [not win]
- '%LIBRARY_BIN%\\llvm-spirv.exe -help' # [win]
- llvm-spirv -help

about:
Expand Down
26 changes: 26 additions & 0 deletions recipe/patches/0001-Work-around-a-bug-in-the-llvm-config.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From 4e96cd52c7f5c695ecf3da195947874e202df870 Mon Sep 17 00:00:00 2001
From: Yevhenii Havrylko <[email protected]>
Date: Tue, 4 Jun 2024 23:58:29 -0400
Subject: [PATCH] Work around a bug in the llvm config

---
CMakeLists.txt | 3 +++
1 file changed, 3 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3cb4386..0c0c9ae 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -72,6 +72,9 @@ if(LLVM_SPIRV_BUILD_EXTERNAL)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

+ # https://github.com/llvm/llvm-project/issues/83802
+ include(GNUInstallDirs)
+
if(LLVM_SPIRV_INCLUDE_TESTS)
set(LLVM_TEST_COMPONENTS
llvm-as
--
2.40.0.windows.1

0 comments on commit 9927e4b

Please sign in to comment.