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

[spirv-tools] explicitly deletes DLLs, then aborts when consumed via find_package due to missing DLLs #18612

Closed
chrisdjali-wrld3d opened this issue Jun 23, 2021 · 4 comments
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support

Comments

@chrisdjali-wrld3d
Copy link
Contributor

Describe the bug
The spirv-tools package explicitly deletes the output of the SPIRV-Tools-shared target here: https://github.com/barcharcraz/vcpkg/blob/master/ports/spirv-tools/portfile.cmake#L46-L51

The SPIRV-Tools-shared target is still created even with -DSPIRV_TOOLS_BUILD_STATIC=ON (which is set explicitly in the portfile) so the upstream CMake still installs it, and creates a check for its presence in the module importing script.

That means if the package is consumed via find_package, the check will fail, and a FATAL_ERROR message is logged. This aborts the build.

Environment

  • OS: Windows 10
  • Compiler: MSVC 2019 16.9.5

To Reproduce
Steps to reproduce the behavior:

  1. ./vcpkg install spirv-tools
  2. Create a new CMake project including find_package(SPIRV-Tools REQUIRED). A CMakeLists.txt containing this single line should be enough.
  3. Configure the CMake project using the normal Vcpkg toolchain.
  4. Observe that a fatal error is printed stating that:
     The imported target "SPIRV-Tools-shared" references the file
    
        "C:/Clones/vcpkg/installed/x64-windows/debug/bin/SPIRV-Tools-shared.dll"
    
     but this file does not exist.  Possible reasons include:
    
     * The file was deleted, renamed, or moved to another location.
    
     * An install or uninstall procedure did not complete successfully.
    
     * The installation package was faulty and contained
    
        "C:/Clones/vcpkg/installed/x64-windows/share/SPIRV-Tools/SPIRV-ToolsTarget.cmake"
    
     but not all the files it references.
    
    Call Stack (most recent call first):
      C:/Clones/vcpkg/installed/x64-windows/share/SPIRV-Tools/SPIRV-ToolsConfig.cmake:1 (include)
      C:/Clones/vcpkg/scripts/buildsystems/vcpkg.cmake:772 (_find_package)
      CMakeLists.txt:119 (find_package)
    

Expected behavior
Once find_package(SPIRV-Tools REQUIRED) has been called, the configure proceeds and the SPIRV-Tools-static library is available (also as SPIRV-Tools with no suffix).

Failure logs

  • The relevant parts of the log are above.
  • This is a log from a dummy CMake project with literally just the find_package call, so it's got some other warnings about not being a real CMake project: log.log

Additional context
N/A

@NancyLi1013 NancyLi1013 added the category:port-bug The issue is with a library, which is something the port should already support label Jun 24, 2021
@NancyLi1013
Copy link
Contributor

Hi @chrisdjali-wrld3d

Thanks for posting this issue.

@barcharcraz

Could you please help take a look why removing SPIRV-Tools-shared.dll?

file(REMOVE "${CURRENT_PACKAGES_DIR}/bin/SPIRV-Tools-shared.dll")

Is there any reason why this port only supports static build?

@barcharcraz
Copy link
Member

I don't think they actually correctly export symbols on windows. I forget the exact reason, however. I think one of vcpkgs lint checks fires if a static library build installs shared libraries, requiring the deletion. If I recall patching the shared build out of the cmakelists was pretty involved as well due to how their cmake is structured.

I'll take another look when I have time, maybe things have improved upstream.

There's some upstream work in SPIRV-Tools to fix their build options.

@FrankXie05
Copy link
Contributor

@chrisdjali-wrld3d This issue has been fixed upstream, please update to the latest vcpkg and try building again. :)

Successful example:
CMakeLists.txt:

cmake_minimum_required(VERSION 3.9)
set(CMAKE_CXX_STANDARD 20)

project(Bug_test)

add_executable(main main.cpp)

find_package(SPIRV-Tools CONFIG REQUIRED)
target_link_libraries(main PRIVATE SPIRV-Tools-shared SPIRV-Tools-static)

log:

test@test002:~/bug/build$ cmake .. -DCMAKE_TOOLCHAIN_FILE=/home/test/vcpkg/scripts/buildsystems/vcpkg.cmake
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/test/bug/build

@FrankXie05 FrankXie05 removed the depends:upstream-changes Waiting on a change to the upstream project label Apr 27, 2022
@FrankXie05 FrankXie05 changed the title spirv-tools explicitly deletes DLLs, then aborts when consumed via find_package due to missing DLLs [spirv-tools] explicitly deletes DLLs, then aborts when consumed via find_package due to missing DLLs Apr 29, 2022
@dg0yt
Copy link
Contributor

dg0yt commented Apr 29, 2022

target_link_libraries(main PRIVATE SPIRV-Tools-shared SPIRV-Tools-static)

Find the error!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants