summaryrefslogtreecommitdiff
path: root/dev-lang/zig
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2023-11-22 17:18:34 +0000
committerV3n3RiX <venerix@koprulu.sector>2023-11-22 17:18:34 +0000
commitfd87b7c771378b2116981e3924bee5805148e118 (patch)
tree91ed28393c7b534787d3c073e269fe598d0fd535 /dev-lang/zig
parent77b74be093bdf4a0ed4121acc3f8e229103cf004 (diff)
gentoo auto-resync : 22:11:2023 - 17:18:34
Diffstat (limited to 'dev-lang/zig')
-rw-r--r--dev-lang/zig/Manifest6
-rw-r--r--dev-lang/zig/files/zig-0.11.0-first-try-getconf.patch38
-rw-r--r--dev-lang/zig/metadata.xml3
-rw-r--r--dev-lang/zig/zig-9999.ebuild64
4 files changed, 81 insertions, 30 deletions
diff --git a/dev-lang/zig/Manifest b/dev-lang/zig/Manifest
index 6f93464870f0..646349ad4b04 100644
--- a/dev-lang/zig/Manifest
+++ b/dev-lang/zig/Manifest
@@ -1,5 +1,5 @@
-AUX zig-0.11.0-first-try-getconf.patch 5214 BLAKE2B 8129d084fc36a2a8f32c21d13698a4c589ce35da640c4a5e3f95c100266240ba9f0ff9f9146ca5f9c2523257af20ad4cd0557f64228d77c2daadfb3c48e019a0 SHA512 b5ed25905da463c9ba34b82f118fdb0251bb460e8f47a3a37f52857ffc806e9078dc41f8c3aa82abd5f09a37f8fdda7e12c5c245fd181b6b7c54048b9f6662ef
+AUX zig-0.11.0-first-try-getconf.patch 5378 BLAKE2B a5bdb83e4897a0553431b333b0ee3a1fc1ed2da413c177188f6d4b1756c1f06275a548a53bb5885ef912cbf03de07d5302066078281fdd120a3bcffb1375a4d2 SHA512 20252263c52e791829d7fdf8b59f824a4a91252f771fed0b773d7b288cba93cac5ac8c3ebe3134d87b56658192bc6eb9dfde9f85d2490a596e594034c5ac251f
DIST zig-0.11.0.tar.xz 15275316 BLAKE2B 603e4995a36d214ba71cf05b719a04732c8927995c8207ab8fdd574dca3410cdc5ccc8f6aa9964807afc04a5cbce1a3910a6cde4cf12e585cdf7684833217eb2 SHA512 c19a8ae6d440a16dd5e77941fc77c036d1f284f1784376625e63b65f30b4acad62f9f4217bc818c401f88c2c33f8722f26fc467c3e23c29a89178c4b1882d1c4
EBUILD zig-0.11.0-r1.ebuild 5069 BLAKE2B 7b8fa2a72d67c7c211cf228fac00ead39dbc070ab5757d7245e507d2f5006f939a763fafac70e39b56fd82d16d11cc9d2df9c209a8950de28c87d9be6503a6c5 SHA512 275589b2ac7bcc71b2a65042a3473fe41c33e9729c12450dbf9d3559ed622db73958e5ae9bf9c5d704235d9ed7642b58a81ec4bb6e65b15939b3c5922e5fd233
-EBUILD zig-9999.ebuild 5006 BLAKE2B f5cf38fa29d81a493816477db31a721b2c8cf36c555ecddde177a432c143e1299b9365f0bafac64c5fa5a415ce8ee8218c5806320162e362beae69a84bd84b7d SHA512 16591b69fc074cff217a36bc0c0c05cd7871d107ff7b8bddd0a4699d43b5eb0ced46b1a51f5eb92bb75fa66560655253184b4fe634ae29560224242d55a4a0ef
-MISC metadata.xml 541 BLAKE2B 6f5c7fbf759f0430f69073a17a0dae4b8bebf335b54c3b43da6b24104dc3de05a3b686cddbbd31e4dae1fc31695a2f08d000d22437ed6f1847de8fa95e3b1952 SHA512 d49cf0a8ad76ac9a6f6fb091effddbbcd812b56f91df6d3c782e15197cb4ff4423fb1076671a232aabcb9833af19ef8c820ad6df312a1e4d72e665680314c083
+EBUILD zig-9999.ebuild 6312 BLAKE2B 2d23f9e146a38c724c47426bde87832302e3b80c29f45d2cfc72165a9be3bc246f297f713fd22a2378f201d7fb12591edcfe35c7993f62561a752dbacff90216 SHA512 c43f7712ed05c0ca7e0556a5dd5bfe779e66a7110b1cb0fb3d38d5a3e76b1742e4d4be6d3cbfa6fc568b296e0b489aab0308c93c6a32cfc041b22b8132c0eaf6
+MISC metadata.xml 631 BLAKE2B bec6fe40717f526f8153f5d4c4da47ed4daf1c359af09a43cbb592058aba9b0aff3745998c45b91c6b58ef8a4cd7b263c2f3c537ec8911377a803e8688e1b3ad SHA512 0c91bae1b6f224f177719af7cc664398d8a031934cbeaec7d08794f46ab9c1fa7a130c4cf459f738a120867367ffca186298e67aa738e7161576ea602847f52b
diff --git a/dev-lang/zig/files/zig-0.11.0-first-try-getconf.patch b/dev-lang/zig/files/zig-0.11.0-first-try-getconf.patch
index 6d1b3ca7e5b7..5a63e9e74ad9 100644
--- a/dev-lang/zig/files/zig-0.11.0-first-try-getconf.patch
+++ b/dev-lang/zig/files/zig-0.11.0-first-try-getconf.patch
@@ -17,14 +17,14 @@ Bug: https://bugs.gentoo.org/914731
Bug: https://bugs.gentoo.org/914101
diff --git a/lib/std/zig/system/NativeTargetInfo.zig b/lib/std/zig/system/NativeTargetInfo.zig
-index 99a1a8f2e..d1032a716 100644
+index 99a1a8f2e..0250db968 100644
--- a/lib/std/zig/system/NativeTargetInfo.zig
+++ b/lib/std/zig/system/NativeTargetInfo.zig
@@ -19,6 +19,32 @@ dynamic_linker: DynamicLinker = DynamicLinker{},
-
+
pub const DynamicLinker = Target.DynamicLinker;
-
-+// Copy-pasted from `std.zig.CrossTarget.parse` to avoid changing visibility of mentioned function.
+
++// Copy-pasted from `std.zig.CrossTarget.parse` to avoid introducing unexpected new public function as part of standard library.
+/// Parses a version with an omitted patch component, such as "1.0",
+/// which SemanticVersion.parse is not capable of.
+fn parseWithOptionalPatchField(ver: []const u8) error{ InvalidVersion, Overflow }!std.SemanticVersion {
@@ -38,7 +38,7 @@ index 99a1a8f2e..d1032a716 100644
+ };
+ }
+ }.parseVersionComponent;
-+ var version_components = mem.split(u8, ver, ".");
++ var version_components = mem.splitScalar(u8, ver, '.');
+ const major = version_components.first();
+ const minor = version_components.next() orelse return error.InvalidVersion;
+ const patch = version_components.next() orelse "0";
@@ -53,10 +53,10 @@ index 99a1a8f2e..d1032a716 100644
pub const DetectError = error{
FileSystem,
SystemResources,
-@@ -307,6 +333,35 @@ fn detectAbiAndDynamicLinker(
+@@ -307,6 +333,39 @@ fn detectAbiAndDynamicLinker(
}
const ld_info_list = ld_info_list_buffer[0..ld_info_list_len];
-
+
+ if (is_linux and !os_is_non_native and cross_target.glibc_version == null) try_getconf: {
+ var buf: [4096]u8 = undefined;
+ var fba = std.heap.FixedBufferAllocator.init(&buf);
@@ -68,20 +68,24 @@ index 99a1a8f2e..d1032a716 100644
+ .max_output_bytes = 1024,
+ }) catch break :try_getconf;
+ if (!std.mem.startsWith(u8, getconf.stdout, "glibc ")) break :try_getconf;
-+ const version_string = getconf.stdout["glibc ".len..];
++ const version_string = std.mem.trim(u8, getconf.stdout["glibc ".len..], &std.ascii.whitespace);
+ const glibc_version = parseWithOptionalPatchField(version_string) catch break :try_getconf;
+
+ var os_with_glibc = os;
+ os_with_glibc.version_range.linux.glibc = glibc_version;
+
++ const target: Target = .{
++ .cpu = cpu,
++ .os = os_with_glibc,
++ .abi = .gnu,
++ .ofmt = cross_target.ofmt orelse Target.ObjectFormat.default(os_with_glibc.tag, cpu.arch),
++ };
+ const result: NativeTargetInfo = .{
-+ .target = .{
-+ .cpu = cpu,
-+ .os = os_with_glibc,
-+ .abi = cross_target.abi orelse Target.Abi.default(cpu.arch, os_with_glibc),
-+ .ofmt = cross_target.ofmt orelse Target.ObjectFormat.default(os_with_glibc.tag, cpu.arch),
-+ },
-+ .dynamic_linker = cross_target.dynamic_linker,
++ .target = target,
++ .dynamic_linker = if (cross_target.dynamic_linker.get() == null)
++ target.standardDynamicLinkerPath()
++ else
++ cross_target.dynamic_linker,
+ };
+ return result;
+ }
@@ -89,7 +93,7 @@ index 99a1a8f2e..d1032a716 100644
// Best case scenario: the executable is dynamically linked, and we can iterate
// over our own shared objects and find a dynamic linker.
const elf_file = blk: {
-@@ -563,7 +618,7 @@ fn glibcVerFromSoFile(file: fs.File) !std.SemanticVersion {
+@@ -563,7 +622,7 @@ fn glibcVerFromSoFile(file: fs.File) !std.SemanticVersion {
while (it.next()) |s| {
if (mem.startsWith(u8, s, "GLIBC_2.")) {
const chopped = s["GLIBC_".len..];
@@ -98,7 +102,7 @@ index 99a1a8f2e..d1032a716 100644
error.Overflow => return error.InvalidGnuLibCVersion,
error.InvalidVersion => return error.InvalidGnuLibCVersion,
};
-@@ -586,7 +641,7 @@ fn glibcVerFromLinkName(link_name: []const u8, prefix: []const u8) !std.Semantic
+@@ -586,7 +645,7 @@ fn glibcVerFromLinkName(link_name: []const u8, prefix: []const u8) !std.Semantic
}
// chop off "libc-" and ".so"
const link_name_chopped = link_name[prefix.len .. link_name.len - suffix.len];
diff --git a/dev-lang/zig/metadata.xml b/dev-lang/zig/metadata.xml
index a5a5818faae7..ad21fd6654d5 100644
--- a/dev-lang/zig/metadata.xml
+++ b/dev-lang/zig/metadata.xml
@@ -9,6 +9,9 @@
<email>proxy-maint@gentoo.org</email>
<name>Proxy Maintainers</name>
</maintainer>
+ <use>
+ <flag name="llvm">Build with LLVM backend and extensions enabled.</flag>
+ </use>
<upstream>
<remote-id type="github">ziglang/zig</remote-id>
<bugs-to>https://github.com/ziglang/zig/issues</bugs-to>
diff --git a/dev-lang/zig/zig-9999.ebuild b/dev-lang/zig/zig-9999.ebuild
index 9605234cfc43..6e98f73a3af4 100644
--- a/dev-lang/zig/zig-9999.ebuild
+++ b/dev-lang/zig/zig-9999.ebuild
@@ -29,7 +29,8 @@ fi
# lib/libc/glibc: BSD HPND ISC inner-net LGPL-2.1+
LICENSE="MIT Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT ) || ( Apache-2.0-with-LLVM-exceptions Apache-2.0 MIT BSD-2 ) public-domain BSD-2 ZPL ISC HPND BSD inner-net LGPL-2.1+"
SLOT="$(ver_cut 1-2)"
-IUSE="doc"
+IUSE="doc +llvm"
+REQUIRED_USE="!llvm? ( !doc )"
BUILD_DIR="${S}/build"
@@ -39,9 +40,11 @@ BUILD_DIR="${S}/build"
# You can check https://github.com/ziglang/zig-bootstrap in future, to see
# options that are passed to LLVM CMake building (excluding "static" ofc).
DEPEND="
- sys-devel/clang:${LLVM_MAX_SLOT}=
- sys-devel/lld:${LLVM_MAX_SLOT}=
- sys-devel/llvm:${LLVM_MAX_SLOT}=[zstd]
+ llvm? (
+ sys-devel/clang:${LLVM_MAX_SLOT}=
+ sys-devel/lld:${LLVM_MAX_SLOT}=
+ sys-devel/llvm:${LLVM_MAX_SLOT}=[zstd]
+ )
"
RDEPEND="
@@ -54,6 +57,8 @@ IDEPEND="app-eselect/eselect-zig"
# For now, Zig Build System doesn't support enviromental CFLAGS/LDFLAGS/etc.
QA_FLAGS_IGNORED="usr/.*/zig/${PV}/bin/zig"
+RESTRICT="!llvm? ( test )"
+
# Since commit https://github.com/ziglang/zig/commit/e7d28344fa3ee81d6ad7ca5ce1f83d50d8502118
# Zig uses self-hosted compiler only
CHECKREQS_MEMORY="4G"
@@ -103,14 +108,31 @@ get_zig_target() {
}
pkg_setup() {
- llvm_pkg_setup
+ # Useful for debugging and a little bit more deterministic.
+ export ZIG_LOCAL_CACHE_DIR="${T}/zig-local-cache"
+ export ZIG_GLOBAL_CACHE_DIR="${T}/zig-global-cache"
+
+ export ZIG_SYS_INSTALL_DEST="${EPREFIX}/usr/$(get_libdir)/zig/${PV}"
+
+ use llvm && llvm_pkg_setup
check-reqs_pkg_setup
}
src_configure() {
- # Useful for debugging and a little bit more deterministic.
- export ZIG_LOCAL_CACHE_DIR="${T}/zig-local-cache"
- export ZIG_GLOBAL_CACHE_DIR="${T}/zig-global-cache"
+ if ! use llvm; then
+ mkdir -p "${BUILD_DIR}/stage3" || die
+ # Currently, Zig without LLVM extensions lacks most optimizations.
+ export ZIG_BOOTSTRAP_STAGE3_FLAGS=(
+ -Dtarget="$(get_zig_target)"
+ -Dcpu="$(get_zig_mcpu)"
+ -Doptimize=Debug
+ -Dno-autodocs
+ -Dno-langref
+ -Denable-llvm=false
+ -Dforce-link-libc
+ )
+ return
+ fi
local mycmakeargs=(
-DZIG_USE_CCACHE=OFF
@@ -119,13 +141,20 @@ src_configure() {
-DZIG_TARGET_MCPU="$(get_zig_mcpu)"
-DZIG_USE_LLVM_CONFIG=ON
-DCMAKE_PREFIX_PATH="$(get_llvm_prefix ${LLVM_MAX_SLOT})"
- -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/$(get_libdir)/zig/${PV}"
+ -DCMAKE_INSTALL_PREFIX="${ZIG_SYS_INSTALL_DEST}"
)
cmake_src_configure
}
src_compile() {
+ if ! use llvm; then
+ $(tc-getCC) -o bootstrap bootstrap.c || die "Zig's bootstrap.c compilation failed"
+ edob ./bootstrap
+ edo ./zig2 build install --prefix "${BUILD_DIR}/stage3/" "${ZIG_BOOTSTRAP_STAGE3_FLAGS[@]}"
+ return
+ fi
+
cmake_src_compile
"${BUILD_DIR}/stage3/bin/zig" env || die "Zig compilation failed"
@@ -154,8 +183,15 @@ src_test() {
}
src_install() {
+ local DOCS=( "README.md" "doc/build.zig.zon.md" )
use doc && local HTML_DOCS=( "docgen/doc/langref.html" "docgen/doc/std" )
- cmake_src_install
+
+ if ! use llvm; then
+ DESTDIR="${D}" edo ./zig2 build install --prefix "${ZIG_SYS_INSTALL_DEST}" "${ZIG_BOOTSTRAP_STAGE3_FLAGS[@]}"
+ einstalldocs
+ else
+ cmake_src_install
+ fi
cd "${ED}/usr/$(get_libdir)/zig/${PV}/" || die
mv lib/zig/ lib2/ || die
@@ -166,6 +202,14 @@ src_install() {
pkg_postinst() {
eselect zig update ifunset
+
+ if ! use llvm; then
+ elog "Currently, Zig built without LLVM support lacks some"
+ elog "important features such as most optimizations, @cImport, etc."
+ elog "They are listed under \"Building from Source without LLVM\""
+ elog "section of the README file from \"/usr/share/doc/${PF}\" ."
+ elog "It's recommended to use C backend directly with this stage2 build."
+ fi
}
pkg_postrm() {