Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ports/llvm/0005-fix-tools-path.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp
index 53ba24efc00..0badcafe000 100644
--- a/llvm/tools/llvm-config/llvm-config.cpp
+++ b/llvm/tools/llvm-config/llvm-config.cpp
@@ -304,8 +304,8 @@ int main(int argc, char **argv) {
// Create an absolute path, and pop up one directory (we expect to be inside a
// bin dir).
sys::fs::make_absolute(CurrentPath);
CurrentExecPrefix =
- sys::path::parent_path(sys::path::parent_path(CurrentPath)).str();
+ sys::path::parent_path(sys::path::parent_path(sys::path::parent_path(CurrentPath))).str();

// Check to see if we are inside a development tree by comparing to possible
// locations (prefix style or CMake style).
2 changes: 1 addition & 1 deletion ports/llvm/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: llvm
Version: 10.0.0
Port-Version: 6
Port-Version: 7
Homepage: https://llvm.org/
Description: The LLVM Compiler Infrastructure
Supports: !uwp
Expand Down
54 changes: 6 additions & 48 deletions ports/llvm/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ vcpkg_from_github(
0002-fix-install-paths.patch
0003-fix-vs2019-v16.6.patch
0004-fix-dr-1734.patch
0005-fix-tools-path.patch
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
Expand Down Expand Up @@ -145,57 +146,15 @@ vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH share/${PORT})
if("clang" IN_LIST FEATURES)
vcpkg_fixup_cmake_targets(CONFIG_PATH share/clang TARGET_PATH share/clang)
endif()

if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
file(GLOB_RECURSE _llvm_release_targets
"${CURRENT_PACKAGES_DIR}/share/llvm/*-release.cmake"
)
set(_clang_release_targets)
if("clang" IN_LIST FEATURES)
file(GLOB_RECURSE _clang_release_targets
"${CURRENT_PACKAGES_DIR}/share/clang/*-release.cmake"
)
endif()
foreach(_target IN LISTS _llvm_release_targets _clang_release_targets)
file(READ ${_target} _contents)
# LLVM tools should be located in the bin folder because llvm-config expects to be inside a bin dir.
# Rename `/tools/${PORT}` to `/bin` back because there is no way to avoid this in vcpkg_fixup_cmake_targets.
string(REPLACE "{_IMPORT_PREFIX}/tools/${PORT}" "{_IMPORT_PREFIX}/bin" _contents "${_contents}")
file(WRITE ${_target} "${_contents}")
endforeach()
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/tools)
file(RENAME ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/tools/${PORT})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The halide failure is caused by

CMake Error at D:/installed/x64-windows/share/llvm/LLVMExports.cmake:716 (message):
  The imported target "LTO" references the file

     "D:/installed/x64-windows/debug/bin/LTOd.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

     "D:/installed/x64-windows/share/llvm/LLVMExports.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  D:/installed/x64-windows/share/llvm/LLVMConfig.cmake:174 (include)
  C:/a/1/s/scripts/buildsystems/vcpkg.cmake:555 (_find_package)
  dependencies/llvm/CMakeLists.txt:12 (find_package)

I think this needs to use vcpkg_copy_tools or something like that instead so that only exes are moved?

endif()

if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
file(GLOB_RECURSE _llvm_debug_targets
"${CURRENT_PACKAGES_DIR}/share/llvm/*-debug.cmake"
)
set(_clang_debug_targets)
if("clang" IN_LIST FEATURES)
file(GLOB_RECURSE _clang_debug_targets
"${CURRENT_PACKAGES_DIR}/share/clang/*-debug.cmake"
)
endif()
foreach(_target IN LISTS _llvm_debug_targets _clang_debug_targets)
file(READ ${_target} _contents)
# LLVM tools should be located in the bin folder because llvm-config expects to be inside a bin dir.
# Rename `/tools/${PORT}` to `/bin` back because there is no way to avoid this in vcpkg_fixup_cmake_targets.
string(REPLACE "{_IMPORT_PREFIX}/tools/${PORT}" "{_IMPORT_PREFIX}/bin" _contents "${_contents}")
# Debug shared libraries should have `d` suffix and should be installed in the `/bin` directory.
# Rename `/debug/bin/` to `/bin`
string(REPLACE "{_IMPORT_PREFIX}/debug/bin/" "{_IMPORT_PREFIX}/bin/" _contents "${_contents}")
file(WRITE ${_target} "${_contents}")
endforeach()

# Install debug shared libraries in the `/bin` directory
file(GLOB _debug_shared_libs ${CURRENT_PACKAGES_DIR}/debug/bin/*${CMAKE_SHARED_LIBRARY_SUFFIX})
file(INSTALL ${_debug_shared_libs} DESTINATION ${CURRENT_PACKAGES_DIR}/bin)

file(REMOVE_RECURSE
${CURRENT_PACKAGES_DIR}/debug/bin
${CURRENT_PACKAGES_DIR}/debug/include
${CURRENT_PACKAGES_DIR}/debug/share
)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
endif()

# Handle copyright
Expand All @@ -205,4 +164,3 @@ if("clang" IN_LIST FEATURES)
endif()

# Don't fail if the bin folder exists.
Comment thread
JackBoosY marked this conversation as resolved.
Outdated
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)