Skip to content
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

-DIGC_OPTION__SPIRV_TOOLS_MODE=Prebuilds fails unless SPIRV-Tools built with -DSPIRV_TOOLS_BUILD_STATIC=OFF #241

Closed
jbeich opened this issue Apr 27, 2022 · 2 comments

Comments

@jbeich
Copy link
Contributor

jbeich commented Apr 27, 2022

Regressed by 7e6b78d + acfa99b. Related to KhronosGroup/SPIRV-Tools#3909

-DSPIRV_TOOLS_BUILD_STATIC=OFF package content diff
--- /usr/lib/cmake/SPIRV-Tools/SPIRV-ToolsTarget-release.cmake	default
+++ /usr/lib/cmake/SPIRV-Tools/SPIRV-ToolsTarget-release.cmake	-DSPIRV_TOOLS_BUILD_STATIC=OFF
@@ -5,15 +5,15 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
 # Commands may need to know the format version.
 set(CMAKE_IMPORT_FILE_VERSION 1)
 
-# Import target "SPIRV-Tools-static" for configuration "Release"
-set_property(TARGET SPIRV-Tools-static APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
-set_target_properties(SPIRV-Tools-static PROPERTIES
+# Import target "SPIRV-Tools" for configuration "Release"
+set_property(TARGET SPIRV-Tools APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+set_target_properties(SPIRV-Tools PROPERTIES
   IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
   IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libSPIRV-Tools.a"
   )
 
-list(APPEND _IMPORT_CHECK_TARGETS SPIRV-Tools-static )
-list(APPEND _IMPORT_CHECK_FILES_FOR_SPIRV-Tools-static "${_IMPORT_PREFIX}/lib/libSPIRV-Tools.a" )
+list(APPEND _IMPORT_CHECK_TARGETS SPIRV-Tools )
+list(APPEND _IMPORT_CHECK_FILES_FOR_SPIRV-Tools "${_IMPORT_PREFIX}/lib/libSPIRV-Tools.a" )
 
 # Import target "SPIRV-Tools-shared" for configuration "Release"
 set_property(TARGET SPIRV-Tools-shared APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
--- /usr/lib/cmake/SPIRV-Tools/SPIRV-ToolsTarget.cmake	default
+++ /usr/lib/cmake/SPIRV-Tools/SPIRV-ToolsTarget.cmake	-DSPIRV_TOOLS_BUILD_STATIC=OFF
@@ -16,7 +16,7 @@ set(_expectedTargets)
 set(_targetsDefined)
 set(_targetsNotDefined)
 set(_expectedTargets)
-foreach(_expectedTarget SPIRV-Tools-static SPIRV-Tools-shared)
+foreach(_expectedTarget SPIRV-Tools SPIRV-Tools-shared)
   list(APPEND _expectedTargets ${_expectedTarget})
   if(NOT TARGET ${_expectedTarget})
     list(APPEND _targetsNotDefined ${_expectedTarget})
@@ -50,10 +50,10 @@ endif()
   set(_IMPORT_PREFIX "")
 endif()
 
-# Create imported target SPIRV-Tools-static
-add_library(SPIRV-Tools-static STATIC IMPORTED)
+# Create imported target SPIRV-Tools
+add_library(SPIRV-Tools STATIC IMPORTED)
 
-set_target_properties(SPIRV-Tools-static PROPERTIES
+set_target_properties(SPIRV-Tools PROPERTIES
   INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
 )
 
--- /usr/lib/cmake/SPIRV-Tools-diff/SPIRV-Tools-diffTargets.cmake	default
+++ /usr/lib/cmake/SPIRV-Tools-diff/SPIRV-Tools-diffTargets.cmake	-DSPIRV_TOOLS_BUILD_STATIC=OFF
@@ -55,7 +55,7 @@ set_target_properties(SPIRV-Tools-diff PROPERTIES
 
 set_target_properties(SPIRV-Tools-diff PROPERTIES
   INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
-  INTERFACE_LINK_LIBRARIES "SPIRV-Tools-static;SPIRV-Tools-opt"
+  INTERFACE_LINK_LIBRARIES "SPIRV-Tools;SPIRV-Tools-opt"
 )
 
 if(CMAKE_VERSION VERSION_LESS 2.8.12)
@@ -94,7 +94,7 @@ unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_tar
 # Make sure the targets which have been exported in some other
 # export set exist.
 unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)
-foreach(_target "SPIRV-Tools-static" "SPIRV-Tools-opt" )
+foreach(_target "SPIRV-Tools" "SPIRV-Tools-opt" )
   if(NOT TARGET "${_target}" )
     set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets} ${_target}")
   endif()
--- /usr/lib/cmake/SPIRV-Tools-lint/SPIRV-Tools-lintTargets.cmake	default
+++ /usr/lib/cmake/SPIRV-Tools-lint/SPIRV-Tools-lintTargets.cmake	-DSPIRV_TOOLS_BUILD_STATIC=OFF
@@ -55,7 +55,7 @@ set_target_properties(SPIRV-Tools-lint PROPERTIES
 
 set_target_properties(SPIRV-Tools-lint PROPERTIES
   INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
-  INTERFACE_LINK_LIBRARIES "SPIRV-Tools-static;SPIRV-Tools-opt"
+  INTERFACE_LINK_LIBRARIES "SPIRV-Tools;SPIRV-Tools-opt"
 )
 
 if(CMAKE_VERSION VERSION_LESS 2.8.12)
@@ -94,7 +94,7 @@ unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_tar
 # Make sure the targets which have been exported in some other
 # export set exist.
 unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)
-foreach(_target "SPIRV-Tools-static" "SPIRV-Tools-opt" )
+foreach(_target "SPIRV-Tools" "SPIRV-Tools-opt" )
   if(NOT TARGET "${_target}" )
     set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets} ${_target}")
   endif()
--- /usr/lib/cmake/SPIRV-Tools-opt/SPIRV-Tools-optTargets.cmake	default
+++ /usr/lib/cmake/SPIRV-Tools-opt/SPIRV-Tools-optTargets.cmake	-DSPIRV_TOOLS_BUILD_STATIC=OFF
@@ -55,7 +55,7 @@ set_target_properties(SPIRV-Tools-opt PROPERTIES
 
 set_target_properties(SPIRV-Tools-opt PROPERTIES
   INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
-  INTERFACE_LINK_LIBRARIES "SPIRV-Tools-static"
+  INTERFACE_LINK_LIBRARIES "SPIRV-Tools"
 )
 
 if(CMAKE_VERSION VERSION_LESS 2.8.12)
@@ -94,7 +94,7 @@ unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_tar
 # Make sure the targets which have been exported in some other
 # export set exist.
 unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)
-foreach(_target "SPIRV-Tools-static" )
+foreach(_target "SPIRV-Tools" )
   if(NOT TARGET "${_target}" )
     set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets} ${_target}")
   endif()
--- /usr/lib/cmake/SPIRV-Tools-reduce/SPIRV-Tools-reduceTarget.cmake	default
+++ /usr/lib/cmake/SPIRV-Tools-reduce/SPIRV-Tools-reduceTarget.cmake	-DSPIRV_TOOLS_BUILD_STATIC=OFF
@@ -55,7 +55,7 @@ set_target_properties(SPIRV-Tools-reduce PROPERTIES
 
 set_target_properties(SPIRV-Tools-reduce PROPERTIES
   INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
-  INTERFACE_LINK_LIBRARIES "SPIRV-Tools-static;SPIRV-Tools-opt"
+  INTERFACE_LINK_LIBRARIES "SPIRV-Tools;SPIRV-Tools-opt"
 )
 
 if(CMAKE_VERSION VERSION_LESS 2.8.12)
@@ -94,7 +94,7 @@ unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_tar
 # Make sure the targets which have been exported in some other
 # export set exist.
 unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)
-foreach(_target "SPIRV-Tools-static" "SPIRV-Tools-opt" )
+foreach(_target "SPIRV-Tools" "SPIRV-Tools-opt" )
   if(NOT TARGET "${_target}" )
     set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets} ${_target}")
   endif()
$ cmake -DIGC_OPTION__SPIRV_TOOLS_MODE=Prebuilds
[...]
-- [SPIRV-Tools] : Searching prebuilt SPIRV-Tools package
-- [SPIRV-Tools] : Found prebuilt SPIRV-Tools package in: /usr/lib/cmake/SPIRV-Tools/SPIRV-ToolsConfig.cmake
CMake Error at external/SPIRV-Tools/CMakeLists.txt:36 (set_target_properties):
  set_target_properties Can not find target to add properties to: SPIRV-Tools
Call Stack (most recent call first):
  IGC/CMakeLists.txt:1402 (include)


-- =============================================================================
CMake Error at IGC/CMakeLists.txt:1409 (message):
  Error while adding SPIR-V Tools project.  Please make sure
  /usr/lib/cmake/SPIRV-Tools../../..  is present.


-- Configuring incomplete, errors occurred!
@ArchangeGabriel
Copy link
Contributor

Similar to what was discussed in #224 (comment). Thing is currently it seems to be impossible to support both static and shared? And Arch only has shared for instance.

@mnaczk
Copy link
Contributor

mnaczk commented Jun 13, 2022

According to commit KhronosGroup/SPIRV-Tools@6aed7ff
SPIRV-Tools should be built primarily as a static lib but could be also built as shared lib depending on flag BUILD_SHARED_LIBS. In both cases, it should create target ${SPIRV_TOOLS} which should be an alias to a suitable target (static or shared).

The flag SPIRV_TOOLS_BUILD_STATIC in its default state (ON) should produce an appropriate alias target. According to commit KhronosGroup/SPIRV-Tools@7403dfa

I do not know why for proper working the flag SPIRV_TOOLS_BUILD_STATIC must be set to OFF. It probably is related, as you mentioned earlier, to the issue KhronosGroup/SPIRV-Tools#3909

On the IGC site, we made the decision to support SPIRV-Tools only as a shared lib. To communicate this, we will add an annotation in the file https://github.com/intel/intel-graphics-compiler/blob/master/documentation/build_ubuntu.md#use-preinstalled-packages, that till the time the issue KhronosGroup/SPIRV-Tools#3909 will not be resolved we support only SPIRV-Tools as a shared lib and we encourage to build SPIRV-Tools prebuild with SPIRV_TOOLS_BUILD_STATIC=OFF flag.

@jbeich thanks for spotting this issue.

Link to commit on the IGC side. 205e9c3

@mnaczk mnaczk closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants