pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Add a package for rust-beta
Module Name: pkgsrc-wip
Committed By: pin <voidpin%protonmail.com@localhost>
Pushed By: pin
Date: Wed Apr 8 21:39:41 2026 +0200
Changeset: 072240af5872e9cba35a5dcecb141a3049eb5c54
Modified Files:
Makefile
Added Files:
rust-beta/DESCR
rust-beta/Makefile
rust-beta/buildlink3.mk
rust-beta/cargo.mk
rust-beta/distinfo
rust-beta/files/gcc-wrap
rust-beta/options.mk
rust-beta/patches/patch-compiler_rustc__llvm_build.rs
rust-beta/patches/patch-library_backtrace_src_symbolize_gimli.rs
rust-beta/patches/patch-library_backtrace_src_symbolize_gimli_elf.rs
rust-beta/patches/patch-src_bootstrap_bootstrap.py
rust-beta/patches/patch-src_bootstrap_src_core_build__steps_install.rs
rust-beta/patches/patch-src_bootstrap_src_core_builder_cargo.rs
rust-beta/patches/patch-src_bootstrap_src_lib.rs
rust-beta/patches/patch-src_llvm-project_llvm_utils_FileCheck_FileCheck.cpp
rust-beta/patches/patch-src_tools_rust-installer_install-template.sh
rust-beta/patches/patch-vendor_libc-0.2.155_src_unix_bsd_netbsdlike_netbsd_mod.rs
rust-beta/patches/patch-vendor_libc-0.2.168_src_unix_bsd_netbsdlike_netbsd_mod.rs
rust-beta/patches/patch-vendor_libc-0.2.169_src_unix_bsd_netbsdlike_netbsd_mod.rs
rust-beta/patches/patch-vendor_lzma-sys-0.1.20_config.h
rust-beta/patches/patch-vendor_openssl-src-111.28.2+1.1.1w_openssl_Configurations_10-main.conf
rust-beta/patches/patch-vendor_openssl-src-111.28.2+1.1.1w_openssl_crypto_aria_aria.c
rust-beta/patches/patch-vendor_openssl-src-111.28.2+1.1.1w_src_lib.rs
rust-beta/patches/patch-vendor_openssl-src-300.5.0+3.5.0_openssl_Configurations_10-main.conf
rust-beta/patches/patch-vendor_openssl-src-300.5.0+3.5.0_openssl_crypto_aria_aria.c
rust-beta/patches/patch-vendor_openssl-src-300.5.0+3.5.0_src_lib.rs
rust-beta/patches/patch-vendor_openssl-src-300.5.4+3.5.4_openssl_Configurations_10-main.conf
rust-beta/patches/patch-vendor_openssl-src-300.5.4+3.5.4_openssl_crypto_aria_aria.c
rust-beta/patches/patch-vendor_openssl-src-300.5.4+3.5.4_src_lib.rs
rust-beta/patches/patch-vendor_openssl-sys-0.9.107_build_find__normal.rs
rust-beta/patches/patch-vendor_openssl-sys-0.9.107_build_main.rs
rust-beta/patches/patch-vendor_openssl-sys-0.9.109_build_find__normal.rs
rust-beta/patches/patch-vendor_openssl-sys-0.9.109_build_main.rs
rust-beta/patches/patch-vendor_openssl-sys-0.9.111_build_find__normal.rs
rust-beta/patches/patch-vendor_openssl-sys-0.9.111_build_main.rs
rust-beta/patches/patch-vendor_openssl-sys-0.9.92_build_find__normal.rs
rust-beta/patches/patch-vendor_openssl-sys-0.9.92_build_main.rs
rust-beta/platform.mk
rust-beta/rust.mk
Log Message:
Add a package for rust-beta
This package is for NetBSD amd64, a.k.a. x86_64 only!
Everything related to other OSs and/or target platforms has been stripped off.
The beta channel has several iterations along the path to next stable release.
Regenerating checksums may be needed to build the correct rust-beta iteration.
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=072240af5872e9cba35a5dcecb141a3049eb5c54
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
Makefile | 1 +
rust-beta/DESCR | 13 +
rust-beta/Makefile | 310 +++++++++++++++++++++
rust-beta/buildlink3.mk | 26 ++
rust-beta/cargo.mk | 121 ++++++++
rust-beta/distinfo | 41 +++
rust-beta/files/gcc-wrap | 215 ++++++++++++++
rust-beta/options.mk | 48 ++++
.../patches/patch-compiler_rustc__llvm_build.rs | 50 ++++
.../patch-library_backtrace_src_symbolize_gimli.rs | 14 +
...ch-library_backtrace_src_symbolize_gimli_elf.rs | 26 ++
rust-beta/patches/patch-src_bootstrap_bootstrap.py | 48 ++++
...-src_bootstrap_src_core_build__steps_install.rs | 15 +
.../patch-src_bootstrap_src_core_builder_cargo.rs | 26 ++
rust-beta/patches/patch-src_bootstrap_src_lib.rs | 40 +++
...llvm-project_llvm_utils_FileCheck_FileCheck.cpp | 15 +
...ch-src_tools_rust-installer_install-template.sh | 72 +++++
...c-0.2.155_src_unix_bsd_netbsdlike_netbsd_mod.rs | 15 +
...c-0.2.168_src_unix_bsd_netbsdlike_netbsd_mod.rs | 15 +
...c-0.2.169_src_unix_bsd_netbsdlike_netbsd_mod.rs | 15 +
.../patches/patch-vendor_lzma-sys-0.1.20_config.h | 25 ++
...28.2+1.1.1w_openssl_Configurations_10-main.conf | 18 ++
...-src-111.28.2+1.1.1w_openssl_crypto_aria_aria.c | 18 ++
...h-vendor_openssl-src-111.28.2+1.1.1w_src_lib.rs | 67 +++++
...0.5.0+3.5.0_openssl_Configurations_10-main.conf | 18 ++
...sl-src-300.5.0+3.5.0_openssl_crypto_aria_aria.c | 18 ++
...tch-vendor_openssl-src-300.5.0+3.5.0_src_lib.rs | 30 ++
...0.5.4+3.5.4_openssl_Configurations_10-main.conf | 18 ++
...sl-src-300.5.4+3.5.4_openssl_crypto_aria_aria.c | 18 ++
...tch-vendor_openssl-src-300.5.4+3.5.4_src_lib.rs | 30 ++
...endor_openssl-sys-0.9.107_build_find__normal.rs | 30 ++
.../patch-vendor_openssl-sys-0.9.107_build_main.rs | 23 ++
...endor_openssl-sys-0.9.109_build_find__normal.rs | 30 ++
.../patch-vendor_openssl-sys-0.9.109_build_main.rs | 23 ++
...endor_openssl-sys-0.9.111_build_find__normal.rs | 30 ++
.../patch-vendor_openssl-sys-0.9.111_build_main.rs | 23 ++
...vendor_openssl-sys-0.9.92_build_find__normal.rs | 30 ++
.../patch-vendor_openssl-sys-0.9.92_build_main.rs | 23 ++
rust-beta/platform.mk | 34 +++
rust-beta/rust.mk | 68 +++++
40 files changed, 1700 insertions(+)
diffs:
diff --git a/Makefile b/Makefile
index d39fe545c7..6bf51a6db8 100644
--- a/Makefile
+++ b/Makefile
@@ -5330,6 +5330,7 @@ SUBDIR+= ruby-yaml_waml
SUBDIR+= runas
SUBDIR+= runcpm
SUBDIR+= rust-analyzer
+SUBDIR+= rust-beta
SUBDIR+= rust-synapse-compress-state
SUBDIR+= rust193
SUBDIR+= rust193-bin
diff --git a/rust-beta/DESCR b/rust-beta/DESCR
new file mode 100644
index 0000000000..6dc90a671e
--- /dev/null
+++ b/rust-beta/DESCR
@@ -0,0 +1,13 @@
+Rust is a systems programming language focused on three goals: safety,
+speed, and concurrency. It maintains these goals without having a
+garbage collector, making it a useful language for a number of use cases
+other languages aren't good at: embedding in other languages, programs
+with specific space and time requirements, and writing low-level code,
+like device drivers and operating systems.
+
+It improves on current languages targeting this space by having a number
+of compile-time safety checks that produce no runtime overhead, while
+eliminating all data races. Rust also aims to achieve "zero-cost
+abstractions" even though some of these abstractions feel like those of
+a high-level language. Even then, Rust still allows precise control
+like a low-level language would.
diff --git a/rust-beta/Makefile b/rust-beta/Makefile
new file mode 100644
index 0000000000..9c8f4a046a
--- /dev/null
+++ b/rust-beta/Makefile
@@ -0,0 +1,310 @@
+# $NetBSD$
+
+# This package is for NetBSD amd64, a.k.a. x86_64 only!
+# Everything related to other OSs and/or target platforms has been stripped off.
+# The beta channel has several iterations along the path to next stable.
+# Regenerating checksums may be needed to build the current rust-beta.
+
+DISTNAME= rustc-beta-src
+PKGNAME= ${DISTNAME:S/rustc/rust/:S/-src//}
+CATEGORIES= lang
+MASTER_SITES= https://static.rust-lang.org/dist/
+EXTRACT_SUFX= .tar.xz
+
+MAINTAINER= pin%NetBSD.org@localhost
+HOMEPAGE= https://www.rust-lang.org/
+COMMENT= Safe, concurrent, practical language
+LICENSE= mit OR apache-2.0
+
+CONFLICTS+= rust-bin-[0-9]*
+
+# LLVM uses -std=c++17
+USE_CXX_FEATURES+= c++17
+USE_GCC_RUNTIME= yes
+USE_LANGUAGES= c c++
+USE_LIBTOOL= yes
+USE_TOOLS+= bash grep gmake perl:build pkg-config
+
+HAS_CONFIGURE= yes
+PYTHON_FOR_BUILD_ONLY= tool
+CONFIG_SHELL= ${TOOL_PYTHONBIN}
+CONFIGURE_SCRIPT= src/bootstrap/configure.py
+CONFIGURE_ARGS+= --prefix=${PREFIX}
+CONFIGURE_ARGS+= --mandir=${PREFIX}/${PKGMANDIR}
+CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
+CONFIGURE_ARGS+= --python=${TOOL_PYTHONBIN}
+CONFIGURE_ARGS+= --release-channel=stable
+CONFIGURE_ARGS+= --local-rust-root=${RUST_BOOTSTRAP_PATH}
+CONFIGURE_ARGS+= --enable-extended
+CONFIGURE_ARGS+= --enable-rpath
+CONFIGURE_ARGS+= --disable-codegen-tests
+CONFIGURE_ARGS+= --disable-compiler-docs
+CONFIGURE_ARGS+= --disable-llvm-static-stdcpp
+CONFIGURE_ARGS+= --disable-ninja
+CONFIGURE_ARGS+= --dist-compression-formats=xz
+CONFIGURE_ARGS+= --set dist.vendor=false
+
+REPLACE_BASH+= library/portable-simd/subtree-sync.sh
+CB= library/compiler-builtins
+REPLACE_BASH+= ${CB}/ci/bench-icount.sh
+REPLACE_BASH+= ${CB}/ci/miri.sh
+REPLACE_BASH+= ${CB}/ci/run-docker.sh
+REPLACE_BASH+= ${CB}/ci/run-extensive.sh
+REPLACE_BASH+= ${CB}/ci/run.sh
+
+REPLACE_PYTHON+= ${CB}/ci/ci-util.py
+REPLACE_PYTHON+= ${CB}/etc/update-api-list.py
+
+# This should allow us to perform "offline" builds (so cargo doesn't fetch
+# dependencies during the build stage) but this isn't hooked up yet.
+CONFIGURE_ARGS+= --enable-vendor
+
+# cargo defaults to using the number of available CPUs
+MAKE_ENV+= CARGO_BUILD_JOBS=${_MAKE_JOBS_N}
+
+UNLIMIT_RESOURCES+= cputime stacksize datasize virtualsize
+
+TEST_TARGET= check
+
+# bin/* lib/*, but names vary
+CHECK_RELRO_SUPPORTED= no
+CHECK_SSP_SUPPORTED= no
+
+.include "../../mk/bsd.prefs.mk"
+
+# Getting RPATH with $ORIGIN into the bootstrap binaries is
+# problematic, since pkgsrc refuses to put $ORIGIN into RPATHs
+# of executables. So instead we need these so that the bootstrap
+# compiler can be run out of the $RUST_BOOTSTRAP_PATH directory as
+# part of the initial part of the rust compiler build.
+# This problem is not present with the amd64 bootstrap bits,
+# which are built by upstream and uses $ORIGIN/../lib in RPATH.
+MAKE_ENV+= LD_LIBRARY_PATH=${RUST_BOOTSTRAP_PATH:Q}/lib
+PKGSRC_MAKE_ENV+= LD_LIBRARY_PATH=${RUST_BOOTSTRAP_PATH:Q}/lib
+
+# Allow overriding MAKE_JOBS_SAFE
+.if !empty(rust.MAKE_JOBS_SAFE)
+. if ${rust.MAKE_JOBS_SAFE:tl} == "yes"
+MAKE_JOBS_SAFE= yes
+. endif
+.endif
+
+.if !empty(rust.BUILD_TARGET)
+BUILD_TARGET= ${rust.BUILD_TARGET}
+.endif
+
+BUILD_TARGET?= build
+
+# Under NetBSD, do not use DT_RUNPATH
+BUILDLINK_TRANSFORM+= rm:-Wl,--enable-new-dtags
+
+# Rust unfortunately requires itself to build. The upstream-provided
+# bootstrap for NetBSD/amd64 uses $ORIGIN/../lib in its RPATH and
+# does not need any special post-processing.
+DISTFILES:= ${DEFAULT_DISTFILES}
+
+RUST_STAGE0_VER= 1.94.1
+RUST_ARCH= x86_64-unknown-netbsd
+RUST_STAGE0:= rust-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.xz
+RUST_STD_STAGE0:= rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.xz
+DISTFILES:= ${DISTFILES} ${RUST_STAGE0} ${RUST_STD_STAGE0}
+
+# You may override RUST_BOOTSTRAP_PATH and RUST_ARCH in mk.conf
+# if you have a local bootstrap compiler.
+RUST_BOOTSTRAP_PATH?= ${WRKDIR}/rust-bootstrap
+
+RUSTLIB_COMPILER= lib/rustlib/rustc-src/rust/compiler
+RUSTC_CG_CRANELIFT= ${RUSTLIB_COMPILER}/rustc_codegen_cranelift
+
+CHECK_INTERPRETER_SKIP+= ${RUSTC_CG_CRANELIFT}/scripts/filter_profile.rs
+CHECK_INTERPRETER_SKIP+= ${RUSTC_CG_CRANELIFT}/scripts/rustup.sh
+CHECK_INTERPRETER_SKIP+= ${RUSTC_CG_CRANELIFT}/scripts/test_bootstrap.sh
+CHECK_INTERPRETER_SKIP+= ${RUSTC_CG_CRANELIFT}/scripts/test_rustc_tests.sh
+CHECK_INTERPRETER_SKIP+= ${RUSTC_CG_CRANELIFT}/.github/scripts/free-disk-space.sh
+CHECK_INTERPRETER_SKIP+= ${RUSTLIB_COMPILER}/rustc_codegen_gcc/y.sh
+CHECK_INTERPRETER_SKIP+= lib/rustlib/src/rust/library/backtrace/ci/*.sh
+CHECK_INTERPRETER_SKIP+= lib/rustlib/src/rust/library/core/src/unicode/printable.py
+CHECK_INTERPRETER_SKIP+= lib/rustlib/src/rust/library/stdarch/ci/*.sh
+CHECK_PORTABILITY_SKIP+= tests/run-make/dump-ice-to-disk/check.sh
+CHECK_PORTABILITY_SKIP+= vendor/libdbus-sys-0.2.5/vendor/dbus/tools/cmake-format
+
+SUBST_CLASSES+= prefix
+SUBST_STAGE.prefix= pre-configure
+SUBST_FILES.prefix+= src/bootstrap/src/core/builder/cargo.rs
+SUBST_FILES.prefix+= src/bootstrap/bootstrap.py
+SUBST_VARS.prefix= PREFIX
+
+# Generate list of subst entries for various .cargo-checksum.json files.
+CKSUM_CRATES+= vendor/openssl-src-300.5.0+3.5.0
+CKSUMS+= 16c0b9fa70475cfb50ac21ad4ce049b494c45b3270fed386013785a28abb8d0a
+CKSUMS+= e2817c457afa7efc0f2ca62ce9dab5254eb5ddd9a5fd9e75bba2789be92c7b14
+CKSUMS+= 6e62515e67910aea2f04b64c643aa2545732f9dd7bf0abf87d8accf8c2c1fb88
+CKSUMS+= ccc5252660386fbfec2d66423f2dc87e6da74efd39ca0fcd7c7fd583056725c1
+CKSUMS+= ac5501e7bff0f4384db0537307b362bf1bcb120d8b5859e5f08bd796e78feaea
+CKSUMS+= 6d2c2831119e059d35e81a89b08195a29e325f68acfd86a3a7157ebf8e78182d
+
+CKSUM_CRATES+= vendor/openssl-src-300.5.4+3.5.4
+CKSUMS+= 33f1e78110293a8558ae997ed57e7aac72c5bfd47a241dc7f6e2ffa98b7a7137
+CKSUMS+= d0232a8b63c2fb396ed7551eb983b16b6ebafbba4b33d4434e167b05ee290f8f
+
+CKSUM_CRATES+= vendor/openssl-sys-0.9.107
+CKSUMS+= a0d47c624273b43b4250cff5fa2f9b75e4199ca76897608563b526aedcdf3a16
+CKSUMS+= fcfc15ca30e1f881ed46cf57597a72bd2a8307269d0394c905f23e076a983e12
+CKSUMS+= e6d478786035538d721d88b7736f602c965a38687a805cb377ebbe0ea1a14617
+CKSUMS+= e2b2473bdf7ce5f854fcef6f07f984accc53b4382dba160d625c1fcbaba31612
+
+CKSUM_CRATES+= vendor/openssl-sys-0.9.109
+CKSUMS+= 112fcb6f18b81f31c23c60e7be5fddc87603c05a595f2e22b6e8f7ed2ea89e5f
+CKSUMS+= 023a3e755d7d4c5ca6e4f8ce7a8b1dc2dd1e50cbfcaa43cc6fe809b251ee7037
+CKSUMS+= f66ce762ec63c28621a0d6d48bd5872b96e71f0bfb6f88576a6e2cba0c229e12
+CKSUMS+= 656834a8bd87476b074f36bcc2aeb33a74a0a0a6db5d140c35c4b3eb385afebe
+
+CKSUM_CRATES+= vendor/openssl-sys-0.9.111
+CKSUMS+= 0c5a4bd38ed007182cfec3cf0824a4806e5c629b9d69e3cc2a5b6e9be3eec280
+CKSUMS+= 777a22f3cd39ad01f2e559ecf600bb9c03ec42e0b9fbe41746f42938e162d523
+CKSUMS+= d17fa8715a43ff0da872ac504abb2cc0a395644e8f5c8c128812758c458d5963
+CKSUMS+= 02d5de4e4976450f8e665e0eff664e93063dd53aec2cb75ecee0847e3c0c086e
+
+CKSUM_CRATES+= vendor/libc-0.2.155
+CKSUMS+= 3e550d95419169febf094c425451ca86b12821fa17839b4b0ba7520b145a5820
+CKSUMS+= 1cf38d9ddeca5295821b4234e17e1fc749f35b00307bdfdacb24c6892a288ad6
+CKSUMS+= b8d6f089fc8eb2cb59e45335a26c9ce871b846216c9859b553c6b91982f8de33
+CKSUMS+= d8c4a979ce9b406fb63c5aaf2827b616689294331341737fec392b8faa2126fa
+
+CKSUM_CRATES+= vendor/libc-0.2.169
+CKSUMS+= dc216609dfc6b2835e26f8c3e70f4c7c65425933eef04538de603f51e9429ec5
+CKSUMS+= 04004bda0ea97d55c3588a7d82fa1faf0d150c5390250a298216ff3cc899b911
+CKSUMS+= b5dae853ebfc3355b155f8c20f3a481517bce27e164e304f56dfff172e313098
+CKSUMS+= 55fb7f2c0877231286b2b6515e08eda1d5cac1311a402d0aa162c7eb867ee19b
+CKSUMS+= 0b1936bad97b3a272c2d323d3435f6860fc355abe7603ca7ed8c4166cac75cc5
+CKSUMS+= 1eb383a057cdf2826d884b19142bf0b68b6b30c5bc20baf7ee10401a92a8ef22
+
+CKSUM_CRATES+= vendor/lzma-sys-0.1.20
+CKSUMS+= 6fd5e9245db34c6f557b8bfcaf03db82fc88c3b06dbfbb5f03b2bcd138983ef9
+CKSUMS+= 2a68e3e635dce81c7dba25b3d3abfaa894ee729e1604f2d000ae3e201f7739a4
+
+SUBST_CLASSES+= cksum
+SUBST_STAGE.cksum= pre-configure
+.for crate in ${CKSUM_CRATES}
+SUBST_FILES.cksum+= ${crate}/.cargo-checksum.json
+.endfor
+.for from to in ${CKSUMS}
+SUBST_SED.cksum+= -e 's,${from},${to},g'
+.endfor
+
+post-extract:
+ set -e; \
+ if ${TEST} -e ${WRKDIR}/rust-${RUST_STAGE0_VER}-${RUST_ARCH}/install.sh \
+ -a ! -e ${RUST_BOOTSTRAP_PATH}/bin/rustc; then \
+ cd ${WRKDIR}/rust-${RUST_STAGE0_VER}-${RUST_ARCH}; \
+ env ${MAKE_ENV} ${TOOLS_BASH} \
+ ./install.sh --prefix=${RUST_BOOTSTRAP_PATH}; \
+ cd ${WRKDIR}/rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}; \
+ env ${MAKE_ENV} ${TOOLS_BASH} \
+ ./install.sh --prefix=${RUST_BOOTSTRAP_PATH}; \
+ fi
+ SDIR=${WRKDIR}/scripts; \
+ ${MKDIR} $${SDIR}; \
+ cd $${SDIR}; \
+ ${RM} -f c++-wrap; \
+ ${RM} -f clang++-wrap; \
+ ${RM} -f clang-wrap; \
+ ${RM} -f ar-wrap; \
+ ${CP} ${.CURDIR}/files/gcc-wrap .; \
+ ${CHMOD} +x gcc-wrap; \
+ ${LN} -s gcc-wrap c++-wrap; \
+ ${LN} -s gcc-wrap clang++-wrap; \
+ ${LN} -s gcc-wrap clang-wrap; \
+ ${LN} -s gcc-wrap ar-wrap
+
+# Rust builds some bundled components with strict version requirements, ensure
+# that any conflicting packages pulled in via dependencies are not buildlinked.
+BUILDLINK_FILES_CMD.xz= ${TRUE}
+MAKE_ENV+= LZMA_API_STATIC=1
+pre-configure:
+ ${RM} -rf ${BUILDLINK_DIR}/include/libssh2*
+
+# These are essentially copies of the "all", "test", and "install" Makefile
+# targets, but are duplicated here so that we can specify -j.
+do-build:
+ ${RUN}${_ULIMIT_CMD} \
+ cd ${WRKSRC} && \
+ ${SETENV} ${MAKE_ENV} \
+ sh -c "if [ \"${BUILD_TARGET}\" = \"dist\" ]; then \
+ unset DESTDIR; \
+ ${TOOL_PYTHONBIN} ./x.py \
+ ${BUILD_TARGET} -j ${_MAKE_JOBS_N}; \
+ else \
+ ${TOOL_PYTHONBIN} ./x.py \
+ ${BUILD_TARGET} --stage 2 -j ${_MAKE_JOBS_N} && \
+ ${TOOL_PYTHONBIN} ./x.py \
+ doc --stage 2 -j ${_MAKE_JOBS_N}; \
+ fi"
+
+do-test:
+ ${RUN}${_ULIMIT_CMD} \
+ cd ${WRKSRC} && \
+ ${SETENV} ${MAKE_ENV} \
+ ${TOOL_PYTHONBIN} ./x.py test -j ${_MAKE_JOBS_N}
+
+do-install:
+ ${RUN}${_ULIMIT_CMD} \
+ cd ${WRKSRC} && \
+ ${SETENV} ${MAKE_ENV} ${INSTALL_ENV} \
+ ${TOOL_PYTHONBIN} ./x.py install -j ${_MAKE_JOBS_N}
+
+SUBST_CLASSES+= destdir
+SUBST_STAGE.destdir= post-install
+SUBST_FILES.destdir= ${DESTDIR}${PREFIX}/lib/rustlib/manifest-*
+SUBST_SED.destdir= -e 's|file:${DESTDIR}${PREFIX}|file:${PREFIX}|'
+
+GENERATE_PLIST+= ${FIND} ${DESTDIR}${PREFIX} \( -type f -o -type l \) -print | \
+ ${SED} -e 's,${DESTDIR}${PREFIX}/,,' | ${SORT} ;
+
+# Create a relocatable stage2 bootstrap from the bits we just built.
+# This target is a developer tool and remains in place for convenience.
+#BOOTSTRAP_NAME= ${PKGNAME_NOREV:C/rust/rust-nightly/}-${RUST_ARCH}
+BOOTSTRAP_NAME= ${PKGNAME_NOREV}-${RUST_ARCH}
+BOOTSTRAP_TMPDIR= ${WRKDIR}/${BOOTSTRAP_NAME}
+USE_TOOLS+= gtar
+
+.PHONY: stage0-bootstrap
+stage0-bootstrap: install
+ ${RM} -rf ${BOOTSTRAP_TMPDIR}
+ ${MKDIR} ${BOOTSTRAP_TMPDIR}
+ (cd ${BOOTSTRAP_TMPDIR}; \
+ DISTDIR=${WRKSRC}/bild/dist; \
+ VER_ARCH=${PKGVERSION}-${RUST_ARCH}; \
+ RUSTC=rustc-$${VER_ARCH}; \
+ RUSTC_FILE=$${RUSTC}.tar.gz; \
+ RUST_STD=rust-std-$${VER_ARCH}; \
+ RUST_STD_FILE=$${RUST_STD}.tar.gz; \
+ ${GTAR} -xzf $${DISTDIR}/$${RUSTC_FILE}; \
+ (cd ${RUSTC}; \
+ RPATH='/usr/pkg/lib:/lib:/usr/lib:$$ORIGIN/../lib'; \
+ for f in rls-preview/bin/rls rustc/bin/rustc rustc/bin/rustdoc; do \
+ chrpath -r $$RPATH $$f; \
+ done; \
+ RPATH='/usr/pkg/lib:/lib:/usr/lib:$$ORIGIN'; \
+ for f in rustc/lib/*.so*; do \
+ chrpath -r $$RPATH $$f; \
+ done; \
+ RPATH='/usr/pkg/lib:/lib:/usr/lib:$$ORIGIN:$$ORIGIN/../../..'; \
+ for f in rustc/lib/rustlib/*/*/*.so*; do \
+ chrpath -r $$RPATH $$f; \
+ done;); \
+ ${GTAR} -czf $${RUSTC_FILE} $${RUSTC}; \
+ ${CP} $${DISTDIR}/$${RUST_STD_FILE} .; \
+ ${ECHO} "Fixed stage0 bootstrap in ${BOOTSTRAP_TMPDIR}:"; \
+ ${ECHO} "$${RUSTC_FILE}"; \
+ ${ECHO} "$${RUST_STD_FILE}"; \
+ )
+
+.include "options.mk"
+
+TOOL_DEPENDS+= cmake-[0-9]*:../../devel/cmake
+
+.include "../../devel/zlib/buildlink3.mk"
+.include "../../lang/python/tool.mk"
+.include "../../lang/python/application.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/rust-beta/buildlink3.mk b/rust-beta/buildlink3.mk
new file mode 100644
index 0000000000..92bdc62c04
--- /dev/null
+++ b/rust-beta/buildlink3.mk
@@ -0,0 +1,26 @@
+# $NetBSD$
+
+BUILDLINK_TREE+= rust
+
+# DO NOT include this directly! Use rust.mk instead.
+
+.if !defined(RUST_BUILDLINK3_MK)
+RUST_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.rust+= rust>=1.85.0
+BUILDLINK_PKGSRCDIR.rust?= ../../lang/rust
+BUILDLINK_PASSTHRU_DIRS+= ${PREFIX}/lib/rustlib
+
+.include "../../mk/bsd.fast.prefs.mk"
+
+pkgbase:= rust
+.include "../../mk/pkg-build-options.mk"
+# unclear why this is necessary, but is actively harmful on Darwin, and
+# likely broken for most uses anyway as rust defaults to DEPMETHOD=build.
+.if empty(PKG_BUILD_OPTIONS.rust:Mrust-internal-llvm) && ${OPSYS} != "Darwin"
+. include "../../lang/libunwind/buildlink3.mk"
+.endif
+
+.endif
+
+BUILDLINK_TREE+= -rust
diff --git a/rust-beta/cargo.mk b/rust-beta/cargo.mk
new file mode 100644
index 0000000000..771d88cb22
--- /dev/null
+++ b/rust-beta/cargo.mk
@@ -0,0 +1,121 @@
+# $NetBSD$
+#
+# Common logic that can be used by packages that depend on cargo crates
+# from crates.io. This lets existing pkgsrc infrastructure fetch and verify
+# cargo crates instead of using the rust package manager in the build phase.
+# Inspired by cargo.mk from FreeBSD ports.
+#
+# Usage example:
+#
+# CARGO_CRATE_DEPENDS+= sha1-0.20
+# .include "../../lang/rust/cargo.mk"
+#
+# If modifying the list of dependencies, re-run the build once without
+# --offline in CARGO_ARGS to generate a new valid Cargo.lock.
+# e.g: make CARGO_ARGS="build --release" build
+#
+# a list of CARGO_CRATE_DEPENDS can be generated via
+# make print-cargo-depends > cargo-depends.mk
+#
+# See also www/geckodriver for a full example.
+
+MASTER_SITES?= -${MASTER_SITE_CRATESIO}${PKGBASE}/${PKGVERSION_NOREV}/download
+
+CHECK_SSP_SUPPORTED= no
+
+.include "../../lang/rust/rust.mk"
+
+USE_TOOLS+= bsdtar digest
+CARGO_VENDOR_DIR= ${WRKDIR}/vendor
+CARGO_WRKSRC?= ${WRKSRC}
+
+# TODO: some Cargo.lock files include git+https sources which need to be fetched from the URL (not necessarily resolving to a crate.io url)
+DISTFILES?= ${DEFAULT_DISTFILES}
+.for crate in ${CARGO_CRATE_DEPENDS}
+DISTFILES+= ${crate}.crate
+. if ${crate:M*+*}
+# E.g., for `curl-sys-0.4.75+curl-8.10.0', we use the URL:
+# https://crates.io/api/v1/crates/curl-sys/0.4.77+curl-8.10.1/download
+SITES.${crate}.crate+= -${MASTER_SITE_CRATESIO}${crate:C/-[0-9]+\.[0-9.]+.*$//}/${crate:C/^.*-([0-9]+\.[0-9.]+.*\+.*)$/\1/}/download
+. else
+SITES.${crate}.crate+= -${MASTER_SITE_CRATESIO}${crate:C/-[0-9]+\.[0-9.]+.*$//}/${crate:C/^.*-([0-9]+\.[0-9.]+.*)$/\1/}/download
+. endif
+EXTRACT_DIR.${crate}.crate?= ${CARGO_VENDOR_DIR}
+.endfor
+
+.include "../../mk/bsd.prefs.mk"
+# Triggers NetBSD ld.so bug (PR toolchain/54192)
+# See Makefile for further information.
+.if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 099957
+MAKE_JOBS_SAFE= no
+.endif
+
+post-extract: cargo-vendor-crates
+.PHONY: cargo-vendor-crates
+cargo-vendor-crates:
+ @${STEP_MSG} "Extracting local cargo crates"
+ ${RUN}${MKDIR} ${WRKDIR}/.cargo
+ ${RUN}${PRINTF} "[source.crates-io]\nreplace-with = \"vendored-sources\"\n[source.vendored-sources]\ndirectory = \"${CARGO_VENDOR_DIR}\"\n" > ${WRKDIR}/.cargo/config.toml
+ ${RUN}${MKDIR} ${CARGO_VENDOR_DIR}
+.for crate in ${CARGO_CRATE_DEPENDS}
+ ${RUN}${PRINTF} '{"package":"%s","files":{}}' \
+ `${DIGEST} sha256 < ${_DISTDIR}/${crate}.crate` \
+ > ${CARGO_VENDOR_DIR}/${crate}/.cargo-checksum.json
+.endfor
+
+# Legacy name
+.PHONY: show-cargo-depends
+show-cargo-depends: print-cargo-depends
+
+.PHONY: print-cargo-depends
+print-cargo-depends:
+ ${RUN}${AWK} 'BEGIN {print "# $$Net" "BSD$$"; print;} \
+ /^name = / { split($$3, a, "\""); name=a[2]; } \
+ /^version = / { split($$3, a, "\""); vers=a[2]; } \
+ /^source = / { \
+ print "CARGO_CRATE_DEPENDS+=\t" name "-" vers; \
+ }' ${CARGO_WRKSRC}/Cargo.lock
+
+.if ${RUST_TYPE} == "native"
+CARGO= cargo
+.else
+CARGO= ${PREFIX}/bin/cargo
+.endif
+DEFAULT_CARGO_ARGS= --offline -j${_MAKE_JOBS_N} \
+ ${CARGO_NO_DEFAULT_FEATURES:M[yY][eE][sS]:C/[yY][eE][sS]/--no-default-features/} \
+ ${CARGO_FEATURES:C/.*/--features/W} \
+ ${CARGO_FEATURES:S/ /,/Wg}
+CARGO_ARGS?= build --release ${DEFAULT_CARGO_ARGS}
+CARGO_INSTALL_ARGS?= install --path . --root ${DESTDIR}${PREFIX} ${DEFAULT_CARGO_ARGS}
+
+MAKE_ENV+= RUSTFLAGS=${RUSTFLAGS:Q}
+ALL_ENV+= CARGO_HOME=${WRKDIR}
+
+.if !target(do-build)
+do-build: do-cargo-build
+.endif
+
+.PHONY: do-cargo-build
+do-cargo-build:
+ ${RUN} cd ${CARGO_WRKSRC} && ${SETENV} ${MAKE_ENV} ${CARGO} ${CARGO_ARGS}
+
+.if !target(do-install) && ${GNU_CONFIGURE:Uno:tl} == no
+do-install: do-cargo-install
+.endif
+
+.PHONY: do-cargo-install
+do-cargo-install:
+ ${RUN} cd ${CARGO_WRKSRC} && ${SETENV} ${MAKE_ENV} ${CARGO} ${CARGO_INSTALL_ARGS}
+ # remove files cargo uses for tracking installations
+ ${RM} -f ${DESTDIR}${PREFIX}/.crates.toml
+ ${RM} -f ${DESTDIR}${PREFIX}/.crates2.json
+
+.if ${OPSYS} == "Darwin"
+.PHONY: do-cargo-post-install-darwin-fix-rpath
+post-install: do-cargo-post-install-darwin-fix-rpath
+do-cargo-post-install-darwin-fix-rpath:
+ ${RUN} cd ${DESTDIR}; \
+ for i in $$(${FIND} .${PREFIX}/lib -name '*.so' | ${SED} -e 's|^\./||'); do \
+ install_name_tool -id /$$i $$i; \
+ done
+.endif
diff --git a/rust-beta/distinfo b/rust-beta/distinfo
new file mode 100644
index 0000000000..0038a85f6b
--- /dev/null
+++ b/rust-beta/distinfo
@@ -0,0 +1,41 @@
+$NetBSD$
+
+BLAKE2s (rust-1.94.1-x86_64-unknown-netbsd.tar.xz) = 0d31f0b6ec5958bcb4a3ca774f79c1a5b66f66a61c9f799891964bc00ee38c9a
+SHA512 (rust-1.94.1-x86_64-unknown-netbsd.tar.xz) = 517a8bc98c909a3310a90578999674014f6d4824c6890bed691d585290cd580367dae0215589a8cb3cd2c6f50dce22a0fa6835181e96f1ec5b2f10c80e62e0d2
+Size (rust-1.94.1-x86_64-unknown-netbsd.tar.xz) = 223382820 bytes
+BLAKE2s (rust-std-1.94.1-x86_64-unknown-netbsd.tar.xz) = 3a49b29eb06d6e05665c6d5cbfcae7ae66291d80acad4ed49be61e0ea6b8ef34
+SHA512 (rust-std-1.94.1-x86_64-unknown-netbsd.tar.xz) = 902f3783f06eae6a4206637c7f5b86c61227a677ff2762044c5549cb66fc785c75e131bc79bc6307899f02bf1c944b3dd6e026f55557c4f681054a7fadfb8532
+Size (rust-std-1.94.1-x86_64-unknown-netbsd.tar.xz) = 27392404 bytes
+BLAKE2s (rustc-beta-src.tar.xz) = eaa6cfb575edeca6ac05ae1c9e240de1bc919e9aa73aa7813dcd1653fd055b2f
+SHA512 (rustc-beta-src.tar.xz) = 56e1f3dbcfa7457ddedf4f33c6439c02efb1838af6767b37539752a4495f960a1ac456ce66fc65e1a81fad71efd15201fc3bdd639562b2536e182a801855f7be
+Size (rustc-beta-src.tar.xz) = 238923476 bytes
+SHA1 (patch-compiler_rustc__llvm_build.rs) = 3acef995e3038a98b29b31b9bdd43286b1ac29f7
+SHA1 (patch-library_backtrace_src_symbolize_gimli.rs) = 9d5ef634c5a454e474ea5fee76da9bb768f5b3d9
+SHA1 (patch-library_backtrace_src_symbolize_gimli_elf.rs) = 8b18e1dbde59f3e8f20e93c7669618b2c7a13294
+SHA1 (patch-src_bootstrap_bootstrap.py) = fb89adaaf01f558d636734db5d778af4a3c67fd6
+SHA1 (patch-src_bootstrap_src_core_build__steps_install.rs) = 5ecf4e371fa48bca72fa5b0adb55152c906bd813
+SHA1 (patch-src_bootstrap_src_core_builder_cargo.rs) = 47735f93b8694e772452b302b15ef8f82da4c86c
+SHA1 (patch-src_bootstrap_src_lib.rs) = 735a3f6cbb3054200dd55eebce6e9acbd285f51e
+SHA1 (patch-src_llvm-project_llvm_utils_FileCheck_FileCheck.cpp) = 2587c2f4d11ad8f75bf8a16de625135b26bacc15
+SHA1 (patch-src_tools_rust-installer_install-template.sh) = f222961e0fd4bac2f680f90d34a3e01864e3cebb
+SHA1 (patch-vendor_libc-0.2.155_src_unix_bsd_netbsdlike_netbsd_mod.rs) = 36d927a0c3fd6ef8d211da5389a981e077aedc29
+SHA1 (patch-vendor_libc-0.2.168_src_unix_bsd_netbsdlike_netbsd_mod.rs) = c5cd529719daee44aead47ffd97e682ca9d9a1ae
+SHA1 (patch-vendor_libc-0.2.169_src_unix_bsd_netbsdlike_netbsd_mod.rs) = 02c4efefbf1e9e1bd98eb9524515677250ae7454
+SHA1 (patch-vendor_lzma-sys-0.1.20_config.h) = 4849052ddb2f04f539fd7060fc1b43cc3acf99c4
+SHA1 (patch-vendor_openssl-src-111.28.2+1.1.1w_openssl_Configurations_10-main.conf) = 8fc746574f16cd3294edce99beffc3e8c03a089b
+SHA1 (patch-vendor_openssl-src-111.28.2+1.1.1w_openssl_crypto_aria_aria.c) = 1373d2e4ab609956e0e51ca3d900861caf3ee70d
+SHA1 (patch-vendor_openssl-src-111.28.2+1.1.1w_src_lib.rs) = c3260bfdd670c31845189fcb6b4ed19385a03b2a
+SHA1 (patch-vendor_openssl-src-300.5.0+3.5.0_openssl_Configurations_10-main.conf) = 49803c889864dbeccba92095b9fa6f104ff0180a
+SHA1 (patch-vendor_openssl-src-300.5.0+3.5.0_openssl_crypto_aria_aria.c) = 895b5f4d80fb714973f6d6fb1a39d89907e4976d
+SHA1 (patch-vendor_openssl-src-300.5.0+3.5.0_src_lib.rs) = 98e99556c19c055f696f0d9bfbce4aaf207b1640
+SHA1 (patch-vendor_openssl-src-300.5.4+3.5.4_openssl_Configurations_10-main.conf) = cf8ea96ca5e47d8b236e7de9d766badcda7494aa
+SHA1 (patch-vendor_openssl-src-300.5.4+3.5.4_openssl_crypto_aria_aria.c) = 3d3c52cad4faa7af77513eaab26b45ebfbcde906
+SHA1 (patch-vendor_openssl-src-300.5.4+3.5.4_src_lib.rs) = 69420384e4716666011bd2c183aa1dc282f24d85
+SHA1 (patch-vendor_openssl-sys-0.9.107_build_find__normal.rs) = b3de2b9137882e3612291057c1b7793a27de760f
+SHA1 (patch-vendor_openssl-sys-0.9.107_build_main.rs) = 46627c013821166688d16d97f6f8ff4ccb552241
+SHA1 (patch-vendor_openssl-sys-0.9.109_build_find__normal.rs) = 96b7b6067e857ef1ef4c8b832dcbe13496e21ca4
+SHA1 (patch-vendor_openssl-sys-0.9.109_build_main.rs) = bc892cf8e13b6b8c6e30804fa41696bcedbabde3
+SHA1 (patch-vendor_openssl-sys-0.9.111_build_find__normal.rs) = 7548f8ef9ae7e1771035814398d72bec867e59a7
+SHA1 (patch-vendor_openssl-sys-0.9.111_build_main.rs) = 87e4f6c55eaf88ebbc81ff927991d013bfca5a38
+SHA1 (patch-vendor_openssl-sys-0.9.92_build_find__normal.rs) = 0ed143b603eea7c0bddf39e97916608c58978202
+SHA1 (patch-vendor_openssl-sys-0.9.92_build_main.rs) = 842ad74284518fbe8ff65222f7f6f81fb6381e49
diff --git a/rust-beta/files/gcc-wrap b/rust-beta/files/gcc-wrap
new file mode 100644
index 0000000000..48cf4af822
--- /dev/null
+++ b/rust-beta/files/gcc-wrap
@@ -0,0 +1,215 @@
+#! /bin/sh
+
+# Root of targets tools + dest directories
+# or unset to default to a native build.
+
+# This script assumes target tools in $root/tools
+# and target's destdir in $root/dest, the result of a NetBSD build.sh.
+# ...or the native root, when we don't cross-compile
+root=${CROSS_ROOT:-/}
+
+incadd=""
+native=false
+if [ $root = "/" ]; then
+ native=true
+else
+ # What's the tools/bin prefix (if we're cross-building)?
+ gnuarch=${GNU_CROSS_TARGET:?}
+
+ # A special hack for netbsd-8 targets.
+ # netbsd-8 has gcc 5.5, but llvm and rust needs >= 7
+ # so we build tools from -9, and try to use that, but
+ # then the include path becomes wrong, and <stdatomic.h>
+ # is no longer picked up automatically by the compiler
+ # from the target destination directory
+ case $gnuarch in
+ sparc64*) incadd="-I=/usr/include/gcc-5"
+ ;;
+
+ # immintrin & from gcc-5 not
+ # compatible with gcc7, apparently
+ i[3456]86*) incadd="-I=/usr/include/gcc-7"
+ ;;
+
+ # mips64 does soft-float
+ mips64*) madd="-msoft-float"
+ ;;
+ powerpc*) # Now needed due to bloat
+ madd="-mlongcall"
+ ;;
+ m68k-*) # needed due to exceeding 16-bit offsets
+ # ref.
+ # relocation truncated to fit: R_68K_PC16 against ...
+ madd="-mlong-jump-table-offsets"
+ ;;
+ esac
+ # We build both for -8 and -9 due to ABI differences,
+ # so can't just test $gnuarch... Yes, a vile hack.
+ if [ "$root" = "/u/macppc" ]; then
+ incadd="-I=/usr/include/gcc-5"
+ fi
+fi
+
+# Who are we a wrapper for? (Typically either gcc or c++)
+who=$(basename $0 | sed -e 's/-wrap$//')
+
+args=""
+if [ ! -z "$madd" ]; then
+ args="$args $madd"
+fi
+
+# May need to add $linkadd before first -l or fist -L
+linkadd="-Wl,--sysroot=${root}/dest"
+# (perhaps this is overly cautious, other adjustments we do
+# below may be sufficient...)
+# Lib directories to ensure we search and have in run-path
+libs="/lib /usr/lib /usr/pkg/lib"
+
+for d in $libs; do
+ if ! $native; then
+ linkadd="$linkadd -L=$d"
+ linkadd="$linkadd -Wl,-rpath-link=${root}/dest/$d"
+ fi
+ # Run-path is for when we execute on the target,
+ # so no $root prefix
+ linkadd="$linkadd -Wl,-rpath,$d"
+done
+
+# ...and add a placeholder so we can tweak RPATH with chrpath,
+# since chrpath can't extend the length of the run path
+# (This may also not be needed, we use LD_LIBRARY_PATH instead)
+placeholder="placeholder-$(date | openssl dgst -sha1 | \
+ awk '{ print $2 }')"
+linkadd="$linkadd -Wl,-rpath,/$placeholder"
+# the / is a sneaky attempt to let it past cwrapper...
+
+# More debugging
+linkadd="$linkadd -Wl,--verbose"
+
+linktweaked=false
+
+# Step through args, tweak where required
+set -- "$@"
+while [ $# -gt 0 ]; do
+ case "$1" in
+# Insert = at the front of -isystem args.
+# This is to get --sysroot prepended, so that
+# we pick up the correct set of header files.
+# (I thought this wasn't reqired, but apparently it is...)
+ -isystem)
+ shift
+ case "$1" in
+ # Apparent mis-use of -isystem:
+ */siphash/*)
+ args="$args -I $1"
+ ;;
+ *)
+ args="$args -isystem =$1"
+ ;;
+ esac
+ ;;
+# Also doctor -I directives of known paths and
+# redirect them to the --sysroot.
+ -I/usr/include)
+ args="$args -I=/usr/include"
+ ;;
+ -I/usr/include/krb5)
+ args="$args -I=/usr/include/krb5"
+ ;;
+ -I/usr/pkg/include)
+# Try to drop this...
+ if ! $native; then
+ args="$args -I=/usr/pkg/include"
+ fi
+ ;;
+ -I)
+ if [ $2 = "/usr/include" ]; then
+ args="$args -I=/usr/include"
+ shift
+ elif [ $2 = "/usr/include/krb5" ]; then
+ args="$args -I=/usr/include/krb5"
+ shift
+ elif [ $2 = "/usr/pkg/include" ]; then
+# Try to drop this too...
+ if ! $native; then
+ args="$args -I=/usr/pkg/include"
+ fi
+ shift
+ else
+ args="$args -I"
+ fi
+ ;;
+ -l*)
+ if ! $linktweaked; then
+ args="$args $linkadd"
+ linktweaked=true
+ fi
+ args="$args $1"
+ ;;
+ -L)
+ if ! $linktweaked; then
+ args="$args $linkadd"
+ linktweaked=true
+ fi
+ shift
+ tweaked=false
+ # redirect these to -Wl,--sysroot
+ for d in /lib /usr/lib /usr/pkg/lib; do
+ if [ $1 = $d ]; then
+ args="$args -L =$d"
+ tweaked=true
+ fi
+ done
+ # Not redirected? If so we need to add
+ if ! $tweaked; then
+ args="$args -L $1"
+ fi
+ ;;
+
+ -L/lib)
+ if ! $linktweaked; then
+ args="$args $linkadd"
+ linktweaked=true
+ fi
+ args="$args -L=/lib"
+ ;;
+ -L/usr/lib)
+ if ! $linktweaked; then
+ args="$args $linkadd"
+ linktweaked=true
+ fi
+ args="$args -L=/usr/lib"
+ ;;
+ -L/usr/pkg/lib)
+ if ! $linktweaked; then
+ args="$args $linkadd"
+ linktweaked=true
+ fi
+ args="$args -L=/usr/pkg/lib"
+ ;;
+ -Wl,--enable-new-dtags)
+ # ignore
+ ;;
+ *)
+ args="$args $1"
+ ;;
+ esac
+ shift
+done
+
+if $native; then
+ # Try to avoid cwrappers, which does "undocumented magic"
+ # by invoking the compiler "directly".
+ #cmd="/usr/bin/${who} $args"
+ # (however, this wrapper isn't used when buliding natively...)
+ cmd="${who} $args"
+else
+ cmd="${root}/tools/bin/${gnuarch}-${who} \
+ --sysroot=${root}/dest \
+ $incadd \
+ $args"
+fi
+
+# Cannot echo to stdout, messes up e.g. "gcc -print-prog-name=ld" output...
+#echo $cmd >> /tmp/gcc-wrap.log
+exec $cmd
diff --git a/rust-beta/options.mk b/rust-beta/options.mk
new file mode 100644
index 0000000000..8f2b9af1fe
--- /dev/null
+++ b/rust-beta/options.mk
@@ -0,0 +1,48 @@
+# $NetBSD$
+
+PKG_OPTIONS_VAR= PKG_OPTIONS.rust
+PKG_SUPPORTED_OPTIONS+= rust-cargo-static rust-docs
+
+.include "../../mk/bsd.fast.prefs.mk"
+
+# The bundled LLVM is the supported choice; the external LLVM option is also
+# available.
+PKG_SUPPORTED_OPTIONS+= rust-internal-llvm
+.if !empty(HAVE_LLVM)
+PKG_SUGGESTED_OPTIONS+= rust-internal-llvm
+.endif
+
+PKG_OPTIONS_LEGACY_OPTS+= rust-llvm:rust-internal-llvm
+
+.include "../../mk/bsd.options.mk"
+
+# Use the internal copy of LLVM or the external one?
+.if empty(PKG_OPTIONS:Mrust-internal-llvm)
+.include "../../lang/libunwind/buildlink3.mk"
+.include "../../lang/llvm/buildlink3.mk"
+CONFIGURE_ARGS+= --enable-llvm-link-shared
+CONFIGURE_ARGS+= --llvm-libunwind=system
+CONFIGURE_ARGS+= --llvm-root=${BUILDLINK_PREFIX.llvm}
+# Also turn off build of the internal LLD, as the external LLVM
+# may be older (e.g., 18) than the internal LLD (now 19.x), ref.
+# https://github.com/rust-lang/rust/issues/131291
+CONFIGURE_ARGS+= --set rust.lld=false
+.endif
+
+# Link cargo statically against "native" libraries
+# (openssl and curl specifically).
+.if !empty(PKG_OPTIONS:Mrust-cargo-static)
+CONFIGURE_ARGS+= --enable-cargo-native-static
+.else
+BUILDLINK_API_DEPENDS.nghttp2+= nghttp2>=1.41.0
+BUILDLINK_API_DEPENDS.curl+= curl>=7.67.0
+.include "../../www/curl/buildlink3.mk"
+.include "../../security/openssl/buildlink3.mk"
+.endif
+
+# Install documentation.
+.if !empty(PKG_OPTIONS:Mrust-docs)
+CONFIGURE_ARGS+= --enable-docs
+.else
+CONFIGURE_ARGS+= --disable-docs
+.endif
diff --git a/rust-beta/patches/patch-compiler_rustc__llvm_build.rs b/rust-beta/patches/patch-compiler_rustc__llvm_build.rs
new file mode 100644
index 0000000000..096133453c
--- /dev/null
+++ b/rust-beta/patches/patch-compiler_rustc__llvm_build.rs
@@ -0,0 +1,50 @@
+$NetBSD: patch-compiler_rustc__llvm_build.rs,v 1.20 2025/08/25 17:51:12 wiz Exp $
+
+Fix build on NetBSD HEAD-llvm. XXX there is probably a better way to do this.
+
+Pick up -latomic tweak from
+https://github.com/rust-lang/rust/issues/104220
+and
+https://github.com/rust-lang/rust/pull/104572
+
+--- compiler/rustc_llvm/build.rs.orig 2023-10-03 02:52:17.000000000 +0000
++++ compiler/rustc_llvm/build.rs
+@@ -249,6 +249,10 @@ fn main() {
+ {
+ // 32-bit targets need to link libatomic.
+ println!("cargo:rustc-link-lib=atomic");
++ if target.contains("netbsd")
++ {
++ println!("cargo:rustc-link-lib=z");
++ }
+ } else if target.contains("windows-gnu") {
+ println!("cargo:rustc-link-lib=shell32");
+ println!("cargo:rustc-link-lib=uuid");
+@@ -261,7 +265,11 @@ fn main() {
+ // On NetBSD/i386, gcc and g++ is built for i486 (to maximize backward compat)
+ // However, LLVM insists on using 64-bit atomics.
+ // This gives rise to a need to link rust itself with -latomic for these targets
+- if target.starts_with("i586") || target.starts_with("i686") {
++ if target.starts_with("i386")
++ || target.starts_with("i486")
++ || target.starts_with("i586")
++ || target.starts_with("i686")
++ {
+ println!("cargo:rustc-link-lib=atomic");
+ }
+ println!("cargo:rustc-link-lib=z");
+@@ -352,7 +360,13 @@ fn main() {
+ "c++"
+ } else if target.contains("netbsd") && llvm_static_stdcpp.is_some() {
+ // NetBSD uses a separate library when relocation is required
+- "stdc++_p"
++ if env::var_os("PKGSRC_HAVE_LIBCPP").is_some() {
++ "c++_pic"
++ } else {
++ "stdc++_pic"
++ }
++ } else if env::var_os("PKGSRC_HAVE_LIBCPP").is_some() {
++ "c++"
+ } else if llvm_use_libcxx.is_some() {
+ "c++"
+ } else {
diff --git a/rust-beta/patches/patch-library_backtrace_src_symbolize_gimli.rs b/rust-beta/patches/patch-library_backtrace_src_symbolize_gimli.rs
new file mode 100644
index 0000000000..76eba086d0
--- /dev/null
+++ b/rust-beta/patches/patch-library_backtrace_src_symbolize_gimli.rs
@@ -0,0 +1,14 @@
+$NetBSD: patch-library_backtrace_src_symbolize_gimli.rs,v 1.9 2025/08/25 17:51:12 wiz Exp $
+
+Add NetBSD to the family who is in the unix class.
+
+--- library/backtrace/src/symbolize/gimli.rs.orig 2006-07-24 01:21:28.000000000 +0000
++++ library/backtrace/src/symbolize/gimli.rs
+@@ -40,6 +40,7 @@ cfg_if::cfg_if! {
+ target_os = "haiku",
+ target_os = "hurd",
+ target_os = "linux",
++ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "solaris",
+ target_os = "illumos",
diff --git a/rust-beta/patches/patch-library_backtrace_src_symbolize_gimli_elf.rs b/rust-beta/patches/patch-library_backtrace_src_symbolize_gimli_elf.rs
new file mode 100644
index 0000000000..ced576df71
--- /dev/null
+++ b/rust-beta/patches/patch-library_backtrace_src_symbolize_gimli_elf.rs
@@ -0,0 +1,26 @@
+$NetBSD: patch-library_backtrace_src_symbolize_gimli_elf.rs,v 1.10 2025/08/25 17:51:12 wiz Exp $
+
+Make NetBSD also find its debug libraries, if present.
+
+--- library/backtrace/src/symbolize/gimli/elf.rs.orig 2022-04-04 09:41:26.000000000 +0000
++++ library/backtrace/src/symbolize/gimli/elf.rs
+@@ -395,11 +395,18 @@ fn decompress_zstd(mut input: &[u8], mut
+ Some(())
+ }
+
++#[cfg(target_os = "netbsd")]
++const DEBUG_PATH: &str = "/usr/libdata/debug";
++#[cfg(not(target_os = "netbsd"))]
+ const DEBUG_PATH: &str = "/usr/lib/debug";
+
+ fn debug_path_exists() -> bool {
+ cfg_if::cfg_if! {
+- if #[cfg(any(target_os = "freebsd", target_os = "hurd", target_os = "linux"))] {
++ if #[cfg(any(target_os = "freebsd",
++ target_os = "netbsd",
++ target_os = "hurd",
++ target_os = "linux"
++ ))] {
+ use core::sync::atomic::{AtomicU8, Ordering};
+ static DEBUG_PATH_EXISTS: AtomicU8 = AtomicU8::new(0);
+
diff --git a/rust-beta/patches/patch-src_bootstrap_bootstrap.py b/rust-beta/patches/patch-src_bootstrap_bootstrap.py
new file mode 100644
index 0000000000..d7d8d0ad43
--- /dev/null
+++ b/rust-beta/patches/patch-src_bootstrap_bootstrap.py
@@ -0,0 +1,48 @@
+$NetBSD: patch-src_bootstrap_bootstrap.py,v 1.28 2026/01/13 20:48:23 wiz Exp $
+
+Use `uname -p` on NetBSD, as that is reliable and sensible there.
+Use @PREFIX@ and not $ORIGIN in rpath.
+
+--- src/bootstrap/bootstrap.py.orig 2025-10-28 16:34:16.000000000 +0000
++++ src/bootstrap/bootstrap.py
+@@ -330,6 +330,11 @@ def default_build_triple(verbose):
+ "GNU": "unknown-hurd",
+ }
+
++ # For NetBSD, use `uname -p`, as there it is reliable & sensible
++ if kernel == 'NetBSD':
++ cputype = subprocess.check_output(
++ ['uname', '-p']).strip().decode(default_encoding)
++
+ # Consider the direct transformation first and then the special cases
+ if kernel in kerneltype_mapper:
+ kernel = kerneltype_mapper[kernel]
+@@ -706,11 +711,11 @@ class RustBuild(object):
+ )
+ p = Pool(pool_size)
+ try:
+- # FIXME: A cheap workaround for https://github.com/rust-lang/rust/issues/125578,
+- # remove this once the issue is closed.
+- bootstrap_build_artifacts = os.path.join(self.bootstrap_out(), "debug")
+- if os.path.exists(bootstrap_build_artifacts):
+- shutil.rmtree(bootstrap_build_artifacts)
++# # FIXME: A cheap workaround for https://github.com/rust-lang/rust/issues/125578,
++# # remove this once the issue is closed.
++# bootstrap_build_artifacts = os.path.join(self.bootstrap_out(), "debug")
++# if os.path.exists(bootstrap_build_artifacts):
++# shutil.rmtree(bootstrap_build_artifacts)
+
+ p.map(unpack_component, tarballs_download_info)
+ finally:
+@@ -857,7 +862,10 @@ class RustBuild(object):
+ self.nix_deps_dir = nix_deps_dir
+
+ patchelf = "{}/bin/patchelf".format(nix_deps_dir)
+- rpath_entries = [os.path.join(os.path.realpath(nix_deps_dir), "lib")]
++ rpath_entries = [
++ "@PREFIX@/lib",
++ os.path.join(os.path.realpath(nix_deps_dir), "lib")
++ ]
+ patchelf_args = ["--add-rpath", ":".join(rpath_entries)]
+ if ".so" not in fname:
+ # Finally, set the correct .interp for binaries
diff --git a/rust-beta/patches/patch-src_bootstrap_src_core_build__steps_install.rs b/rust-beta/patches/patch-src_bootstrap_src_core_build__steps_install.rs
new file mode 100644
index 0000000000..2b14fb1b9e
--- /dev/null
+++ b/rust-beta/patches/patch-src_bootstrap_src_core_build__steps_install.rs
@@ -0,0 +1,15 @@
+$NetBSD: patch-src_bootstrap_src_core_build__steps_install.rs,v 1.5 2026/04/02 19:06:34 wiz Exp $
+
+Drop "docs" from installation (takes forever), add "rust".
+
+--- src/bootstrap/src/core/build_steps/install.rs.orig 2025-10-28 16:34:16.000000000 +0000
++++ src/bootstrap/src/core/build_steps/install.rs
+@@ -206,7 +206,7 @@ macro_rules! install {
+ install!((self, builder, _config),
+ Docs, path = "src/doc", _config.docs, IS_HOST: false, {
+ let tarball = builder.ensure(dist::Docs { host: self.target }).expect("missing docs");
+- install_sh(builder, "docs", self.build_compiler, Some(self.target), &tarball);
++ install_sh(builder, "rust", self.build_compiler, Some(self.target), &tarball);
+ };
+ Std, path = "library/std", true, IS_HOST: false, {
+ // `expect` should be safe, only None when host != build, but this
diff --git a/rust-beta/patches/patch-src_bootstrap_src_core_builder_cargo.rs b/rust-beta/patches/patch-src_bootstrap_src_core_builder_cargo.rs
new file mode 100644
index 0000000000..9a30513d86
--- /dev/null
+++ b/rust-beta/patches/patch-src_bootstrap_src_core_builder_cargo.rs
@@ -0,0 +1,26 @@
+$NetBSD$
+
+Find external libunwind and libLLVM in pkgsrc (not just Linux).
+Use @PREFIX@ in rpath.
+
+--- src/bootstrap/src/core/builder/cargo.rs.orig 2026-04-08 12:20:36.460289424 +0000
++++ src/bootstrap/src/core/builder/cargo.rs
+@@ -299,7 +299,7 @@ impl Cargo {
+ && !target.contains("xous")
+ {
+ self.rustflags.arg("-Clink-args=-Wl,-z,origin");
+- Some(format!("-Wl,-rpath,$ORIGIN/../{libdir}"))
++ Some(format!("-Wl,-rpath,@PREFIX@/lib"))
+ } else {
+ None
+ };
+@@ -1421,6 +1421,9 @@ impl Builder<'_> {
+ (_, false) => Some("dev"),
+ }
+ };
++
++ // added for pkgsrc libunwind or external LLVM
++ rustflags.arg("-Clink-args=-Wl,-rpath,@PREFIX@/lib,-L@PREFIX@/lib");
+
+ Cargo {
+ command: cargo,
diff --git a/rust-beta/patches/patch-src_bootstrap_src_lib.rs b/rust-beta/patches/patch-src_bootstrap_src_lib.rs
new file mode 100644
index 0000000000..9f8eabe566
--- /dev/null
+++ b/rust-beta/patches/patch-src_bootstrap_src_lib.rs
@@ -0,0 +1,40 @@
+$NetBSD: patch-src_bootstrap_src_lib.rs,v 1.10 2026/01/14 06:44:31 wiz Exp $
+
+Don't filter out optimization flags.
+FreeBSD has a particular C++ runtime library name.
+Don't assume files in ${PREFIX}/lib are readable by the building user.
+
+--- src/bootstrap/src/lib.rs.orig 2025-09-14 15:05:11.000000000 +0000
++++ src/bootstrap/src/lib.rs
+@@ -1256,7 +1256,6 @@ impl Build {
+ base.args()
+ .iter()
+ .map(|s| s.to_string_lossy().into_owned())
+- .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
+ .collect::<Vec<String>>()
+ }
+
+@@ -1272,7 +1271,8 @@ impl Build {
+ // If we're compiling C++ on macOS then we add a flag indicating that
+ // we want libc++ (more filled out than libstdc++), ensuring that
+ // LLVM/etc are all properly compiled.
+- if matches!(c, CLang::Cxx) && target.contains("apple-darwin") {
++ if matches!(c, CLang::Cxx) &&
++ (target.contains("apple-darwin") || target.contains("freebsd")) {
+ base.push("-stdlib=libc++".into());
+ }
+
+@@ -1813,7 +1813,12 @@ impl Build {
+ // but if that fails just fall back to a slow `copy` operation.
+ } else {
+ if let Err(e) = fs::copy(&src, dst) {
+- panic!("failed to copy `{}` to `{}`: {}", src.display(), dst.display(), e)
++ if e.kind() == io::ErrorKind::PermissionDenied {
++ eprintln!("Skipping copy of `{}` to `{}`: {}", src.display(), dst.display(), e);
++ return;
++ } else {
++ panic!("failed to copy `{}` to `{}`: {}", src.display(), dst.display(), e)
++ }
+ }
+ t!(fs::set_permissions(dst, metadata.permissions()));
+
diff --git a/rust-beta/patches/patch-src_llvm-project_llvm_utils_FileCheck_FileCheck.cpp b/rust-beta/patches/patch-src_llvm-project_llvm_utils_FileCheck_FileCheck.cpp
new file mode 100644
index 0000000000..e255aa5af9
--- /dev/null
+++ b/rust-beta/patches/patch-src_llvm-project_llvm_utils_FileCheck_FileCheck.cpp
@@ -0,0 +1,15 @@
+$NetBSD: patch-src_llvm-project_llvm_utils_FileCheck_FileCheck.cpp,v 1.13 2024/04/18 09:29:42 pin Exp $
+
+Avoid ambiguous function call.
+
+--- src/llvm-project/llvm/utils/FileCheck/FileCheck.cpp.orig 2019-02-12 15:22:48.000000000 +0000
++++ src/llvm-project/llvm/utils/FileCheck/FileCheck.cpp
+@@ -592,7 +592,7 @@ static void DumpAnnotatedInput(raw_ostre
+ unsigned LineCount = InputFileText.count('\n');
+ if (InputFileEnd[-1] != '\n')
+ ++LineCount;
+- unsigned LineNoWidth = std::log10(LineCount) + 1;
++ unsigned LineNoWidth = std::log10((float)LineCount) + 1;
+ // +3 below adds spaces (1) to the left of the (right-aligned) line numbers
+ // on input lines and (2) to the right of the (left-aligned) labels on
+ // annotation lines so that input lines and annotation lines are more
diff --git a/rust-beta/patches/patch-src_tools_rust-installer_install-template.sh b/rust-beta/patches/patch-src_tools_rust-installer_install-template.sh
new file mode 100644
index 0000000000..2cbfd02690
--- /dev/null
+++ b/rust-beta/patches/patch-src_tools_rust-installer_install-template.sh
@@ -0,0 +1,72 @@
+$NetBSD: patch-src_tools_rust-installer_install-template.sh,v 1.15 2026/04/02 19:06:34 wiz Exp $
+
+No logging to 'install.log'.
+Do not create 'uninstall.sh'.
+Do not make file backups (filename.old), so these will not end up in the final package.
+
+Rewrite to not use a whole lot of subprocesses just for doing
+pattern matching and substitution in the install phase using "grep"
+and "sed" when shell builtin "case" and "omit shortest match" ops
+should do just fine.
+
+--- src/tools/rust-installer/install-template.sh.orig 2023-12-21 16:55:28.000000000 +0000
++++ src/tools/rust-installer/install-template.sh
+@@ -6,20 +6,12 @@ set -u
+ init_logging() {
+ local _abs_libdir="$1"
+ local _logfile="$_abs_libdir/$TEMPLATE_REL_MANIFEST_DIR/install.log"
+- rm -f "$_logfile"
+- need_ok "failed to remove old installation log"
+- touch "$_logfile"
+- need_ok "failed to create installation log"
+ LOGFILE="$_logfile"
+ }
+
+ log_line() {
+ local _line="$1"
+
+- if [ -n "${LOGFILE-}" -a -e "${LOGFILE-}" ]; then
+- echo "$_line" >> "$LOGFILE"
+- # Ignore errors, which may happen e.g. after the manifest dir is deleted
+- fi
+ }
+
+ msg() {
+@@ -433,8 +425,8 @@ uninstall_components() {
+ local _directive
+ while read _directive; do
+
+- local _command=`echo $_directive | cut -f1 -d:`
+- local _file=`echo $_directive | cut -f2 -d:`
++ local _command="${_directive%%:*}"
++ local _file="${_directive#*:}"
+
+ # Sanity checks
+ if [ ! -n "$_command" ]; then critical_err "malformed installation directive"; fi
+@@ -541,8 +533,8 @@ install_components() {
+ local _directive
+ while read _directive; do
+
+- local _command=`echo $_directive | cut -f1 -d:`
+- local _file=`echo $_directive | cut -f2 -d:`
++ local _command="${_directive%%:*}"
++ local _file="${_directive#*:}"
+
+ # Sanity checks
+ if [ ! -n "$_command" ]; then critical_err "malformed installation directive"; fi
+@@ -628,7 +620,6 @@ install_components() {
+
+ verbose_msg "copying directory $_file_install_path"
+
+- maybe_backup_path "$_file_install_path"
+
+ run cp -R "$_src_dir/$_component/$_file" "$_file_install_path"
+ critical_need_ok "failed to copy directory"
+@@ -977,7 +968,6 @@ write_to_file "$TEMPLATE_RUST_INSTALLER_
+ critical_need_ok "failed to write installer version"
+
+ # Install the uninstaller
+-install_uninstaller "$src_dir" "$src_basename" "$abs_libdir"
+
+ # Install each component
+ install_components "$src_dir" "$abs_libdir" "$dest_prefix" "$components"
diff --git a/rust-beta/patches/patch-vendor_libc-0.2.155_src_unix_bsd_netbsdlike_netbsd_mod.rs b/rust-beta/patches/patch-vendor_libc-0.2.155_src_unix_bsd_netbsdlike_netbsd_mod.rs
new file mode 100644
index 0000000000..24c498026b
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_libc-0.2.155_src_unix_bsd_netbsdlike_netbsd_mod.rs
@@ -0,0 +1,15 @@
+$NetBSD: patch-vendor_libc-0.2.155_src_unix_bsd_netbsdlike_netbsd_mod.rs,v 1.2 2025/08/25 17:51:12 wiz Exp $
+
+Apply https://github.com/rust-lang/libc/pull/4265/files
+to fix getmntinfo() from rust.
+
+--- vendor/libc-0.2.155/src/unix/bsd/netbsdlike/netbsd/mod.rs.orig 2025-02-14 14:04:45.438043897 +0000
++++ vendor/libc-0.2.155/src/unix/bsd/netbsdlike/netbsd/mod.rs
+@@ -3142,6 +3142,7 @@ cfg_if! {
+ if #[cfg(libc_union)] {
+ extern {
+ // these functions use statvfs:
++ #[link_name = "__getmntinfo13"]
+ pub fn getmntinfo(mntbufp: *mut *mut ::statvfs, flags: ::c_int) -> ::c_int;
+ pub fn getvfsstat(buf: *mut statvfs, bufsize: ::size_t, flags: ::c_int) -> ::c_int;
+ }
diff --git a/rust-beta/patches/patch-vendor_libc-0.2.168_src_unix_bsd_netbsdlike_netbsd_mod.rs b/rust-beta/patches/patch-vendor_libc-0.2.168_src_unix_bsd_netbsdlike_netbsd_mod.rs
new file mode 100644
index 0000000000..b33dd8a12f
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_libc-0.2.168_src_unix_bsd_netbsdlike_netbsd_mod.rs
@@ -0,0 +1,15 @@
+$NetBSD: patch-vendor_libc-0.2.168_src_unix_bsd_netbsdlike_netbsd_mod.rs,v 1.3 2026/01/13 20:48:23 wiz Exp $
+
+Apply https://github.com/rust-lang/libc/pull/4265/files
+to fix getmntinfo() from rust.
+
+--- vendor/libc-0.2.168/src/unix/bsd/netbsdlike/netbsd/mod.rs.orig 2025-04-05 11:35:20.818765987 +0000
++++ vendor/libc-0.2.168/src/unix/bsd/netbsdlike/netbsd/mod.rs
+@@ -2850,6 +2850,7 @@ extern "C" {
+ hint: *const c_void,
+ ) -> c_int;
+
++ #[link_name = "__getmntinfo13"]
+ pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int;
+ pub fn getvfsstat(buf: *mut statvfs, bufsize: size_t, flags: c_int) -> c_int;
+ }
diff --git a/rust-beta/patches/patch-vendor_libc-0.2.169_src_unix_bsd_netbsdlike_netbsd_mod.rs b/rust-beta/patches/patch-vendor_libc-0.2.169_src_unix_bsd_netbsdlike_netbsd_mod.rs
new file mode 100644
index 0000000000..b4de45f7bb
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_libc-0.2.169_src_unix_bsd_netbsdlike_netbsd_mod.rs
@@ -0,0 +1,15 @@
+$NetBSD: patch-vendor_libc-0.2.169_src_unix_bsd_netbsdlike_netbsd_mod.rs,v 1.2 2025/08/25 17:51:12 wiz Exp $
+
+Apply https://github.com/rust-lang/libc/pull/4265/files
+to fix getmntinfo() from rust.
+
+--- vendor/libc-0.2.169/src/unix/bsd/netbsdlike/netbsd/mod.rs.orig 2025-02-14 14:04:45.438043897 +0000
++++ vendor/libc-0.2.169/src/unix/bsd/netbsdlike/netbsd/mod.rs
+@@ -2850,6 +2850,7 @@ extern "C" {
+ hint: *const c_void,
+ ) -> c_int;
+
++ #[link_name = "__getmntinfo13"]
+ pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int;
+ pub fn getvfsstat(buf: *mut statvfs, bufsize: size_t, flags: c_int) -> c_int;
+ }
diff --git a/rust-beta/patches/patch-vendor_lzma-sys-0.1.20_config.h b/rust-beta/patches/patch-vendor_lzma-sys-0.1.20_config.h
new file mode 100644
index 0000000000..e2824c4f23
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_lzma-sys-0.1.20_config.h
@@ -0,0 +1,25 @@
+$NetBSD: patch-vendor_lzma-sys-0.1.20_config.h,v 1.2 2025/08/25 17:51:13 wiz Exp $
+
+clock_gettime() is available also on NetBSD.
+
+This takes care of this build error:
+
+ cargo:warning=xz-5.2/src/common/mythread.h: In function 'mythread_condtime_set':
+ cargo:warning=xz-5.2/src/common/mythread.h:312:9: error: implicit declaration of function 'gettimeofday' [-Wimplicit-function-declaration]
+ cargo:warning= 312 | gettimeofday(&now, NULL);
+ cargo:warning= | ^~~~~~~~~~~~
+
+which popped up when switching powerpc to using gcc14, but strangely
+was not triggered by gcc12 or in-tree gcc.
+
+--- vendor/lzma-sys-0.1.20/config.h.orig 2025-02-11 23:15:56.129312069 +0000
++++ vendor/lzma-sys-0.1.20/config.h
+@@ -39,7 +39,7 @@
+ #define MYTHREAD_POSIX 1
+ #endif
+
+-#if defined(__sun)
++#if defined(__sun) || defined(__NetBSD__)
+ #define HAVE_CLOCK_GETTIME 1
+ #define HAVE_DECL_CLOCK_MONOTONIC 1
+ #endif
diff --git a/rust-beta/patches/patch-vendor_openssl-src-111.28.2+1.1.1w_openssl_Configurations_10-main.conf b/rust-beta/patches/patch-vendor_openssl-src-111.28.2+1.1.1w_openssl_Configurations_10-main.conf
new file mode 100644
index 0000000000..73143bcc7b
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-src-111.28.2+1.1.1w_openssl_Configurations_10-main.conf
@@ -0,0 +1,18 @@
+$NetBSD: patch-vendor_openssl-src-111.28.2+1.1.1w_openssl_Configurations_10-main.conf,v 1.4 2025/10/18 17:14:36 he Exp $
+
+Replicate part of
+https://github.com/openssl/openssl/pull/15086
+
+--- vendor/openssl-src-111.28.2+1.1.1w/openssl/Configurations/10-main.conf.orig 2025-05-18 13:23:47.013841572 +0000
++++ vendor/openssl-src-111.28.2+1.1.1w/openssl/Configurations/10-main.conf
+@@ -943,6 +943,10 @@ my %targets = (
+ shared_cflag => "-fPIC",
+ shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
+ },
++ "NetBSD-generic32" => {
++ inherit_from => [ "BSD-generic32" ],
++ ex_libs => add(threads("-latomic")),
++ },
+ "BSD-generic64" => {
+ inherit_from => [ "BSD-generic32" ],
+ bn_ops => "SIXTY_FOUR_BIT_LONG",
diff --git a/rust-beta/patches/patch-vendor_openssl-src-111.28.2+1.1.1w_openssl_crypto_aria_aria.c b/rust-beta/patches/patch-vendor_openssl-src-111.28.2+1.1.1w_openssl_crypto_aria_aria.c
new file mode 100644
index 0000000000..9f96455bcb
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-src-111.28.2+1.1.1w_openssl_crypto_aria_aria.c
@@ -0,0 +1,18 @@
+$NetBSD: patch-vendor_openssl-src-111.28.2+1.1.1w_openssl_crypto_aria_aria.c,v 1.1 2025/10/18 17:14:36 he Exp $
+
+Make this build if bswap32 is already defined, as for NetBSD/i586.
+
+--- vendor/openssl-src-111.28.2+1.1.1w/openssl/crypto/aria/aria.c.orig 2025-05-19 20:01:02.477323075 +0000
++++ vendor/openssl-src-111.28.2+1.1.1w/openssl/crypto/aria/aria.c
+@@ -32,9 +32,11 @@
+ #define rotl32(v, r) (((uint32_t)(v) << (r)) | ((uint32_t)(v) >> (32 - r)))
+ #define rotr32(v, r) (((uint32_t)(v) >> (r)) | ((uint32_t)(v) << (32 - r)))
+
++#ifndef bswap32
+ #define bswap32(v) \
+ (((v) << 24) ^ ((v) >> 24) ^ \
+ (((v) & 0x0000ff00) << 8) ^ (((v) & 0x00ff0000) >> 8))
++#endif
+
+ #define GET_U8_BE(X, Y) ((uint8_t)((X) >> ((3 - Y) * 8)))
+ #define GET_U32_BE(X, Y) ( \
diff --git a/rust-beta/patches/patch-vendor_openssl-src-111.28.2+1.1.1w_src_lib.rs b/rust-beta/patches/patch-vendor_openssl-src-111.28.2+1.1.1w_src_lib.rs
new file mode 100644
index 0000000000..278b50f295
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-src-111.28.2+1.1.1w_src_lib.rs
@@ -0,0 +1,67 @@
+$NetBSD: patch-vendor_openssl-src-111.28.2+1.1.1w_src_lib.rs,v 1.5 2026/04/02 19:06:35 wiz Exp $
+
+Add the various NetBSD targets.
+
+--- vendor/openssl-src-111.28.2+1.1.1w/src/lib.rs.orig 2026-02-11 07:30:54.000000000 +0000
++++ vendor/openssl-src-111.28.2+1.1.1w/src/lib.rs
+@@ -239,6 +239,8 @@ impl Build {
+ "aarch64-unknown-freebsd" => "BSD-generic64",
+ "aarch64-unknown-linux-gnu" => "linux-aarch64",
+ "aarch64-unknown-linux-musl" => "linux-aarch64",
++ "aarch64-unknown-netbsd" => "BSD-generic64",
++ "aarch64_be-unknown-netbsd" => "BSD-generic64",
+ "aarch64-pc-windows-msvc" => "VC-WIN64-ARM",
+ "arm-linux-androideabi" => "linux-armv4",
+ "armv7-linux-androideabi" => "linux-armv4",
+@@ -249,14 +251,17 @@ impl Build {
+ "armv5te-unknown-linux-gnueabi" => "linux-armv4",
+ "armv5te-unknown-linux-musleabi" => "linux-armv4",
+ "armv6-unknown-freebsd" => "BSD-generic32",
++ "armv6-unknown-netbsd-eabihf" => "BSD-generic32",
+ "armv7-unknown-freebsd" => "BSD-generic32",
+ "armv7-unknown-linux-gnueabi" => "linux-armv4",
+ "armv7-unknown-linux-musleabi" => "linux-armv4",
+ "armv7-unknown-linux-gnueabihf" => "linux-armv4",
+ "armv7-unknown-linux-musleabihf" => "linux-armv4",
++ "armv7-unknown-netbsd-eabihf" => "BSD-generic32",
+ "asmjs-unknown-emscripten" => "gcc",
+ "i586-unknown-linux-gnu" => "linux-elf",
+ "i586-unknown-linux-musl" => "linux-elf",
++ "i586-unknown-netbsd" => "BSD-x86-elf",
+ "i686-apple-darwin" => "darwin-i386-cc",
+ "i686-linux-android" => "linux-elf",
+ "i686-pc-windows-gnu" => "mingw",
+@@ -264,8 +269,10 @@ impl Build {
+ "i686-unknown-freebsd" => "BSD-x86-elf",
+ "i686-unknown-linux-gnu" => "linux-elf",
+ "i686-unknown-linux-musl" => "linux-elf",
++ "i686-unknown-netbsd" => "BSD-x86-elf",
+ "loongarch64-unknown-linux-gnu" => "linux-generic64",
+ "loongarch64-unknown-linux-musl" => "linux-generic64",
++ "m68k-unknown-netbsd" => NetBSD-generic32,
+ "mips-unknown-linux-gnu" => "linux-mips32",
+ "mips-unknown-linux-musl" => "linux-mips32",
+ "mips64-unknown-linux-gnuabi64" => "linux64-mips64",
+@@ -274,9 +281,11 @@ impl Build {
+ "mips64el-unknown-linux-muslabi64" => "linux64-mips64",
+ "mipsel-unknown-linux-gnu" => "linux-mips32",
+ "mipsel-unknown-linux-musl" => "linux-mips32",
++ "mipsel-unknown-netbsd" => "NetBSD-generic32",
+ "powerpc-unknown-freebsd" => "BSD-generic32",
+ "powerpc-unknown-linux-gnu" => "linux-ppc",
+ "powerpc-unknown-linux-gnuspe" => "linux-ppc",
++ "powerpc-unknown-netbsd" => "NetBSD-generic32",
+ "powerpc64-unknown-freebsd" => "BSD-generic64",
+ "powerpc64-unknown-linux-gnu" => "linux-ppc64",
+ "powerpc64-unknown-linux-musl" => "linux-ppc64",
+@@ -284,8 +293,10 @@ impl Build {
+ "powerpc64le-unknown-linux-gnu" => "linux-ppc64le",
+ "powerpc64le-unknown-linux-musl" => "linux-ppc64le",
+ "riscv64gc-unknown-linux-gnu" => "linux-generic64",
++ "riscv64gc-unknown-netbsd" => "BSD-generic64",
+ "s390x-unknown-linux-gnu" => "linux64-s390x",
+ "s390x-unknown-linux-musl" => "linux64-s390x",
++ "sparc64-unknown-netbsd" => "BSD-generic64",
+ "x86_64-apple-darwin" => "darwin64-x86_64-cc",
+ "x86_64-linux-android" => "linux-x86_64",
+ "x86_64-pc-windows-gnu" => "mingw64",
diff --git a/rust-beta/patches/patch-vendor_openssl-src-300.5.0+3.5.0_openssl_Configurations_10-main.conf b/rust-beta/patches/patch-vendor_openssl-src-300.5.0+3.5.0_openssl_Configurations_10-main.conf
new file mode 100644
index 0000000000..8b8658489d
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-src-300.5.0+3.5.0_openssl_Configurations_10-main.conf
@@ -0,0 +1,18 @@
+$NetBSD: patch-vendor_openssl-src-300.5.0+3.5.0_openssl_Configurations_10-main.conf,v 1.1 2025/10/18 17:14:36 he Exp $
+
+Replicate part of
+https://github.com/openssl/openssl/pull/15086
+
+--- vendor/openssl-src-300.5.0+3.5.0/openssl/Configurations/10-main.conf.orig 2025-05-20 09:03:49.120083364 +0000
++++ vendor/openssl-src-300.5.0+3.5.0/openssl/Configurations/10-main.conf
+@@ -1033,6 +1033,10 @@ my %targets = (
+ shared_target => "bsd-gcc-shared",
+ shared_cflag => "-fPIC",
+ },
++ "NetBSD-generic32" => {
++ inherit_from => [ "BSD-generic32" ],
++ ex_libs => add(threads("-latomic")),
++ },
+ "BSD-generic64" => {
+ inherit_from => [ "BSD-generic32" ],
+ bn_ops => "SIXTY_FOUR_BIT_LONG",
diff --git a/rust-beta/patches/patch-vendor_openssl-src-300.5.0+3.5.0_openssl_crypto_aria_aria.c b/rust-beta/patches/patch-vendor_openssl-src-300.5.0+3.5.0_openssl_crypto_aria_aria.c
new file mode 100644
index 0000000000..77c8b0f3e0
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-src-300.5.0+3.5.0_openssl_crypto_aria_aria.c
@@ -0,0 +1,18 @@
+$NetBSD: patch-vendor_openssl-src-300.5.0+3.5.0_openssl_crypto_aria_aria.c,v 1.1 2025/10/18 17:14:36 he Exp $
+
+Make this build also if bswap32 is already defined, as for NetBSD/i586.
+
+--- vendor/openssl-src-300.5.0+3.5.0/openssl/crypto/aria/aria.c.orig 2025-05-19 20:04:00.808387729 +0000
++++ vendor/openssl-src-300.5.0+3.5.0/openssl/crypto/aria/aria.c
+@@ -32,9 +32,11 @@
+ #define rotl32(v, r) (((uint32_t)(v) << (r)) | ((uint32_t)(v) >> (32 - r)))
+ #define rotr32(v, r) (((uint32_t)(v) >> (r)) | ((uint32_t)(v) << (32 - r)))
+
++#ifndef bswap32
+ #define bswap32(v) \
+ (((v) << 24) ^ ((v) >> 24) ^ \
+ (((v) & 0x0000ff00) << 8) ^ (((v) & 0x00ff0000) >> 8))
++#endif
+
+ #define GET_U8_BE(X, Y) ((uint8_t)((X) >> ((3 - Y) * 8)))
+ #define GET_U32_BE(X, Y) ( \
diff --git a/rust-beta/patches/patch-vendor_openssl-src-300.5.0+3.5.0_src_lib.rs b/rust-beta/patches/patch-vendor_openssl-src-300.5.0+3.5.0_src_lib.rs
new file mode 100644
index 0000000000..11a1eaf2db
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-src-300.5.0+3.5.0_src_lib.rs
@@ -0,0 +1,30 @@
+$NetBSD: patch-vendor_openssl-src-300.5.0+3.5.0_src_lib.rs,v 1.2 2026/04/02 19:06:35 wiz Exp $
+
+Make this build on NetBSD for arm6, mipsel and m68k as well.
+
+--- vendor/openssl-src-300.5.0+3.5.0/src/lib.rs.orig 2026-02-11 07:30:54.000000000 +0000
++++ vendor/openssl-src-300.5.0+3.5.0/src/lib.rs
+@@ -321,6 +321,7 @@ impl Build {
+ "armv5te-unknown-linux-gnueabi" => "linux-armv4",
+ "armv5te-unknown-linux-musleabi" => "linux-armv4",
+ "armv6-unknown-freebsd" => "BSD-generic32",
++ "armv6-unknown-netbsd-eabihf" => "BSD-generic32",
+ "armv6-alpine-linux-musleabihf" => "linux-armv6",
+ "armv7-unknown-freebsd" => "BSD-armv4",
+ "armv7-unknown-linux-gnueabi" => "linux-armv4",
+@@ -348,6 +349,7 @@ impl Build {
+ "i686-uwp-windows-msvc" => "VC-WIN32-UWP",
+ "loongarch64-unknown-linux-gnu" => "linux-generic64",
+ "loongarch64-unknown-linux-musl" => "linux-generic64",
++ "m68k-unknown-netbsd" => "NetBSD-generic32",
+ "mips-unknown-linux-gnu" => "linux-mips32",
+ "mips-unknown-linux-musl" => "linux-mips32",
+ "mips64-unknown-linux-gnuabi64" => "linux64-mips64",
+@@ -356,6 +358,7 @@ impl Build {
+ "mips64el-unknown-linux-muslabi64" => "linux64-mips64",
+ "mipsel-unknown-linux-gnu" => "linux-mips32",
+ "mipsel-unknown-linux-musl" => "linux-mips32",
++ "mipsel-unknown-netbsd" => "NetBSD-generic32",
+ "powerpc-unknown-freebsd" => "BSD-ppc",
+ "powerpc-unknown-linux-gnu" => "linux-ppc",
+ "powerpc-unknown-linux-gnuspe" => "linux-ppc",
diff --git a/rust-beta/patches/patch-vendor_openssl-src-300.5.4+3.5.4_openssl_Configurations_10-main.conf b/rust-beta/patches/patch-vendor_openssl-src-300.5.4+3.5.4_openssl_Configurations_10-main.conf
new file mode 100644
index 0000000000..7106eca190
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-src-300.5.4+3.5.4_openssl_Configurations_10-main.conf
@@ -0,0 +1,18 @@
+$NetBSD: patch-vendor_openssl-src-300.5.4+3.5.4_openssl_Configurations_10-main.conf,v 1.1 2026/04/02 19:06:35 wiz Exp $
+
+Replicate part of
+https://github.com/openssl/openssl/pull/15086
+
+--- vendor/openssl-src-300.5.4+3.5.4/openssl/Configurations/10-main.conf.orig 2025-11-02 17:12:27.865420544 +0000
++++ vendor/openssl-src-300.5.4+3.5.4/openssl/Configurations/10-main.conf
+@@ -1033,6 +1033,10 @@ my %targets = (
+ shared_target => "bsd-gcc-shared",
+ shared_cflag => "-fPIC",
+ },
++ "NetBSD-generic32" => {
++ inherit_from => [ "BSD-generic32" ],
++ ex_libs => add(threads("-latomic")),
++ },
+ "BSD-generic64" => {
+ inherit_from => [ "BSD-generic32" ],
+ bn_ops => "SIXTY_FOUR_BIT_LONG",
diff --git a/rust-beta/patches/patch-vendor_openssl-src-300.5.4+3.5.4_openssl_crypto_aria_aria.c b/rust-beta/patches/patch-vendor_openssl-src-300.5.4+3.5.4_openssl_crypto_aria_aria.c
new file mode 100644
index 0000000000..e404768278
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-src-300.5.4+3.5.4_openssl_crypto_aria_aria.c
@@ -0,0 +1,18 @@
+$NetBSD: patch-vendor_openssl-src-300.5.4+3.5.4_openssl_crypto_aria_aria.c,v 1.1 2026/04/02 19:06:35 wiz Exp $
+
+Make this build also if bswap32 is already defined, as for NetBSD/i586.
+
+--- vendor/openssl-src-300.5.4+3.5.4/openssl/crypto/aria/aria.c.orig 2025-11-02 17:14:42.569500518 +0000
++++ vendor/openssl-src-300.5.4+3.5.4/openssl/crypto/aria/aria.c
+@@ -32,9 +32,11 @@
+ #define rotl32(v, r) (((uint32_t)(v) << (r)) | ((uint32_t)(v) >> (32 - r)))
+ #define rotr32(v, r) (((uint32_t)(v) >> (r)) | ((uint32_t)(v) << (32 - r)))
+
++#ifndef bswap32
+ #define bswap32(v) \
+ (((v) << 24) ^ ((v) >> 24) ^ \
+ (((v) & 0x0000ff00) << 8) ^ (((v) & 0x00ff0000) >> 8))
++#endif
+
+ #define GET_U8_BE(X, Y) ((uint8_t)((X) >> ((3 - Y) * 8)))
+ #define GET_U32_BE(X, Y) ( \
diff --git a/rust-beta/patches/patch-vendor_openssl-src-300.5.4+3.5.4_src_lib.rs b/rust-beta/patches/patch-vendor_openssl-src-300.5.4+3.5.4_src_lib.rs
new file mode 100644
index 0000000000..18315cd251
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-src-300.5.4+3.5.4_src_lib.rs
@@ -0,0 +1,30 @@
+$NetBSD: patch-vendor_openssl-src-300.5.4+3.5.4_src_lib.rs,v 1.1 2026/04/02 19:06:35 wiz Exp $
+
+Make this build on NetBSD for armv6, mipsel and m68k as well.
+
+--- vendor/openssl-src-300.5.4+3.5.4/src/lib.rs.orig 2026-02-11 07:30:54.000000000 +0000
++++ vendor/openssl-src-300.5.4+3.5.4/src/lib.rs
+@@ -326,6 +326,7 @@ impl Build {
+ "armv5te-unknown-linux-gnueabi" => "linux-armv4",
+ "armv5te-unknown-linux-musleabi" => "linux-armv4",
+ "armv6-unknown-freebsd" => "BSD-generic32",
++ "armv6-unknown-netbsd-eabihf" => "BSD-generic32",
+ "armv6-alpine-linux-musleabihf" => "linux-armv6",
+ "armv7-unknown-freebsd" => "BSD-armv4",
+ "armv7-unknown-linux-gnueabi" => "linux-armv4",
+@@ -353,6 +354,7 @@ impl Build {
+ "i686-uwp-windows-msvc" => "VC-WIN32-UWP",
+ "loongarch64-unknown-linux-gnu" => "linux-generic64",
+ "loongarch64-unknown-linux-musl" => "linux-generic64",
++ "m68k-unknown-netbsd" => "NetBSD-generic32",
+ "mips-unknown-linux-gnu" => "linux-mips32",
+ "mips-unknown-linux-musl" => "linux-mips32",
+ "mips64-unknown-linux-gnuabi64" => "linux64-mips64",
+@@ -361,6 +363,7 @@ impl Build {
+ "mips64el-unknown-linux-muslabi64" => "linux64-mips64",
+ "mipsel-unknown-linux-gnu" => "linux-mips32",
+ "mipsel-unknown-linux-musl" => "linux-mips32",
++ "mipsel-unknown-netbsd" => "NetBSD-generic32",
+ "powerpc-unknown-freebsd" => "BSD-ppc",
+ "powerpc-unknown-linux-gnu" => "linux-ppc",
+ "powerpc-unknown-linux-gnuspe" => "linux-ppc",
diff --git a/rust-beta/patches/patch-vendor_openssl-sys-0.9.107_build_find__normal.rs b/rust-beta/patches/patch-vendor_openssl-sys-0.9.107_build_find__normal.rs
new file mode 100644
index 0000000000..ec68e07374
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-sys-0.9.107_build_find__normal.rs
@@ -0,0 +1,30 @@
+$NetBSD: patch-vendor_openssl-sys-0.9.107_build_find__normal.rs,v 1.1 2025/08/25 17:51:13 wiz Exp $
+
+Add hack for Darwin when homebrew is installed.
+
+--- vendor/openssl-sys-0.9.107/build/find_normal.rs.orig 2025-06-28 08:24:16.945712755 +0000
++++ vendor/openssl-sys-0.9.107/build/find_normal.rs
+@@ -72,23 +72,6 @@ fn resolve_with_wellknown_location(dir:
+ fn find_openssl_dir(target: &str) -> OsString {
+ let host = env::var("HOST").unwrap();
+
+- if host == target && target.ends_with("-apple-darwin") {
+- let homebrew_dir = match target {
+- "aarch64-apple-darwin" => "/opt/homebrew",
+- _ => "/usr/local",
+- };
+-
+- if let Some(dir) = resolve_with_wellknown_homebrew_location(homebrew_dir) {
+- return dir.into();
+- } else if let Some(dir) = resolve_with_wellknown_location("/opt/pkg") {
+- // pkgsrc
+- return dir.into();
+- } else if let Some(dir) = resolve_with_wellknown_location("/opt/local") {
+- // MacPorts
+- return dir.into();
+- }
+- }
+-
+ try_pkg_config();
+ try_vcpkg();
+
diff --git a/rust-beta/patches/patch-vendor_openssl-sys-0.9.107_build_main.rs b/rust-beta/patches/patch-vendor_openssl-sys-0.9.107_build_main.rs
new file mode 100644
index 0000000000..1af0475acb
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-sys-0.9.107_build_main.rs
@@ -0,0 +1,23 @@
+$NetBSD: patch-vendor_openssl-sys-0.9.107_build_main.rs,v 1.1 2025/08/25 17:51:13 wiz Exp $
+
+Patterned after Linux and Android, on 32-bit NetBSD ports
+include -latomic. Parts of this inspired by
+https://github.com/sfackler/rust-openssl/commit/a0a1d1d29263abb7c47fc2e58cef8dab13762a45
+
+--- vendor/openssl-sys-0.9.107/build/main.rs.orig 2025-06-28 08:26:57.774420907 +0000
++++ vendor/openssl-sys-0.9.107/build/main.rs
+@@ -269,6 +269,14 @@ fn main() {
+ println!("cargo:rustc-link-lib=atomic");
+ }
+
++ // Patterned of the above, make sure we include -latomic
++ // on ilp32 NetBSD ports (yes, this only tests the "p32" part).
++ if env::var("CARGO_CFG_TARGET_OS").unwrap() == "netbsd"
++ && env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32"
++ {
++ println!("cargo:rustc-link-lib=atomic");
++ }
++
+ if kind == "static" && target.contains("windows") {
+ println!("cargo:rustc-link-lib=dylib=gdi32");
+ println!("cargo:rustc-link-lib=dylib=user32");
diff --git a/rust-beta/patches/patch-vendor_openssl-sys-0.9.109_build_find__normal.rs b/rust-beta/patches/patch-vendor_openssl-sys-0.9.109_build_find__normal.rs
new file mode 100644
index 0000000000..ae3496cdbc
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-sys-0.9.109_build_find__normal.rs
@@ -0,0 +1,30 @@
+$NetBSD: patch-vendor_openssl-sys-0.9.109_build_find__normal.rs,v 1.1 2025/10/18 17:14:36 he Exp $
+
+Add hack for Darwin when homebrew is installed.
+
+--- vendor/openssl-sys-0.9.109/build/find_normal.rs.orig 2025-06-28 08:28:59.789478187 +0000
++++ vendor/openssl-sys-0.9.109/build/find_normal.rs
+@@ -72,23 +72,6 @@ fn resolve_with_wellknown_location(dir:
+ fn find_openssl_dir(target: &str) -> OsString {
+ let host = env::var("HOST").unwrap();
+
+- if host == target && target.ends_with("-apple-darwin") {
+- let homebrew_dir = match target {
+- "aarch64-apple-darwin" => "/opt/homebrew",
+- _ => "/usr/local",
+- };
+-
+- if let Some(dir) = resolve_with_wellknown_homebrew_location(homebrew_dir) {
+- return dir.into();
+- } else if let Some(dir) = resolve_with_wellknown_location("/opt/pkg") {
+- // pkgsrc
+- return dir.into();
+- } else if let Some(dir) = resolve_with_wellknown_location("/opt/local") {
+- // MacPorts
+- return dir.into();
+- }
+- }
+-
+ try_pkg_config();
+ try_vcpkg();
+
diff --git a/rust-beta/patches/patch-vendor_openssl-sys-0.9.109_build_main.rs b/rust-beta/patches/patch-vendor_openssl-sys-0.9.109_build_main.rs
new file mode 100644
index 0000000000..1ac33e4b86
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-sys-0.9.109_build_main.rs
@@ -0,0 +1,23 @@
+$NetBSD: patch-vendor_openssl-sys-0.9.109_build_main.rs,v 1.1 2025/10/18 17:14:36 he Exp $
+
+Patterned after Linux and Android, on 32-bit NetBSD ports
+include -latomic. Parts of this inspired by
+https://github.com/sfackler/rust-openssl/commit/a0a1d1d29263abb7c47fc2e58cef8dab13762a45
+
+--- vendor/openssl-sys-0.9.109/build/main.rs.orig 2025-06-28 08:30:05.194163693 +0000
++++ vendor/openssl-sys-0.9.109/build/main.rs
+@@ -269,6 +269,14 @@ fn main() {
+ println!("cargo:rustc-link-lib=atomic");
+ }
+
++ // Patterned of the above, make sure we include -latomic
++ // on ilp32 ports (yes, this only tests the "p32" part).
++ if env::var("CARGO_CFG_TARGET_OS").unwrap() == "netbsd"
++ && env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32"
++ {
++ println!("cargo:rustc-link-lib=atomic");
++ }
++
+ if kind == "static" && target.contains("windows") {
+ println!("cargo:rustc-link-lib=dylib=gdi32");
+ println!("cargo:rustc-link-lib=dylib=user32");
diff --git a/rust-beta/patches/patch-vendor_openssl-sys-0.9.111_build_find__normal.rs b/rust-beta/patches/patch-vendor_openssl-sys-0.9.111_build_find__normal.rs
new file mode 100644
index 0000000000..c6257491a1
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-sys-0.9.111_build_find__normal.rs
@@ -0,0 +1,30 @@
+$NetBSD: patch-vendor_openssl-sys-0.9.111_build_find__normal.rs,v 1.1 2026/04/02 19:06:35 wiz Exp $
+
+Add hack for Darwin when homebrew is installed.
+
+--- vendor/openssl-sys-0.9.111/build/find_normal.rs.orig 2026-01-25 08:56:08.257782732 +0000
++++ vendor/openssl-sys-0.9.111/build/find_normal.rs
+@@ -72,23 +72,6 @@ fn resolve_with_wellknown_location(dir:
+ fn find_openssl_dir(target: &str) -> OsString {
+ let host = env::var("HOST").unwrap();
+
+- if host == target && target.ends_with("-apple-darwin") {
+- let homebrew_dir = match target {
+- "aarch64-apple-darwin" => "/opt/homebrew",
+- _ => "/usr/local",
+- };
+-
+- if let Some(dir) = resolve_with_wellknown_homebrew_location(homebrew_dir) {
+- return dir.into();
+- } else if let Some(dir) = resolve_with_wellknown_location("/opt/pkg") {
+- // pkgsrc
+- return dir.into();
+- } else if let Some(dir) = resolve_with_wellknown_location("/opt/local") {
+- // MacPorts
+- return dir.into();
+- }
+- }
+-
+ try_pkg_config();
+ try_vcpkg();
+
diff --git a/rust-beta/patches/patch-vendor_openssl-sys-0.9.111_build_main.rs b/rust-beta/patches/patch-vendor_openssl-sys-0.9.111_build_main.rs
new file mode 100644
index 0000000000..0567c8f980
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-sys-0.9.111_build_main.rs
@@ -0,0 +1,23 @@
+$NetBSD: patch-vendor_openssl-sys-0.9.111_build_main.rs,v 1.1 2026/04/02 19:06:35 wiz Exp $
+
+Patterned after Linux and Android, on 32-bit NetBSD ports
+include -latomic. Parts of this inspired by
+https://github.com/sfackler/rust-openssl/commit/a0a1d1d29263abb7c47fc2e58cef8dab13762a45
+
+--- vendor/openssl-sys-0.9.111/build/main.rs.orig 2026-01-25 08:57:28.677889187 +0000
++++ vendor/openssl-sys-0.9.111/build/main.rs
+@@ -279,6 +279,14 @@ fn main() {
+ println!("cargo:rustc-link-lib=atomic");
+ }
+
++ // Patterned of the above, make sure we include -latomic
++ // on ilp32 ports (yes, this only tests the "p32" part).
++ if env::var("CARGO_CFG_TARGET_OS").unwrap() == "netbsd"
++ && env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32"
++ {
++ println!("cargo:rustc-link-lib=atomic");
++ }
++
+ if kind == "static" && target.contains("windows") {
+ println!("cargo:rustc-link-lib=dylib=gdi32");
+ println!("cargo:rustc-link-lib=dylib=user32");
diff --git a/rust-beta/patches/patch-vendor_openssl-sys-0.9.92_build_find__normal.rs b/rust-beta/patches/patch-vendor_openssl-sys-0.9.92_build_find__normal.rs
new file mode 100644
index 0000000000..eadb21f4b0
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-sys-0.9.92_build_find__normal.rs
@@ -0,0 +1,30 @@
+$NetBSD: patch-vendor_openssl-sys-0.9.92_build_find__normal.rs,v 1.4 2025/10/18 17:14:36 he Exp $
+
+Add hack for Darwin when homebrew is installed.
+
+--- vendor/openssl-sys-0.9.92/build/find_normal.rs.orig 2025-09-19 21:56:18.930723780 +0000
++++ vendor/openssl-sys-0.9.92/build/find_normal.rs
+@@ -72,23 +72,6 @@ fn resolve_with_wellknown_location(dir:
+ fn find_openssl_dir(target: &str) -> OsString {
+ let host = env::var("HOST").unwrap();
+
+- if host == target && target.ends_with("-apple-darwin") {
+- let homebrew_dir = match target {
+- "aarch64-apple-darwin" => "/opt/homebrew",
+- _ => "/usr/local",
+- };
+-
+- if let Some(dir) = resolve_with_wellknown_homebrew_location(homebrew_dir) {
+- return dir.into();
+- } else if let Some(dir) = resolve_with_wellknown_location("/opt/pkg") {
+- // pkgsrc
+- return dir.into();
+- } else if let Some(dir) = resolve_with_wellknown_location("/opt/local") {
+- // MacPorts
+- return dir.into();
+- }
+- }
+-
+ try_pkg_config();
+ try_vcpkg();
+
diff --git a/rust-beta/patches/patch-vendor_openssl-sys-0.9.92_build_main.rs b/rust-beta/patches/patch-vendor_openssl-sys-0.9.92_build_main.rs
new file mode 100644
index 0000000000..09c1b546a4
--- /dev/null
+++ b/rust-beta/patches/patch-vendor_openssl-sys-0.9.92_build_main.rs
@@ -0,0 +1,23 @@
+$NetBSD: patch-vendor_openssl-sys-0.9.92_build_main.rs,v 1.4 2025/10/18 17:14:37 he Exp $
+
+Patterned after Linux and Android, on 32-bit NetBSD ports
+include -latomic. Parts of this inspired by
+https://github.com/sfackler/rust-openssl/commit/a0a1d1d29263abb7c47fc2e58cef8dab13762a45
+
+--- vendor/openssl-sys-0.9.92/build/main.rs.orig 2025-09-19 21:57:47.732695298 +0000
++++ vendor/openssl-sys-0.9.92/build/main.rs
+@@ -115,6 +115,14 @@ fn main() {
+ println!("cargo:rustc-link-lib={}={}", kind, lib);
+ }
+
++ // Patterned of the above, make sure we include -latomic
++ // on NetBSD ilp32 ports (yes, this only tests the "p32" part).
++ if env::var("CARGO_CFG_TARGET_OS").unwrap() == "netbsd"
++ && env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32"
++ {
++ println!("cargo:rustc-link-lib=atomic");
++ }
++
+ if kind == "static" && target.contains("windows") {
+ println!("cargo:rustc-link-lib=dylib=gdi32");
+ println!("cargo:rustc-link-lib=dylib=user32");
diff --git a/rust-beta/platform.mk b/rust-beta/platform.mk
new file mode 100644
index 0000000000..da2b1bce36
--- /dev/null
+++ b/rust-beta/platform.mk
@@ -0,0 +1,34 @@
+# $NetBSD$
+
+# This file encodes whether a given platform has support for rust.
+
+# Platforms where rust ought to work but does not require a link to an
+# open PR.
+
+.if !defined(PLATFORM_SUPPORTS_RUST)
+
+# Rust needs NetBSD>8
+.for rust_arch in aarch64 earmv7hf i386 powerpc riscv64 sparc64 x86_64
+. for rust_os in Darwin FreeBSD Linux NetBSD SunOS
+. if ${OPSYS} != "NetBSD" || empty(OS_VERSION:M[0-8].*)
+RUST_PLATFORMS+= ${rust_os}-*-${rust_arch}
+. endif
+. endfor
+.endfor
+
+# rust does not build in the VA space available on earm.
+# \todo Consider extension to other platforms.
+.if ${NATIVE_MACHINE_PLATFORM:M*-*-earm*}
+RUST_TYPE?= bin
+.endif
+
+RUST_DIR?= ../../lang/rust
+
+.for rust_platform in ${RUST_PLATFORMS}
+. if !empty(MACHINE_PLATFORM:M${rust_platform})
+PLATFORM_SUPPORTS_RUST?= yes
+. endif
+.endfor
+PLATFORM_SUPPORTS_RUST?= no
+
+.endif # !defined(PLATFORM_SUPPORTS_RUST)
diff --git a/rust-beta/rust.mk b/rust-beta/rust.mk
new file mode 100644
index 0000000000..5cd646afbf
--- /dev/null
+++ b/rust-beta/rust.mk
@@ -0,0 +1,68 @@
+# $NetBSD$
+#
+# This file determines the type of rust package to use.
+#
+# It should be included by rust-dependent packages that don't use
+# cargo.mk.
+#
+# === User-settable variables ===
+#
+# RUST_TYPE
+# The preferred type of Rust release to use - either build from source,
+# or use a binary installation.
+#
+# Official Rust binaries are only published for certain platforms. The
+# "bin" option uses the lang/rust-bin package, whereas "native" uses
+# binaries installed on the host system. If using "native" with a rustup
+# installation, you will probably also need to set RUSTUP_HOME in your
+# MAKE_ENV pointing to the 'rustup show home' directory. This is due to
+# pkgsrc overwriting the HOME environment variable during build.
+#
+# Possible values: src bin native
+# Default: "src", except on 32-bit arm where it's "bin"
+#
+# === Package-settable variables ===
+#
+# RUST_REQ
+# The minimum version of Rust required by the package.
+#
+# Default: 1.85.0
+#
+# RUST_RUNTIME
+# Whether rust is a runtime dependency.
+# Usually it is only needed to build.
+#
+# Possible values: yes no
+# Default: no
+
+.include "../../mk/bsd.fast.prefs.mk"
+.include "platform.mk"
+
+RUST_REQ?= 1.85.0
+RUST_RUNTIME?= no
+
+.if ${MACHINE_PLATFORM:M*-*-earm*}
+RUST_TYPE?= bin
+.else
+RUST_TYPE?= src
+.endif
+
+.if ${RUST_TYPE} == "bin"
+. if ${RUST_RUNTIME} == "no"
+BUILDLINK_DEPMETHOD.rust-bin?= build
+. endif
+BUILDLINK_API_DEPENDS.rust-bin+= rust-bin>=${RUST_REQ}
+. include "${RUST_DIR}-bin/buildlink3.mk"
+.endif
+
+.if ${RUST_TYPE} == "src"
+. if ${RUST_RUNTIME} == "no"
+BUILDLINK_DEPMETHOD.rust?= build
+. endif
+BUILDLINK_API_DEPENDS.rust+= rust>=${RUST_REQ}
+. include "${RUST_DIR}/buildlink3.mk"
+.endif
+
+.if ${OPSYS} == "NetBSD"
+ALL_ENV+= PTHREAD_KEYS_MAX=512
+.endif
Home |
Main Index |
Thread Index |
Old Index