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

Semi-colon separated lists in portfile becomes multi-quote guarded, space delimited strings on the command line #4320

Closed
MathiasMagnus opened this issue Sep 21, 2018 · 0 comments · Fixed by #12977
Assignees
Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed

Comments

@MathiasMagnus
Copy link
Contributor

I'm trying to enhance the LLVM package to suit my needs, but there is a big problem which I spent over a day now trying to come over. (This is the kind of aggravation which makes me start to think that Vcpkg does not scale.)

LLVM requires a LLVM_TARGETS_TO_BUILD variable which by the docs should be a semi-colon delimited string, so the native CMake encoding for lists. Currently the LLVM port only builds the X86 target, but I want it to also build GPU-related targets. (Currently it's hardcoded, but before I submit, I'll make non-x86 targets features of the package.) Problem is, that if I write this in the portfile:

vcpkg_configure_cmake(
    SOURCE_PATH ${SOURCE_PATH}
    PREFER_NINJA
    OPTIONS
        -DLLVM_TARGETS_TO_BUILD="X86;AMDGPU;NVPTX"
        -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="X86;AMDGPU;NVPTX"
        -DLLVM_INCLUDE_TOOLS=ON
        -DLLVM_INCLUDE_UTILS=OFF
        -DLLVM_INCLUDE_EXAMPLES=OFF
        -DLLVM_INCLUDE_TESTS=OFF
        -DLLVM_ABI_BREAKING_CHECKS=FORCE_OFF
        -DLLVM_TOOLS_INSTALL_DIR=tools/llvm
        -DLLVM_PARALLEL_LINK_JOBS=8
)

It does not matter if I use quotes or not, the command-line invocation contains:

"-DLLVM_TARGETS_TO_BUILD="X86" "AMDGPU" "NVPTX""

Things from here on start to fall apart spectacularly. (LLVM_EXPERIMENTAL_TARGETS_TO_BUILD is undocumented, which targets should be placed there, it just argues seemingly randomly if something's not there. So I just duplicate everything. The two get merged anyway in the main CMakeLists.txt file via)

set(LLVM_TARGETS_TO_BUILD
   ${LLVM_TARGETS_TO_BUILD}
   ${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD})
list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD)

This is the code snippet that calls the LLVM-build Python scripts:

message(STATUS "Constructing LLVMBuild project information")
execute_process(
  COMMAND ${PYTHON_EXECUTABLE} -B ${LLVMBUILDTOOL}
            ...
            --enable-targets "${LLVM_TARGETS_TO_BUILD}"
            ...
  RESULT_VARIABLE LLVMBUILDRESULT)

The error becomes:

-- LLVMHello ignored -- Loadable modules not supported on this platform.
-- Targeting X86 AMDGPU NVPTX
CMake Error at lib/Target/CMakeLists.txt:18 (add_subdirectory):
  add_subdirectory given source "X86 AMDGPU NVPTX" which is not an existing
  directory.


CMake Error at cmake/modules/LLVM-Config.cmake:175 (message):
  Target X86 AMDGPU NVPTX is not in the set of libraries.
Call Stack (most recent call first):

of course, because the scripts got derailed a few lines back in LLVM-Config.cmake before invoking the Python scripts when it tried

list(FIND LLVM_TARGETS_TO_BUILD "${LLVM_NATIVE_ARCH}" have_native_backend)

The variable with the semi-colons stripped is no longer a list.

The fix is to add:

message(STATUS "Constructing LLVMBuild project information")
message(STATUS "LLVM_TARGETS_TO_BUILD: ${LLVM_TARGETS_TO_BUILD}")
string(REPLACE " " ";" LLVM_TARGETS_TO_BUILD ${LLVM_TARGETS_TO_BUILD})
message(STATUS "LLVM_TARGETS_TO_BUILD: ${LLVM_TARGETS_TO_BUILD}")

which results in configuration succeeding.

-- Constructing LLVMBuild project information
-- LLVM_TARGETS_TO_BUILD: X86 AMDGPU NVPTX
-- LLVM_TARGETS_TO_BUILD: X86;AMDGPU;NVPTX
-- LLVMHello ignored -- Loadable modules not supported on this platform.
-- Targeting X86
-- Targeting AMDGPU
-- Targeting NVPTX

Summa summarum

Having to patch the build scripts solely because Vcpkg messes up command-line invocations containing native CMake lists is not okay.

@MathiasMagnus MathiasMagnus changed the title Semi-colon separated lists in potfile become multi-quote guarded, space delimited strings on the command line Semi-colon separated lists in portfile becomes multi-quote guarded, space delimited strings on the command line Sep 21, 2018
@PhoebeHui PhoebeHui added the category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed label Jan 24, 2019
jgehw pushed a commit to jgehw/vcpkg that referenced this issue Aug 18, 2020
@JackBoosY JackBoosY self-assigned this Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants