Github messages for voidlinux
 help / color / mirror / Atom feed
From: jjsullivan5196 <jjsullivan5196@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] zig: enable cross-compile support
Date: Mon, 21 Sep 2020 12:14:45 +0200	[thread overview]
Message-ID: <20200921101445.k8GvlGbXa8Z7cIxGHpxAhBD-dLvovTHD1m0b7Prifn8@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-25004@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

There is an updated pull request by jjsullivan5196 against master on the void-packages repository

https://github.com/jjsullivan5196/void-packages zig-cross
https://github.com/void-linux/void-packages/pull/25004

zig: enable cross-compile support
Closes #24959 

A patch file from https://github.com/void-linux/void-packages/pull/25004.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-zig-cross-25004.patch --]
[-- Type: text/x-diff, Size: 4221 bytes --]

From 352f3585ffd2c7352fdae73d2760614c833dbeaf Mon Sep 17 00:00:00 2001
From: John Sullivan <jsullivan@csumb.edu>
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                          | 52 ++++++++++++++++++-
 2 files changed, 89 insertions(+), 2 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..04a4fbd4d19
--- /dev/null
+++ b/srcpkgs/zig/patches/0001-cmake-add-option-to-use-llvm-config-to-find-cross-ta.patch
@@ -0,0 +1,39 @@
+From 314c780371c3bfa3680445cec67f649800c6942b Mon Sep 17 00:00:00 2001
+From: John Sullivan <jsullivan@csumb.edu>
+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..ee323cce0 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_PREFER_LLVM_CONFIG off CACHE BOOL "(when cross compiling) use llvm-config to find target llvm dependencies if needed")
+ 
+ find_package(llvm)
+ find_package(clang)
+diff --git a/cmake/Findllvm.cmake b/cmake/Findllvm.cmake
+index 7d6a4b04d..314367b7b 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_PREFER_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..157b787f6f8 100644
--- a/srcpkgs/zig/template
+++ b/srcpkgs/zig/template
@@ -2,7 +2,7 @@
 pkgname=zig
 version=0.6.0
 revision=1
-archs="x86_64*"
+archs="x86_64* i686* aarch64* arm*"
 build_style=cmake
 makedepends="clang llvm10 lld-devel"
 short_desc="Programming language designed for robustness, optimality, and clarity"
@@ -11,9 +11,57 @@ 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
+	# TODO _mcpu might be a candidate for cross-profiles
+	#
+	# Set _cross_triple and _mcpu for target triples that are not directly
+	# available in zig's targets.
+	#
+	# List targets with: zig targets
+
+	case "${XBPS_CROSS_TRIPLET}" in
+		armv7l*)
+			_cross_triple="arm-linux-${XBPS_CROSS_TRIPLET#arm*-linux-*}"
+			_mcpu="generic+v7a"
+			;;
+		i686*)
+			_cross_triple="i386-linux-${XBPS_CROSS_TRIPLET#i686*-linux-*}"
+			_mcpu="baseline"
+			;;
+		*)
+			_cross_triple="${XBPS_CROSS_TRIPLET}"
+			_mcpu="baseline"
+			;;
+	esac
+
+	hostmakedepends="zig llvm10"
+	configure_args+="
+	-DZIG_PREFER_LLVM_CONFIG=on
+	-DZIG_TARGET_TRIPLE=${_cross_triple}
+	-DZIG_TARGET_MCPU=${_mcpu}
+	-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
 }

  parent reply	other threads:[~2020-09-21 10:14 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-21  1:45 [PR PATCH] " jjsullivan5196
2020-09-21  1:49 ` [PR REVIEW] " ericonr
2020-09-21  1:55 ` jjsullivan5196
2020-09-21  1:56 ` jjsullivan5196
2020-09-21  2:29 ` ericonr
2020-09-21  9:38 ` [PR PATCH] [Updated] " jjsullivan5196
2020-09-21  9:39 ` [PR REVIEW] " jjsullivan5196
2020-09-21  9:57 ` jjsullivan5196
2020-09-21 10:14 ` jjsullivan5196 [this message]
2020-09-21 12:43 ` ericonr
2020-09-21 14:28 ` ericonr
2020-09-21 14:29 ` ericonr
2020-09-21 19:07 ` ericonr
2020-09-21 19:16 ` ericonr
2020-09-21 19:21 ` [PR REVIEW] " ericonr
2020-09-21 19:32 ` ericonr
2020-09-21 19:35 ` ericonr
2020-09-21 20:31 ` jjsullivan5196
2020-09-21 20:34 ` [PR REVIEW] " jjsullivan5196
2020-09-21 20:35 ` jjsullivan5196
2020-09-21 20:43 ` jjsullivan5196
2020-09-21 22:16 ` ericonr
2020-09-21 22:40 ` [PR REVIEW] " ericonr
2020-09-21 22:52 ` ericonr
2020-09-21 23:10 ` jjsullivan5196
2020-09-22  2:01 ` [PR PATCH] [Updated] " jjsullivan5196
2020-09-22  2:04 ` jjsullivan5196
2020-09-22  2:05 ` [PR REVIEW] " jjsullivan5196
2020-09-22  2:07 ` ericonr
2020-09-22  2:23 ` jjsullivan5196
2020-09-28 21:24 ` pullmoll
2020-09-30  5:25 ` jjsullivan5196
2020-09-30  6:26 ` ericonr
2020-10-02 16:36 ` Piraty
2020-10-02 16:39 ` Piraty
2020-10-02 16:44 ` q66
2020-10-02 16:47 ` Piraty
2020-10-02 16:55 ` jjsullivan5196
2020-10-02 16:56 ` jjsullivan5196
2020-10-02 22:04 ` jjsullivan5196
2020-10-03 16:15 ` Piraty
2020-10-03 16:50 ` jjsullivan5196
2020-10-03 16:50 ` jjsullivan5196
2020-10-03 16:51 ` jjsullivan5196
2020-10-03 17:01 ` jjsullivan5196
2020-10-03 17:07 ` jjsullivan5196
2020-10-03 17:17 ` Piraty
2021-01-21 17:44 ` ericonr
2021-01-22  2:16 ` jjsullivan5196
2021-08-03  3:02 ` ericonr
2021-08-03  4:22 ` jjsullivan5196
2021-08-03  4:22 ` [PR PATCH] [Closed]: " jjsullivan5196

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200921101445.k8GvlGbXa8Z7cIxGHpxAhBD-dLvovTHD1m0b7Prifn8@z \
    --to=jjsullivan5196@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).