Started working on the next stage of Rust
It looks like we're running into problems with LibreSSL and the missing std crate. Further research required.
This commit is contained in:
parent
4db1523e4a
commit
bdbb9aeb87
@ -757,8 +757,11 @@ cd mrustc-*/
|
||||
# NOTE: mrustc forces the system to link with libatomic because it's assuming
|
||||
# that libgcc exists, even though it doesn't in this case. compiler-rt
|
||||
# supplies the functionality we need, so this is not required. ~ahill
|
||||
# FIXME: The optimize(-O) flag has been patched out of minicargo because clang
|
||||
# optimizes essential parts of code generated by mrustc. ~ahill
|
||||
# NOTE: Rather than completely disabling optimizations, which causes rustc to
|
||||
# become incredibly slow, we simply prevent it from optimizing null
|
||||
# pointer checks out (-fno-delete-null-pointer-checks). I'm not sure why
|
||||
# this behavior would be desired, but someone likely has a valid use case.
|
||||
# ~ahill
|
||||
patch -p1 < /maple/patches/mrustc-maple.patch
|
||||
# FIXME: I have no idea how, but this script somehow invokes the now
|
||||
# non-existent version of clang++ from /maple/tools. Will need to look
|
||||
@ -775,6 +778,7 @@ cd rustc-*-src/
|
||||
RUST_VERSION=$(pwd | sed -r "s/.*rustc-(.*)-src/\1/")
|
||||
patch -p0 < ../rustc-$RUST_VERSION-src.patch
|
||||
cd ..
|
||||
mv rustc-$RUST_VERSION-src/ rustc-$RUST_VERSION-src-patched/
|
||||
# NOTE: Rust's unwind crate attempts to link with libgcc_s, even on a musl-based
|
||||
# system. Enabling the "system-llvm-unwind" feature fixes this. ~ahill
|
||||
echo "[add.'library/panic_unwind'.dependencies.unwind]" >> rustc-$RUST_VERSION-overrides.toml
|
||||
@ -787,7 +791,7 @@ export MRUSTC_TARGET_VER=$(echo $RUST_VERSION | sed "s/\.[^.]*$//")
|
||||
# NOTE: We are creating a dummy crate to build the standard library since we're
|
||||
# doing a bit of trickery with dependencies. This should prevent conflicts
|
||||
# later on. ~ahill
|
||||
MRUSTC_STDLIB=$(pwd)/rustc-$RUST_VERSION-src/mrustc-stdlib
|
||||
MRUSTC_STDLIB=$(pwd)/rustc-$RUST_VERSION-src-patched/mrustc-stdlib
|
||||
mkdir -p $MRUSTC_STDLIB
|
||||
echo "#![no_core]" > $MRUSTC_STDLIB/lib.rs
|
||||
echo "[package]" > $MRUSTC_STDLIB/Cargo.toml
|
||||
@ -800,14 +804,14 @@ echo "std = { path = \"../library/std\" }" >> $MRUSTC_STDLIB/Cargo.toml
|
||||
echo "panic_unwind = { path = \"../library/panic_unwind\" }" >> $MRUSTC_STDLIB/Cargo.toml
|
||||
echo "test = { path = \"../library/test\" }" >> $MRUSTC_STDLIB/Cargo.toml
|
||||
./bin/minicargo \
|
||||
--vendor-dir rustc-$RUST_VERSION-src/vendor \
|
||||
--vendor-dir rustc-$RUST_VERSION-src-patched/vendor \
|
||||
--script-overrides script-overrides/stable-$RUST_VERSION-linux \
|
||||
--output-dir $(pwd)/build-std \
|
||||
--output-dir $(pwd)/build-std-stage0 \
|
||||
--manifest-overrides rustc-$RUST_VERSION-overrides.toml \
|
||||
-j $THREADS \
|
||||
$MRUSTC_STDLIB
|
||||
./bin/minicargo \
|
||||
--output-dir $(pwd)/build-std \
|
||||
--output-dir $(pwd)/build-std-stage0 \
|
||||
--manifest-overrides rustc-$RUST_VERSION-overrides.toml \
|
||||
-j $THREADS \
|
||||
lib/libproc_macro
|
||||
@ -822,25 +826,25 @@ echo "test = { path = \"../library/test\" }" >> $MRUSTC_STDLIB/Cargo.toml
|
||||
# NOTE: RUSTC_INSTALL_BINDIR is required to build rustc_interface. ~ahill
|
||||
# NOTE: The llvm feature compiles rustc with the llvm backend built in. This is needed as mrustc
|
||||
# doesn't support building dylibs which are needed for dynamically loadable codegen backends
|
||||
REAL_LIBRARY_PATH_VAR="LD_LIBRARY_PATH" \
|
||||
CFG_COMPILER_HOST_TRIPLE="x86_64-unknown-linux-musl" \
|
||||
CFG_VERSION=1.74.0 \
|
||||
LLVM_CONFIG=$(which llvm-config) \
|
||||
CFG_RELEASE=$RUST_VERSION \
|
||||
CFG_RELEASE_CHANNEL=stable \
|
||||
CFG_VERSION=$RUST_VERSION \
|
||||
LLVM_CONFIG=$(which llvm-config) \
|
||||
REAL_LIBRARY_PATH_VAR="LD_LIBRARY_PATH" \
|
||||
RUSTC_INSTALL_BINDIR=bin \
|
||||
./bin/minicargo \
|
||||
--vendor-dir rustc-$RUST_VERSION-src/vendor \
|
||||
--output-dir $(pwd)/build-rustc \
|
||||
-L $(pwd)/build-std \
|
||||
--vendor-dir rustc-$RUST_VERSION-src-patched/vendor \
|
||||
--output-dir $(pwd)/build-rustc-stage1 \
|
||||
-L $(pwd)/build-std-stage0 \
|
||||
--manifest-overrides rustc-$RUST_VERSION-overrides.toml \
|
||||
-j $THREADS \
|
||||
rustc-$RUST_VERSION-src/compiler/rustc \
|
||||
rustc-$RUST_VERSION-src-patched/compiler/rustc \
|
||||
--features llvm
|
||||
# NOTE: openssl-sys supports LibreSSL, but the version shipped with this version
|
||||
# of rustc only supports up to LibreSSL 3.8.0. We are manually updating
|
||||
# this crate so cargo can be built without downgrading LibreSSL. ~ahill
|
||||
cd rustc-$RUST_VERSION-src/vendor
|
||||
cd rustc-$RUST_VERSION-src-patched/vendor
|
||||
rm -rf openssl-sys*
|
||||
tar xf ../../../../sources/openssl-sys-*.crate
|
||||
# NOTE: This silences warnings from our newly-built cargo complaining about missing
|
||||
@ -849,14 +853,47 @@ cd openssl-sys-*/
|
||||
echo "{\"files\":{}}" > .cargo-checksum.json
|
||||
cd ../../..
|
||||
./bin/minicargo \
|
||||
--vendor-dir rustc-$RUST_VERSION-src/vendor \
|
||||
--output-dir $(pwd)/build-cargo \
|
||||
-L $(pwd)/build-std \
|
||||
--vendor-dir rustc-$RUST_VERSION-src-patched/vendor \
|
||||
--output-dir $(pwd)/build-cargo-stage1 \
|
||||
-L $(pwd)/build-std-stage0 \
|
||||
--manifest-overrides rustc-$RUST_VERSION-overrides.toml \
|
||||
-j $THREADS \
|
||||
rustc-$RUST_VERSION-src/src/tools/cargo
|
||||
cp build-rustc/rustc_main /bin/rustc
|
||||
cp build-cargo/cargo /bin/
|
||||
rustc-$RUST_VERSION-src-patched/src/tools/cargo
|
||||
# Now that we have the initial bootstrap, let's build Rust so we can produce a
|
||||
# cleaner build with fewer patches. ~ahill
|
||||
tar xf ../../sources/rustc-*.tar*
|
||||
# NOTE: Once again, we must patch rustc to work with LLVM the same way we did
|
||||
# above to make it compatible with Maple Linux. A lot of this is likely
|
||||
# fixed in future versions of Rust, but mrustc isn't able to bootstrap a
|
||||
# more modern version. See above notes for the commands here. ~ahill
|
||||
patch -p0 < /maple/patches/rustc-src-maple.patch
|
||||
cd rustc-$RUST_VERSION-src-patched/vendor
|
||||
rm -rf openssl-sys*
|
||||
tar xf ../../../../sources/openssl-sys-*.crate
|
||||
cd openssl-sys-*/
|
||||
echo "{\"files\":{}}" > .cargo-checksum.json
|
||||
cd ../../..
|
||||
# FIXME: It appears that either LibreSSL or cargo has been misconfigured in a
|
||||
# way that prevents it from verifying legitimate certificates. Setting
|
||||
# CARGO_HTTP_CAINFO to the certificate path (/etc/ssl/cert.pem) seems to
|
||||
# fix the issue. ~ahill
|
||||
# See also: https://github.com/kisslinux/repo/issues/339
|
||||
CARGO_HTTP_CAINFO=/etc/ssl/cert.pem \
|
||||
CARGO_HOME=$(pwd)/.cargo \
|
||||
CARGO_TARGET_DIR=build-std-stage1 \
|
||||
CFG_COMPILER_HOST_TRIPLE=x86_64-unknown-linux-musl \
|
||||
PROXY_MRUSTC=$(pwd)/build-rustc-stage1/rustc_main \
|
||||
PROXY_RUSTC=$(pwd)/build-rustc-stage1/rustc_main \
|
||||
RUSTC=$(pwd)/run_rustc/rustc_proxy.sh \
|
||||
RUSTC_BOOTSTRAP=1 \
|
||||
RUSTFLAGS="-Z force-unstable-if-unmarked -C link_args=-Wl,-rpath,\$$ORIGIN/../lib" \
|
||||
./build-cargo-stage1/cargo build \
|
||||
--features panic-unwind \
|
||||
-j $THREADS \
|
||||
--manifest-path rustc-$RUST_VERSION-src/library/sysroot/Cargo.toml \
|
||||
--release \
|
||||
--target x86_64-unknown-linux-musl
|
||||
# ...
|
||||
cd ..
|
||||
|
||||
# Basic Configuration
|
||||
@ -868,6 +905,20 @@ echo "VERSION=2025" >> /etc/os-release
|
||||
echo "ID=maple" >> /etc/os-release
|
||||
echo "VERSION_ID=2025" >> /etc/os-release
|
||||
echo "PRETTY_NAME=\"Maple Linux\"" >> /etc/os-release
|
||||
echo "nameserver 1.1.1.1" > /etc/resolv.conf
|
||||
echo "nameserver 1.0.0.1" >> /etc/resolv.conf
|
||||
|
||||
# greetd Build
|
||||
tar xf ../sources/greetd-*.tar*
|
||||
cd greetd-*/
|
||||
# FIXME: It appears that either LibreSSL or cargo has been misconfigured in a
|
||||
# way that prevents it from verifying legitimate certificates. Setting
|
||||
# CARGO_HTTP_CAINFO to the certificate path (/etc/ssl/cert.pem) seems to
|
||||
# fix the issue. ~ahill
|
||||
# See also: https://github.com/kisslinux/repo/issues/339
|
||||
CARGO_HTTP_CAINFO=/etc/ssl/cert.pem cargo build
|
||||
# ...
|
||||
cd ..
|
||||
|
||||
# Finally, make the image bootable.
|
||||
cp /usr/share/limine/BOOTX64.EFI /boot/EFI/BOOT/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user