Skip to content

Commit

Permalink
Add community triple arm64-linux and arm-linux. (#11880)
Browse files Browse the repository at this point in the history
Verify the following command on both 32 bits and 64 bits OS on Raspberry pi 3.

    ./bootstrap-vcpkg.sh
    ./vcpkg install boost
  • Loading branch information
xieyubo committed Sep 5, 2020
1 parent bd8af07 commit fdac1fc
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ports/boost-build/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: boost-build
Version: 1.73.0
Port-Version: 3
Port-Version: 4
Homepage: https://github.com/boostorg/build
Description: Boost.Build
Build-Depends: boost-uninstall
4 changes: 1 addition & 3 deletions ports/boost-build/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ include(vcpkg_common_functions)

set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

if(NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "x64" AND NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" AND NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "s390x")
return()
elseif(CMAKE_HOST_WIN32 AND VCPKG_CMAKE_SYSTEM_NAME AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "MinGW")
if(CMAKE_HOST_WIN32 AND VCPKG_CMAKE_SYSTEM_NAME AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "MinGW")
return()
endif()

Expand Down
2 changes: 2 additions & 0 deletions ports/boost-modular-build-helper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ endif()

if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "s390x")
list(APPEND B2_OPTIONS architecture=s390x)
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
list(APPEND B2_OPTIONS architecture=arm)
else()
list(APPEND B2_OPTIONS architecture=x86)
endif()
Expand Down
2 changes: 1 addition & 1 deletion ports/boost-modular-build-helper/CONTROL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Source: boost-modular-build-helper
Version: 1.73.0
Port-Version: 4
Port-Version: 5
Build-Depends: boost-uninstall
20 changes: 17 additions & 3 deletions ports/boost-modular-build-helper/boost-modular-build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ function(boost_modular_build)

# Todo: this serves too similar a purpose as vcpkg_find_acquire_program()
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux" AND VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(BOOST_BUILD_PATH "${CURRENT_INSTALLED_DIR}/../x64-linux/tools/boost-build")
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(BOOST_BUILD_PATH "${CURRENT_INSTALLED_DIR}/../arm64-linux/tools/boost-build")
else()
set(BOOST_BUILD_PATH "${CURRENT_INSTALLED_DIR}/../x64-linux/tools/boost-build")
endif()
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "armv7l")
set(BOOST_BUILD_PATH "${CURRENT_INSTALLED_DIR}/../arm-linux/tools/boost-build")
elseif(CMAKE_HOST_WIN32 AND VCPKG_CMAKE_SYSTEM_NAME AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "MinGW")
get_filename_component(BOOST_BUILD_PATH "${CURRENT_INSTALLED_DIR}/../x86-windows/tools/boost-build" ABSOLUTE)
elseif(NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "x64" AND NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" AND NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "s390x")
Expand All @@ -29,9 +35,17 @@ function(boost_modular_build)

if(NOT EXISTS "${BOOST_BUILD_PATH}")
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux" AND VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
message(FATAL_ERROR "The x64 boost-build tools must be installed to build arm64 for Linux. Please run `vcpkg install boost-build:x64-linux`.")
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64")
message(FATAL_ERROR "The arm64 boost-build tools must be installed to build arm64 for Linux. Please run `vcpkg install boost-build:arm64-linux`.")
else()
message(FATAL_ERROR "The x64 boost-build tools must be installed to build arm64 for Linux. Please run `vcpkg install boost-build:x64-linux`.")
endif()
else()
message(FATAL_ERROR "The x86 boost-build tools must be installed to build for non-x86/x64 platforms. Please run `vcpkg install boost-build:x86-windows`.")
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "armv7l")
message(FATAL_ERROR "The arm boost-build tools must be installed to build arm64 for Linux. Please run `vcpkg install boost-build:arm-linux`.")
else()
message(FATAL_ERROR "The x86 boost-build tools must be installed to build for non-x86/x64 platforms. Please run `vcpkg install boost-build:x86-windows`.")
endif()
endif()
endif()

Expand Down
18 changes: 13 additions & 5 deletions ports/libffi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ endif()
# config variables for ffi.h.in
set(VERSION 3.3)

set(KNOWN_PROCESSORS x86 x86_64 AMD64 ARM ARM64 i386)
set(KNOWN_PROCESSORS x86 x86_64 AMD64 ARM ARM64 i386 armv7l aarch64)

if(NOT CMAKE_SYSTEM_PROCESSOR IN_LIST KNOWN_PROCESSORS)
message(FATAL_ERROR "Unknown processor: ${CMAKE_SYSTEM_PROCESSOR}")
endif()

if(CMAKE_SYSTEM_PROCESSOR MATCHES "ARM")
set(TARGET ARM)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l")
set(TARGET ARM)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set(TARGET ARM64)
elseif(CMAKE_SYSTEM_NAME MATCHES "BSD" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
set(TARGET X86_FREEBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows" AND VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
Expand Down Expand Up @@ -50,9 +54,9 @@ set(FFI_EXEC_TRAMPOLINE_TABLE 0)
configure_file(include/ffi.h.in ${CMAKE_BINARY_DIR}/include/ffi.h)
file(COPY ${FFI_CONFIG_FILE} DESTINATION ${CMAKE_BINARY_DIR})

if ("${TARGET}" STREQUAL "ARM_WIN64")
if ("${TARGET}" STREQUAL "ARM_WIN64" OR "${TARGET}" STREQUAL "ARM64")
file(COPY src/aarch64/ffitarget.h DESTINATION ${CMAKE_BINARY_DIR}/include)
elseif ("${TARGET}" STREQUAL "ARM_WIN32")
elseif ("${TARGET}" STREQUAL "ARM_WIN32" OR "${TARGET}" STREQUAL "ARM")
file(COPY src/arm/ffitarget.h DESTINATION ${CMAKE_BINARY_DIR}/include)
else()
file(COPY src/x86/ffitarget.h DESTINATION ${CMAKE_BINARY_DIR}/include)
Expand All @@ -72,11 +76,11 @@ set(FFI_SOURCES
src/prep_cif.c
src/types.c)

if ("${TARGET}" STREQUAL "ARM_WIN64")
if ("${TARGET}" STREQUAL "ARM_WIN64" OR "${TARGET}" STREQUAL "ARM64")
set(FFI_SOURCES
${FFI_SOURCES}
src/aarch64/ffi.c)
elseif("${TARGET}" STREQUAL "ARM_WIN32")
elseif("${TARGET}" STREQUAL "ARM_WIN32" OR "${TARGET}" STREQUAL "ARM")
set(FFI_SOURCES
${FFI_SOURCES}
src/arm/ffi.c)
Expand Down Expand Up @@ -162,8 +166,12 @@ elseif("${TARGET}" STREQUAL "X86_WIN64")
add_assembly(src/x86/win64_intel.S)
elseif("${TARGET}" STREQUAL "ARM_WIN32")
add_assembly(src/arm/sysv_msvc_arm32.S)
elseif("${TARGET}" STREQUAL "ARM")
add_assembly(src/arm/sysv.S)
elseif("${TARGET}" STREQUAL "ARM_WIN64")
add_assembly(src/aarch64/win64_armasm.S)
elseif("${TARGET}" STREQUAL "ARM64")
add_assembly(src/aarch64/sysv.S)
else()
message(FATAL_ERROR "Target not implemented")
endif()
Expand Down
2 changes: 1 addition & 1 deletion ports/libffi/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: libffi
Version: 3.3
Port-Version: 4
Port-Version: 5
Homepage: https://github.com/libffi/libffi
Description: Portable, high level programming interface to various calling conventions
18 changes: 18 additions & 0 deletions scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ vcpkgCheckRepoTool()
fi
}

vcpkgCheckBuildTool()
{
__tool=$1
if ! command -v "$__tool" >/dev/null 2>&1 ; then
echo "Could not find $__tool. Please install it (and other dependencies) with:"
echo "sudo apt-get install cmake ninja-build"
exit 1
fi
}

vcpkgCheckEqualFileHash()
{
url=$1; filePath=$2; expectedHash=$3
Expand Down Expand Up @@ -226,10 +236,18 @@ selectCXX()

# Preparation
UNAME="$(uname)"
ARCH="$(uname -m)"

# Force using system utilities for building vcpkg if host arch is arm or arm64.
if [ "$ARCH" = "armv7l" -o "$ARCH" = "aarch64" ]; then
vcpkgUseSystem=true
fi

if $vcpkgUseSystem; then
cmakeExe="cmake"
ninjaExe="ninja"
vcpkgCheckBuildTool "$cmakeExe"
vcpkgCheckBuildTool "$ninjaExe"
else
fetchTool "cmake" "$UNAME" cmakeExe || exit 1
fetchTool "ninja" "$UNAME" ninjaExe || exit 1
Expand Down
4 changes: 4 additions & 0 deletions scripts/buildsystems/vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ else()
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "s390x")
set(_VCPKG_TARGET_TRIPLET_ARCH s390x)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "armv7l")
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(_VCPKG_TARGET_TRIPLET_ARCH arm64)
else()
if( _CMAKE_IN_TRY_COMPILE )
message(STATUS "Unable to determine target architecture, continuing without vcpkg.")
Expand Down
2 changes: 1 addition & 1 deletion scripts/cmake/vcpkg_configure_cmake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function(vcpkg_configure_cmake)
endif()

# If we use Ninja, make sure it's on PATH
if(GENERATOR STREQUAL "Ninja")
if(GENERATOR STREQUAL "Ninja" AND NOT DEFINED ENV{VCPKG_FORCE_SYSTEM_BINARIES})
vcpkg_find_acquire_program(NINJA)
get_filename_component(NINJA_PATH ${NINJA} DIRECTORY)
vcpkg_add_to_path("${NINJA_PATH}")
Expand Down
8 changes: 8 additions & 0 deletions toolsrc/src/vcpkg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ int main(const int argc, const char* const* const argv)

load_config(fs);

#if (defined(__aarch64__) || defined(__arm__) || defined(_M_ARM) || defined(_M_ARM64)) && !defined(_WIN32)
if (!System::get_environment_variable("VCPKG_FORCE_SYSTEM_BINARIES").has_value())
{
Checks::exit_with_message(VCPKG_LINE_INFO,
"Environment variable VCPKG_FORCE_SYSTEM_BINARIES must be set on arm platform.");
}
#endif

VcpkgCmdArguments args = VcpkgCmdArguments::create_from_command_line(fs, argc, argv);
args.imbue_from_environment();
args.check_feature_flag_consistency();
Expand Down
6 changes: 6 additions & 0 deletions toolsrc/src/vcpkg/triplet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ namespace vcpkg
#elif defined(__FreeBSD__)
return Triplet::from_canonical_name("x64-freebsd");
#elif defined(__GLIBC__)
#if defined(__aarch64__)
return Triplet::from_canonical_name("arm64-linux");
#elif defined(__arm__)
return Triplet::from_canonical_name("arm-linux");
#else
return Triplet::from_canonical_name("x64-linux");
#endif
#else
return Triplet::from_canonical_name("x64-linux-musl");
#endif
Expand Down
9 changes: 9 additions & 0 deletions triplets/community/arm-linux.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(VCPKG_TARGET_ARCHITECTURE arm)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CMAKE_SYSTEM_NAME Linux)

if(NOT CMAKE_HOST_SYSTEM_PROCESSOR)
execute_process(COMMAND "uname" "-m" OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
9 changes: 9 additions & 0 deletions triplets/community/arm64-linux.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CMAKE_SYSTEM_NAME Linux)

if(NOT CMAKE_HOST_SYSTEM_PROCESSOR)
execute_process(COMMAND "uname" "-m" OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()

0 comments on commit fdac1fc

Please sign in to comment.