From 7daed9ea34206df6f4c0b6d05e2e38624947586c Mon Sep 17 00:00:00 2001 From: John Sullivan Date: Thu, 17 Sep 2020 14:14:59 -0700 Subject: [PATCH] zig: enable cross-compile support --- ...-to-use-llvm-config-to-find-cross-ta.patch | 39 +++++++++++++++++++ srcpkgs/zig/template | 31 +++++++++++++-- 2 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 srcpkgs/zig/patches/0001-cmake-add-option-to-use-llvm-config-to-find-cross-ta.patch diff --git a/srcpkgs/zig/patches/0001-cmake-add-option-to-use-llvm-config-to-find-cross-ta.patch b/srcpkgs/zig/patches/0001-cmake-add-option-to-use-llvm-config-to-find-cross-ta.patch new file mode 100644 index 00000000000..525c46b67d7 --- /dev/null +++ b/srcpkgs/zig/patches/0001-cmake-add-option-to-use-llvm-config-to-find-cross-ta.patch @@ -0,0 +1,39 @@ +From 35e2d40ac60034e0e3fbcad44d3c11769567c5cf Mon Sep 17 00:00:00 2001 +From: John Sullivan +Date: Sun, 20 Sep 2020 14:55:43 -0700 +Subject: [PATCH] cmake: add option to use llvm-config to find cross-target + llvm deps + +--- + CMakeLists.txt | 1 + + cmake/Findllvm.cmake | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 27bc6a04f..b7c1dc047 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -66,6 +66,7 @@ option(ZIG_FORCE_EXTERNAL_LLD "does nothing" OFF) + set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for") + set(ZIG_TARGET_MCPU "baseline" CACHE STRING "-mcpu parameter to output binaries for") + set(ZIG_EXECUTABLE "" CACHE STRING "(when cross compiling) path to already-built zig binary") ++set(ZIG_FORCE_LLVM_CONFIG off CACHE BOOL "(when cross compiling) use llvm-config to find target llvm dependencies") + + find_package(llvm) + find_package(clang) +diff --git a/cmake/Findllvm.cmake b/cmake/Findllvm.cmake +index 7d6a4b04d..3cbd7fd9c 100644 +--- a/cmake/Findllvm.cmake ++++ b/cmake/Findllvm.cmake +@@ -7,7 +7,7 @@ + # LLVM_LIBRARIES + # LLVM_LIBDIRS + +-if("${ZIG_TARGET_TRIPLE}" STREQUAL "native") ++if(("${ZIG_TARGET_TRIPLE}" STREQUAL "native") OR ZIG_FORCE_LLVM_CONFIG) + find_program(LLVM_CONFIG_EXE + NAMES llvm-config-10 llvm-config-10.0 llvm-config100 llvm-config10 llvm-config + PATHS +-- +2.28.0 + diff --git a/srcpkgs/zig/template b/srcpkgs/zig/template index c3ab8e62a11..b02dd5f239c 100644 --- a/srcpkgs/zig/template +++ b/srcpkgs/zig/template @@ -1,8 +1,8 @@ # Template file for 'zig' pkgname=zig version=0.6.0 -revision=1 -archs="x86_64*" +revision=2 +archs="x86_64* aarch64*" build_style=cmake makedepends="clang llvm10 lld-devel" short_desc="Programming language designed for robustness, optimality, and clarity" @@ -11,9 +11,34 @@ license="MIT" homepage="https://ziglang.org/" distfiles="https://ziglang.org/download/${version}/zig-${version}.tar.xz" checksum=5d167dc19354282dd35dd17b38e99e1763713b9be8a4ba9e9e69284e059e7204 +patch_args="-Np1" nopie=yes -nocross=yes + +if [ "${CROSS_BUILD}" ]; then + hostmakedepends="zig llvm10" + configure_args+=" + -DZIG_FORCE_LLVM_CONFIG=on + -DZIG_TARGET_TRIPLE=${XBPS_CROSS_TRIPLET} + -DZIG_EXECUTABLE='/usr/bin/zig'" +fi + +pre_configure() { + local _llvm_config + + # When cross-compiling, need to re-write the host root provided by llvm-config + # to the cross-target root + if [ "${CROSS_BUILD}" ]; then + _llvm_config="${XBPS_WRAPPERDIR}/llvm-config" + + cat > "${_llvm_config}" <<-EOF + #!/bin/sh + /usr/bin/llvm-config "\$@" | sed 's,/usr,${XBPS_CROSS_BASE}/usr,g' + EOF + chmod +x "${_llvm_config}" + fi +} post_install() { + # vmove zig for great justice vlicense LICENSE }