diff --git a/pkgs/development/tools/spirv-tools/default.nix b/pkgs/development/tools/spirv-tools/default.nix index 0a476e346ced..274aff3f4e15 100644 --- a/pkgs/development/tools/spirv-tools/default.nix +++ b/pkgs/development/tools/spirv-tools/default.nix @@ -11,6 +11,11 @@ stdenv.mkDerivation rec { hash = "sha256-K7cv0mMNrXYOlJsxAPwz3rVX5FnsnBNvaU33k9hYnQc="; }; + # The cmake options are sufficient for turning on static building, but not + # for disabling shared building, just trim the shared lib from the CMake + # description + patches = lib.optional stdenv.hostPlatform.isStatic ./no-shared-libs.patch; + nativeBuildInputs = [ cmake python3 ]; cmakeFlags = [ @@ -39,7 +44,7 @@ stdenv.mkDerivation rec { description = "The SPIR-V Tools project provides an API and commands for processing SPIR-V modules"; homepage = "https://github.com/KhronosGroup/SPIRV-Tools"; license = licenses.asl20; - platforms = platforms.unix; + platforms = with platforms; unix ++ windows; maintainers = [ maintainers.ralith ]; }; } diff --git a/pkgs/development/tools/spirv-tools/no-shared-libs.patch b/pkgs/development/tools/spirv-tools/no-shared-libs.patch new file mode 100644 index 000000000000..45d2be6ec6ac --- /dev/null +++ b/pkgs/development/tools/spirv-tools/no-shared-libs.patch @@ -0,0 +1,30 @@ +diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt +index acfa0c12..bf3eb686 100644 +--- a/source/CMakeLists.txt ++++ b/source/CMakeLists.txt +@@ -378,16 +378,6 @@ function(spirv_tools_default_target_options target) + add_dependencies(${target} spirv-tools-build-version core_tables enum_string_mapping extinst_tables) + endfunction() + +-# Always build ${SPIRV_TOOLS}-shared. This is expected distro packages, and +-# unlike the other SPIRV_TOOLS target, defaults to hidden symbol visibility. +-add_library(${SPIRV_TOOLS}-shared SHARED ${SPIRV_SOURCES}) +-spirv_tools_default_target_options(${SPIRV_TOOLS}-shared) +-set_target_properties(${SPIRV_TOOLS}-shared PROPERTIES CXX_VISIBILITY_PRESET hidden) +-target_compile_definitions(${SPIRV_TOOLS}-shared +- PRIVATE SPIRV_TOOLS_IMPLEMENTATION +- PUBLIC SPIRV_TOOLS_SHAREDLIB +-) +- + if(SPIRV_TOOLS_BUILD_STATIC) + add_library(${SPIRV_TOOLS}-static STATIC ${SPIRV_SOURCES}) + spirv_tools_default_target_options(${SPIRV_TOOLS}-static) +@@ -402,7 +392,7 @@ if(SPIRV_TOOLS_BUILD_STATIC) + add_library(${SPIRV_TOOLS} ALIAS ${SPIRV_TOOLS}-static) + endif() + +- set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-static ${SPIRV_TOOLS}-shared) ++ set(SPIRV_TOOLS_TARGETS ${SPIRV_TOOLS}-static) + else() + add_library(${SPIRV_TOOLS} ${SPIRV_TOOLS_LIBRARY_TYPE} ${SPIRV_SOURCES}) + spirv_tools_default_target_options(${SPIRV_TOOLS})