pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
rust: Import version 1.47.0.
Module Name: pkgsrc-wip
Committed By: Jonathan Perkin <jperkin%joyent.com@localhost>
Pushed By: jperkin
Date: Fri Oct 9 11:06:11 2020 +0100
Changeset: cdcd746dfa60300935578072cba21b007020d82c
Added Files:
rust/DESCR
rust/Makefile
rust/buildlink3.mk
rust/cargo.mk
rust/cross.mk
rust/distinfo
rust/files/gcc-wrap
rust/options.mk
rust/patches/patch-library_backtrace_crates_backtrace-sys_src_libbacktrace_configure
rust/patches/patch-library_std_build.rs
rust/patches/patch-library_std_src_sys_unix_thread.rs
rust/patches/patch-library_unwind_build.rs
rust/patches/patch-src_bootstrap_bootstrap.py
rust/patches/patch-src_bootstrap_builder.rs
rust/patches/patch-src_bootstrap_compile.rs
rust/patches/patch-src_bootstrap_lib.rs
rust/patches/patch-src_librustc__codegen__ssa_back_linker.rs
rust/patches/patch-src_librustc__llvm_build.rs
rust/patches/patch-src_librustc__target_spec_solaris__base.rs
rust/patches/patch-src_librustc__target_spec_x86__64__sun__solaris.rs
rust/patches/patch-src_llvm-project_llvm_CMakeLists.txt
rust/patches/patch-src_llvm-project_llvm_cmake_modules_AddLLVM.cmake
rust/patches/patch-src_llvm-project_llvm_include_llvm-c_DataTypes.h
rust/patches/patch-src_llvm-project_llvm_include_llvm_Analysis_ConstantFolding.h
rust/patches/patch-src_llvm-project_llvm_utils_FileCheck_FileCheck.cpp
rust/patches/patch-src_tools_cargo_src_cargo_core_profiles.rs
rust/patches/patch-src_tools_cargo_tests_testsuite_build.rs
rust/patches/patch-src_tools_rls_rls_src_cmd.rs
rust/patches/patch-src_tools_rls_rls_src_server_io.rs
rust/patches/patch-src_tools_rust-installer_install-template.sh
rust/patches/patch-vendor_libc_src_unix_solarish_mod.rs
rust/patches/patch-vendor_lzma-sys_config.h
rust/patches/patch-vendor_stacker_src_lib.rs
rust/platform.mk
rust/rust.mk
Log Message:
rust: Import version 1.47.0.
This is a copy of lang/rust, updated to 1.47.0, but will track the
latest stable release of rust, for when either the lack of NetBSD
bootstraps or some package dependencies stop us from upgrading.
The alternative was to import it as lang/rust-latest, which didn't
really sit well with me. Maybe in time if this continues to be an issue
we can import this as lang/rust and create a lang/rust-legacy or similar
for systems that can't update.
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=cdcd746dfa60300935578072cba21b007020d82c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
rust/DESCR | 13 +
rust/Makefile | 543 +++++++++++++++++++++
rust/buildlink3.mk | 16 +
rust/cargo.mk | 78 +++
rust/cross.mk | 67 +++
rust/distinfo | 127 +++++
rust/files/gcc-wrap | 161 ++++++
rust/options.mk | 32 ++
...crates_backtrace-sys_src_libbacktrace_configure | 15 +
rust/patches/patch-library_std_build.rs | 33 ++
.../patch-library_std_src_sys_unix_thread.rs | 15 +
rust/patches/patch-library_unwind_build.rs | 17 +
rust/patches/patch-src_bootstrap_bootstrap.py | 43 ++
rust/patches/patch-src_bootstrap_builder.rs | 26 +
rust/patches/patch-src_bootstrap_compile.rs | 15 +
rust/patches/patch-src_bootstrap_lib.rs | 27 +
...patch-src_librustc__codegen__ssa_back_linker.rs | 15 +
rust/patches/patch-src_librustc__llvm_build.rs | 21 +
...atch-src_librustc__target_spec_solaris__base.rs | 14 +
..._librustc__target_spec_x86__64__sun__solaris.rs | 15 +
.../patch-src_llvm-project_llvm_CMakeLists.txt | 18 +
...c_llvm-project_llvm_cmake_modules_AddLLVM.cmake | 16 +
...rc_llvm-project_llvm_include_llvm-c_DataTypes.h | 34 ++
...ct_llvm_include_llvm_Analysis_ConstantFolding.h | 17 +
...llvm-project_llvm_utils_FileCheck_FileCheck.cpp | 15 +
...atch-src_tools_cargo_src_cargo_core_profiles.rs | 17 +
.../patch-src_tools_cargo_tests_testsuite_build.rs | 31 ++
rust/patches/patch-src_tools_rls_rls_src_cmd.rs | 27 +
.../patch-src_tools_rls_rls_src_server_io.rs | 41 ++
...ch-src_tools_rust-installer_install-template.sh | 36 ++
.../patch-vendor_libc_src_unix_solarish_mod.rs | 15 +
rust/patches/patch-vendor_lzma-sys_config.h | 18 +
rust/patches/patch-vendor_stacker_src_lib.rs | 15 +
rust/platform.mk | 28 ++
rust/rust.mk | 55 +++
35 files changed, 1676 insertions(+)
diffs:
diff --git a/rust/DESCR b/rust/DESCR
new file mode 100644
index 0000000000..6dc90a671e
--- /dev/null
+++ b/rust/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/Makefile b/rust/Makefile
new file mode 100644
index 0000000000..61c0eaba3d
--- /dev/null
+++ b/rust/Makefile
@@ -0,0 +1,543 @@
+# $NetBSD: Makefile,v 1.197 2020/09/29 16:45:16 gdt Exp $
+
+DISTNAME= rustc-1.47.0-src
+PKGNAME= ${DISTNAME:S/rustc/rust/:S/-src//}
+CATEGORIES= lang
+MASTER_SITES= https://static.rust-lang.org/dist/
+
+MAINTAINER= pkgsrc-users%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]*
+
+# uses -std=c++14
+GCC_REQD+= 5
+
+USE_GCC_RUNTIME= yes
+USE_LANGUAGES= c c++11
+USE_LIBTOOL= yes
+USE_TOOLS+= bash ggrep gmake perl:build pkg-config
+
+# The NetBSD bootstraps are built for NetBSD 8 (because rust doesn't
+# build on 7). Mark earlier versions as broken.
+BROKEN_ON_PLATFORM+= NetBSD-[1-7].*-*
+
+HAS_CONFIGURE= yes
+PYTHON_FOR_BUILD_ONLY= yes
+CONFIG_SHELL= ${PYTHONBIN}
+CONFIGURE_SCRIPT= src/bootstrap/configure.py
+CONFIGURE_ARGS+= --prefix=${PREFIX}
+CONFIGURE_ARGS+= --mandir=${PREFIX}/${PKGMANDIR}
+CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
+CONFIGURE_ARGS+= --python=${PYTHONBIN}
+CONFIGURE_ARGS+= --release-channel=stable
+#CONFIGURE_ARGS+= --enable-local-rust
+CONFIGURE_ARGS+= --local-rust-root=${RUST_BOOTSTRAP_PATH}
+CONFIGURE_ARGS+= --enable-extended # Build and install cargo too.
+CONFIGURE_ARGS+= --enable-rpath
+CONFIGURE_ARGS+= --disable-codegen-tests
+CONFIGURE_ARGS+= --disable-dist-src
+CONFIGURE_ARGS+= --disable-llvm-static-stdcpp
+CONFIGURE_ARGS+= --disable-ninja
+# XXX: to be enabled in the future
+#CONFIGURE_ARGS+= --jemalloc-root=${BUILDLINK_PREFIX.jemalloc}/lib
+
+# Use "dist" build target for cross compile of bootstrap
+#BUILD_TARGET= dist
+BUILD_TARGET= build
+
+# Include (optional) settings to cross-build rust
+.include "cross.mk"
+
+# Getting RPATH with $ORIGIN into bootstrap may be troublesome, so
+# uncommenting the LD_LIBRARY_PATH setting may be required to run
+# the bootstrap
+PKGSRC_MAKE_ENV+= LD_LIBRARY_PATH=${RUST_BOOTSTRAP_PATH:Q}/lib
+
+# 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}
+
+CFLAGS.SunOS+= -D_POSIX_PTHREAD_SEMANTICS
+
+UNLIMIT_RESOURCES+= cputime datasize virtualsize
+
+TEST_TARGET= check
+
+# bin/* lib/*, but names vary
+CHECK_RELRO_SUPPORTED= no
+CHECK_SSP_SUPPORTED= no
+
+.include "../../mk/bsd.prefs.mk"
+
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-powerpc) || \
+ !empty(MACHINE_PLATFORM:MNetBSD-*-earmv7hf)
+# Bootstrapping on NetBSD/powerpc requires no debug-info from rustc
+# (both for amd64->powerpc built and powerpc->powerpc built bootstrap bits)
+CONFIGURE_ARGS+= --disable-debug
+CONFIGURE_ARGS+= --disable-debug-assertions
+CONFIGURE_ARGS+= --disable-llvm-release-debuginfo
+CONFIGURE_ARGS+= --debuginfo-level=0
+CONFIGURE_ARGS+= --debuginfo-level-rustc=0
+CONFIGURE_ARGS+= --debuginfo-level-std=0
+CONFIGURE_ARGS+= --debuginfo-level-tools=0
+CONFIGURE_ARGS+= --debuginfo-level-tests=0
+.endif
+
+# Only build the ARM target on/for this host, due to resource constraints
+# (X86 needs to go along due to 2-stage build process)
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-earmv7hf) || \
+ !empty(TARGET:Marmv7-unknown-netbsd-eabihf)
+CONFIGURE_ARGS+= --set llvm.targets="ARM;X86"
+.endif
+
+.if ${OPSYS} == "NetBSD"
+# This block contains information about known trouble on NetBSD and workarounds.
+
+# Parallel builds failed on NetBSD due to dynamic linker locking bugs.
+# \todo Explain if the build is believed to be sound if not parallel,
+# or if a non-parallel build is merely more likely to work.
+#
+# See toolchain/54192 at
+# http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=54192
+# which was fixed in -current on 2020-04-19:
+# http://mail-index.netbsd.org/source-changes/2020/04/16/msg116256.html
+# http://mail-index.netbsd.org/source-changes/2020/04/19/msg116337.html
+# These were pulled up to netbsd-9 on 2020-05-13:
+# http://releng.netbsd.org/cgi-bin/req-9.cgi?show=907
+# This has not been pulled up to netbsd-8
+# \todo Explain if it's not applicable, shouldn't be pulled up, should be
+# but hasn't, is too hard, etc.
+#
+# On pkgbuild for 2020Q1 9.0_RELEASE amd64, rust did not build despite
+# MAKE_JOBS_SAFE=no, but setting MAKE_JOBS=1 resulted in success. (No
+# PR is open for this.) \todo Understand and fix.
+#
+# If we aren't on 9-current, and are on 8.x or 9.x, avoid parallel.
+# \todo Consider avoiding setting this on netbsd-9 past the fix.
+. if ${MACHINE_PLATFORM:MNetBSD-[1-9].*} && !${MACHINE_PLATFORM:MNetBSD-9.99.*}
+MAKE_JOBS_SAFE= no
+. endif
+
+# Open PRs
+#
+# Broken package with PREFIX not /usr/pkg:
+# http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=54453
+#
+# NetBSD 8.1 earmv7hf: unknown configure option
+# http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=54621
+
+.endif
+
+#
+# Under NetBSD, do not use DT_RUNPATH
+#
+BUILDLINK_TRANSFORM.NetBSD+= rm:-Wl,--enable-new-dtags
+
+.PHONY: pre-build-fix
+#
+# Rust unfortunately requires itself to build. On platforms which aren't
+# supported by upstream (where they offer binary bootstraps), or where we do
+# not trust random binaries from the Internet, we need to build and provide our
+# own bootstrap. See the stage0-bootstrap below for more details.
+#
+DISTFILES:= ${DEFAULT_DISTFILES}
+
+.if !empty(MACHINE_PLATFORM:MDarwin-*-x86_64) || make(distinfo) || make (makesum) || make(mdi)
+RUST_STAGE0_VER= 1.44.1
+RUST_ARCH:= x86_64-apple-darwin
+RUST_STAGE0:= rust-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+RUST_STD_STAGE0:= rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+DISTFILES:= ${DISTFILES} ${RUST_STAGE0} ${RUST_STD_STAGE0}
+pre-build-fix:
+.endif
+.if !empty(MACHINE_PLATFORM:MLinux-*-i386) || make(distinfo) || make (makesum) || make(mdi)
+RUST_STAGE0_VER= 1.44.1
+RUST_ARCH:= i686-unknown-linux-gnu
+RUST_STAGE0:= rust-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+RUST_STD_STAGE0:= rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+DISTFILES:= ${DISTFILES} ${RUST_STAGE0} ${RUST_STD_STAGE0}
+pre-build-fix:
+.endif
+.if !empty(MACHINE_PLATFORM:MLinux-*-x86_64) || make(distinfo) || make (makesum) || make(mdi)
+RUST_STAGE0_VER= 1.44.1
+RUST_ARCH:= x86_64-unknown-linux-gnu
+RUST_STAGE0:= rust-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+RUST_STD_STAGE0:= rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+DISTFILES:= ${DISTFILES} ${RUST_STAGE0} ${RUST_STD_STAGE0}
+pre-build-fix:
+.endif
+.if !empty(MACHINE_PLATFORM:MSunOS-*-x86_64) || make(distinfo) || make (makesum) || make(mdi)
+RUST_STAGE0_VER= 1.46.0
+RUST_ARCH:= x86_64-sun-solaris
+#RUST_ARCH:= x86_64-unknown-illumos
+RUST_STAGE0:= rust-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+SITES.${RUST_STAGE0}= https://us-east.manta.joyent.com/pkgsrc/public/pkg-bootstraps/
+DISTFILES:= ${DISTFILES} ${RUST_STAGE0}
+RUST_BOOTSTRAP_PATH?= ${WRKDIR}/rust-${RUST_STAGE0_VER}-${RUST_ARCH}
+pre-build-fix:
+.endif
+.if !empty(MACHINE_PLATFORM:MFreeBSD-*-i386) || make(distinfo) || make (makesum) || make(mdi)
+RUST_STAGE0_VER= 1.44.1
+RUST_ARCH:= i686-unknown-freebsd
+RUST_STAGE0:= rust-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+RUST_STD_STAGE0:= rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+DISTFILES:= ${DISTFILES} ${RUST_STAGE0} ${RUST_STD_STAGE0}
+pre-build-fix:
+.endif
+.if !empty(MACHINE_PLATFORM:MFreeBSD-*-x86_64) || make(distinfo) || make (makesum) || make(mdi)
+RUST_STAGE0_VER= 1.44.1
+RUST_ARCH:= x86_64-unknown-freebsd
+RUST_STAGE0:= rust-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+RUST_STD_STAGE0:= rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+DISTFILES:= ${DISTFILES} ${RUST_STAGE0} ${RUST_STD_STAGE0}
+pre-build-fix:
+.endif
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-i386) || make(distinfo) || make (makesum) || make(mdi)
+RUST_STAGE0_VER= 1.44.1
+RUST_ARCH= i686-unknown-netbsd
+RUST_STAGE0:= rust-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+RUST_STD_STAGE0:= rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+SITES.${RUST_STAGE0}= ${MASTER_SITE_LOCAL:=rust/}
+SITES.${RUST_STD_STAGE0}= ${MASTER_SITE_LOCAL:=rust/}
+DISTFILES:= ${DISTFILES} ${RUST_STAGE0} ${RUST_STD_STAGE0}
+# Setting this changes it for every distfile, which doesn't match what is
+# currently in distinfo.
+#DIST_SUBDIR= ${PKGNAME}
+# For atomic ops
+CFLAGS+= -march=i586
+pre-build-fix:
+ ${TOOLS_PLATFORM.paxctl} +am ${WRKDIR}/rust-bootstrap/bin/cargo
+ ${TOOLS_PLATFORM.paxctl} +am ${WRKDIR}/rust-bootstrap/bin/rustc
+.endif
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-x86_64) || make(distinfo) || make (makesum) || make(mdi)
+RUST_STAGE0_VER= 1.44.1
+RUST_ARCH= x86_64-unknown-netbsd
+RUST_STAGE0:= rust-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+RUST_STD_STAGE0:= rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+DISTFILES:= ${DISTFILES} ${RUST_STAGE0} ${RUST_STD_STAGE0}
+pre-build-fix:
+.endif
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-powerpc) || make(distinfo) || make (makesum) || make(mdi)
+RUST_STAGE0_VER= 1.44.1
+RUST_ARCH= powerpc-unknown-netbsd
+RUST_STAGE0:= rust-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+RUST_STD_STAGE0:= rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+DISTFILES:= ${DISTFILES} ${RUST_STAGE0} ${RUST_STD_STAGE0}
+SITES.${RUST_STAGE0}= ${MASTER_SITE_LOCAL:=rust/}
+SITES.${RUST_STD_STAGE0}= ${MASTER_SITE_LOCAL:=rust/}
+pre-build-fix:
+.endif
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-aarch64) || make(distinfo) || make (makesum) || make(mdi)
+RUST_STAGE0_VER= 1.44.1
+RUST_ARCH= aarch64-unknown-netbsd
+RUST_STAGE0:= rust-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+RUST_STD_STAGE0:= rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+DISTFILES:= ${DISTFILES} ${RUST_STAGE0} ${RUST_STD_STAGE0}
+SITES.${RUST_STAGE0}= ${MASTER_SITE_LOCAL:=rust/}
+SITES.${RUST_STD_STAGE0}= ${MASTER_SITE_LOCAL:=rust/}
+pre-build-fix:
+.endif
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-sparc64) || make(distinfo) || make (makesum) || make(mdi)
+RUST_STAGE0_VER= 1.44.1
+RUST_ARCH= sparc64-unknown-netbsd
+RUST_STAGE0:= rust-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+RUST_STD_STAGE0:= rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+DISTFILES:= ${DISTFILES} ${RUST_STAGE0} ${RUST_STD_STAGE0}
+SITES.${RUST_STAGE0}= ${MASTER_SITE_LOCAL:=rust/}
+SITES.${RUST_STD_STAGE0}= ${MASTER_SITE_LOCAL:=rust/}
+pre-build-fix:
+.endif
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-earmv7hf) || make(distinfo) || make (makesum) || make(mdi)
+RUST_ARCH= armv7-unknown-netbsd-eabihf
+RUST_STAGE0_VER= 1.44.0
+RUST_STAGE0:= rust-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+RUST_STD_STAGE0:= rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.gz
+DISTFILES:= ${DISTFILES} ${RUST_STAGE0} ${RUST_STD_STAGE0}
+SITES.${RUST_STAGE0}= ${MASTER_SITE_LOCAL:=rust/}
+SITES.${RUST_STD_STAGE0}= ${MASTER_SITE_LOCAL:=rust/}
+pre-build-fix:
+.endif
+
+# You may override RUST_BOOTSTRAP_PATH and RUST_ARCH in mk.conf if you have a local bootstrap compiler.
+.if !defined(RUST_ARCH) && !defined(RUST_BOOTSTRAP_PATH)
+NOT_FOR_PLATFORM+= ${MACHINE_PLATFORM}
+.else
+RUST_BOOTSTRAP_PATH?= ${WRKDIR}/rust-bootstrap
+.endif
+
+.if ${OPSYS} == "SunOS"
+BUILD_DEPENDS+= coreutils>=0:../../sysutils/coreutils
+BUILD_DEPENDS+= gzip>=0:../../archivers/gzip
+TOOLS_CREATE+= md5sum
+TOOLS_PATH.md5sum= ${PREFIX}/bin/gmd5sum
+TOOLS_PLATFORM.gzcat= ${PREFIX}/bin/gzip -cd
+.endif
+
+SUBST_CLASSES+= rpath
+SUBST_STAGE.rpath= pre-configure
+SUBST_FILES.rpath+= src/librustc_codegen_ssa/back/linker.rs
+SUBST_FILES.rpath+= src/bootstrap/builder.rs
+SUBST_VARS.rpath= PREFIX
+
+#
+# Generate list of subst entries for various .cargo-checksum.json files. These
+# are all handled together in one big substitution to simplify things rather
+# than one substitution entry per file, but are kept separate below to ease
+# updating and verification.
+#
+#CKSUM_CRATES+= vendor/backtrace-sys
+CKSUMS+= dbe2eb824252135e7a154805c148defb2142a26b0c2267f5b1033ad69f441e33
+CKSUMS+= 323987bb2d5b7ec6044b881b70f339472d886fc23bf212392b8a0158b15d3862
+
+CKSUM_CRATES+= vendor/libc
+CKSUMS+= 9f96e346d87296e2b0b87b9fe375d67fb66cd88ce61ea2905466c8c5891d3108
+CKSUMS+= ebcb0709586e6ed1e8b4538368201638006e26042d464bbc1151bef9eb158f8c
+
+#CKSUM_CRATES+= vendor/libssh2-sys
+CKSUMS+= 0d80edbdffcf36a165578b3cffe9bc4e9eab3b3ae94a170ec8bc18764159cabb
+CKSUMS+= fd601d3ea2ff745c3d73a546cc553f656924f3e985b87bc4db025c5c51ed3db5
+
+CKSUM_CRATES+= vendor/lzma-sys
+CKSUMS+= 6fd5e9245db34c6f557b8bfcaf03db82fc88c3b06dbfbb5f03b2bcd138983ef9
+CKSUMS+= 5e252578b5d266f6a4c8dc9f71ca7a91536ccb8c5c7d7753b82f12ec886459ef
+
+#CKSUM_CRATES+= vendor/rand-0.6.1
+CKSUMS+= 1e732c2e3b4bd1561f11e0979bf9d20669a96eae7afe0deff9dfbb980ee47bf1
+CKSUMS+= bc03f2345d7cfa7000f9da817120b6afa073359789c21a9a790ebd8676c50cca
+
+#CKSUM_CRATES+= vendor/mio-0.6.16
+CKSUMS+= 62331824b1f5022e372b875faad41a970abb13e63c15e3fae9af948a2b06e4e1
+CKSUMS+= 6fc27e48d0c7275588da244c372994ef442bc4ecd78264cc5337a55b79798f62
+CKSUMS+= bf76f97c0dc9dfe870b8e865ea03ebbdfa939494a6fea809ac530d8055a56ec0
+CKSUMS+= f4d143c57f3b87e4af6381ea33cb81c3c3577aa717bf7690e0a5c1eea73d2baa
+
+#CKSUM_CRATES+= vendor/net2-0.2.33
+CKSUMS+= b9300ae246e9ac451889f146ece8bb6ed4a95482edf806373de5af759cd09360
+CKSUMS+= 762a881d936363f4140bc6befc516f9b3f321ef0a6eb9f3f812aa15ab32b56c0
+CKSUMS+= bb28a7275eac021132b01206d134802902d616c0be3e82100b45a3ff1eba4c02
+CKSUMS+= baa97a46744047bef086334ed9a63b340e4aba85e6471493780fc99d8e6445ed
+CKSUMS+= 8d8a171090b75e86e7505921460fba072db0077942edd11c4a3c8a70e9164eef
+CKSUMS+= 7ad3b486020bd652ad7c5af752f039c30ee0099c86ff6b6f336587db7a2bc523
+
+CKSUM_CRATES+= vendor/stacker
+CKSUMS+= 37ef9666d048191eeca23d8f7d99cf912b953cc489bf860107aec306b95b2d99
+CKSUMS+= 410f22f5e95860530be1abaaf2e279d2f4226e5c17c2cee302661d8079246b3a
+
+#CKSUM_CRATES+= vendor/time-0.1.42
+CKSUMS+= 4f6bc5c6300c2d49da7d21615152872e16d53c0f02540824f48c45edd4d3140f
+CKSUMS+= 9d8d3f70e87a0d61693ac3ea430b39612aa9ab63cbfc5343445b8466d2690fd3
+
+#CKSUM_CRATES+= vendor/tokio-uds
+CKSUMS+= 2d4ba4a488ebc43333a5a89dbf1bf614d157e916e97b0364c06e3056d5865913
+CKSUMS+= 9b9f0d753fdd362defe0c28c118b80dee04a8d736c5b090a62560e9bc771c7ea
+
+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}; \
+ ${TOOLS_BASH} ./install.sh --prefix=${RUST_BOOTSTRAP_PATH}; \
+ cd ${WRKDIR}/rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}; \
+ ${TOOLS_BASH} ./install.sh --prefix=${RUST_BOOTSTRAP_PATH}; \
+ fi
+.if ${OPSYS} == "NetBSD"
+ SDIR=${WRKDIR}/scripts; \
+ ${MKDIR} $${SDIR}; \
+ cd $${SDIR}; \
+ ${RM} -f c++-wrap; \
+ ${RM} -f clang++-wrap; \
+ ${RM} -f clang-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
+.endif
+
+.if ${OPSYS} == "FreeBSD"
+MAKE_ENV+= OPENSSL_DIR=${SSLBASE}
+.endif
+
+.if ${OPSYS} == "NetBSD" && !empty(PKGSRC_COMPILER:Mclang) && !exists(/lib/libgcc_s.so)
+BUILDLINK_TRANSFORM+= rm:-lgcc_s
+MAKE_ENV+= PKGSRC_HAVE_LIBCPP=yes
+.endif
+
+pre-build: pre-build-fix
+.if ${OPSYS} == "NetBSD" && !empty(PKGSRC_COMPILER:Mclang) && !exists(/lib/libgcc_s.so)
+ cp ${FILESDIR}/libgcc_s.so.1 ${RUST_BOOTSTRAP_PATH}/lib/.
+.endif
+
+do-build:
+ cd ${WRKSRC} \
+ && ${_ULIMIT_CMD} ${SETENV} ${INSTALL_ENV} ${MAKE_ENV} \
+ sh -c "if [ \"${BUILD_TARGET}\" = \"dist\" ]; then \
+ unset DESTDIR; \
+ fi; \
+ ${PYTHONBIN} ./x.py -v ${BUILD_TARGET} -j ${_MAKE_JOBS_N}"
+
+do-install:
+ cd ${WRKSRC} \
+ && ${_ULIMIT_CMD} ${SETENV} ${INSTALL_ENV} ${MAKE_ENV} \
+ ${PYTHONBIN} ./x.py -v install -j ${_MAKE_JOBS_N}
+
+.if ${OPSYS} == "Darwin"
+.PHONY: fix-darwin-install-name
+post-install: fix-darwin-install-name
+fix-darwin-install-name:
+ for f in ${DESTDIR}${PREFIX}/lib/librustc_macros-*.dylib \
+ ${DESTDIR}${PREFIX}/lib/libchalk_derive-*.dylib; do \
+ install_name_tool -id `${ECHO} $$f | ${SED} -e 's,${DESTDIR},,g'` $$f; \
+ done
+.endif
+
+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 that can be
+# used to build the next version of rust. Currently only tested on SmartOS.
+#
+BOOTSTRAP_TMPDIR= ${WRKDIR}/${PKGNAME_NOREV}-${RUST_ARCH}
+USE_TOOLS+= gtar
+
+# The NetBSD part is so far untested, because I could not convince
+# the rust build to use the gcc wrapper when building natively,
+# so that I could get a placeholder in the RPATH, because chrpath
+# cannot extend the length of the RPATH...
+ELFEDIT?= /usr/bin/elfedit
+
+.PHONY: stage0-bootstrap
+stage0-bootstrap: install
+ ${RM} -rf ${BOOTSTRAP_TMPDIR}
+ ${MKDIR} ${BOOTSTRAP_TMPDIR}
+.if ${OPSYS} == "NetBSD"
+ (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}"; \
+ )
+.endif
+.if ${OS_VARIANT} == "SmartOS"
+ ${CP} -R ${DESTDIR}/${PREFIX}/bin ${BOOTSTRAP_TMPDIR}/
+ ${CP} -R ${DESTDIR}/${PREFIX}/lib ${BOOTSTRAP_TMPDIR}/
+ ${MKDIR} ${BOOTSTRAP_TMPDIR}/lib/pkgsrc
+ for lib in libgcc_s.so.1 libssp.so.0 libstdc++.so.6; do \
+ ${CP} `${PKG_CC} -print-file-name=$${lib}` \
+ ${BOOTSTRAP_TMPDIR}/lib/pkgsrc/; \
+ done
+ # direct dependencies
+ for lib in libLLVM-10.so libcrypto.so.1.1 libcurl.so.4 \
+ libssl.so.1.1 libz.so.1; do \
+ ${CP} ${PREFIX}/lib/$${lib} ${BOOTSTRAP_TMPDIR}/lib/pkgsrc/; \
+ done
+ # libcurl dependencies
+ for lib in libiconv.so.2 libidn2.so.0 libintl.so.8 liblber-2.4.so.2 \
+ libldap-2.4.so.2 libnghttp2.so.14 libsasl2.so.3 \
+ libssh2.so.1 libunistring.so.2; do \
+ ${CP} ${PREFIX}/lib/$${lib} ${BOOTSTRAP_TMPDIR}/lib/pkgsrc/; \
+ done
+ for f in ${BOOTSTRAP_TMPDIR}/bin/*; do \
+ /bin/file -b "$$f" | grep ^ELF >/dev/null || continue; \
+ ${ELFEDIT} -e 'dyn:runpath $$ORIGIN/../lib:$$ORIGIN/../lib/pkgsrc' $$f; \
+ done
+ for f in ${BOOTSTRAP_TMPDIR}/lib/pkgsrc/*.so*; do \
+ ${ELFEDIT} -e 'dyn:runpath $$ORIGIN' $$f; \
+ done
+ for f in ${BOOTSTRAP_TMPDIR}/lib/*.so*; do \
+ ${ELFEDIT} -e 'dyn:runpath $$ORIGIN:$$ORIGIN/pkgsrc' $$f; \
+ done
+ for f in ${BOOTSTRAP_TMPDIR}/lib/rustlib/*/*/*.so*; do \
+ ${ELFEDIT} -e 'dyn:runpath $$ORIGIN:$$ORIGIN/../../..:$$ORIGIN/../../../pkgsrc' $$f; \
+ done
+ (cd ${WRKDIR}; \
+ ${GTAR} -zcf ${PKGNAME_NOREV}-${RUST_ARCH}.tar.gz ${PKGNAME_NOREV}-${RUST_ARCH})
+.endif
+
+.include "options.mk"
+
+# These dependencies currently use the bundled sources as they require
+# development features not yet available in released versions.
+#
+#.include "../../devel/libgit2/buildlink3.mk"
+#.include "../../security/libssh2/buildlink3.mk"
+#.include "../../www/http-parser/buildlink3.mk"
+#.include "../../devel/jemalloc/buildlink3.mk"
+
+## Issues specific to: bootstrap AND NetBSD follow
+
+# (I wish this worked on powerpc, but it doesn't since
+# I can't build with the internal LLVM, ref.
+# https://github.com/rust-lang/rust/issues/65862)
+
+.if (${OPSYS} == "NetBSD") && \
+ ((${MACHINE_ARCH} == "i386") || \
+ (${MACHINE_ARCH} == "sparc64") || \
+ (${MACHINE_ARCH} == "powerpc")) \
+ && (empty(OS_VERSION:M[012345678].*) || \
+ !empty(OS_VERSION:M8.99.*))
+# Bootstrap kits are built on 8.0, so that a single bootstrap can run
+# on multiple systems. Thus later versions need the compat80 package.
+# \todo Explain why this is limited to a small list of architectures,
+# and in particular why not x86_64.
+DEPENDS+= compat80>=0:../../emulators/compat80
+.endif
+
+.if (${OPSYS} == "NetBSD") && \
+ ((${MACHINE_ARCH} == "i386")) \
+ && (empty(OS_VERSION:M[012345678].*) || \
+ !empty(OS_VERSION:M8.99.*))
+# Bootstrap kits use openssl, which on NetBSD 8 comes from pkgsrc.
+# Therefore the pkgsrc openssl libs need to be present as well.
+# The 1.44.1 i686 bootstrap links with pkgsrc openssl. The others do
+# not. When the package is built,
+# cargo links against pkgsrc openssl, so it must be a run-time
+# dependency as well. Forcing USE_BUILTIN.openssl=no results in a
+# mysterious heimdal error, but straight DEPENDS seems to result in a
+# satisfactory package build.
+# While this is icky, it is for the time being better than no rust package.
+DEPENDS+= openssl>=1.1:../../security/openssl
+.endif
+
+.include "../../devel/zlib/buildlink3.mk"
+.include "../../lang/python/tool.mk"
+.include "../../security/openssl/buildlink3.mk"
+BUILDLINK_API_DEPENDS.curl+= curl>=7.67.0
+.include "../../www/curl/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/rust/buildlink3.mk b/rust/buildlink3.mk
new file mode 100644
index 0000000000..346f079673
--- /dev/null
+++ b/rust/buildlink3.mk
@@ -0,0 +1,16 @@
+# $NetBSD: buildlink3.mk,v 1.6 2020/07/08 14:46:14 jperkin Exp $
+
+#
+# DO NOT include this directly! Use rust.mk instead.
+#
+BUILDLINK_TREE+= rust
+
+.if !defined(RUST_BUILDLINK3_MK)
+RUST_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.rust+= rust>=1.20.0
+BUILDLINK_PKGSRCDIR.rust?= ../../wip/rust
+BUILDLINK_PASSTHRU_DIRS+= ${PREFIX}/lib/rustlib
+.endif
+
+BUILDLINK_TREE+= -rust
diff --git a/rust/cargo.mk b/rust/cargo.mk
new file mode 100644
index 0000000000..ebc8867e9f
--- /dev/null
+++ b/rust/cargo.mk
@@ -0,0 +1,78 @@
+# $NetBSD: cargo.mk,v 1.22 2020/08/14 21:19:22 tnn Exp $
+#
+# 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
+
+.include "../../lang/rust/rust.mk"
+
+USE_TOOLS+= bsdtar digest
+CARGO_VENDOR_DIR= ${WRKDIR}/vendor
+
+DISTFILES?= ${DEFAULT_DISTFILES}
+.for crate in ${CARGO_CRATE_DEPENDS}
+DISTFILES+= ${crate}.crate
+SITES.${crate}.crate+= -${MASTER_SITE_CRATESIO}${crate:C/-[0-9]+\.[0-9.]+.*$//}/${crate:C/^.*-([0-9]+\.[0-9.]+.*)$/\1/}/download
+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 ${MACHINE_PLATFORM:MNetBSD-[1-9].*} && !${MACHINE_PLATFORM:MNetBSD-9.99.*}
+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} ${WRKSRC}/.cargo
+ ${RUN}${PRINTF} "[source.crates-io]\nreplace-with = \"vendored-sources\"\n[source.vendored-sources]\ndirectory = \"${CARGO_VENDOR_DIR}\"\n" > ${WRKSRC}/.cargo/config
+ ${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; \
+ }' ${WRKSRC}/Cargo.lock
+
+DEFAULT_CARGO_ARGS= build --offline --release -j${_MAKE_JOBS_N}
+CARGO_ARGS?= ${DEFAULT_CARGO_ARGS}
+
+.if !target(do-build)
+do-build: do-cargo-build
+.endif
+
+.PHONY: do-cargo-build
+do-cargo-build:
+ ${RUN} cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${PREFIX}/bin/cargo ${CARGO_ARGS}
diff --git a/rust/cross.mk b/rust/cross.mk
new file mode 100644
index 0000000000..3ae16dfd9a
--- /dev/null
+++ b/rust/cross.mk
@@ -0,0 +1,67 @@
+# $NetBSD: cross.mk,v 1.3 2020/07/16 09:35:37 jperkin Exp $
+
+# These settings may be used to cross-build rust.
+#
+# They interact with the files/gcc-wrap script to pick the
+# right compiler for the different phases of the build, and
+# use the headers for the target when required. Note that the
+# cross-root tree will need to have the required binary packages
+# installed (curl etc., see list of buildlink3.mk includes in main
+# Makefile).
+
+# The gcc-wrap / c++-wrap script takes CROSS_ROOT environment variable
+# to do a cross-build. The wrapper script assumes dest/ and tools/
+# as a result of a cross-build of NetBSD as subdirectories of this root
+#CROSS_ROOT= /u/evbarm-armv7hf
+#CROSS_ROOT= /u/sparc64
+#CROSS_ROOT= /u/macppc
+#CROSS_ROOT= /u/9.0-macppc
+#CROSS_ROOT= /u/evbarm64
+#CROSS_ROOT= /u/i386
+#MAKE_ENV+= CROSS_ROOT=${CROSS_ROOT}
+
+# The GNU cross target designation
+#GNU_CROSS_TARGET= armv7--netbsdelf-eabihf
+#GNU_CROSS_TARGET= sparc64--netbsd
+#GNU_CROSS_TARGET= i486--netbsdelf
+#GNU_CROSS_TARGET= powerpc--netbsd
+#GNU_CROSS_TARGET= aarch64--netbsd
+#MAKE_ENV+= GNU_CROSS_TARGET=${GNU_CROSS_TARGET}
+
+# To cross-build rust, you need to specify
+# the ultimate target to built for, as well as the
+# host the compiler is supposed to run on.
+# Rust's target designation
+#TARGET= armv7-unknown-netbsd-eabihf
+#TARGET= sparc64-unknown-netbsd
+#TARGET= powerpc-unknown-netbsd
+#TARGET= aarch64-unknown-netbsd
+#TARGET= i686-unknown-netbsd
+#
+#SCRIPTS= ${WRKDIR}/scripts
+#CONFIGURE_ARGS+= --host=${TARGET}
+#CONFIGURE_ARGS+= --target=${TARGET}
+#CONFIGURE_ARGS+= --set=target.${TARGET}.cc=${SCRIPTS}/gcc-wrap
+#CONFIGURE_ARGS+= --set=target.${TARGET}.cxx=${SCRIPTS}/c++-wrap
+#CONFIGURE_ARGS+= --set=target.${TARGET}.linker=${SCRIPTS}/gcc-wrap
+#CONFIGURE_ARGS+= --set=target.${TARGET}.ar=${CROSS_ROOT}/tools/bin/${GNU_CROSS_TARGET}-ar
+
+# May be required when cross-building on NetBSD
+#MAKE_ENV+= OPENSSL_DIR=/usr
+
+#
+# Cross-compile illumos target. The host is identical, it's just the target
+# that is renamed from x86_64-sun-solaris to x86_64-unknown-illumos.
+#
+#TARGET= x86_64-unknown-illumos
+#
+# Use these variables for "cross-compiling" from x86_64-sun-solaris.
+#
+#CONFIGURE_ARGS+= --set=target.${TARGET}.llvm-config=${LLVM_CONFIG_PATH}
+#CONFIGURE_ARGS+= --host=${TARGET}
+#CONFIGURE_ARGS+= --target=${TARGET}
+#
+# Set this variable when using a native x86_64-unknown-illumos bootstrap, as
+# the build still defaults to x86_64-sun-solaris based on uname.
+#
+#CONFIGURE_ARGS+= --build=${TARGET}
diff --git a/rust/distinfo b/rust/distinfo
new file mode 100644
index 0000000000..d2312f79d8
--- /dev/null
+++ b/rust/distinfo
@@ -0,0 +1,127 @@
+$NetBSD: distinfo,v 1.118 2020/08/06 11:42:56 jperkin Exp $
+
+SHA1 (rust-1.44.0-armv7-unknown-netbsd-eabihf.tar.gz) = c08ff8852b5a8af3df62728ead7a5bd342b416d6
+RMD160 (rust-1.44.0-armv7-unknown-netbsd-eabihf.tar.gz) = 512a339ae09b7803d2d97d1a65e35a32022bac5b
+SHA512 (rust-1.44.0-armv7-unknown-netbsd-eabihf.tar.gz) = c2bae11700ceb20753ced519db77b58640b6306d9cbf979cbc3fcb80dcd6d580283a227599aa7e5dee2dac5ad230290f6ee19843ae5522103e41e9d5c14ff2cc
+Size (rust-1.44.0-armv7-unknown-netbsd-eabihf.tar.gz) = 148880580 bytes
+SHA1 (rust-1.44.1-aarch64-unknown-netbsd.tar.gz) = e5ff7fdc3d6c126867b0a8d029bf23d38bf61b01
+RMD160 (rust-1.44.1-aarch64-unknown-netbsd.tar.gz) = 7d0a0c3ae1c1c579ee282bd14f8f97577f94799a
+SHA512 (rust-1.44.1-aarch64-unknown-netbsd.tar.gz) = ffde9bb83988291e259377de7229380cb6eee47342fb6465a0aa80efa6f98b33ec0f20eb3eb8bbeb7c8dd4cd8468d47ce61f0297987d22d73a3f0db4af01b49e
+Size (rust-1.44.1-aarch64-unknown-netbsd.tar.gz) = 155146344 bytes
+SHA1 (rust-1.44.1-i686-unknown-freebsd.tar.gz) = 84de4d6ac613724d4a3d7077411bb2e617888a19
+RMD160 (rust-1.44.1-i686-unknown-freebsd.tar.gz) = 1ac0f9dff7f32f8637af8d066e09c8aea39de716
+SHA512 (rust-1.44.1-i686-unknown-freebsd.tar.gz) = 913b8d7016eccb2bdec3ddfbf25f6e00319e4b9a7151426bc374c5ab1d6e1703eccf1a8a40dfcb34b12a96079b36bcc76ed8842c9e2cfcb44c9b3d2d14c23bea
+Size (rust-1.44.1-i686-unknown-freebsd.tar.gz) = 123791731 bytes
+SHA1 (rust-1.44.1-i686-unknown-linux-gnu.tar.gz) = 053e7703cef1cce55a032198d60245c8713b5176
+RMD160 (rust-1.44.1-i686-unknown-linux-gnu.tar.gz) = 4d17c0ed0df388dad2e07992ea278d7004550b7a
+SHA512 (rust-1.44.1-i686-unknown-linux-gnu.tar.gz) = eadcb9feb8cfefd23b8d75324fb9de01d983c5ddfdfe9ca1f909470bfe5a4fe90cd85f5d3d76c13e24b60acf99305a14311a030e153fd3f92dc420bcfcd7e029
+Size (rust-1.44.1-i686-unknown-linux-gnu.tar.gz) = 205340142 bytes
+SHA1 (rust-1.44.1-i686-unknown-netbsd.tar.gz) = 8de77aa5ce6e4ed3ab3e88e09820a7490adf4564
+RMD160 (rust-1.44.1-i686-unknown-netbsd.tar.gz) = f7bd0f5ccca4be910bd1eae5d68d89d1ce03c9f5
+SHA512 (rust-1.44.1-i686-unknown-netbsd.tar.gz) = d14eb2968b2bf5fe6329fddce652ac53c1179caffefac9117bb1397092df2cd7749804b8351aedbb16a2cbce990fac11a5021a189aeb9f87885d716a1a9488f5
+Size (rust-1.44.1-i686-unknown-netbsd.tar.gz) = 164323310 bytes
+SHA1 (rust-1.44.1-powerpc-unknown-netbsd.tar.gz) = c126c0124efcc36df0ac7c2c4e0836e1587fa2be
+RMD160 (rust-1.44.1-powerpc-unknown-netbsd.tar.gz) = 160ae6e795e7dd28f3e9e095da5a026f34b5fa40
+SHA512 (rust-1.44.1-powerpc-unknown-netbsd.tar.gz) = 704095c99a43e3d61f6329187ea96b011561ca07c576de4b60778b2e09e4d8f7365d746a5ac075cdde36738275b745bc119b11e908024b07690a401bb2936985
+Size (rust-1.44.1-powerpc-unknown-netbsd.tar.gz) = 172387750 bytes
+SHA1 (rust-1.44.1-sparc64-unknown-netbsd.tar.gz) = 88d53387943b9456ab9660bb0a9556f0c635cc85
+RMD160 (rust-1.44.1-sparc64-unknown-netbsd.tar.gz) = 0c59faa5190dfeb161bf5752d03f548efb19a4bc
+SHA512 (rust-1.44.1-sparc64-unknown-netbsd.tar.gz) = b48cbb0903ff3e4b64f593f9d3ba93d5049ceacf4b1945ccc487e4e94e09592b80a2992171b6f55887d7e9b77b5e8d6a65ce8c24b40bd47ff89440c19f031e5c
+Size (rust-1.44.1-sparc64-unknown-netbsd.tar.gz) = 163658729 bytes
+SHA1 (rust-1.44.1-x86_64-apple-darwin.tar.gz) = efce87a3d3d48d93f031e165b9794a850eafee2e
+RMD160 (rust-1.44.1-x86_64-apple-darwin.tar.gz) = d4aa88273da38bfc74030dd4e15f7dac11c2afc6
+SHA512 (rust-1.44.1-x86_64-apple-darwin.tar.gz) = 81b923805f0425311073142e6cb798429c1833240b3951cd615850f13900d6a47e2751bf65389246db7b98a7a81c11fa90d3a6861c4eff579cda6af53097c0d4
+Size (rust-1.44.1-x86_64-apple-darwin.tar.gz) = 173941368 bytes
+SHA1 (rust-1.44.1-x86_64-unknown-freebsd.tar.gz) = a4a32fc0300272f7ab75973cf95ca7a52b4cba24
+RMD160 (rust-1.44.1-x86_64-unknown-freebsd.tar.gz) = a26b6a2df7e8d09e92549490121b73fd6a938ce5
+SHA512 (rust-1.44.1-x86_64-unknown-freebsd.tar.gz) = 750d0e7b07bc3fba1980ef4ccd777a2c062283b9c94798e6150ade7f1de40d32f3398a8f6675220649ee2fc3c537f6071981dd852ba0933c7619731d33be1244
+Size (rust-1.44.1-x86_64-unknown-freebsd.tar.gz) = 124148420 bytes
+SHA1 (rust-1.44.1-x86_64-unknown-linux-gnu.tar.gz) = d9f79f976c7270a782cba9e5c08f3064d94ccb1e
+RMD160 (rust-1.44.1-x86_64-unknown-linux-gnu.tar.gz) = 3a5cbf8538b3aadfe2bda6cbec5599a2eccba9ce
+SHA512 (rust-1.44.1-x86_64-unknown-linux-gnu.tar.gz) = aa78c32a3dfd4b01d5e69a44bc978206b50581586af1b45105400fbd6b28a9946141063d68781218ca9fbaaf0edfdfe708081ecf97facba176095868b6187773
+Size (rust-1.44.1-x86_64-unknown-linux-gnu.tar.gz) = 189534350 bytes
+SHA1 (rust-1.44.1-x86_64-unknown-netbsd.tar.gz) = fdb370afafbd7d5d2664ca1e7193d7fab3ec37fe
+RMD160 (rust-1.44.1-x86_64-unknown-netbsd.tar.gz) = 9947ed43a8291676505b2890bf586be3499df691
+SHA512 (rust-1.44.1-x86_64-unknown-netbsd.tar.gz) = 06e21c3ca1ef29a6d2239a89eb207b4cbc03f9f86a74edf9aebebb2260fdbd7adcaa0ffcd4526d5447fb0b05491819ed61262c90210095a9db83f6ee4da38e86
+Size (rust-1.44.1-x86_64-unknown-netbsd.tar.gz) = 129662288 bytes
+SHA1 (rust-1.46.0-x86_64-sun-solaris.tar.gz) = 081ed2fab901b7b4fbf5035b731abe7793e927b8
+RMD160 (rust-1.46.0-x86_64-sun-solaris.tar.gz) = fdac437710f87a228d4c56b569fc831784f193c5
+SHA512 (rust-1.46.0-x86_64-sun-solaris.tar.gz) = cbb5be647b1ee0f2f2074d1e3138e6b1ec69e500e4411342255128b1625cb78797af15e0bc895601d62f43ce50049401b2f88edb7c951a405ee7aa645e4b67cf
+Size (rust-1.46.0-x86_64-sun-solaris.tar.gz) = 174780795 bytes
+SHA1 (rust-1.46.0-x86_64-unknown-illumos.tar.gz) = f9b133e52fc471ff516abae622ef828a5f4cafed
+RMD160 (rust-1.46.0-x86_64-unknown-illumos.tar.gz) = 65cd79b4a437d50054b942f302199bae4554638c
+SHA512 (rust-1.46.0-x86_64-unknown-illumos.tar.gz) = 85d93cd49a595c854f8174d0406da631e094af9aa9889124c072fb62b55d8bae75fc291df1a12635cd3bf9110d7f9aa1d1c9240592f811937b70f563a588d24a
+Size (rust-1.46.0-x86_64-unknown-illumos.tar.gz) = 174764552 bytes
+SHA1 (rust-std-1.44.0-armv7-unknown-netbsd-eabihf.tar.gz) = ef2043dd95e4b56526060f9497c523ca7670ebcd
+RMD160 (rust-std-1.44.0-armv7-unknown-netbsd-eabihf.tar.gz) = f2a11dea07bd9982b99e26baf74259ce21af3121
+SHA512 (rust-std-1.44.0-armv7-unknown-netbsd-eabihf.tar.gz) = 8903e258f3cc3a9fd8b1bf982b42560bbc47b3be583dea8687d50eadc92a98f739211d865a812de2cf6e4828e94e97a5934a02120d3eaff8342669ee1e0afc37
+Size (rust-std-1.44.0-armv7-unknown-netbsd-eabihf.tar.gz) = 17716720 bytes
+SHA1 (rust-std-1.44.1-aarch64-unknown-netbsd.tar.gz) = 546a8299b855cb900ac6faaf388225635d7db3eb
+RMD160 (rust-std-1.44.1-aarch64-unknown-netbsd.tar.gz) = aa115005fda7c572546aba6eed507a9d1cfb311d
+SHA512 (rust-std-1.44.1-aarch64-unknown-netbsd.tar.gz) = 5eaf1d1d334e30c713c2b3da9de59e6ddd2970371b3e797cf5306e44ad4babcd6e8c0bd392306e65e44e0b3a3ecca40adf4ae1a083911cb4203f40f758f9ee4f
+Size (rust-std-1.44.1-aarch64-unknown-netbsd.tar.gz) = 17873583 bytes
+SHA1 (rust-std-1.44.1-i686-unknown-freebsd.tar.gz) = 68cc2c9fc4af62e0b2d1a39e18c714895fa95c8f
+RMD160 (rust-std-1.44.1-i686-unknown-freebsd.tar.gz) = 823551f739cf6d0a75b973696d93bd7d9bfccea5
+SHA512 (rust-std-1.44.1-i686-unknown-freebsd.tar.gz) = 1a395c368f6b64876e3169934d9c3f8ea07bfd509bbd80a958d0db9903fc7f99b1f2b3222ad69ebc576a916fe185d3730f2521afa2e523ecee1245c494f21b4d
+Size (rust-std-1.44.1-i686-unknown-freebsd.tar.gz) = 22674933 bytes
+SHA1 (rust-std-1.44.1-i686-unknown-linux-gnu.tar.gz) = 630421b44f3d1c6028be520cd9f01704e1c5b7cb
+RMD160 (rust-std-1.44.1-i686-unknown-linux-gnu.tar.gz) = 4a059a0a969cb3c8dcc2b70d45f63967c69e0a65
+SHA512 (rust-std-1.44.1-i686-unknown-linux-gnu.tar.gz) = a1a837f3740651f4985589350c0cfbf01c696e319086efe209adf7aa018de594f32b40cb5cafd376448b828a32a074b7d5a8535f48d4427e06092b8b6ae3b033
+Size (rust-std-1.44.1-i686-unknown-linux-gnu.tar.gz) = 23338895 bytes
+SHA1 (rust-std-1.44.1-i686-unknown-netbsd.tar.gz) = 6474a717f40ea14d562f9e5ad94e1ebfdfd36a8f
+RMD160 (rust-std-1.44.1-i686-unknown-netbsd.tar.gz) = bf861949d2ee970f23598f93f45b14704e476982
+SHA512 (rust-std-1.44.1-i686-unknown-netbsd.tar.gz) = ce194778568f96baf42163a46ac56719f8827d904c9dcda0a9bb5916ca32f5fbd40aa9620d2ebbaf8532c826d4265874a617f670b771680a6dfb1bcc64c15687
+Size (rust-std-1.44.1-i686-unknown-netbsd.tar.gz) = 19334579 bytes
+SHA1 (rust-std-1.44.1-powerpc-unknown-netbsd.tar.gz) = 128b4213938261131f7db2f853cfa6f337c66b72
+RMD160 (rust-std-1.44.1-powerpc-unknown-netbsd.tar.gz) = 12749d0af13fff59359d901014550627a8d72540
+SHA512 (rust-std-1.44.1-powerpc-unknown-netbsd.tar.gz) = bdbb4310cf34db0283544ea61336e28ee721fe1092faba09d946f769f7d0f3f9efb11579154b1572bec1b95fd35133e676e20a59ecaf2bec71d4541849553d56
+Size (rust-std-1.44.1-powerpc-unknown-netbsd.tar.gz) = 17452288 bytes
+SHA1 (rust-std-1.44.1-sparc64-unknown-netbsd.tar.gz) = a3c9f64fba652ae7d3c16cde7ee2547bc87fd92d
+RMD160 (rust-std-1.44.1-sparc64-unknown-netbsd.tar.gz) = ab1ab014a26c5d724bb0745bfab951ef2123d5bc
+SHA512 (rust-std-1.44.1-sparc64-unknown-netbsd.tar.gz) = d96f88e872669fb5c36804b1f99422f36c23d7ca0cd12bb2b31485e3993c5639fd9d79ef8ea8df4f6aacfea4620239c3379586856ba76309705965c048330a98
+Size (rust-std-1.44.1-sparc64-unknown-netbsd.tar.gz) = 17626664 bytes
+SHA1 (rust-std-1.44.1-x86_64-apple-darwin.tar.gz) = 06df3959bedb25a5f47e6f050a4c26217a303d9e
+RMD160 (rust-std-1.44.1-x86_64-apple-darwin.tar.gz) = 770585582cc6af8f96464140001ef5cddba899a9
+SHA512 (rust-std-1.44.1-x86_64-apple-darwin.tar.gz) = f121d275b2fddf3bbf24f4f23d2f156e4b8da838a408e5268c1b755e1b400c0199477890a49aaf9331376d4c364d2ef90c3293d3e7b5ddea78b43587489ba3ba
+Size (rust-std-1.44.1-x86_64-apple-darwin.tar.gz) = 23935573 bytes
+SHA1 (rust-std-1.44.1-x86_64-unknown-freebsd.tar.gz) = b6d63ae79006d0e1e16954d5f490b599e95e524e
+RMD160 (rust-std-1.44.1-x86_64-unknown-freebsd.tar.gz) = c7d893fbdf4d28386ab059a595ecb1e2b999fc92
+SHA512 (rust-std-1.44.1-x86_64-unknown-freebsd.tar.gz) = 2d052db6eab154366fc872a96a11a5c81f87b7b93ac348bd4e059291fffc6b2d111b98fa6e73dd5098e33bd0294dac50efde52c26d93b5f8f57978d2b09f3952
+Size (rust-std-1.44.1-x86_64-unknown-freebsd.tar.gz) = 22873337 bytes
+SHA1 (rust-std-1.44.1-x86_64-unknown-linux-gnu.tar.gz) = d39a6f66ec30a2bf19730f901727fdc3943bc607
+RMD160 (rust-std-1.44.1-x86_64-unknown-linux-gnu.tar.gz) = fade7ca14a845c1433db0f91785125e0d470b6f3
+SHA512 (rust-std-1.44.1-x86_64-unknown-linux-gnu.tar.gz) = ac700cb7c7133cfd2a53a12be7b6955c435032a237235d803a26ae9dac793ff14d09155271da160f35b93c25970920ceddacd7f413292caa90ea7dd125cc5d93
+Size (rust-std-1.44.1-x86_64-unknown-linux-gnu.tar.gz) = 26512846 bytes
+SHA1 (rust-std-1.44.1-x86_64-unknown-netbsd.tar.gz) = 08b3b9c6f88d4775fef9884ae78e95dc4af3057e
+RMD160 (rust-std-1.44.1-x86_64-unknown-netbsd.tar.gz) = 880bf477fd42647db5c20b810442060ab12ec3b1
+SHA512 (rust-std-1.44.1-x86_64-unknown-netbsd.tar.gz) = 489a702fdec977d82e497e9ab692eb41f1bf0573fa8b3d8c0c07b5e0faf2a866865b4c275826a23f0cdfcd34b89df3190e34990e9e7092f20ce4bf4e387548c1
+Size (rust-std-1.44.1-x86_64-unknown-netbsd.tar.gz) = 22890301 bytes
+SHA1 (rustc-1.47.0-src.tar.gz) = 5a337c88aeb04a31011037671588fd66b046ca32
+RMD160 (rustc-1.47.0-src.tar.gz) = 2fee85c5e52046982a51eff62f64e123f798ed56
+SHA512 (rustc-1.47.0-src.tar.gz) = a6df9e2d599806eeddbfb35f7dea976781533f63d369a765b8a304221281c9f9e642ff952978f69eaaa0b28740ab5ea566b35ce481097c37fd5117bfec1f43dd
+Size (rustc-1.47.0-src.tar.gz) = 151861620 bytes
+SHA1 (patch-library_backtrace_crates_backtrace-sys_src_libbacktrace_configure) = 5dc1cfc843894156b513c86453db5032917a5529
+SHA1 (patch-library_std_build.rs) = 34b95b6dcaa788fe7e0e10e9c77a796d35e6ca14
+SHA1 (patch-library_std_src_sys_unix_thread.rs) = f3af869fba5bc0ab8d28042f55fe830f93b8ef54
+SHA1 (patch-library_unwind_build.rs) = ae096a20aed95304eb3806be4cd237fe4ffd9afb
+SHA1 (patch-src_bootstrap_bootstrap.py) = 53e0409527f3e52dd00b5c86e6c38047626e2379
+SHA1 (patch-src_bootstrap_builder.rs) = d0fa2a58fa89171cb58e236384bcce614daf412f
+SHA1 (patch-src_bootstrap_compile.rs) = 67d5ad13e13e6818535a319f55e990d511e7b83f
+SHA1 (patch-src_bootstrap_lib.rs) = 3277f2be69a269ac761a2a6ab4d5389d121e6ca6
+SHA1 (patch-src_librustc__codegen__ssa_back_linker.rs) = 48b71063184c1ef608d41a8cf5014a6c064a8893
+SHA1 (patch-src_librustc__llvm_build.rs) = 7cc2aa0568aa2cbf4eb1fdbb00922b10df0b3ff6
+SHA1 (patch-src_librustc__target_spec_solaris__base.rs) = 10b00a889f2d3788172098021e8fc1e4939ec897
+SHA1 (patch-src_librustc__target_spec_x86__64__sun__solaris.rs) = f6ad33b41906bbf83a1cbd0e2fe13a4da37266fa
+SHA1 (patch-src_llvm-project_llvm_CMakeLists.txt) = d49503d19c30a64d571eb7fa79e7aad7038cd427
+SHA1 (patch-src_llvm-project_llvm_cmake_modules_AddLLVM.cmake) = 77a2a9e4d324885d6fa5e68cf15ef84db0a2483b
+SHA1 (patch-src_llvm-project_llvm_include_llvm-c_DataTypes.h) = 7588a46aaa277ef04b33ac6d904b9d1d81579f2a
+SHA1 (patch-src_llvm-project_llvm_include_llvm_Analysis_ConstantFolding.h) = 977de4b2a9d37f7e7c782f2407c15591e032b6c6
+SHA1 (patch-src_llvm-project_llvm_utils_FileCheck_FileCheck.cpp) = 2675b93a1d636b297a3e1e84b915a15a3da67939
+SHA1 (patch-src_tools_cargo_src_cargo_core_profiles.rs) = 3aac5d54a6fe96b9559552e67e497488142d4e80
+SHA1 (patch-src_tools_cargo_tests_testsuite_build.rs) = 10e6c1253adac0262b000aec7636fa0d2ebb666c
+SHA1 (patch-src_tools_rls_rls_src_cmd.rs) = fade3e60fecac5c4e4d4ee5bee82659b4eb385b7
+SHA1 (patch-src_tools_rls_rls_src_server_io.rs) = 51af64526db55abcf6b4b3165df314a16cf62e34
+SHA1 (patch-src_tools_rust-installer_install-template.sh) = f2ec6dced2be1fa23773d5827503ad07d0913dc2
+SHA1 (patch-vendor_libc_src_unix_solarish_mod.rs) = 804ea03be546fef0d2bd37d7f8abb26d38a7892b
+SHA1 (patch-vendor_lzma-sys_config.h) = b654c7e129fa02697734bc87173f89b3056a5437
+SHA1 (patch-vendor_stacker_src_lib.rs) = 2f4db9971c0558ec7034052c810b8c8be80c4ae3
diff --git a/rust/files/gcc-wrap b/rust/files/gcc-wrap
new file mode 100644
index 0000000000..53b45e099f
--- /dev/null
+++ b/rust/files/gcc-wrap
@@ -0,0 +1,161 @@
+#! /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:-/}
+
+native=false
+if [ $root = "/" ]; then
+ native=true
+else
+ # What's the tools/bin prefix (if we're cross-building)?
+ gnuarch=${GNU_CROSS_TARGET:?}
+fi
+
+# Who are we a wrapper for? (Typically either gcc or c++)
+who=$(basename $0 | sed -e 's/-wrap$//')
+
+args=""
+
+# 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
+ args="$args -isystem =$1"
+ ;;
+# 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)
+ args="$args -I=/usr/pkg/include"
+ ;;
+ -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
+ args="$args -I=/usr/pkg/include"
+ 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"
+else
+ cmd="${root}/tools/bin/${gnuarch}-${who} \
+ --sysroot=${root}/dest \
+ $args"
+fi
+
+# Cannot echo to stdout, messes up e.g. "gcc -print-prog-name=ld" output...
+#echo $cmd >&2
+exec $cmd
diff --git a/rust/options.mk b/rust/options.mk
new file mode 100644
index 0000000000..4af966e7d4
--- /dev/null
+++ b/rust/options.mk
@@ -0,0 +1,32 @@
+# $NetBSD: options.mk,v 1.7 2020/06/24 09:46:26 nia Exp $
+
+PKG_OPTIONS_VAR= PKG_OPTIONS.rust
+PKG_SUPPORTED_OPTIONS= # empty
+
+.include "../../mk/bsd.fast.prefs.mk"
+
+# The bundled LLVM current has issues building on SunOS.
+.if ${OPSYS} != "SunOS" && ${OPSYS} != "Darwin"
+PKG_SUPPORTED_OPTIONS+= rust-llvm
+# There may be compatibility issues with base LLVM.
+. if !empty(HAVE_LLVM)
+PKG_SUGGESTED_OPTIONS+= rust-llvm
+. endif
+.endif
+
+.include "../../mk/bsd.options.mk"
+
+#
+# Use the internal copy of LLVM.
+# This contains some extra optimizations.
+#
+.if !empty(PKG_OPTIONS:Mrust-llvm)
+BUILD_DEPENDS+= cmake-[0-9]*:../../devel/cmake
+.include "../../devel/cmake/buildlink3.mk"
+.else
+.include "../../lang/llvm/buildlink3.mk"
+CONFIGURE_ARGS+= --enable-llvm-link-shared
+CONFIGURE_ARGS+= --llvm-root=${BUILDLINK_PREFIX.llvm}
+# XXX: fix for Rust 1.41.0 https://github.com/rust-lang/rust/issues/68714
+MAKE_ENV+= LIBRARY_PATH=${BUILDLINK_PREFIX.llvm}/lib
+.endif
diff --git a/rust/patches/patch-library_backtrace_crates_backtrace-sys_src_libbacktrace_configure b/rust/patches/patch-library_backtrace_crates_backtrace-sys_src_libbacktrace_configure
new file mode 100644
index 0000000000..22cd6d2c9d
--- /dev/null
+++ b/rust/patches/patch-library_backtrace_crates_backtrace-sys_src_libbacktrace_configure
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Use pkgsrc libtool.
+
+--- library/backtrace/crates/backtrace-sys/src/libbacktrace/configure.orig 2020-10-07 08:04:03.000000000 +0000
++++ library/backtrace/crates/backtrace-sys/src/libbacktrace/configure
+@@ -7916,7 +7916,7 @@ fi
+ LIBTOOL_DEPS="$ltmain"
+
+ # Always use our own libtool.
+-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
++LIBTOOL='libtool'
+
+
+
diff --git a/rust/patches/patch-library_std_build.rs b/rust/patches/patch-library_std_build.rs
new file mode 100644
index 0000000000..838fe6d070
--- /dev/null
+++ b/rust/patches/patch-library_std_build.rs
@@ -0,0 +1,33 @@
+$NetBSD$
+
+Add libexecinfo for backtrace() on NetBSD.
+Add libumem and SSP (ugly) on SunOS.
+
+--- library/std/build.rs.orig 2020-10-07 07:53:22.000000000 +0000
++++ library/std/build.rs
+@@ -20,6 +20,7 @@ fn main() {
+ println!("cargo:rustc-cfg=freebsd12");
+ }
+ } else if target.contains("netbsd") {
++ println!("cargo:rustc-link-lib=execinfo");
+ println!("cargo:rustc-link-lib=pthread");
+ println!("cargo:rustc-link-lib=rt");
+ } else if target.contains("dragonfly") || target.contains("openbsd") {
+@@ -29,6 +30,9 @@ fn main() {
+ println!("cargo:rustc-link-lib=posix4");
+ println!("cargo:rustc-link-lib=pthread");
+ println!("cargo:rustc-link-lib=resolv");
++ println!("cargo:rustc-link-lib=nsl");
++ println!("cargo:rustc-link-lib=umem");
++ println!("cargo:rustc-link-lib=ssp");
+ } else if target.contains("illumos") {
+ println!("cargo:rustc-link-lib=socket");
+ println!("cargo:rustc-link-lib=posix4");
+@@ -37,6 +41,7 @@ fn main() {
+ println!("cargo:rustc-link-lib=nsl");
+ // Use libumem for the (malloc-compatible) allocator
+ println!("cargo:rustc-link-lib=umem");
++ println!("cargo:rustc-link-lib=ssp");
+ } else if target.contains("apple-darwin") {
+ println!("cargo:rustc-link-lib=System");
+
diff --git a/rust/patches/patch-library_std_src_sys_unix_thread.rs b/rust/patches/patch-library_std_src_sys_unix_thread.rs
new file mode 100644
index 0000000000..c88d599d98
--- /dev/null
+++ b/rust/patches/patch-library_std_src_sys_unix_thread.rs
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Fix stack-clash on SunOS.
+
+--- library/std/src/sys/unix/thread.rs.orig 2020-10-07 07:53:22.000000000 +0000
++++ library/std/src/sys/unix/thread.rs
+@@ -333,7 +333,7 @@ pub mod guard {
+ let page_size = os::page_size();
+ PAGE_SIZE.store(page_size, Ordering::Relaxed);
+
+- if cfg!(all(target_os = "linux", not(target_env = "musl"))) {
++ if cfg!(any(target_os = "solaris", all(target_os = "linux", not(target_env = "musl")))) {
+ // Linux doesn't allocate the whole stack right away, and
+ // the kernel has its own stack-guard mechanism to fault
+ // when growing too close to an existing mapping. If we map
diff --git a/rust/patches/patch-library_unwind_build.rs b/rust/patches/patch-library_unwind_build.rs
new file mode 100644
index 0000000000..a4d557934b
--- /dev/null
+++ b/rust/patches/patch-library_unwind_build.rs
@@ -0,0 +1,17 @@
+$NetBSD$
+
+Fix build on NetBSD HEAD-llvm. XXX there is probably a better way to do this.
+
+--- library/unwind/build.rs.orig 2020-10-07 07:53:22.000000000 +0000
++++ library/unwind/build.rs
+@@ -23,7 +23,9 @@ fn main() {
+ } else if target.contains("rumprun") {
+ println!("cargo:rustc-link-lib=unwind");
+ } else if target.contains("netbsd") {
+- println!("cargo:rustc-link-lib=gcc_s");
++ if !env::var_os("PKGSRC_HAVE_LIBCPP").is_some() {
++ println!("cargo:rustc-link-lib=gcc_s");
++ }
+ } else if target.contains("openbsd") {
+ if target.contains("sparc64") {
+ println!("cargo:rustc-link-lib=gcc");
diff --git a/rust/patches/patch-src_bootstrap_bootstrap.py b/rust/patches/patch-src_bootstrap_bootstrap.py
new file mode 100644
index 0000000000..10bfd17f30
--- /dev/null
+++ b/rust/patches/patch-src_bootstrap_bootstrap.py
@@ -0,0 +1,43 @@
+$NetBSD: patch-src_bootstrap_bootstrap.py,v 1.4 2020/02/17 20:24:18 jperkin Exp $
+
+Use `uname -p` on NetBSD, as that is reliable and sensible there.
+Do not use debuginfo; optimize 'bootstrap' instead.
+Handle earmv7hf for NetBSD.
+
+--- src/bootstrap/bootstrap.py.orig 2020-01-27 15:34:02.000000000 +0000
++++ src/bootstrap/bootstrap.py
+@@ -185,6 +185,11 @@ def default_build_triple():
+ 'OpenBSD': 'unknown-openbsd'
+ }
+
++ # For NetBSD, use `uname -p`, as there it is reliable & sensible
++ if ostype == 'NetBSD':
++ cputype = subprocess.check_output(
++ ['uname', '-p']).strip().decode(default_encoding)
++
+ # Consider the direct transformation first and then the special cases
+ if ostype in ostype_mapper:
+ ostype = ostype_mapper[ostype]
+@@ -271,10 +276,12 @@ def default_build_triple():
+ ostype = 'linux-androideabi'
+ else:
+ ostype += 'eabihf'
+- elif cputype in {'armv7l', 'armv8l'}:
++ elif cputype in {'armv7l', 'armv8l', 'earmv7hf'}:
+ cputype = 'armv7'
+ if ostype == 'linux-android':
+ ostype = 'linux-androideabi'
++ elif ostype == 'unknown-netbsd':
++ ostype += '-eabihf'
+ else:
+ ostype += 'eabihf'
+ elif cputype == 'mips':
+@@ -645,7 +652,7 @@ class RustBuild(object):
+ if "LIBRARY_PATH" in env else ""
+ # preserve existing RUSTFLAGS
+ env.setdefault("RUSTFLAGS", "")
+- env["RUSTFLAGS"] += " -Cdebuginfo=2"
++ env["RUSTFLAGS"] += " -Copt-level=2"
+
+ build_section = "target.{}".format(self.build_triple())
+ target_features = []
diff --git a/rust/patches/patch-src_bootstrap_builder.rs b/rust/patches/patch-src_bootstrap_builder.rs
new file mode 100644
index 0000000000..326c4a8189
--- /dev/null
+++ b/rust/patches/patch-src_bootstrap_builder.rs
@@ -0,0 +1,26 @@
+$NetBSD: patch-src_bootstrap_builder.rs,v 1.11 2020/07/06 13:56:32 he Exp $
+
+Do not install 'src'.
+Use @PREFIX@, not $ORIGIN in rpath.
+
+Fix RPATH for pkgsrc.
+
+--- src/bootstrap/builder.rs.orig 2020-08-24 15:00:49.000000000 +0000
++++ src/bootstrap/builder.rs
+@@ -481,7 +481,6 @@ impl<'a> Builder<'a> {
+ install::Clippy,
+ install::Miri,
+ install::Analysis,
+- install::Src,
+ install::Rustc
+ ),
+ Kind::Run => describe!(run::ExpandYamlAnchors,),
+@@ -1003,7 +1002,7 @@ impl<'a> Builder<'a> {
+ rustflags.arg("-Zosx-rpath-install-name");
+ Some("-Wl,-rpath,@loader_path/../lib")
+ } else if !target.contains("windows") {
+- Some("-Wl,-rpath,$ORIGIN/../lib")
++ Some("-Wl,-rpath,@PREFIX@/lib")
+ } else {
+ None
+ };
diff --git a/rust/patches/patch-src_bootstrap_compile.rs b/rust/patches/patch-src_bootstrap_compile.rs
new file mode 100644
index 0000000000..4477683d77
--- /dev/null
+++ b/rust/patches/patch-src_bootstrap_compile.rs
@@ -0,0 +1,15 @@
+$NetBSD: patch-src_bootstrap_compile.rs,v 1.1 2020/03/14 08:02:46 jperkin Exp $
+
+On Darwin, do not use @rpath for internal libraries.
+
+--- src/bootstrap/compile.rs.orig 2020-03-09 22:11:17.000000000 +0000
++++ src/bootstrap/compile.rs
+@@ -290,7 +290,7 @@ fn copy_sanitizers(
+ // Update the library install name reflect the fact it has been renamed.
+ let status = Command::new("install_name_tool")
+ .arg("-id")
+- .arg(format!("@rpath/{}", runtime.name))
++ .arg(format!("@PREFIX@/lib/{}", runtime.name))
+ .arg(&dst)
+ .status()
+ .expect("failed to execute `install_name_tool`");
diff --git a/rust/patches/patch-src_bootstrap_lib.rs b/rust/patches/patch-src_bootstrap_lib.rs
new file mode 100644
index 0000000000..f7549fe29e
--- /dev/null
+++ b/rust/patches/patch-src_bootstrap_lib.rs
@@ -0,0 +1,27 @@
+$NetBSD: patch-src_bootstrap_lib.rs,v 1.7 2020/03/13 18:34:53 jperkin Exp $
+
+Don't filter out optimization flags.
+FreeBSD has a particular C++ runtime library name
+
+--- src/bootstrap/lib.rs.orig 2020-03-09 22:11:17.000000000 +0000
++++ src/bootstrap/lib.rs
+@@ -759,7 +759,6 @@ impl Build {
+ .args()
+ .iter()
+ .map(|s| s.to_string_lossy().into_owned())
+- .filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
+ .collect::<Vec<String>>();
+
+ // If we're compiling on macOS then we add a few unconditional flags
+@@ -770,6 +769,11 @@ impl Build {
+ base.push("-stdlib=libc++".into());
+ }
+
++ // FreeBSD (from 10.2) also uses libc++.
++ if target.contains("freebsd") {
++ base.push("-stdlib=libc++".into());
++ }
++
+ // Work around an apparently bad MinGW / GCC optimization,
+ // See: http://lists.llvm.org/pipermail/cfe-dev/2016-December/051980.html
+ // See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78936
diff --git a/rust/patches/patch-src_librustc__codegen__ssa_back_linker.rs b/rust/patches/patch-src_librustc__codegen__ssa_back_linker.rs
new file mode 100644
index 0000000000..adf11fc4bf
--- /dev/null
+++ b/rust/patches/patch-src_librustc__codegen__ssa_back_linker.rs
@@ -0,0 +1,15 @@
+$NetBSD: patch-src_librustc__codegen__ssa_back_linker.rs,v 1.1 2019/09/09 16:19:49 adam Exp $
+
+Do not use @rpath on Darwin.
+
+--- src/librustc_codegen_ssa/back/linker.rs.orig 2020-08-24 15:00:49.000000000 +0000
++++ src/librustc_codegen_ssa/back/linker.rs
+@@ -244,7 +244,7 @@ impl<'a> GccLinker<'a> {
+ // the right `-Wl,-install_name` with an `@rpath` in it.
+ if self.sess.opts.cg.rpath || self.sess.opts.debugging_opts.osx_rpath_install_name {
+ self.linker_arg("-install_name");
+- let mut v = OsString::from("@rpath/");
++ let mut v = OsString::from("@PREFIX@/lib/");
+ v.push(out_filename.file_name().unwrap());
+ self.linker_arg(&v);
+ }
diff --git a/rust/patches/patch-src_librustc__llvm_build.rs b/rust/patches/patch-src_librustc__llvm_build.rs
new file mode 100644
index 0000000000..7398c1e442
--- /dev/null
+++ b/rust/patches/patch-src_librustc__llvm_build.rs
@@ -0,0 +1,21 @@
+$NetBSD: patch-src_librustc__llvm_build.rs,v 1.6 2019/09/19 17:37:29 jperkin Exp $
+
+fix build on NetBSD HEAD-llvm. XXX there is probably a better way to do this.
+
+--- src/librustc_llvm/build.rs.orig 2019-08-13 06:27:22.000000000 +0000
++++ src/librustc_llvm/build.rs
+@@ -261,7 +261,13 @@ fn main() {
+ "c++"
+ } else if target.contains("netbsd") && llvm_static_stdcpp.is_some() {
+ // NetBSD uses a separate library when relocation is required
+- "stdc++_pic"
++ 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/patches/patch-src_librustc__target_spec_solaris__base.rs b/rust/patches/patch-src_librustc__target_spec_solaris__base.rs
new file mode 100644
index 0000000000..20cf835a47
--- /dev/null
+++ b/rust/patches/patch-src_librustc__target_spec_solaris__base.rs
@@ -0,0 +1,14 @@
+$NetBSD: patch-src_librustc__target_spec_solaris__base.rs,v 1.3 2020/03/13 18:34:53 jperkin Exp $
+
+Enable frame pointers on SunOS.
+
+--- src/librustc_target/spec/solaris_base.rs.orig 2020-08-24 15:00:49.000000000 +0000
++++ src/librustc_target/spec/solaris_base.rs
+@@ -7,6 +7,7 @@ pub fn opts() -> TargetOptions {
+ has_rpath: true,
+ target_family: Some("unix".to_string()),
+ is_like_solaris: true,
++ eliminate_frame_pointer: false,
+ limit_rdylib_exports: false, // Linker doesn't support this
+ eh_frame_header: false,
+
diff --git a/rust/patches/patch-src_librustc__target_spec_x86__64__sun__solaris.rs b/rust/patches/patch-src_librustc__target_spec_x86__64__sun__solaris.rs
new file mode 100644
index 0000000000..9401273cf7
--- /dev/null
+++ b/rust/patches/patch-src_librustc__target_spec_x86__64__sun__solaris.rs
@@ -0,0 +1,15 @@
+$NetBSD: patch-src_librustc__target_spec_x86__64__sun__solaris.rs,v 1.1 2019/05/31 14:11:23 jperkin Exp $
+
+Enable stack probes on SunOS.
+
+--- src/librustc_target/spec/x86_64_sun_solaris.rs.orig 2019-01-16 09:30:27.000000000 +0000
++++ src/librustc_target/spec/x86_64_sun_solaris.rs
+@@ -15,7 +15,7 @@ pub fn target() -> TargetResult {
+ base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".to_string()]);
+ base.cpu = "x86-64".to_string();
+ base.max_atomic_width = Some(64);
+- base.stack_probes = true;
++ base.stack_probes = false;
+
+ Ok(Target {
+ llvm_target: "x86_64-pc-solaris".to_string(),
diff --git a/rust/patches/patch-src_llvm-project_llvm_CMakeLists.txt b/rust/patches/patch-src_llvm-project_llvm_CMakeLists.txt
new file mode 100644
index 0000000000..c0bacd7327
--- /dev/null
+++ b/rust/patches/patch-src_llvm-project_llvm_CMakeLists.txt
@@ -0,0 +1,18 @@
+$NetBSD: patch-src_llvm-project_llvm_CMakeLists.txt,v 1.1 2019/04/14 12:42:03 he Exp $
+
+Don't implement sys/regset.h workaround, fix source instead.
+
+--- src/llvm-project/llvm/CMakeLists.txt.orig 2018-03-10 02:51:13.000000000 +0000
++++ src/llvm-project/llvm/CMakeLists.txt
+@@ -806,11 +806,6 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBS
+ link_directories("/usr/local/lib")
+ endif(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
+
+-if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
+- # special hack for Solaris to handle crazy system sys/regset.h
+- include_directories("${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris")
+-endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
+-
+ # Make sure we don't get -rdynamic in every binary. For those that need it,
+ # use export_executable_symbols(target).
+ set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
diff --git a/rust/patches/patch-src_llvm-project_llvm_cmake_modules_AddLLVM.cmake b/rust/patches/patch-src_llvm-project_llvm_cmake_modules_AddLLVM.cmake
new file mode 100644
index 0000000000..b832b38dba
--- /dev/null
+++ b/rust/patches/patch-src_llvm-project_llvm_cmake_modules_AddLLVM.cmake
@@ -0,0 +1,16 @@
+$NetBSD: patch-src_llvm-project_llvm_cmake_modules_AddLLVM.cmake,v 1.3 2020/08/06 11:42:56 jperkin Exp $
+
+"-z discard-unused" is only supported by Oracle Solaris ld.
+On Darwin, use correct install-name for shared libraries.
+
+--- src/llvm-project/llvm/cmake/modules/AddLLVM.cmake.orig 2020-09-22 17:14:20.000000000 +0000
++++ src/llvm-project/llvm/cmake/modules/AddLLVM.cmake
+@@ -2063,7 +2063,7 @@ function(llvm_setup_rpath name)
+ endif()
+
+ if (APPLE)
+- set(_install_name_dir INSTALL_NAME_DIR "@rpath")
++ set(_install_name_dir INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
+ set(_install_rpath "@loader_path/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
+ elseif(UNIX)
+ set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
diff --git a/rust/patches/patch-src_llvm-project_llvm_include_llvm-c_DataTypes.h b/rust/patches/patch-src_llvm-project_llvm_include_llvm-c_DataTypes.h
new file mode 100644
index 0000000000..6e8f9b1cdd
--- /dev/null
+++ b/rust/patches/patch-src_llvm-project_llvm_include_llvm-c_DataTypes.h
@@ -0,0 +1,34 @@
+$NetBSD: patch-src_llvm-project_llvm_include_llvm-c_DataTypes.h,v 1.1 2019/04/14 12:42:03 he Exp $
+
+Don't implement sys/regset.h workaround, fix source instead.
+
+--- src/llvm-project/llvm/include/llvm-c/DataTypes.h.orig 2018-08-01 16:32:37.000000000 +0000
++++ src/llvm-project/llvm/include/llvm-c/DataTypes.h
+@@ -87,4 +87,27 @@ typedef signed int ssize_t;
+ #define HUGE_VALF (float)HUGE_VAL
+ #endif
+
++#if defined(__sun)
++#include <sys/regset.h>
++#undef CS
++#undef DS
++#undef ES
++#undef FS
++#undef GS
++#undef SS
++#undef EAX
++#undef ECX
++#undef EDX
++#undef EBX
++#undef ESP
++#undef EBP
++#undef ESI
++#undef EDI
++#undef EIP
++#undef UESP
++#undef EFL
++#undef ERR
++#undef TRAPNO
++#endif
++
+ #endif /* LLVM_C_DATATYPES_H */
diff --git a/rust/patches/patch-src_llvm-project_llvm_include_llvm_Analysis_ConstantFolding.h b/rust/patches/patch-src_llvm-project_llvm_include_llvm_Analysis_ConstantFolding.h
new file mode 100644
index 0000000000..42a14ee2e9
--- /dev/null
+++ b/rust/patches/patch-src_llvm-project_llvm_include_llvm_Analysis_ConstantFolding.h
@@ -0,0 +1,17 @@
+$NetBSD: patch-src_llvm-project_llvm_include_llvm_Analysis_ConstantFolding.h,v 1.1 2019/04/14 12:42:03 he Exp $
+
+Fix SunOS CS conflict not handled by include/llvm-c/DataTypes.h
+
+--- src/llvm-project/llvm/include/llvm/Analysis/ConstantFolding.h.orig 2018-08-01 16:32:37.000000000 +0000
++++ src/llvm-project/llvm/include/llvm/Analysis/ConstantFolding.h
+@@ -20,6 +20,10 @@
+ #ifndef LLVM_ANALYSIS_CONSTANTFOLDING_H
+ #define LLVM_ANALYSIS_CONSTANTFOLDING_H
+
++#ifdef __sun
++#undef CS
++#endif
++
+ namespace llvm {
+ class APInt;
+ template <typename T> class ArrayRef;
diff --git a/rust/patches/patch-src_llvm-project_llvm_utils_FileCheck_FileCheck.cpp b/rust/patches/patch-src_llvm-project_llvm_utils_FileCheck_FileCheck.cpp
new file mode 100644
index 0000000000..69f1312485
--- /dev/null
+++ b/rust/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.2 2019/10/02 12:51:43 he 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
+@@ -406,7 +406,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/patches/patch-src_tools_cargo_src_cargo_core_profiles.rs b/rust/patches/patch-src_tools_cargo_src_cargo_core_profiles.rs
new file mode 100644
index 0000000000..7262e6fbba
--- /dev/null
+++ b/rust/patches/patch-src_tools_cargo_src_cargo_core_profiles.rs
@@ -0,0 +1,17 @@
+$NetBSD: patch-src_tools_cargo_src_cargo_core_profiles.rs,v 1.3 2019/03/07 20:19:11 jperkin Exp $
+
+Turn off incremental builds for sparc64, ref.
+https://sources.debian.org/patches/cargo/0.29.0-1/2007_sparc64_disable_incremental_build.patch/
+
+--- src/tools/cargo/src/cargo/core/profiles.rs.orig 2018-10-24 20:01:28.000000000 +0000
++++ src/tools/cargo/src/cargo/core/profiles.rs
+@@ -458,6 +458,9 @@ impl Profile {
+ debuginfo: Some(2),
+ debug_assertions: true,
+ overflow_checks: true,
++ #[cfg(target_arch = "sparc64")]
++ incremental: false,
++ #[cfg(not(target_arch = "sparc64"))]
+ incremental: true,
+ ..Profile::default()
+ }
diff --git a/rust/patches/patch-src_tools_cargo_tests_testsuite_build.rs b/rust/patches/patch-src_tools_cargo_tests_testsuite_build.rs
new file mode 100644
index 0000000000..1770ff452d
--- /dev/null
+++ b/rust/patches/patch-src_tools_cargo_tests_testsuite_build.rs
@@ -0,0 +1,31 @@
+$NetBSD: patch-src_tools_cargo_tests_testsuite_build.rs,v 1.5 2019/08/29 14:09:57 he Exp $
+
+Don't attempt incremental operations on sparc64, ref.
+https://sources.debian.org/patches/cargo/0.29.0-1/2007_sparc64_disable_incremental_build.patch/
+
+--- src/tools/cargo/tests/testsuite/build.rs.orig 2019-08-13 06:27:40.000000000 +0000
++++ src/tools/cargo/tests/testsuite/build.rs
+@@ -38,6 +38,7 @@ fn cargo_fail_with_no_stderr() {
+
+ /// Checks that the `CARGO_INCREMENTAL` environment variable results in
+ /// `rustc` getting `-C incremental` passed to it.
++#[cfg(not(target_arch = "sparc64"))]
+ #[cargo_test]
+ fn cargo_compile_incremental() {
+ let p = project()
+@@ -60,6 +61,7 @@ fn cargo_compile_incremental() {
+ .run();
+ }
+
++#[cfg(not(target_arch = "sparc64"))]
+ #[cargo_test]
+ fn incremental_profile() {
+ let p = project()
+@@ -102,6 +104,7 @@ fn incremental_profile() {
+ .run();
+ }
+
++#[cfg(not(target_arch = "sparc64"))]
+ #[cargo_test]
+ fn incremental_config() {
+ let p = project()
diff --git a/rust/patches/patch-src_tools_rls_rls_src_cmd.rs b/rust/patches/patch-src_tools_rls_rls_src_cmd.rs
new file mode 100644
index 0000000000..bb99f197b0
--- /dev/null
+++ b/rust/patches/patch-src_tools_rls_rls_src_cmd.rs
@@ -0,0 +1,27 @@
+$NetBSD: patch-src_tools_rls_rls_src_cmd.rs,v 1.1 2019/04/14 12:42:03 he Exp $
+
+Use 32-bit atomic instead of 64-bit; latter may not be available on
+32-bit platforms (powerpc, earmv7).
+
+--- src/tools/rls/rls/src/cmd.rs.orig 2019-04-10 18:46:16.000000000 +0000
++++ src/tools/rls/rls/src/cmd.rs
+@@ -17,7 +17,7 @@ use crate::config::Config;
+ use crate::server::{self, LsService, Notification, Request, RequestId};
+ use rls_analysis::{AnalysisHost, Target};
+ use rls_vfs::Vfs;
+-use std::sync::atomic::{AtomicU64, Ordering};
++use std::sync::atomic::{AtomicU32, Ordering};
+
+ use lsp_types::{
+ ClientCapabilities, CodeActionContext, CodeActionParams, CompletionItem,
+@@ -323,8 +323,8 @@ fn url(file_name: &str) -> Url {
+ }
+
+ fn next_id() -> RequestId {
+- static ID: AtomicU64 = AtomicU64::new(1);
+- RequestId::Num(ID.fetch_add(1, Ordering::SeqCst))
++ static ID: AtomicU32 = AtomicU32::new(1);
++ RequestId::Num(ID.fetch_add(1, Ordering::SeqCst) as u64)
+ }
+
+ // Custom reader and output for the RLS server.
diff --git a/rust/patches/patch-src_tools_rls_rls_src_server_io.rs b/rust/patches/patch-src_tools_rls_rls_src_server_io.rs
new file mode 100644
index 0000000000..e2e80ac290
--- /dev/null
+++ b/rust/patches/patch-src_tools_rls_rls_src_server_io.rs
@@ -0,0 +1,41 @@
+$NetBSD: patch-src_tools_rls_rls_src_server_io.rs,v 1.2 2019/05/31 14:11:23 jperkin Exp $
+
+Use 32-bit atomic instead of 64-bit; latter may not be available on
+32-bit platforms (powerpc, earmv7).
+
+--- src/tools/rls/rls/src/server/io.rs.orig 2019-05-20 12:10:32.000000000 +0000
++++ src/tools/rls/rls/src/server/io.rs
+@@ -7,7 +7,7 @@ use crate::lsp_data::{LSPNotification, L
+
+ use std::fmt;
+ use std::io::{self, BufRead, Write};
+-use std::sync::atomic::{AtomicU64, Ordering};
++use std::sync::atomic::{AtomicU32, Ordering};
+ use std::sync::Arc;
+
+ use jsonrpc_core::{self as jsonrpc, response, version, Id};
+@@ -171,13 +171,13 @@ pub trait Output: Sync + Send + Clone +
+ /// An output that sends notifications and responses on `stdout`.
+ #[derive(Clone)]
+ pub(super) struct StdioOutput {
+- next_id: Arc<AtomicU64>,
++ next_id: Arc<AtomicU32>,
+ }
+
+ impl StdioOutput {
+ /// Constructs a new `stdout` output.
+ pub(crate) fn new() -> StdioOutput {
+- StdioOutput { next_id: Arc::new(AtomicU64::new(1)) }
++ StdioOutput { next_id: Arc::new(AtomicU32::new(1)) }
+ }
+ }
+
+@@ -194,7 +194,7 @@ impl Output for StdioOutput {
+ }
+
+ fn provide_id(&self) -> RequestId {
+- RequestId::Num(self.next_id.fetch_add(1, Ordering::SeqCst))
++ RequestId::Num(self.next_id.fetch_add(1, Ordering::SeqCst) as u64)
+ }
+ }
+
diff --git a/rust/patches/patch-src_tools_rust-installer_install-template.sh b/rust/patches/patch-src_tools_rust-installer_install-template.sh
new file mode 100644
index 0000000000..adae00e912
--- /dev/null
+++ b/rust/patches/patch-src_tools_rust-installer_install-template.sh
@@ -0,0 +1,36 @@
+$NetBSD: patch-src_tools_rust-installer_install-template.sh,v 1.3 2018/11/27 15:45:23 adam Exp $
+
+No logging to 'install.log'.
+Do not create 'uninstall.sh'.
+
+--- src/tools/rust-installer/install-template.sh.orig 2018-11-07 03:23:50.000000000 +0000
++++ src/tools/rust-installer/install-template.sh
+@@ -15,20 +15,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() {
+@@ -972,7 +964,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/patches/patch-vendor_libc_src_unix_solarish_mod.rs b/rust/patches/patch-vendor_libc_src_unix_solarish_mod.rs
new file mode 100644
index 0000000000..3ae0e9e640
--- /dev/null
+++ b/rust/patches/patch-vendor_libc_src_unix_solarish_mod.rs
@@ -0,0 +1,15 @@
+$NetBSD: patch-vendor_libc_src_unix_solarish_mod.rs,v 1.1 2019/05/31 14:11:23 jperkin Exp $
+
+Fix xattr build.
+
+--- vendor/libc/src/unix/solarish/mod.rs.orig 2019-05-20 13:47:24.000000000 +0000
++++ vendor/libc/src/unix/solarish/mod.rs
+@@ -981,6 +981,8 @@ pub const EOWNERDEAD: ::c_int = 58;
+ pub const ENOTRECOVERABLE: ::c_int = 59;
+ pub const ENOSTR: ::c_int = 60;
+ pub const ENODATA: ::c_int = 61;
++// This is not supported but is required for xattr
++pub const ENOATTR: ::c_int = ::ENODATA;
+ pub const ETIME: ::c_int = 62;
+ pub const ENOSR: ::c_int = 63;
+ pub const ENONET: ::c_int = 64;
diff --git a/rust/patches/patch-vendor_lzma-sys_config.h b/rust/patches/patch-vendor_lzma-sys_config.h
new file mode 100644
index 0000000000..67963cec47
--- /dev/null
+++ b/rust/patches/patch-vendor_lzma-sys_config.h
@@ -0,0 +1,18 @@
+$NetBSD: patch-vendor_lzma-sys_config.h,v 1.1 2019/10/28 00:42:21 jperkin Exp $
+
+Fix SunOS builds with newer compilers.
+
+--- vendor/lzma-sys/config.h.orig 2020-10-07 09:33:31.000000000 +0000
++++ vendor/lzma-sys/config.h
+@@ -35,7 +35,11 @@
+ // change to `MYTHREAD_WIN95` if targeting Windows XP or earlier
+ #define MYTHREAD_VISTA 1
+ #else
++#if !defined(__sun) || (__STDC_VERSION__-0 < 199901L)
+ #define _POSIX_C_SOURCE 199506L
++#else
++ #define _POSIX_C_SOURCE 200112L
++#endif
+ #define MYTHREAD_POSIX 1
+ #endif
+
diff --git a/rust/patches/patch-vendor_stacker_src_lib.rs b/rust/patches/patch-vendor_stacker_src_lib.rs
new file mode 100644
index 0000000000..c875d3bffc
--- /dev/null
+++ b/rust/patches/patch-vendor_stacker_src_lib.rs
@@ -0,0 +1,15 @@
+$NetBSD: patch-vendor_stacker_src_lib.rs,v 1.1 2020/08/06 11:42:56 jperkin Exp $
+
+Avoid missing pthread_* on older SunOS.
+
+--- vendor/stacker/src/lib.rs.orig 2020-07-13 18:18:17.000000000 +0000
++++ vendor/stacker/src/lib.rs
+@@ -355,7 +355,7 @@ cfg_if! {
+ );
+ Some(mi.assume_init().AllocationBase as usize + get_thread_stack_guarantee() + 0x1000)
+ }
+- } else if #[cfg(any(target_os = "linux", target_os="solaris", target_os = "netbsd"))] {
++ } else if #[cfg(any(target_os = "linux", target_os = "netbsd"))] {
+ unsafe fn guess_os_stack_limit() -> Option<usize> {
+ let mut attr = std::mem::MaybeUninit::<libc::pthread_attr_t>::uninit();
+ assert_eq!(libc::pthread_attr_init(attr.as_mut_ptr()), 0);
diff --git a/rust/platform.mk b/rust/platform.mk
new file mode 100644
index 0000000000..750faeab9e
--- /dev/null
+++ b/rust/platform.mk
@@ -0,0 +1,28 @@
+# $NetBSD: platform.mk,v 1.5 2020/08/06 11:42:56 jperkin Exp $
+
+# 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>7
+. for rust_arch in aarch64 armv7 i386 powerpc sparc64 x86_64
+. for rust_os in Darwin FreeBSD Linux NetBSD SunOS
+# rust fails to build on NetBSD/earmv7
+# http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=54621
+. if ${OPSYS} != "NetBSD" || empty(OS_VERSION:M[0-7].*)
+RUST_PLATFORMS+= ${rust_os}-*-${rust_arch}
+. endif
+. endfor
+. endfor
+
+. 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/rust.mk b/rust/rust.mk
new file mode 100644
index 0000000000..fd55f46a3c
--- /dev/null
+++ b/rust/rust.mk
@@ -0,0 +1,55 @@
+# $NetBSD: rust.mk,v 1.6 2020/09/27 18:38:35 nia Exp $
+#
+# 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 bootstrap-from-source or an official binary.
+#
+# Official Rust binaries are only published for certain platforms,
+# including Darwin, Linux, and NetBSD x86_64.
+#
+# Possible values: src bin
+# Default: src
+#
+# === Package-settable variables ===
+#
+# RUST_REQ
+# The minimum version of Rust required by the package.
+#
+# Default: 1.20.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"
+
+RUST_REQ?= 1.20.0
+RUST_RUNTIME?= no
+
+RUST_TYPE?= src
+
+.if ${RUST_TYPE} == "bin"
+. if ${RUST_RUNTIME} == "no"
+BUILDLINK_DEPMETHOD.rust-bin?= build
+. endif
+BUILDLINK_API_DEPENDS.rust-bin+= rust-bin>=${RUST_REQ}
+. include "../../lang/rust-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 "../../lang/rust/buildlink3.mk"
+.endif
Home |
Main Index |
Thread Index |
Old Index