Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 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
72 changes: 25 additions & 47 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,31 @@ 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"
)
if(VCPKG_TARGET_IS_WINDOWS)
set(LLVM_EXECUTABLE_REGEX [[^([^.]*|[^.]*\.lld)\.exe$]])
else()
set(LLVM_EXECUTABLE_REGEX [[^([^.]*|[^.]*\.lld)$]])
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()
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}")
file(GLOB LLVM_TOOL_FILES "${CURRENT_PACKAGES_DIR}/bin/*")
set(LLVM_TOOLS)
foreach(tool_file IN LISTS LLVM_TOOL_FILES)
get_filename_component(tool_file "${tool_file}" NAME)
if(tool_file MATCHES "${LLVM_EXECUTABLE_REGEX}")
list(APPEND LLVM_TOOLS "${CMAKE_MATCH_1}")
endif()
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)
vcpkg_copy_tools(
TOOL_NAMES ${LLVM_TOOLS}
AUTO_CLEAN)
endif()

file(REMOVE_RECURSE
${CURRENT_PACKAGES_DIR}/debug/bin
${CURRENT_PACKAGES_DIR}/debug/include
${CURRENT_PACKAGES_DIR}/debug/share
)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
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 @@ -204,5 +179,8 @@ if("clang" IN_LIST FEATURES)
file(INSTALL ${SOURCE_PATH}/clang/LICENSE.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/clang RENAME copyright)
endif()

# Don't fail if the bin folder exists.
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
# LLVM still generates a few DLLs in the static build:
# * libclang.dll
# * LTO.dll
# * Remarks.dll
set(VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY enabled)
5 changes: 4 additions & 1 deletion scripts/build_info.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ endif()
if (DEFINED VCPKG_POLICY_DLLS_WITHOUT_EXPORTS)
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyDLLsWithoutExports: ${VCPKG_POLICY_DLLS_WITHOUT_EXPORTS}\n")
endif()
if (DEFINED VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY)
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyDLLsInStaticLibrary: ${VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY}\n")
endif()
if (DEFINED VCPKG_POLICY_EMPTY_PACKAGE)
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyEmptyPackage: ${VCPKG_POLICY_EMPTY_PACKAGE}\n")
endif()
Expand All @@ -31,4 +34,4 @@ if (DEFINED VCPKG_POLICY_SKIP_ARCHITECTURE_CHECK)
endif()
if (DEFINED VCPKG_HEAD_VERSION)
file(APPEND ${BUILD_INFO_FILE_PATH} "Version: ${VCPKG_HEAD_VERSION}\n")
endif()
endif()
9 changes: 9 additions & 0 deletions test.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(LLVM_EXECUTABLE_REGEX [[^([^.]*|[^.]*\.lld)\.exe$]])
foreach(el "bugpoint.exe" "ld.lld.exe" "asdf.dll" "asdf")
message(STATUS "Matching ${el}")
if(el MATCHES "${LLVM_EXECUTABLE_REGEX}")
message(STATUS "Matching ${el} - match (${CMAKE_MATCH_1}).")
else()
message(STATUS "Matching ${el} - no match.")
endif()
endforeach()
2 changes: 1 addition & 1 deletion toolsrc/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"2020.06.15"
"2020.11.11"
2 changes: 2 additions & 0 deletions toolsrc/include/vcpkg/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ namespace vcpkg::Build
EMPTY_PACKAGE,
DLLS_WITHOUT_LIBS,
DLLS_WITHOUT_EXPORTS,
DLLS_IN_STATIC_LIBRARY,
ONLY_RELEASE_CRT,
EMPTY_INCLUDE_FOLDER,
ALLOW_OBSOLETE_MSVCRT,
Expand All @@ -257,6 +258,7 @@ namespace vcpkg::Build
BuildPolicy::EMPTY_PACKAGE,
BuildPolicy::DLLS_WITHOUT_LIBS,
BuildPolicy::DLLS_WITHOUT_EXPORTS,
BuildPolicy::DLLS_IN_STATIC_LIBRARY,
BuildPolicy::ONLY_RELEASE_CRT,
BuildPolicy::EMPTY_INCLUDE_FOLDER,
BuildPolicy::ALLOW_OBSOLETE_MSVCRT,
Expand Down
14 changes: 0 additions & 14 deletions toolsrc/src/vcpkg/base/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,6 @@

namespace
{
#if defined(_WIN32)

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.

Oops

struct IsSlash
{
bool operator()(const wchar_t c) const noexcept { return c == L'/' || c == L'\\'; }
};
#else
struct IsSlash
{
bool operator()(const char c) const noexcept { return c == '/'; }
};
#endif

constexpr IsSlash is_slash;

struct NativeStringView
{
const fs::path::value_type* first;
Expand Down
3 changes: 3 additions & 0 deletions toolsrc/src/vcpkg/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ namespace vcpkg::Build
static const std::string NAME_EMPTY_PACKAGE = "PolicyEmptyPackage";
static const std::string NAME_DLLS_WITHOUT_LIBS = "PolicyDLLsWithoutLIBs";
static const std::string NAME_DLLS_WITHOUT_EXPORTS = "PolicyDLLsWithoutExports";
static const std::string NAME_DLLS_IN_STATIC_LIBRARY = "PolicyDLLsInStaticLibrary";
static const std::string NAME_ONLY_RELEASE_CRT = "PolicyOnlyReleaseCRT";
static const std::string NAME_EMPTY_INCLUDE_FOLDER = "PolicyEmptyIncludeFolder";
static const std::string NAME_ALLOW_OBSOLETE_MSVCRT = "PolicyAllowObsoleteMsvcrt";
Expand All @@ -217,6 +218,7 @@ namespace vcpkg::Build
case BuildPolicy::EMPTY_PACKAGE: return NAME_EMPTY_PACKAGE;
case BuildPolicy::DLLS_WITHOUT_LIBS: return NAME_DLLS_WITHOUT_LIBS;
case BuildPolicy::DLLS_WITHOUT_EXPORTS: return NAME_DLLS_WITHOUT_EXPORTS;
case BuildPolicy::DLLS_IN_STATIC_LIBRARY: return NAME_DLLS_IN_STATIC_LIBRARY;
case BuildPolicy::ONLY_RELEASE_CRT: return NAME_ONLY_RELEASE_CRT;
case BuildPolicy::EMPTY_INCLUDE_FOLDER: return NAME_EMPTY_INCLUDE_FOLDER;
case BuildPolicy::ALLOW_OBSOLETE_MSVCRT: return NAME_ALLOW_OBSOLETE_MSVCRT;
Expand All @@ -234,6 +236,7 @@ namespace vcpkg::Build
case BuildPolicy::EMPTY_PACKAGE: return "VCPKG_POLICY_EMPTY_PACKAGE";
case BuildPolicy::DLLS_WITHOUT_LIBS: return "VCPKG_POLICY_DLLS_WITHOUT_LIBS";
case BuildPolicy::DLLS_WITHOUT_EXPORTS: return "VCPKG_POLICY_DLLS_WITHOUT_EXPORTS";
case BuildPolicy::DLLS_IN_STATIC_LIBRARY: return "VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY";
case BuildPolicy::ONLY_RELEASE_CRT: return "VCPKG_POLICY_ONLY_RELEASE_CRT";
case BuildPolicy::EMPTY_INCLUDE_FOLDER: return "VCPKG_POLICY_EMPTY_INCLUDE_FOLDER";
case BuildPolicy::ALLOW_OBSOLETE_MSVCRT: return "VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT";
Expand Down
13 changes: 8 additions & 5 deletions toolsrc/src/vcpkg/postbuildlint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,9 @@ namespace vcpkg::PostBuildLint
return LintStatus::SUCCESS;
}

static LintStatus check_no_dlls_present(const std::vector<fs::path>& dlls)
static LintStatus check_no_dlls_present(const Build::BuildPolicies& policies, const std::vector<fs::path>& dlls)
{
if (dlls.empty())
if (dlls.empty() || policies.is_enabled(BuildPolicy::DLLS_IN_STATIC_LIBRARY))
{
return LintStatus::SUCCESS;
}
Expand Down Expand Up @@ -628,9 +628,12 @@ namespace vcpkg::PostBuildLint
return LintStatus::SUCCESS;
}

static LintStatus check_bin_folders_are_not_present_in_static_build(const Files::Filesystem& fs,
static LintStatus check_bin_folders_are_not_present_in_static_build(const Build::BuildPolicies& policies,
const Files::Filesystem& fs,
const fs::path& package_dir)
{
if (policies.is_enabled(BuildPolicy::DLLS_IN_STATIC_LIBRARY)) return LintStatus::SUCCESS;

const fs::path bin = package_dir / "bin";
const fs::path debug_bin = package_dir / "debug" / "bin";

Expand Down Expand Up @@ -921,9 +924,9 @@ namespace vcpkg::PostBuildLint
{
auto dlls = release_dlls;
dlls.insert(dlls.end(), debug_dlls.begin(), debug_dlls.end());
error_count += check_no_dlls_present(dlls);
error_count += check_no_dlls_present(build_info.policies, dlls);

error_count += check_bin_folders_are_not_present_in_static_build(fs, package_dir);
error_count += check_bin_folders_are_not_present_in_static_build(build_info.policies, fs, package_dir);

if (!toolset.dumpbin.empty() && !build_info.policies.is_enabled(BuildPolicy::SKIP_DUMPBIN_CHECKS))
{
Expand Down