summaryrefslogtreecommitdiff
path: root/lang/rust
diff options
context:
space:
mode:
authorhe <he@pkgsrc.org>2018-10-13 10:03:36 +0000
committerhe <he@pkgsrc.org>2018-10-13 10:03:36 +0000
commit74967afe00d9b4bc810f4afdc693dfbfa21dd5be (patch)
treeb74a7b4946b2729c3b7755b4952cb91b52cd847f /lang/rust
parent1daea4ac30470a7b7d224af5030df99d754cdcd1 (diff)
downloadpkgsrc-74967afe00d9b4bc810f4afdc693dfbfa21dd5be.tar.gz
Add the bits required to build rust on NetBSD/powerpc ports, and
point to the bootstrap kit for NetBSD/powerpc I'm hosting at the moment. Also add the bits I used when cross-building the NetBSD/powerpc rust on amd64, commented out, as well as the gcc / c++ wrapper script I used in the process. The changes affecting other ports are: * We now add LD_LIBRARY_PATH in the make environment, so that if the bootstrap kit binaries and shared libraries don't have the $ORIGIN-style RPATH entries, it will still work * The bootstrap.py script has been changed to turn off the generation of debuginfo in "RUSTFLAGS"; for some so far unknown reason, the NetBSD/powerpc rust will not build if you ask for debug info. This could perhaps have been made OS-variant dependent, but isn't at the moment. So .. bump PKGREVISION.
Diffstat (limited to 'lang/rust')
-rw-r--r--lang/rust/Makefile98
-rw-r--r--lang/rust/distinfo13
-rw-r--r--lang/rust/files/gcc-wrap94
-rw-r--r--lang/rust/patches/patch-src_bootstrap_bootstrap.py29
-rw-r--r--lang/rust/patches/patch-src_libstd_build.rs12
5 files changed, 239 insertions, 7 deletions
diff --git a/lang/rust/Makefile b/lang/rust/Makefile
index 7558127d0a6..c001043a931 100644
--- a/lang/rust/Makefile
+++ b/lang/rust/Makefile
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.54 2018/10/09 12:40:05 ryoon Exp $
+# $NetBSD: Makefile,v 1.55 2018/10/13 10:03:36 he Exp $
DISTNAME= rustc-1.29.1-src
PKGNAME= ${DISTNAME:S/rustc/rust/:S/-src//}
+PKGREVISION= 1
CATEGORIES= lang
MASTER_SITES= http://static.rust-lang.org/dist/
@@ -33,6 +34,48 @@ CONFIGURE_ARGS+= --disable-llvm-static-stdcpp
CONFIGURE_ARGS+= --disable-ninja
CONFIGURE_ARGS.SunOS+= --disable-jemalloc
+# 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 as subdirectories of this root
+#CROSS_ROOT= /u/macppc
+#MAKE_ENV+= CROSS_ROOT=${CROSS_ROOT}
+
+# The GNU cross target designation
+#GNU_CROSS_TARGET= powerpc--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= powerpc-unknown-netbsd
+#CONFIGURE_ARGS+= --host=${TARGET}
+#CONFIGURE_ARGS+= --target=${TARGET}
+#CONFIGURE_ARGS+= --set=target.${TARGET}.cc=${.CURDIR}/files/gcc-wrap
+#CONFIGURE_ARGS+= --set=target.${TARGET}.cxx=${.CURDIR}/files/c++-wrap
+#CONFIGURE_ARGS+= --set=target.${TARGET}.linker=${.CURDIR}/files/gcc-wrap
+#CONFIGURE_ARGS+= --set=target.${TARGET}.ar=${CROSS_ROOT}/tools/bin/${CROSS_TARGET}-ar
+
+# May be required when cross-building on NetBSD
+#MAKE_ENV+= OPENSSL_DIR=/usr
+
+# Getting RPATH with $ORIGIN into bootstrap may be troublesome, so
+# uncommenting the LD_LIBRARY_PATH setting may be required to run
+# the bootstrap
+MAKE_ENV+= LD_LIBRARY_PATH=${.CURDIR}/work/rust-bootstrap/lib
+
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-powerpc)
+# 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-debuginfo-tests
+CONFIGURE_ARGS+= --disable-debug-assertions
+CONFIGURE_ARGS+= --disable-debuginfo
+CONFIGURE_ARGS+= --disable-debuginfo-lines
+CONFIGURE_ARGS+= --disable-debuginfo-only-std
+CONFIGURE_ARGS+= --disable-debuginfo-tools
+.endif
+
# 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
@@ -145,6 +188,17 @@ 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_ARCH= powerpc-unknown-netbsd
+RUST_STAGE0_VER= 1.28.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}
+# Do not trust he@.
+SITES.${RUST_STAGE0}= ftp://golden-delicious.urc.uninett.no/pub/rust/
+SITES.${RUST_STD_STAGE0}= ftp://golden-delicious.urc.uninett.no/pub/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)
@@ -181,6 +235,10 @@ post-extract:
${WRKSRC}/src/vendor/libc/.cargo-checksum.json.patched
${CP} -f ${WRKSRC}/src/vendor/libc/.cargo-checksum.json.patched \
${WRKSRC}/src/vendor/libc/.cargo-checksum.json
+.if ${OPSYS} == "NetBSD"
+ ${RM} -f ${.CURDIR}/files/c++-wrap
+ ${LN} -s ${.CURDIR}/files/gcc-wrap ${.CURDIR}/files/c++-wrap
+.endif
.if ${OPSYS} != "SunOS"
LD_LIBRARY_PATH= ${RUST_BOOTSTRAP_PATH}/lib
@@ -246,12 +304,46 @@ fix-darwin-install-name:
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...
+
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}/
-.if ${OS_VARIANT} == "SmartOS"
${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}` \
@@ -275,9 +367,9 @@ stage0-bootstrap: install
for f in ${BOOTSTRAP_TMPDIR}/lib/rustlib/${RUST_ARCH}/*/*.so*; do \
/usr/bin/elfedit -e 'dyn:runpath $$ORIGIN:$$ORIGIN/../../..:$$ORIGIN/../../../pkgsrc' $$f; \
done
-.endif
(cd ${WRKDIR}; \
${GTAR} -zcf ${PKGNAME_NOREV}-${RUST_ARCH}.tar.gz ${PKGNAME_NOREV}-${RUST_ARCH})
+.endif
.include "../../devel/cmake/buildlink3.mk"
.include "../../devel/libgit2/buildlink3.mk"
diff --git a/lang/rust/distinfo b/lang/rust/distinfo
index f48eb7d2e6b..928c7e62dbf 100644
--- a/lang/rust/distinfo
+++ b/lang/rust/distinfo
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.39 2018/09/30 17:46:24 minskim Exp $
+$NetBSD: distinfo,v 1.40 2018/10/13 10:03:36 he Exp $
SHA1 (rust-1.28.0-i686-apple-darwin.tar.gz) = 85d947b4d260361f63f77e1f4921ac89bd849d78
RMD160 (rust-1.28.0-i686-apple-darwin.tar.gz) = 963abf1b0b5e2673c8e2d6c1b4d5a2d8ed9d8d2f
@@ -68,15 +68,24 @@ SHA1 (rust-std-1.28.0-x86_64-unknown-netbsd.tar.gz) = a0b835fe0ad2b5a6d94bd99323
RMD160 (rust-std-1.28.0-x86_64-unknown-netbsd.tar.gz) = d06cabb8232d66d2a5cf3a1ee0f0f676c698e6c0
SHA512 (rust-std-1.28.0-x86_64-unknown-netbsd.tar.gz) = 726c5ef43db24b3d0548a2b0534934d6fcb04b0b9228b80cace18f59e21ad6facfbc2af3220867988a35414ba95fb90e38cc47d826dd73cb588622132ea6e9da
Size (rust-std-1.28.0-x86_64-unknown-netbsd.tar.gz) = 69236192 bytes
+SHA1 (rust-1.28.0-powerpc-unknown-netbsd.tar.gz) = 0e3e5be17acc8b088c2716e6d47ef6a51069fdde
+RMD160 (rust-1.28.0-powerpc-unknown-netbsd.tar.gz) = 848a243fa072eaf475583d8575d5457e66854c19
+SHA512 (rust-1.28.0-powerpc-unknown-netbsd.tar.gz) = 054837b5ddb0ec598d84336d4c257a430e8c096447c51e5e08b418d7a97f8ca5280998175f205cb2d901e7b92026c31ba3b972a0534f47eecd6d4aa0542a9655
+Size (rust-1.28.0-powerpc-unknown-netbsd.tar.gz) = 192518386 bytes
+SHA1 (rust-std-1.28.0-powerpc-unknown-netbsd.tar.gz) = 2eb760731636e19094d36aae84fca72094e1600a
+RMD160 (rust-std-1.28.0-powerpc-unknown-netbsd.tar.gz) = aa764f9cc59dd256718e17d5683bbc7e14657a75
+SHA512 (rust-std-1.28.0-powerpc-unknown-netbsd.tar.gz) = 265e71e390689a6e7624e3378fae767c22225bcbc03ad5fb84b91b48c53c3d364a3dc8bdcf11028aa618f0d11d126220911bb17e5c91f38361548e7673d37718
+Size (rust-std-1.28.0-powerpc-unknown-netbsd.tar.gz) = 66023865 bytes
SHA1 (rustc-1.29.1-src.tar.gz) = 5b1cc48bda7d77137062908def9b3f428dc3996d
RMD160 (rustc-1.29.1-src.tar.gz) = 780a25bb9c8fd60cde53ce617a0065362337d6ad
SHA512 (rustc-1.29.1-src.tar.gz) = 3151c398a79169af7dd0735d5115112cb64858120a637eda018cb4544dd9988f7540120cc0122d2af7348968285650d8605837e9f40337ec95e549d5e8763f04
Size (rustc-1.29.1-src.tar.gz) = 106095241 bytes
SHA1 (patch-src_bootstrap_bin_rustc.rs) = 0abf893090a6053e01fd658096d9a2b5b8c144da
+SHA1 (patch-src_bootstrap_bootstrap.py) = ed0c794ed15454acb3cbb9ede38ed76be35c7ca6
SHA1 (patch-src_bootstrap_lib.rs) = d86e173b931099730a4f18d044d7977c89f87b91
SHA1 (patch-src_libbacktrace_configure) = b2c1e9b93a99408aad42ab9f1af27704cc81bdd8
SHA1 (patch-src_liblibc_src_unix_solaris_mod.rs) = aeb7c22995e33c700ce3ea4336368a1fd08120e1
-SHA1 (patch-src_libstd_build.rs) = 32dad8a474300f9f37bce8b92acca762cf8cc4ab
+SHA1 (patch-src_libstd_build.rs) = 1edbf87339bd88e3178d4fa2fc408a6e802ed488
SHA1 (patch-src_libstd_sys_unix_thread.rs) = 46ef46365658e2f895bd3dde9c74f352890e9ccc
SHA1 (patch-src_llvm_CMakeLists.txt) = ffdf4337fdc84d8314c97c4e492e6b84244a99d1
SHA1 (patch-src_llvm_cmake_modules_AddLLVM.cmake) = f0620ac62ecfb1d62d2dfa61b4c063d21c29b8f5
diff --git a/lang/rust/files/gcc-wrap b/lang/rust/files/gcc-wrap
new file mode 100644
index 00000000000..3483266307f
--- /dev/null
+++ b/lang/rust/files/gcc-wrap
@@ -0,0 +1,94 @@
+#! /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=""
+linking=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"
+ ;;
+ -l*)
+ args="$args $1"
+ linking=true
+ ;;
+ *)
+ args="$args $1"
+ ;;
+ esac
+ shift
+done
+
+if $linking; then
+ # Lib directories to ensure we search and have in run-path
+ libs="/lib /usr/lib /usr/pkg/lib"
+
+ for d in $libs; do
+ # Run-path is for when we execute on the target,
+ # so no $root prefix
+ if ! $native; then
+ args="$args -L ${root}/dest/$d"
+ fi
+ args="$args -Wl,-rpath,$d"
+ done
+
+ # ...and add a placeholder so we can tweak with chrpath,
+ # since chrpath can't extend the length of the run path
+ placeholder="placeholder-$(date | openssl dgst -sha1 | \
+ awk '{ print $2 }')"
+ args="$args -Wl,-rpath,/$placeholder"
+ # the / is a sneaky attempt to let it past cwrapper...
+
+ # More debugging
+ args="$args -Wl,--verbose"
+
+ # For backtrace() (have patch now elsewhere)
+ #args="$args -lexecinfo"
+fi
+
+if $native; then
+ # Try to avoid cwrappers, which does "undocumented magic"
+ 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/lang/rust/patches/patch-src_bootstrap_bootstrap.py b/lang/rust/patches/patch-src_bootstrap_bootstrap.py
new file mode 100644
index 00000000000..3ed19333fbd
--- /dev/null
+++ b/lang/rust/patches/patch-src_bootstrap_bootstrap.py
@@ -0,0 +1,29 @@
+$NetBSD: patch-src_bootstrap_bootstrap.py,v 1.1 2018/10/13 10:03:37 he Exp $
+
+Use `uname -p` on NetBSD, as that's reliable & sensible there.
+Also force debuginfo to 0, otherwise the build doesn't work on
+NetBSD/macppc (powerpc).
+
+--- src/bootstrap/bootstrap.py.orig 2018-09-20 17:28:03.000000000 +0000
++++ src/bootstrap/bootstrap.py
+@@ -193,6 +193,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]
+@@ -619,7 +624,7 @@ class RustBuild(object):
+ env["LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib") + \
+ (os.pathsep + env["LIBRARY_PATH"]) \
+ if "LIBRARY_PATH" in env else ""
+- env["RUSTFLAGS"] = "-Cdebuginfo=2 "
++ env["RUSTFLAGS"] = "-Cdebuginfo=0 "
+
+ build_section = "target.{}".format(self.build_triple())
+ target_features = []
diff --git a/lang/rust/patches/patch-src_libstd_build.rs b/lang/rust/patches/patch-src_libstd_build.rs
index 4b5bcdd2e0d..1e9f9415d90 100644
--- a/lang/rust/patches/patch-src_libstd_build.rs
+++ b/lang/rust/patches/patch-src_libstd_build.rs
@@ -1,12 +1,20 @@
-$NetBSD: patch-src_libstd_build.rs,v 1.1 2017/11/16 19:48:24 jperkin Exp $
+$NetBSD: patch-src_libstd_build.rs,v 1.2 2018/10/13 10:03:37 he Exp $
SunOS support:
- Support PKGSRC_USE_SSP (ugly for now).
- Add libumem support.
+ - Add libexecinfo for backtrace().
--- src/libstd/build.rs.orig 2017-10-09 20:04:51.000000000 +0000
+++ src/libstd/build.rs
-@@ -46,6 +46,9 @@ fn main() {
+@@ -43,12 +43,16 @@ fn main() {
+ println!("cargo:rustc-link-lib=pthread");
+ } else if target.contains("dragonfly") || target.contains("bitrig") ||
+ target.contains("netbsd") || target.contains("openbsd") {
++ println!("cargo:rustc-link-lib=execinfo");
+ println!("cargo:rustc-link-lib=pthread");
+ } else if target.contains("solaris") {
+ println!("cargo:rustc-link-lib=socket");
println!("cargo:rustc-link-lib=posix4");
println!("cargo:rustc-link-lib=pthread");
println!("cargo:rustc-link-lib=resolv");