From 18b6d4234546b5a083f61ae589ee66e11a720f05 Mon Sep 17 00:00:00 2001 From: Niels Sascha Reedijk Date: Sat, 14 Mar 2020 18:47:00 +0000 Subject: [PATCH] Rust: add recipe for 1.42.0 (#4791) --- dev-lang/rust/patches/rust-1.42.0.patchset | 66 ++++++++ dev-lang/rust/rust-1.42.0.recipe | 171 +++++++++++++++++++++ dev-lang/rust_bin/rust_bin-1.42.0.recipe | 101 ++++++++++++ 3 files changed, 338 insertions(+) create mode 100644 dev-lang/rust/patches/rust-1.42.0.patchset create mode 100644 dev-lang/rust/rust-1.42.0.recipe create mode 100644 dev-lang/rust_bin/rust_bin-1.42.0.recipe diff --git a/dev-lang/rust/patches/rust-1.42.0.patchset b/dev-lang/rust/patches/rust-1.42.0.patchset new file mode 100644 index 000000000..e4f71a7c3 --- /dev/null +++ b/dev-lang/rust/patches/rust-1.42.0.patchset @@ -0,0 +1,66 @@ +From d99359e82eb3a2bcb418c33ed1a9f9e48fe49073 Mon Sep 17 00:00:00 2001 +From: Niels Sascha Reedijk +Date: Sat, 14 Mar 2020 09:48:41 +0000 +Subject: Apply Haiku patches for Rust 1.42.0 + + +diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs +index a5b34ee..75d0d13 100644 +--- a/src/libstd/sys/unix/thread.rs ++++ b/src/libstd/sys/unix/thread.rs +@@ -183,7 +183,7 @@ impl Thread { + unsafe { + let ret = libc::pthread_join(self.id, ptr::null_mut()); + mem::forget(self); +- assert!(ret == 0, "failed to join thread: {}", io::Error::from_raw_os_error(ret)); ++ debug_assert_eq!(ret, 0); + } + } + +diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs +index 4d37734..592a065 100644 +--- a/src/libstd/sys/windows/c.rs ++++ b/src/libstd/sys/windows/c.rs +@@ -255,7 +255,6 @@ pub const FILE_END: DWORD = 2; + + pub const WAIT_OBJECT_0: DWORD = 0x00000000; + pub const WAIT_TIMEOUT: DWORD = 258; +-pub const WAIT_FAILED: DWORD = 0xFFFFFFFF; + + pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001; + pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002; +diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs +index c828243..891cd4c 100644 +--- a/src/libstd/sys/windows/thread.rs ++++ b/src/libstd/sys/windows/thread.rs +@@ -65,10 +65,7 @@ impl Thread { + } + + pub fn join(self) { +- let rc = unsafe { c::WaitForSingleObject(self.handle.raw(), c::INFINITE) }; +- if rc == c::WAIT_FAILED { +- panic!("failed to join on thread: {}", io::Error::last_os_error()); +- } ++ unsafe { c::WaitForSingleObject(self.handle.raw(), c::INFINITE); } + } + + pub fn yield_now() { +diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs +index 0dc43c7..13dd5a7 100644 +--- a/src/libstd/thread/mod.rs ++++ b/src/libstd/thread/mod.rs +@@ -1465,11 +1465,6 @@ impl JoinHandle { + /// [`panic`]: ../../std/macro.panic.html + /// [atomic memory orderings]: ../../std/sync/atomic/index.html + /// +- /// # Panics +- /// +- /// This function may panic on some platforms if a thread attempts to join +- /// itself or otherwise may create a deadlock with joining threads. +- /// + /// # Examples + /// + /// ``` +-- +2.19.0 + diff --git a/dev-lang/rust/rust-1.42.0.recipe b/dev-lang/rust/rust-1.42.0.recipe new file mode 100644 index 000000000..1f7323c6e --- /dev/null +++ b/dev-lang/rust/rust-1.42.0.recipe @@ -0,0 +1,171 @@ +SUMMARY="Modern and safe systems programming language" +DESCRIPTION="Rust is a systems programming language that runs blazingly fast, \ +prevents almost all crashes*, and eliminates data races." +HOMEPAGE="https://www.rust-lang.org/" +COPYRIGHT="2020 The Rust Project Developers" +LICENSE="MIT" +REVISION="1" +cargoVersion="0.43.0" +rlsVersion="1.41.0" +rustfmtVersion="1.4.11" +clippyVersion="0.0.212" +miriVersion="0.1.0" +SOURCE_URI="https://static.rust-lang.org/dist/rustc-$portVersion-src.tar.xz" +CHECKSUM_SHA256="aa5b4c0f2bac33cc26a11523fce9b0f120d2eff510ed148ae7c586501481ed04" +SOURCE_DIR="rustc-$portVersion-src" +PATCHES="rust-$portVersion.patchset" + +ARCHITECTURES="!x86_gcc2 ?x86 ?x86_64" +SECONDARY_ARCHITECTURES="?x86" + +PROVIDES=" + rust_bin$secondaryArchSuffix = $portVersion + cmd:rustc$secondaryArchSuffix = $portVersion + cmd:rustdoc$secondaryArchSuffix = $portVersion + cmd:rustfmt$secondaryArchSuffix = $portVersion + cmd:rust_gdb$secondaryArchSuffix = $portVersion + cmd:rust_lldb$secondaryArchSuffix = $portVersion + cmd:cargo$secondaryArchSuffix = $cargoVersion + cmd:cargo_clippy$secondaryArchSuffix = $clippyVersion + cmd:cargo_fmt$secondaryArchSuffix = $cargoVersion + cmd:cargo_miri$secondaryArchSuffix = $miriVersion + cmd:clippy_driver$secondaryArchSuffix = $clippyVersion + cmd:miri$secondaryArchSuffix = $miriVersion + cmd:rls$secondaryArchSuffix = $rlsVersion + cmd:rustfmt = $rustfmtVersion + " +REQUIRES=" + haiku$secondaryArchSuffix + lib:libcrypto$secondaryArchSuffix + lib:libcurl$secondaryArchSuffix + lib:libssl$secondaryArchSuffix + lib:libz$secondaryArchSuffix + " + +BUILD_REQUIRES=" + haiku${secondaryArchSuffix}_devel + devel:libcurl$secondaryArchSuffix + devel:libssl$secondaryArchSuffix + devel:libz$secondaryArchSuffix + " +BUILD_PREREQUIRES=" + cmd:cargo$secondaryArchSuffix == $cargoVersion + cmd:cmake + cmd:cmp + cmd:file + cmd:find + cmd:gcc$secondaryArchSuffix + cmd:git + cmd:grep + cmd:ld$secondaryArchSuffix + cmd:make + cmd:pkg_config$secondaryArchSuffix + cmd:python + cmd:rustc$secondaryArchSuffix == $portVersion + cmd:sed + cmd:tar + cmd:which + cmd:xargs + " + +relativeInstallDir="develop/tools$secondaryArchSubDir/rust" +installDir="$prefix/$relativeInstallDir" + +BUILD() +{ + # write the build configuration + tr -d '\t' >config.toml <<- EOL + [llvm] + targets = "X86" + experimental-targets = "" + + [build] + cargo = "/$relativeBinDir/cargo" + rustc = "/$relativeBinDir/rustc" + submodules = false + extended = true + tools = ["cargo", "clippy", "rls", "rustfmt", "analysis"] + + [install] + prefix = "$installDir" + libdir = "$installDir/bin/lib" + mandir = "$manDir" + docdir = "$developDocDir" + sysconfdir = "$dataDir" + + [rust] + channel = "stable" + rpath = false + deny-warnings = false + dist-src = false + + [dist] + src-tarball = false +EOL + # Disable ASLR: compiling stage 1 rustc requires a lot of RAM (about 1.5 + # GB). Haiku has a per-process limit of 2GB on 32 bit systems. ASLR makes + # the available space even smaller. Disabling it will give us the space to + # compile Rust + export DISABLE_ASLR=1 + + # now build rust and cargo + ./x.py dist +} + +INSTALL() +{ + # we will manually invoke the install scripts + if [ $effectiveTargetArchitecture = x86 ]; then + architecture="i686-unknown-haiku" + fi + if [ $effectiveTargetArchitecture = x86_64 ]; then + architecture="x86_64-unknown-haiku" + fi + + # let's install the packages one by one + cd $sourceDir/build/tmp/dist/ + for module in "rust-docs-$srcGitRev-$architecture" \ + "rust-std-$srcGitRev-$architecture" \ + "rustc-$srcGitRev-$architecture" \ + "rust-analysis-$srcGitRev-$architecture" \ + "cargo-$cargoVersion-$architecture" \ + "clippy-$clippyVersion-$architecture" \ + "rls-$rlsVersion-$architecture" \ + "rustfmt-$rustfmtVersion-$architecture" \ + "miri-$miriVersion-$architecture" + do + ./$module/install.sh \ + --prefix=$installDir \ + --docdir=$developDocDir \ + --mandir=$manDir \ + --sysconfdir=$dataDir \ + --disable-ldconfig + done + + # move zsh data to the datadir + mv $installDir/share/zsh $dataDir + rm -rf $installDir/share + + # clean out unneccesary files created by the rust installer + rm $installDir/lib/rustlib/components + rm $installDir/lib/rustlib/install.log + rm $installDir/lib/rustlib/manifest-* + rm $installDir/lib/rustlib/rust-installer-version + rm $installDir/lib/rustlib/uninstall.sh + + # link the binaries in $binDir + mkdir -p $binDir + for f in cargo cargo-clippy cargo-fmt clippy-driver rls rust-gdb \ + rust-lldb rustc rustdoc rustfmt miri cargo-miri; do + symlinkRelative -sfn $installDir/bin/$f $binDir + done + + # make sure runtime_loader can find the libraries in the lib dir relative + # to the binaries + symlinkRelative -sfn $installDir/lib $installDir/bin/lib +} + +TEST() +{ + ./x.py test +} diff --git a/dev-lang/rust_bin/rust_bin-1.42.0.recipe b/dev-lang/rust_bin/rust_bin-1.42.0.recipe new file mode 100644 index 000000000..1693abfdc --- /dev/null +++ b/dev-lang/rust_bin/rust_bin-1.42.0.recipe @@ -0,0 +1,101 @@ +SUMMARY="Modern and safe systems programming language" +DESCRIPTION="Rust is a systems programming language that runs blazingly fast, \ +prevents almost all crashes*, and eliminates data races." +HOMEPAGE="https://www.rust-lang.org/" +COPYRIGHT="2020 The Rust Project Developers" +LICENSE="MIT" +REVISION="1" + +case "$effectiveTargetArchitecture" in + x86) +SOURCE_URI="http://dl.rust-on-haiku.com/dist/$portVersion/rust-$portVersion-i686-unknown-haiku.tar.xz" +CHECKSUM_SHA256="d6d0f714d8de442bc279c860694c9292a18615e58862e5a28ba46387666e292a" +SOURCE_DIR="rust-$portVersion-i686-unknown-haiku" + ;; + x86_64) +SOURCE_URI="http://dl.rust-on-haiku.com/dist/$portVersion/rust-$portVersion-x86_64-unknown-haiku.tar.xz" +CHECKSUM_SHA256="1a36bd114beac05c48ed89f12b0055f93c396ffdf1e601ca5f1022465ef803f1" +SOURCE_DIR="rust-$portVersion-x86_64-unknown-haiku" + ;; + *) +SOURCE_URI="http://dl.rust-on-haiku.com/dist/$portVersion/rustc-$portVersion-src.tar.xz" +CHECKSUM_SHA256="a33f0977039319c25f12e04f5eb5ef2b90c36b7a68d03eb4f0a17e73effd18bd" +SOURCE_DIR="rustc-$portVersion-src" + ;; +esac + +ARCHITECTURES="!x86_gcc2 ?x86 x86_64" +SECONDARY_ARCHITECTURES="x86" +DISABLE_SOURCE_PACKAGE=yes + +cargoVersion="0.43.0" +rlsVersion="1.41.0" +rustfmtVersion="1.4.11" +clippyVersion="0.0.212" +miriVersion="0.1.0" + +PROVIDES=" + rust_bin$secondaryArchSuffix = $portVersion + cmd:rustc$secondaryArchSuffix = $portVersion + cmd:rustdoc$secondaryArchSuffix = $portVersion + cmd:rustfmt$secondaryArchSuffix = $portVersion + cmd:rust_gdb$secondaryArchSuffix = $portVersion + cmd:rust_lldb$secondaryArchSuffix = $portVersion + cmd:cargo$secondaryArchSuffix = $cargoVersion + cmd:cargo_clippy$secondaryArchSuffix = $clippyVersion + cmd:cargo_fmt$secondaryArchSuffix = $cargoVersion + cmd:cargo_miri$secondaryArchSuffix = $miriVersion + cmd:clippy_driver$secondaryArchSuffix = $clippyVersion + cmd:miri$secondaryArchSuffix = $miriVersion + cmd:rls$secondaryArchSuffix = $rlsVersion + cmd:rustfmt = $rustfmtVersion + " +REQUIRES=" + haiku$secondaryArchSuffix + lib:libcrypto$secondaryArchSuffix + lib:libcurl$secondaryArchSuffix + lib:libssl$secondaryArchSuffix + lib:libz$secondaryArchSuffix + " +CONFLICTS=" + rust$secondaryArchSuffix + " + +BUILD_REQUIRES=" + haiku${secondaryArchSuffix}_devel + " + +relativeInstallDir="develop/tools$secondaryArchSubDir/rust" +installDir="$prefix/$relativeInstallDir" + +INSTALL() +{ + ./install.sh \ + --prefix=$installDir \ + --docdir=$developDocDir \ + --mandir=$manDir \ + --sysconfdir=$dataDir \ + --disable-ldconfig + + # move zsh data to the datadir + mv $installDir/share/zsh $dataDir + rm -rf $installDir/share + + # clean out unneccesary files created by the rust installer + rm $installDir/lib/rustlib/components + rm $installDir/lib/rustlib/install.log + rm $installDir/lib/rustlib/manifest-* + rm $installDir/lib/rustlib/rust-installer-version + rm $installDir/lib/rustlib/uninstall.sh + + # link the binaries in $binDir + mkdir -p $binDir + for f in cargo cargo-clippy cargo-fmt clippy-driver rls rust-gdb \ + rust-lldb rustc rustdoc rustfmt miri cargo-miri; do + symlinkRelative -sfn $installDir/bin/$f $binDir + done + + # make sure runtime_loader can find the libraries in the lib dir relative + # to the binaries + symlinkRelative -sfn $installDir/lib $installDir/bin/lib +}