From b393fd1ffd91cfc70698b48fbc95fabe3c3d09f6 Mon Sep 17 00:00:00 2001 From: Alexander Hill Date: Thu, 1 May 2025 20:21:04 -0400 Subject: Successfully built the core crate! Thanks to Mutabah for helping via IRC --- build-chroot.sh | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/build-chroot.sh b/build-chroot.sh index 27c5eac..09f327a 100755 --- a/build-chroot.sh +++ b/build-chroot.sh @@ -741,6 +741,23 @@ cd .. # rustc Build With mrustc Bootstrap tar xf ../sources/mrustc-*.tar* cd mrustc-*/ +# NOTE: Using types such as uint8_t without stdint.h is not portable. ~ahill +sed -i "1i #include " src/debug.cpp +sed -i "1i #include " src/ast/lifetime_ref.hpp +sed -i "1i #include " src/hir/generic_ref.hpp +sed -i "1i #include " src/hir/type_ref.hpp +sed -i "1i #include " tools/minicargo/build.cpp +# NOTE: LLVM loves yelling about unqualified std calls, so we'll just fix them +# so we can properly troubleshoot why this doesn't work. ~ahill +sed -i -r "s/ move\(([a-z_]+)\)/ std::move\(\1\)/g" src/ast/ast.cpp +sed -i -r "s/ move\(([a-z_]+)\)/ std::move\(\1\)/g" src/ast/ast.hpp +sed -i -r "s/ move\(([a-z_]+)\)/ std::move\(\1\)/g" src/ast/expr.hpp +sed -i -r "s/ move\(([a-z_]+)\)/ std::move\(\1\)/g" src/macro_rules/macro_rules.hpp +sed -i -r "s/ move\(([a-z_]+)\)/ std::move\(\1\)/g" src/hir/expr.hpp +# NOTE: mrustc passes -fno-tree-sra to the GCC to work around a bug that is +# present when it comes to linking, however clang has no idea what that +# means. ~ahill +sed -i "s/-fno-tree-sra//" src/trans/codegen_c.cpp # 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 # into this further. CXX=clang++ exists to fix this temporarily. ~ahill @@ -754,46 +771,56 @@ cd rustc-*-src/ RUST_VERSION=$(pwd | sed -r "s/.*rustc-(.*)-src/\1/") patch -p0 < ../rustc-$RUST_VERSION-src.patch cd .. +# NOTE: mrustc defaults to 1.29, which means macros such as asm! do not function +# correctly unless you manually define MRUSTC_TARGET_VER. ~ahill +export MRUSTC_TARGET_VER=$(echo $RUST_VERSION | sed "s/\.[^.]*$//") ./bin/minicargo \ - --vendor-dir rustc-*-src/vendor \ + --vendor-dir rustc-$RUST_VERSION-src/vendor \ --script-overrides script-overrides/stable-$RUST_VERSION-linux \ --output-dir $(pwd)/build \ --manifest-overrides rustc-$RUST_VERSION-overrides.toml \ -j $THREADS \ - ./rustc-*-src/library/std + ./rustc-$RUST_VERSION-src/library/core ./bin/minicargo \ - --vendor-dir rustc-*-src/vendor \ + --vendor-dir rustc-$RUST_VERSION-src/vendor \ --script-overrides script-overrides/stable-$RUST_VERSION-linux \ --output-dir $(pwd)/build \ --manifest-overrides rustc-$RUST_VERSION-overrides.toml \ -j $THREADS \ - ./rustc-*-src/library/panic_unwind -./bin/minicargo --vendor-dir rustc-*-src/vendor \ + ./rustc-$RUST_VERSION-src/library/std +./bin/minicargo \ + --vendor-dir rustc-$RUST_VERSION-src/vendor \ + --script-overrides script-overrides/stable-$RUST_VERSION-linux \ + --output-dir $(pwd)/build \ + --manifest-overrides rustc-$RUST_VERSION-overrides.toml \ + -j $THREADS \ + ./rustc-$RUST_VERSION-src/library/panic_unwind +./bin/minicargo --vendor-dir rustc-$RUST_VERSION-src/vendor \ --script-overrides script-overrides/stable-$RUST_VERSION-linux \ --output-dir $(pwd)/build \ --manifest-overrides rustc-$RUST_VERSION-overrides.toml \ -j $THREADS \ - ./rustc-*-src/library/test + ./rustc-$RUST_VERSION-src/library/test ./bin/minicargo \ --output-dir $(pwd)/build \ --manifest-overrides rustc-$RUST_VERSION-overrides.toml \ -j $THREADS \ lib/libproc_macro ./bin/minicargo \ - --vendor-dir rustc-*-src/vendor \ + --vendor-dir rustc-$RUST_VERSION-src/vendor \ --output-dir $(pwd)/build \ -L $(pwd)/build \ --manifest-overrides rustc-$RUST_VERSION-overrides.toml \ -j $THREADS \ - rustc-*-src/compiler/rustc_driver + rustc-$RUST_VERSION-src/compiler/rustc_driver ./bin/minicargo \ - --vendor-dir rustc-*-src/vendor \ + --vendor-dir rustc-$RUST_VERSION-src/vendor \ --output-dir $(pwd)/build \ -L $(pwd)/build \ --manifest-overrides rustc-$RUST_VERSION-overrides.toml \ -j $THREADS \ --features vendored-openssl \ - rustc-*-src/src/tools/cargo + rustc-$RUST_VERSION-src/src/tools/cargo # ... cd .. -- cgit v1.2.3