Files
haikuports/dev-lang/rust/rust-1.79.0.recipe
PulkoMandy f163d1eec6 Rust: update from-source recipe to 1.79, disable on x86_64
Build fails with:

```
error[E0463]: can't find crate for `core`

error[E0463]: can't find crate for `std`

For more information about this error, try `rustc --explain E0463`.
```

The relevant bit of the "explain":

```
Common causes for missing std or core
*   You are cross-compiling for a target which doesn't have std prepackaged. Consider one of the
    following:
    + Adding a pre-compiled version of std with rustup target add
    + Building std from source with cargo build -Z build-std
    + Using #![no_std] at the crate root, so you won't need std in the first place.
*   You are developing the compiler itself and haven't built libstd from source. You can usually build it with x.py build library/std. More
    information about x.py is available in the rustc-dev-guide.
```

Since I know nothing about Rust, my efforts stop here for today.
According to the git log, this seems to be the same state we were in the
1.73 recipe.
2024-08-10 20:19:47 +02:00

177 lines
4.9 KiB
Bash

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="2023 The Rust Project Developers"
LICENSE="MIT"
REVISION="1"
cargoVersion="0.80.0"
rustfmtVersion="1.79.0"
clippyVersion="0.1.79"
rlsVersion="2.0.0"
SOURCE_URI="https://static.rust-lang.org/dist/rustc-$portVersion-src.tar.xz"
CHECKSUM_SHA256="ab826e84b8d48ec6eda3370065034dea8c006f6a946d78a9ba12bcb50e6d3c7a"
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_analyzer$secondaryArchSuffix = $portVersion
cmd:rust_demangler$secondaryArchSuffix = $portVersion
cmd:rust_gdb$secondaryArchSuffix = $portVersion
cmd:rust_gdbgui$secondaryArchSuffix = $portVersion
cmd:rust_lldb$secondaryArchSuffix = $portVersion
cmd:cargo$secondaryArchSuffix = $cargoVersion
cmd:cargo_clippy$secondaryArchSuffix = $clippyVersion
cmd:cargo_fmt$secondaryArchSuffix = $cargoVersion
cmd:clippy_driver$secondaryArchSuffix = $clippyVersion
"
REQUIRES="
haiku$secondaryArchSuffix
lib:libcrypto$secondaryArchSuffix >= 3
lib:libssl$secondaryArchSuffix
lib:libz$secondaryArchSuffix
"
BUILD_REQUIRES="
haiku${secondaryArchSuffix}_devel
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:ninja
cmd:pkg_config$secondaryArchSuffix
cmd:python3
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 = "WebAssembly;X86"
experimental-targets = ""
static-libstdcpp = false
[build]
host = ["$effectiveTargetArchitecture-unknown-haiku"]
target = ["$effectiveTargetArchitecture-unknown-haiku", "wasm32-unknown-unknown"]
cargo = "/$relativeBinDir/cargo"
rustc = "/$relativeBinDir/rustc"
submodules = false
extended = true
verbose = 1
[install]
prefix = "$installDir"
libdir = "$installDir/bin/lib"
mandir = "$manDir"
docdir = "$developDocDir"
sysconfdir = "$dataDir"
[rust]
channel = "stable"
lld = true
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
# Version-specific fixes: these fixes need to be applied
pushd src/tools/cargo
cargo update -p socket2 --precise 0.4.1
cargo update -p tempfile --precise 3.7.1
popd
# now build rust and cargo
./x.py dist $jobArgs
}
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" \
"rustfmt-$rustfmtVersion-$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; 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
}