diff options
author | V3n3RiX <venerix@koprulu.sector> | 2025-02-17 00:13:57 +0000 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2025-02-17 00:13:57 +0000 |
commit | 27b3683509c5229cce540418778a8b64afbc0009 (patch) | |
tree | b7164898142b8b093b91c8254c4387b6eec679ee /dev-lang/zig | |
parent | f2bdc27fe0f79f8f9a3945eb2b1163ce75c56439 (diff) |
gentoo auto-resync : 17:02:2025 - 00:13:57
Diffstat (limited to 'dev-lang/zig')
-rw-r--r-- | dev-lang/zig/Manifest | 9 | ||||
-rw-r--r-- | dev-lang/zig/files/zig-0.13.0-test-fmt-no-doc.patch | 17 | ||||
-rw-r--r-- | dev-lang/zig/metadata.xml | 1 | ||||
-rw-r--r-- | dev-lang/zig/zig-0.13.0-r1.ebuild | 227 | ||||
-rw-r--r-- | dev-lang/zig/zig-0.13.0-r2.ebuild | 31 | ||||
-rw-r--r-- | dev-lang/zig/zig-0.13.0-r3.ebuild | 355 | ||||
-rw-r--r-- | dev-lang/zig/zig-9999.ebuild | 179 |
7 files changed, 532 insertions, 287 deletions
diff --git a/dev-lang/zig/Manifest b/dev-lang/zig/Manifest index 258015816825..6b6388540826 100644 --- a/dev-lang/zig/Manifest +++ b/dev-lang/zig/Manifest @@ -1,10 +1,9 @@ AUX zig-0.13.0-skip-test-stack_iterator.patch 1443 BLAKE2B 347a7a397c706105456ba83d9511633d3f1a75aa33a06dfccfde457c93af79149c4bb704e0e493a6b69a840784739c34b7a4f570608c368bb84673def0404857 SHA512 7b446efad0a95d3483a570552f3a1df2a535a757e16eb8484571ab1c9fd525b7b68b36ca84fb30bcce77709f9936e4c361ae04362456a60a9f59516824e3a254 -AUX zig-0.13.0-test-fmt-no-doc.patch 653 BLAKE2B 92f28d86fde0ce3315b8e7b50dcdf03c1ef8a95964701d3c3c05dc8c16b08f9e327d190e9f9631c2a3a287b8b2945025abbf1b5c75d3bdb3adf719d1a6513703 SHA512 310d356f07505fa44e8425ec32f823eab5e20f9a0144c2e2ecff38e19ac1814d4320430373d4f2fa5ed9cf57000a126089c185fd6336daed8cc7dc0cffc0c023 AUX zig-0.13.0-test-std-kernel-version.patch 1304 BLAKE2B a266cc8d41df8eabc44cc381fe66e5b548d0e10eb0d0098350ddf596602204a77062b8e4632f58250a40781f7a1d5c7e9905c1387ecf7a0c505e330612944f38 SHA512 a62977e3ba675b60866d7cebdc5ff676825e77dac93029d32af403e567b5ae462d49355407f9dbd33843c8b8393d8f05a39de73a8818daf3424df083e0185da6 DIST zig-0.13.0-llvm-18.1.8-r6-fix.patch 45968 BLAKE2B a07c47b22b079d324b200fe84af5c89ffe51a1c81f50ca894a80f9f9db51a9d4119ae51c2e4e84a9b4f0111b2b809978b88adca42480ee800693afbd78f47387 SHA512 148b3f4807763dfb6a4d4e201890fa8204deaf73e620a8b592dfa03b997bc16ed01ea26e4d85f242473e91ccc45b1a06af22f786851f8e26cec1ac821b14efdc DIST zig-0.13.0.tar.xz 17220728 BLAKE2B f4bbacc2012950c556bebc28fc322fc6424bf20fe118e8362373336b6460e514028978584087f6e7f25ed8b8e6991610edce625676a1dd80c1975c5f9ef48775 SHA512 6f5f31f4ba71a11d8b16c7a5a613e124095e503fa6b02d2b77e5b177674c739287e81d98d96dc261fed24bc836caf196f71c3fcc7a6518387df86ba9e03df4dd DIST zig-0.13.0.tar.xz.minisig 312 BLAKE2B 2d061257c9c75f9c36b01cfb08dcd2040538a125b9ea2cae8617ae5496e685b165933ce8981494419522b7e19b51fc69a651ecaa4a8930753acf2e4ae3d6e00f SHA512 21c6139c06cba6c5e23a3305fed0c0f1b9b32d9140bd686c26365ce0279d5f53cd081894eaba29f0c1ed51b2e831edf7bd4ae6a7eaee5018a252e312e9b65507 -EBUILD zig-0.13.0-r1.ebuild 6212 BLAKE2B dc9966d60858e0c8c9c4a062bc826b502ae56d9432cf447021759976dca3e03d1b8ed7632e210a3f21a5414041d1b490321db970dcffa9181857cc096080577b SHA512 53651f874ee9a26d1d4fd2c6ba5a3d722f1aa086c02d57fed7be6e8e56dcd5dd5746f35c7dfe116cfaf5a008e9033697c8e2fe808f6e4ffc9fb0da357d455b8c -EBUILD zig-0.13.0-r2.ebuild 7263 BLAKE2B e62e6b54292e65fb008e7b005fd87ac1b7dc0caeca7a81c61f45bc3ee03dc18437caef7b320ee2ebf5daefe78799d7a6cde352fe61f4b3397eeee6aef6a9ec0c SHA512 4c535c7407af0bf2f907949e7ae139c06bc864e321829af59a213cc372796f843ebee2b6e449c2eed0b565e3b801521bfc1071487a73d07e5372c4344c16b476 -EBUILD zig-9999.ebuild 6977 BLAKE2B b4c58c01278d130eb0d7bff7bd91c576dda5de97f426ceb55139b0e298836f915f9cb53a39fee3d01de57e2b310d3e2f32d4a16fcf44f22b75a89efdf057f10a SHA512 d998a5b2bee29dd1bf4328858187bd65ac494df53d1e612b61bdaac54c1eba25270a6458c4978e96253ddaa9b23567530b6cec09779f27f56193139f7d51a0e0 -MISC metadata.xml 633 BLAKE2B 46cca8909b0b7d65213dee9c7aa7a2c4b5b529734e3bde4f65320074bc38d68420dfaa28041873c7c2c0f1127aca327e32c103c06ab1b5d5ee0e485cb33bb133 SHA512 1d030ca79a3d49b6f573e7995e6f6ef50a6e33ea7e2755a678625645d5b0587f7877a357ea71905034b7029c8c6315b89ebdb5313102b6638b16c467e2ba1864 +EBUILD zig-0.13.0-r2.ebuild 8233 BLAKE2B cc6ad37897182d87fba862d7ba79207c115817e0f160d32a522ebb6e77af6ecc56dc875a9a332680fdae247fb1a25e99d6aa6933deb34fcca34cd139c427930d SHA512 b22575882bfcf3e39d30cc9e032383ae3f731f769d9493b84735a1b30e3f9a799c139b1272e68835f32d506cbadd50fe15af0528a50e023df396ded001d55fc4 +EBUILD zig-0.13.0-r3.ebuild 11183 BLAKE2B cb17900a2e3d898f768e461c1989e41bf15b8fc9968b2ae48ac8dc8230522ec47bc4a4e1caf9998caead9c5369ba6732982fd2b21c3a49b52a7f31cb4e284b98 SHA512 e47bffbe18e9e6aac725abbbc014a08ef1ad1c91ec68c17a1a656ae4215898c8dc3439fac0d30a920fb1aaf2d042ce453397c23fad4420aae32810aa69ec4db7 +EBUILD zig-9999.ebuild 10890 BLAKE2B 1ecd6a200784792b8f48b5987160cdb41d40e2ac560233d22a325c58762bea69d00b45d41c861f71053f050f5a70203157451951333700f7e12c3126c2a45534 SHA512 1d249d1fe18bf38776abe4f8cc10e9212173e49d1f1d75989875bac13195aa74506f45548ec61f164c3e9f5689df8c0645b9980d81b61af87c44d8c8ac05d81f +MISC metadata.xml 698 BLAKE2B a87c750ce5bf5b4070d9bb175aa7241da124b6362db4fff9cc51f5508d15f16595f79d5018025ae837f48aa2168102dd923798c291ddb455ac7686deb2b74d03 SHA512 9e0109a58cfb1a14e9815951ef7b55d01ffd08ae3936d759bdbaf4ba0180f7720f489e57b3e1773285331da38cd1103176372262372ab6c6924b65daf5f4c1ec diff --git a/dev-lang/zig/files/zig-0.13.0-test-fmt-no-doc.patch b/dev-lang/zig/files/zig-0.13.0-test-fmt-no-doc.patch deleted file mode 100644 index 7bbda741dc6f..000000000000 --- a/dev-lang/zig/files/zig-0.13.0-test-fmt-no-doc.patch +++ /dev/null @@ -1,17 +0,0 @@ -# Docs contain examples of badly formatted code, -# so they should be excluded for test-fmt to pass. -# In the upstream, the "doc" directory -# was removed from fmt_include_paths in -# https://github.com/ziglang/zig/commit/cb1d1bdf - ---- a/build.zig -+++ b/build.zig -@@ -428,7 +428,7 @@ - } - const optimization_modes = chosen_opt_modes_buf[0..chosen_mode_index]; - -- const fmt_include_paths = &.{ "doc", "lib", "src", "test", "tools", "build.zig" }; -+ const fmt_include_paths = &.{ "lib", "src", "test", "tools", "build.zig" }; - const fmt_exclude_paths = &.{"test/cases"}; - const do_fmt = b.addFmt(.{ - .paths = fmt_include_paths, diff --git a/dev-lang/zig/metadata.xml b/dev-lang/zig/metadata.xml index 2364982009cc..34e44a88bfa3 100644 --- a/dev-lang/zig/metadata.xml +++ b/dev-lang/zig/metadata.xml @@ -10,6 +10,7 @@ <name>Proxy Maintainers</name> </maintainer> <use> + <flag name="debug">Build with debug extensions enabled.</flag> <flag name="llvm">Build with LLVM backend and extensions enabled.</flag> </use> <upstream> diff --git a/dev-lang/zig/zig-0.13.0-r1.ebuild b/dev-lang/zig/zig-0.13.0-r1.ebuild deleted file mode 100644 index 867fa84f3b19..000000000000 --- a/dev-lang/zig/zig-0.13.0-r1.ebuild +++ /dev/null @@ -1,227 +0,0 @@ -# Copyright 2019-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -LLVM_MAX_SLOT=18 -inherit edo check-reqs cmake llvm multiprocessing toolchain-funcs - -DESCRIPTION="A robust, optimal, and maintainable programming language" -HOMEPAGE="https://ziglang.org https://github.com/ziglang/zig" - -BDEPEND="test? ( !!<sys-apps/sandbox-2.39 )" -if [[ ${PV} == 9999 ]]; then - EGIT_REPO_URI="https://github.com/ziglang/zig.git" - inherit git-r3 -else - VERIFY_SIG_METHOD=minisig - VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/minisig-keys/zig-software-foundation.pub - inherit verify-sig - - SRC_URI=" - https://ziglang.org/download/${PV}/${P}.tar.xz - verify-sig? ( https://ziglang.org/download/${PV}/${P}.tar.xz.minisig ) - https://codeberg.org/BratishkaErik/distfiles/releases/download/dev-lang%2Fzig-${PV}/${P}-llvm-18.1.8-r6-fix.patch - " - KEYWORDS="~amd64 ~arm ~arm64" - - BDEPEND+=" verify-sig? ( sec-keys/minisig-keys-zig-software-foundation )" -fi - -# project itself: MIT -# There are bunch of projects under "lib/" folder that are needed for cross-compilation. -# Files that are unnecessary for cross-compilation are removed by upstream -# and therefore their licenses (if any special) are not included. -# lib/libunwind: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT ) -# lib/libcxxabi: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT ) -# lib/libcxx: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT ) -# lib/libc/wasi: || ( Apache-2.0-with-LLVM-exceptions Apache-2.0 MIT BSD-2 ) public-domain -# lib/libc/musl: MIT BSD-2 -# lib/libc/mingw: ZPL public-domain BSD-2 ISC HPND -# 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 test" -RESTRICT="!test? ( test )" - -BUILD_DIR="${S}/build" - -# Zig requires zstd and zlib compression support in LLVM, if using LLVM backend. -# (non-LLVM backends don't require these) -# They are not required "on their own", so please don't add them here. -# 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=" - llvm-core/clang:${LLVM_MAX_SLOT}= - llvm-core/lld:${LLVM_MAX_SLOT}= - llvm-core/llvm:${LLVM_MAX_SLOT}=[zstd] -" - -RDEPEND=" - ${DEPEND} -" - -IDEPEND="app-eselect/eselect-zig" - -# see https://github.com/ziglang/zig/issues/3382 -# For now, Zig Build System doesn't support enviromental CFLAGS/LDFLAGS/etc. -QA_FLAGS_IGNORED="usr/.*/zig/${PV}/bin/zig" - -# Since commit https://github.com/ziglang/zig/commit/e7d28344fa3ee81d6ad7ca5ce1f83d50d8502118 -# Zig uses self-hosted compiler only -CHECKREQS_MEMORY="4G" - -PATCHES=( - "${FILESDIR}/${P}-test-fmt-no-doc.patch" - "${FILESDIR}/${P}-test-std-kernel-version.patch" - "${DISTDIR}/${P}-llvm-18.1.8-r6-fix.patch" -) - -llvm_check_deps() { - has_version "llvm-core/clang:${LLVM_SLOT}" -} - -ctarget_to_zigtarget() { - # Zig's Target Format: arch-os-abi - local CTARGET="${CTARGET:-${CHOST}}" - - local ZIG_ARCH - case "${CTARGET%%-*}" in - i?86) ZIG_ARCH=x86;; - sparcv9) ZIG_ARCH=sparc64;; - *) ZIG_ARCH="${CTARGET%%-*}";; # Same as in CHOST - esac - - local ZIG_OS - case "${CTARGET}" in - *linux*) ZIG_OS=linux;; - *apple*) ZIG_OS=macos;; - esac - - local ZIG_ABI - case "${CTARGET##*-}" in - gnu) ZIG_ABI=gnu;; - solaris*) ZIG_OS=solaris ZIG_ABI=none;; - darwin*) ZIG_ABI=none;; - *) ZIG_ABI="${CTARGET##*-}";; # Same as in CHOST - esac - - echo "${ZIG_ARCH}-${ZIG_OS}-${ZIG_ABI}" -} - -get_zig_mcpu() { - local ZIG_DEFAULT_MCPU=native - tc-is-cross-compiler && ZIG_DEFAULT_MCPU=baseline - echo "${ZIG_MCPU:-${ZIG_DEFAULT_MCPU}}" -} - -get_zig_target() { - local ZIG_DEFAULT_TARGET=native - tc-is-cross-compiler && ZIG_DEFAULT_TARGET="$(ctarget_to_zigtarget)" - echo "${ZIG_TARGET:-${ZIG_DEFAULT_TARGET}}" -} - -pkg_setup() { - llvm_pkg_setup - check-reqs_pkg_setup -} - -src_unpack() { - if use verify-sig; then - verify-sig_verify_detached "${DISTDIR}"/${P}.tar.xz{,.minisig} - fi - default -} - -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" - - local mycmakeargs=( - -DZIG_SHARED_LLVM=ON - -DZIG_TARGET_TRIPLE="$(get_zig_target)" - -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}" - ) - - cmake_src_configure -} - -src_compile() { - # Remove "limit memory usage" flags, it's already verified by - # CHECKREQS_MEMORY and causes unneccessary errors. Upstream set them - # according to CI OOM failures, which are higher than during Gentoo build. - sed -i -e '/\.max_rss = .*,/d' build.zig || die - - cmake_src_compile - - "${BUILD_DIR}/stage3/bin/zig" env || die "Zig compilation failed" - - if use doc; then - cd "${BUILD_DIR}" || die - edo ./stage3/bin/zig build std-docs --prefix "${S}/docgen/" - edo ./stage3/bin/zig build langref --prefix "${S}/docgen/" - fi -} - -src_test() { - cd "${BUILD_DIR}" || die - local ZIG_TEST_ARGS=( - -j$(makeopts_jobs) - --color on - --summary all - --verbose - -Dstatic-llvm=false - -Denable-llvm - -Dskip-non-native - -Doptimize=Debug - -Dtarget="$(get_zig_target)" - -Dcpu="$(get_zig_mcpu)" - ) - local ZIG_TEST_STEPS=( - test-asm-link - test-behavior - test-c-abi - test-c-import - test-cases - test-cli - test-compare-output - test-compiler-rt - test-fmt - test-link - test-run-translated-c - test-stack-traces - test-standalone - test-std - test-translate-c - test-universal-libc - ) - - local step - for step in "${ZIG_TEST_STEPS[@]}" ; do - # to keep the verbosity, don't use edob here - ./stage3/bin/zig build ${step} ${ZIG_TEST_ARGS[@]} || die - done -} - -src_install() { - use doc && local HTML_DOCS=( "docgen/doc/langref.html" "docgen/doc/std" ) - cmake_src_install - - cd "${ED}/usr/$(get_libdir)/zig/${PV}/" || die - mv lib/zig/ lib2/ || die - rm -rf lib/ || die - mv lib2/ lib/ || die - dosym -r "/usr/$(get_libdir)/zig/${PV}/bin/zig" "/usr/bin/zig-${PV}" -} - -pkg_postinst() { - eselect zig update ifunset || die -} - -pkg_postrm() { - eselect zig update ifunset || die -} diff --git a/dev-lang/zig/zig-0.13.0-r2.ebuild b/dev-lang/zig/zig-0.13.0-r2.ebuild index b970092ce4e4..a17a501b392e 100644 --- a/dev-lang/zig/zig-0.13.0-r2.ebuild +++ b/dev-lang/zig/zig-0.13.0-r2.ebuild @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Gentoo Authors +# Copyright 2019-2025 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 @@ -209,8 +209,35 @@ src_compile() { } src_test() { + if has_version -b app-emulation/qemu; then + ewarn "QEMU executable was found on your building system." + ewarn "If you have qemu-binfmt (binfmt_misc) hooks enabled for" + ewarn "foreign architectures, Zig tests might fail." + ewarn "In this case, please disable qemu-binfmt and try again." + fi + cd "${BUILD_DIR}" || die + + # XXX: When we pass a libc installation to Zig, it will fail to find + # the bundled libraries for targets like aarch64-macos and + # *-linux-musl. Zig doesn't run binaries for these targets when + # -Dskip-non-native is passed, but they are still compiled, so + # the test will fail. There's no way to disable --libc once passed, + # so we need to strip it from ZBS_ARGS. + # See: https://github.com/ziglang/zig/issues/22383 + local args_backup=("${ZBS_ARGS[@]}") + + for ((i = 0; i < ${#ZBS_ARGS[@]}; i++)); do + if [[ "${ZBS_ARGS[i]}" == "--libc" ]]; then + unset ZBS_ARGS[i] + unset ZBS_ARGS[i+1] + break + fi + done + ZIG_EXE="./stage3/bin/zig" zig_src_test -Dskip-non-native + + ZBS_ARGS=("${args_backup[@]}") } src_install() { @@ -244,5 +271,5 @@ pkg_postinst() { } pkg_postrm() { - eselect zig update ifunset || die + eselect zig update ifunset } diff --git a/dev-lang/zig/zig-0.13.0-r3.ebuild b/dev-lang/zig/zig-0.13.0-r3.ebuild new file mode 100644 index 000000000000..15de59370bbb --- /dev/null +++ b/dev-lang/zig/zig-0.13.0-r3.ebuild @@ -0,0 +1,355 @@ +# Copyright 2019-2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +LLVM_COMPAT=( 18 ) +LLVM_OPTIONAL=1 + +ZIG_SLOT="$(ver_cut 1-2)" +ZIG_OPTIONAL=1 + +inherit check-reqs cmake flag-o-matic edo llvm-r2 toolchain-funcs zig + +DESCRIPTION="A robust, optimal, and maintainable programming language" +HOMEPAGE="https://ziglang.org/ https://github.com/ziglang/zig/" +if [[ ${PV} == 9999 ]]; then + EGIT_REPO_URI="https://github.com/ziglang/zig.git" + inherit git-r3 +else + VERIFY_SIG_METHOD=minisig + VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/minisig-keys/zig-software-foundation.pub + inherit verify-sig + + SRC_URI=" + https://ziglang.org/download/${PV}/${P}.tar.xz + verify-sig? ( https://ziglang.org/download/${PV}/${P}.tar.xz.minisig ) + https://codeberg.org/BratishkaErik/distfiles/releases/download/dev-lang%2Fzig-${PV}/${P}-llvm-18.1.8-r6-fix.patch + " + KEYWORDS="~amd64 ~arm ~arm64" + + BDEPEND="verify-sig? ( sec-keys/minisig-keys-zig-software-foundation )" +fi + +# project itself: MIT +# There are bunch of projects under "lib/" folder that are needed for cross-compilation. +# Files that are unnecessary for cross-compilation are removed by upstream +# and therefore their licenses (if any special) are not included. +# lib/libunwind: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT ) +# lib/libcxxabi: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT ) +# lib/libcxx: Apache-2.0-with-LLVM-exceptions || ( UoI-NCSA MIT ) +# lib/libc/wasi: || ( Apache-2.0-with-LLVM-exceptions Apache-2.0 MIT BSD-2 ) public-domain +# lib/libc/musl: MIT BSD-2 +# lib/libc/mingw: ZPL public-domain BSD-2 ISC HPND +# 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="${ZIG_SLOT}" +IUSE="debug doc +llvm" +REQUIRED_USE=" + !llvm? ( !doc ) + llvm? ( ${LLVM_REQUIRED_USE} ) +" + +# Used by both "cmake" and "zig" eclasses. +BUILD_DIR="${WORKDIR}/${P}_build" + +# Zig requires zstd and zlib compression support in LLVM, if using LLVM backend. +# (non-LLVM backends don't require these) +# They are not required "on their own", so please don't add them here. +# You can check https://github.com/ziglang/zig-bootstrap in future, to see +# options that are passed to LLVM CMake building (excluding "static" ofc). +LLVM_DEPEND="$(llvm_gen_dep ' + llvm-core/clang:${LLVM_SLOT} + llvm-core/lld:${LLVM_SLOT}[zstd] + llvm-core/llvm:${LLVM_SLOT}[zstd] +')" + +BDEPEND+=" llvm? ( ${LLVM_DEPEND} )" +DEPEND="llvm? ( ${LLVM_DEPEND} )" +RDEPEND="${DEPEND}" +IDEPEND="app-eselect/eselect-zig" + +DOCS=( "README.md" "doc/build.zig.zon.md" ) + +PATCHES=( + "${FILESDIR}/zig-0.13.0-test-std-kernel-version.patch" + "${FILESDIR}/zig-0.13.0-skip-test-stack_iterator.patch" + "${DISTDIR}/${P}-llvm-18.1.8-r6-fix.patch" +) + +# zig.eclass does not set this for us since we use ZIG_OPTIONAL=1 +QA_FLAGS_IGNORED="usr/.*/zig/${PV}/bin/zig" + +# Since commit https://github.com/ziglang/zig/commit/e7d28344fa3ee81d6ad7ca5ce1f83d50d8502118 +# Zig uses self-hosted compiler only +CHECKREQS_MEMORY="4G" + +pkg_setup() { + # Skip detecting zig executable. + declare -r -g ZIG_VER="${PV}" + ZIG_EXE="not-applicable" zig_pkg_setup + + declare -r -g ZIG_SYS_INSTALL_DEST="${EPREFIX}/usr/$(get_libdir)/zig/${PV}" + + if use llvm; then + [[ ${MERGE_TYPE} != binary ]] && llvm_cbuild_setup + fi + + # Requires running stage3 which is built for cross-target. + if use doc && tc-is-cross-compiler; then + die "USE=doc is not yet supported when cross-compiling" + fi + + check-reqs_pkg_setup +} + +src_unpack() { + if [[ ${PV} == 9999 ]]; then + git-r3_src_unpack + else + if use verify-sig; then + verify-sig_verify_detached "${DISTDIR}"/${P}.tar.xz{,.minisig} + fi + fi + zig_src_unpack +} + +src_prepare() { + if use llvm; then + cmake_src_prepare + else + # Sync with zig_src_prepare + default_src_prepare + mkdir -p "${BUILD_DIR}" || die + einfo "BUILD_DIR: \"${BUILD_DIR}\"" + # "--system" mode is not used during bootstrap. + fi + + # Remove "limit memory usage" flags, it's already verified by + # CHECKREQS_MEMORY and causes unneccessary errors. Upstream set them + # according to CI OOM failures, which are not applicable to normal Gentoo build. + sed -i -e '/\.max_rss = .*,/d' build.zig || die +} + +src_configure() { + # Has no effect on final binary and only causes failures during bootstrapping. + filter-lto + + # Used during bootstrapping. stage1/stage2 have limited functionality + # and can't resolve native target, so we pass target in exact form. + declare -r -g ZIG_HOST_AS_TARGET="$(zig-utils_c_env_to_zig_target "${CBUILD:-${CHOST}}" "${CFLAGS}"})" + + # Note that if we are building with CMake, "my_zbs_args" + # are used only after compiling zig2. + local my_zbs_args=( + --zig-lib-dir "${S}/lib/" + # Will be a subdir under ZIG_SYS_INSTALL_DEST. + --prefix-lib-dir lib/ + + # These are built separately + -Dno-langref=true + -Dstd-docs=false + + # More commands and options if "debug" is enabled. + -Ddebug-extensions=$(usex debug true false) + # More asserts and so on by default if "debug" is enabled. + --release=$(usex debug safe fast) + ) + + # Scenarios of compilation: + + # With LLVM, native: + # CMake: + # * generate "config.h" for LLVM libraries and build "zigcpp" + # * build "zig2" using common "config.h" and "zigcpp" + # build.zig: + # * build "stage3" using common "config.h" and "zigcpp" + + # With LLVM, cross-compiled: + # CMake: + # * generate cross-target "config.h" for LLVM libraries from ESYSROOT + # and build cross-target "zigcpp", and stash them away + # * generate native "config.h" for LLVM libraries from BROOT and + # build native "zigcpp" + # * build native "zig2" using native "config.h" and "zigcpp" + # build.zig: + # * build cross-target "stage3" using stashed "config.h" and "zigcpp" + + # Without LLVM: + # bootstrap.c: + # * build native "zig2" + # build.zig: + # * build (cross-)target "stage3" + + if use llvm; then + my_zbs_args+=( + -Denable-llvm=true + -Dstatic-llvm=false + -Dconfig_h="${BUILD_DIR}/config.h" + ) + else + my_zbs_args+=( + -Denable-llvm=false + ) + fi + zig_src_configure + + if use llvm; then + local mycmakeargs=( + -DZIG_SHARED_LLVM=ON + -DZIG_USE_LLVM_CONFIG=ON + -DZIG_HOST_TARGET_TRIPLE="${ZIG_HOST_AS_TARGET}" + # Don't set ZIG_TARGET_TRIPLE, ZIG_TARGET_MCPU and + # CMAKE_INSTALL_PREFIX because we build up to zig2 max, + # after that "zig build" is used to compile stage3. + + # Don't set CMAKE_PREFIX_PATH because "llvm_chost_setup" + # and "llvm_cbuild_setup" already set PATH in such way + # that suitable llvm-config is found and used in + # "cmake/Findllvm.cmake", and "cmake.eclass" help with + # cross-compilation pathes for "Findclang" and "Findlld". + + # CMP0144, Zig has own packages with these names, so ignore + # LLVM_ROOT, Clang_ROOT, LLD_ROOT from "llvm_chost_setup". + -DCMAKE_FIND_USE_PACKAGE_ROOT_PATH=OFF + ) + if tc-is-cross-compiler; then + # Enable cross-compilation for CMake when filling "config.h" + # and building "zigcpp". They would be used for stage3 build. + # Here we are using LLVM from ESYSROOT/DEPEND. + # Uses script llvm-config. + + # Isolate PATH changes in subshell so that it would not + # affect next `cmake_src_configure` with BROOT/BDEPEND. + ( + llvm_chost_setup + cmake_src_configure + cmake_build zigcpp + ) + + mv "${BUILD_DIR}/config.h" "${T}/target_config.h" || die + mv "${BUILD_DIR}/zigcpp/" "${T}/target_zigcpp/" || die + rm -rf "${BUILD_DIR}" || die + fi + + # Force disable cross-compilation for CMake when building "zig2". + # Here we are using LLVM from BROOT/BDEPEND. + # Uses native llvm-config. + + # Isolate environment changes in subshell so that it would not + # affect next phases. + ( + export BUILD_CFLAGS="${CFLAGS}" + export BUILD_CXXFLAGS="${CXXFLAGS}" + export BUILD_CPPFLAGS="${CPPFLAGS}" + export BUILD_LDFLAGS="${LDFLAGS}" + tc-env_build + + unset SYSROOT + export CHOST="${CBUILD:-${CHOST}}" + strip-unsupported-flags + cmake_src_configure + ) + fi +} + +src_compile() { + if use llvm; then + cmake_build zig2 + + if tc-is-cross-compiler; then + rm -rf "${BUILD_DIR}/zigcpp/" || die + rm -f "${BUILD_DIR}/config.h" || die + + mv "${T}/target_zigcpp/" "${BUILD_DIR}/zigcpp/" || die + mv "${T}/target_config.h" "${BUILD_DIR}/config.h" || die + fi + else + cd "${BUILD_DIR}" || die + ln -s "${S}/stage1/" . || die + ln -s "${S}/src/" . || die + ln -s "${S}/lib/" . || die + + local native_cc="$(tc-getBUILD_CC)" + "${native_cc}" -o bootstrap "${S}/bootstrap.c" || die "Zig's bootstrap.c compilation failed" + ZIG_HOST_TARGET_TRIPLE="${ZIG_HOST_AS_TARGET}" CC="${native_cc}" edo ./bootstrap + fi + + cd "${BUILD_DIR}" || die + ZIG_EXE="./zig2" zig_src_compile --prefix stage3/ + + # Requires running stage3 which is built for cross-target. + if ! tc-is-cross-compiler; then + ./stage3/bin/zig env || die "Zig compilation failed" + + if use doc; then + ZIG_EXE="./stage3/bin/zig" zig_src_compile langref --prefix "${S}/docgen/" + fi + fi +} + +src_test() { + if has_version -b app-emulation/qemu; then + ewarn "QEMU executable was found on your building system." + ewarn "If you have qemu-binfmt (binfmt_misc) hooks enabled for" + ewarn "foreign architectures, Zig tests might fail." + ewarn "In this case, please disable qemu-binfmt and try again." + fi + + cd "${BUILD_DIR}" || die + + # XXX: When we pass a libc installation to Zig, it will fail to find + # the bundled libraries for targets like aarch64-macos and + # *-linux-musl. Zig doesn't run binaries for these targets when + # -Dskip-non-native is passed, but they are still compiled, so + # the test will fail. There's no way to disable --libc once passed, + # so we need to strip it from ZBS_ARGS. + # See: https://github.com/ziglang/zig/issues/22383 + local args_backup=("${ZBS_ARGS[@]}") + + for ((i = 0; i < ${#ZBS_ARGS[@]}; i++)); do + if [[ "${ZBS_ARGS[i]}" == "--libc" ]]; then + unset ZBS_ARGS[i] + unset ZBS_ARGS[i+1] + break + fi + done + + ZIG_EXE="./stage3/bin/zig" zig_src_test -Dskip-non-native + + ZBS_ARGS=("${args_backup[@]}") +} + +src_install() { + use doc && local HTML_DOCS=( "docgen/doc/langref.html" ) + + ZIG_EXE="./zig2" zig_src_install --prefix "${ZIG_SYS_INSTALL_DEST}" + + cd "${D}/${ZIG_SYS_INSTALL_DEST}" || die + mv lib/zig/ lib2/ || die + rm -rf lib/ || die + mv lib2/ lib/ || die + dosym -r "${ZIG_SYS_INSTALL_DEST}/bin/zig" /usr/bin/zig-${PV} +} + +pkg_postinst() { + eselect zig update ifunset || die + + elog "Starting from 0.12.0, Zig no longer installs" + elog "precompiled standard library documentation." + elog "Instead, you can call \`zig std\` to compile it on-the-fly." + elog "It reflects all edits in standard library automatically." + elog "See \`zig std --help\` for more information." + elog "More details here: https://ziglang.org/download/0.12.0/release-notes.html#Redesign-How-Autodoc-Works" + + 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}\" ." + fi +} + +pkg_postrm() { + eselect zig update ifunset || die +} diff --git a/dev-lang/zig/zig-9999.ebuild b/dev-lang/zig/zig-9999.ebuild index 4f0358a96629..8fb29ab10b9e 100644 --- a/dev-lang/zig/zig-9999.ebuild +++ b/dev-lang/zig/zig-9999.ebuild @@ -1,4 +1,4 @@ -# Copyright 2019-2024 Gentoo Authors +# Copyright 2019-2025 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 @@ -9,7 +9,7 @@ LLVM_OPTIONAL=1 ZIG_SLOT="$(ver_cut 1-2)" ZIG_OPTIONAL=1 -inherit check-reqs cmake flag-o-matic edo llvm-r1 toolchain-funcs zig +inherit check-reqs cmake flag-o-matic edo llvm-r2 toolchain-funcs zig DESCRIPTION="A robust, optimal, and maintainable programming language" HOMEPAGE="https://ziglang.org/ https://github.com/ziglang/zig/" @@ -43,7 +43,7 @@ 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="${ZIG_SLOT}" -IUSE="doc +llvm" +IUSE="debug doc +llvm" REQUIRED_USE=" !llvm? ( !doc ) llvm? ( ${LLVM_REQUIRED_USE} ) @@ -57,18 +57,14 @@ BUILD_DIR="${WORKDIR}/${P}_build" # They are not required "on their own", so please don't add them here. # 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=" - llvm? ( - $(llvm_gen_dep ' - llvm-core/clang:${LLVM_SLOT} - llvm-core/lld:${LLVM_SLOT} - llvm-core/llvm:${LLVM_SLOT}[zstd] - ') - ) -" -BDEPEND+=" - ${DEPEND} -" +LLVM_DEPEND="$(llvm_gen_dep ' + llvm-core/clang:${LLVM_SLOT} + llvm-core/lld:${LLVM_SLOT}[zstd] + llvm-core/llvm:${LLVM_SLOT}[zstd] +')" + +BDEPEND+=" llvm? ( ${LLVM_DEPEND} )" +DEPEND="llvm? ( ${LLVM_DEPEND} )" RDEPEND="${DEPEND}" IDEPEND="app-eselect/eselect-zig" @@ -83,13 +79,18 @@ CHECKREQS_MEMORY="4G" pkg_setup() { # Skip detecting zig executable. - ZIG_EXE="not-applicable" ZIG_VER="${PV}" zig_pkg_setup + declare -r -g ZIG_VER="${PV}" + ZIG_EXE="not-applicable" zig_pkg_setup - export ZIG_SYS_INSTALL_DEST="${EPREFIX}/usr/$(get_libdir)/zig/${PV}" + declare -r -g ZIG_SYS_INSTALL_DEST="${EPREFIX}/usr/$(get_libdir)/zig/${PV}" if use llvm; then - tc-is-cross-compiler && die "USE=llvm is not yet supported when cross-compiling" - llvm-r1_pkg_setup + [[ ${MERGE_TYPE} != binary ]] && llvm_cbuild_setup + fi + + # Requires running stage3 which is built for cross-target. + if use doc && tc-is-cross-compiler; then + die "USE=doc is not yet supported when cross-compiling" fi check-reqs_pkg_setup @@ -139,11 +140,40 @@ src_configure() { --prefix-lib-dir lib/ # These are built separately - -Dno-langref + -Dno-langref=true -Dstd-docs=false - --release=fast + # More commands and options if "debug" is enabled. + -Ddebug-extensions=$(usex debug true false) + # More asserts and so on by default if "debug" is enabled. + --release=$(usex debug safe fast) ) + + # Scenarios of compilation: + + # With LLVM, native: + # CMake: + # * generate "config.h" for LLVM libraries and build "zigcpp" + # * build "zig2" using common "config.h" and "zigcpp" + # build.zig: + # * build "stage3" using common "config.h" and "zigcpp" + + # With LLVM, cross-compiled: + # CMake: + # * generate cross-target "config.h" for LLVM libraries from ESYSROOT + # and build cross-target "zigcpp", and stash them away + # * generate native "config.h" for LLVM libraries from BROOT and + # build native "zigcpp" + # * build native "zig2" using native "config.h" and "zigcpp" + # build.zig: + # * build cross-target "stage3" using stashed "config.h" and "zigcpp" + + # Without LLVM: + # bootstrap.c: + # * build native "zig2" + # build.zig: + # * build (cross-)target "stage3" + if use llvm; then my_zbs_args+=( -Denable-llvm=true @@ -155,31 +185,78 @@ src_configure() { -Denable-llvm=false ) fi - zig_src_configure if use llvm; then - # Build for native only, it's for zig2 (build-time executable) - # LLVM from BDEPEND local mycmakeargs=( -DZIG_SHARED_LLVM=ON -DZIG_USE_LLVM_CONFIG=ON - - -DZIG_TARGET_TRIPLE=native - -DZIG_TARGET_MCPU=native -DZIG_HOST_TARGET_TRIPLE="${ZIG_HOST_AS_TARGET}" - - -DCMAKE_PREFIX_PATH="$(get_llvm_prefix -b)" - -DCMAKE_INSTALL_PREFIX="${ZIG_SYS_INSTALL_DEST}" + # Don't set ZIG_TARGET_TRIPLE, ZIG_TARGET_MCPU and + # CMAKE_INSTALL_PREFIX because we build up to zig2 max, + # after that "zig build" is used to compile stage3. + + # Don't set CMAKE_PREFIX_PATH because "llvm_chost_setup" + # and "llvm_cbuild_setup" already set PATH in such way + # that suitable llvm-config is found and used in + # "cmake/Findllvm.cmake", and "cmake.eclass" help with + # cross-compilation pathes for "Findclang" and "Findlld". + + # CMP0144, Zig has own packages with these names, so ignore + # LLVM_ROOT, Clang_ROOT, LLD_ROOT from "llvm_chost_setup". + -DCMAKE_FIND_USE_PACKAGE_ROOT_PATH=OFF ) + if tc-is-cross-compiler; then + # Enable cross-compilation for CMake when filling "config.h" + # and building "zigcpp". They would be used for stage3 build. + # Here we are using LLVM from ESYSROOT/DEPEND. + # Uses script llvm-config. + + # Isolate PATH changes in subshell so that it would not + # affect next `cmake_src_configure` with BROOT/BDEPEND. + ( + llvm_chost_setup + cmake_src_configure + cmake_build zigcpp + ) + + mv "${BUILD_DIR}/config.h" "${T}/target_config.h" || die + mv "${BUILD_DIR}/zigcpp/" "${T}/target_zigcpp/" || die + rm -rf "${BUILD_DIR}" || die + fi - cmake_src_configure + # Force disable cross-compilation for CMake when building "zig2". + # Here we are using LLVM from BROOT/BDEPEND. + # Uses native llvm-config. + + # Isolate environment changes in subshell so that it would not + # affect next phases. + ( + export BUILD_CFLAGS="${CFLAGS}" + export BUILD_CXXFLAGS="${CXXFLAGS}" + export BUILD_CPPFLAGS="${CPPFLAGS}" + export BUILD_LDFLAGS="${LDFLAGS}" + tc-env_build + + unset SYSROOT + export CHOST="${CBUILD:-${CHOST}}" + strip-unsupported-flags + cmake_src_configure + ) fi } src_compile() { if use llvm; then cmake_build zig2 + + if tc-is-cross-compiler; then + rm -rf "${BUILD_DIR}/zigcpp/" || die + rm -f "${BUILD_DIR}/config.h" || die + + mv "${T}/target_zigcpp/" "${BUILD_DIR}/zigcpp/" || die + mv "${T}/target_config.h" "${BUILD_DIR}/config.h" || die + fi else cd "${BUILD_DIR}" || die ln -s "${S}/stage1/" . || die @@ -192,18 +269,48 @@ src_compile() { fi cd "${BUILD_DIR}" || die - ZIG_EXE="./zig2" zig_src_compile --prefix "${BUILD_DIR}/stage3/" + ZIG_EXE="./zig2" zig_src_compile --prefix stage3/ - ./stage3/bin/zig env || die "Zig compilation failed" + # Requires running stage3 which is built for cross-target. + if ! tc-is-cross-compiler; then + ./stage3/bin/zig env || die "Zig compilation failed" - if use doc; then - ZIG_EXE="./stage3/bin/zig" zig_src_compile langref --prefix "${S}/docgen/" + if use doc; then + ZIG_EXE="./stage3/bin/zig" zig_src_compile langref --prefix "${S}/docgen/" + fi fi } src_test() { + if has_version -b app-emulation/qemu; then + ewarn "QEMU executable was found on your building system." + ewarn "If you have qemu-binfmt (binfmt_misc) hooks enabled for" + ewarn "foreign architectures, Zig tests might fail." + ewarn "In this case, please disable qemu-binfmt and try again." + fi + cd "${BUILD_DIR}" || die + + # XXX: When we pass a libc installation to Zig, it will fail to find + # the bundled libraries for targets like aarch64-macos and + # *-linux-musl. Zig doesn't run binaries for these targets when + # -Dskip-non-native is passed, but they are still compiled, so + # the test will fail. There's no way to disable --libc once passed, + # so we need to strip it from ZBS_ARGS. + # See: https://github.com/ziglang/zig/issues/22383 + local args_backup=("${ZBS_ARGS[@]}") + + for ((i = 0; i < ${#ZBS_ARGS[@]}; i++)); do + if [[ "${ZBS_ARGS[i]}" == "--libc" ]]; then + unset ZBS_ARGS[i] + unset ZBS_ARGS[i+1] + break + fi + done + ZIG_EXE="./stage3/bin/zig" zig_src_test -Dskip-non-native + + ZBS_ARGS=("${args_backup[@]}") } src_install() { @@ -237,5 +344,5 @@ pkg_postinst() { } pkg_postrm() { - eselect zig update ifunset || die + eselect zig update ifunset } |