From cf1ca4b1083bdecae1d6b52e311a10e30d61bb06 Mon Sep 17 00:00:00 2001 From: Kevin Hamacher Date: Wed, 15 Jan 2025 13:55:57 +0100 Subject: [PATCH] Working commands --- Dockerfile | 39 ++++----------------------------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/Dockerfile b/Dockerfile index a5a907e..ecd3dcd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,8 +41,6 @@ RUN mkdir gcc-build && cd gcc-build && \ make -j $(nproc) && \ make install -# --enable-cxx-flags='-fomit-frame-pointer -ffunction-sections -fno-exceptions' -fno-rtti? -# --with-gnu-as --with-gnu-ld? # Clone source repo RUN git clone https://github.com/rust-lang/rustc_codegen_gcc.git @@ -69,48 +67,19 @@ ENV CHANNEL=release # Build project # See https://github.com/rust-lang/rustc_codegen_gcc/blob/master/doc/tips.md#how-to-build-a-cross-compiling-libgccjit RUN cd rustc_codegen_gcc && ./y.sh prepare --cross -#RUN CG_RUSTFLAGS="-Cpanic=abort -Copt-level=3" cd rustc_codegen_gcc && ./y.sh build --sysroot --features compiler_builtins/no-f16-f128 --target-triple m68k-unknown-linux-gnu --target /build/rustc_codegen_gcc/target_specs/m68k-unknown-linux-gnu.json --release ENV CG_RUSTFLAGS="-Cpanic=abort -Crelocation-model=static -Copt-level=3" + RUN cd rustc_codegen_gcc && ./y.sh build --sysroot --features compiler_builtins/no-f16-f128 --target-triple m68k-unknown-linux-gnu --target /build/rustc_codegen_gcc/target_specs/m68k-unknown-linux-gnu.json --release -ENV CG_RUSTFLAGS="-Cpanic=abort -Crelocation-model=static -Copt-level=s" +# ENV CG_RUSTFLAGS="-Cpanic=abort -Crelocation-model=static -Copt-level=s" # Build "megapong" PoC - +# TODO: Make this a Makefile RUN git clone https://github.com/ricky26/rust-mega-drive.git COPY 0001-Make-project-compile-with-GCC.patch /tmp/rust-mega-drive.patch RUN cd rust-mega-drive && patch -p1 < /tmp/rust-mega-drive.patch && rm /tmp/rust-mega-drive.patch # Compile rust code RUN cd rustc_codegen_gcc && ./y.sh cargo build --target /build/rustc_codegen_gcc/target_specs/m68k-unknown-linux-gnu.json --manifest-path /build/rust-mega-drive/examples/megapong/Cargo.toml --release -#RUN cd rust-mega-drive/examples/megapong && find && cat ../../Cargo.toml && false # Compile entrypoint + stdlib stub (should not be strictly necessary to reproduce) RUN cd rust-mega-drive/examples/megapong && m68k-elf-gcc -fno-exceptions -mcpu=68000 -T /build/rust-mega-drive/share/ldscripts/megadrive.x entry.S hack.c /build/rust-mega-drive/target/m68k-unknown-linux-gnu/release/libmegapong.a -o out.elf -O2 -nostartfiles -nostdlib -static -nolibc -s -flto -Wl,-gc-sections -ffunction-sections -fdata-sections -##RUN cd rust-mega-drive/examples/megapong && /usr/local/bin/m68k-elf-gcc -c entry.S -o entry.o -fno-exceptions -mcpu=68000 -##RUN cd rust-mega-drive/examples/megapong && /usr/local/bin/m68k-elf-gcc -c hack.c -o entry.o -fno-exceptions -mcpu=68000 - - -#RUN false - - -# Link everything -#RUN cd rust-mega-drive/examples/megapong && /usr/local/bin/m68k-elf-ld -o out.elf -T /build/rust-mega-drive/share/ldscripts/megadrive.x entry.o stdlib.o /build/rust-mega-drive/target/m68k-unknown-linux-gnu/debug/libmegapong.a -static -z nocopyreloc --no-eh-frame-hdr -nostdlib -# RUN cd rust-mega-drive/examples/megapong && /usr/local/bin/m68k-elf-gcc -fno-exceptions -mcpu=68000 -T /build/rust-mega-drive/share/ldscripts/megadrive.x entry.o stdlib.o /build/rust-mega-drive/target/m68k-unknown-linux-gnu/release/libmegapong.a -static -s -o out.elf -nostdlib -nodefaultlibs -# Create cartridge -#RUN cd rust-mega-drive/examples/megapong && /usr/local/bin/m68k-elf-objcopy -O binary out.elf out.md - -#apt install texinfo -#../binutils-2.43/configure --prefix=/gcc/binutils-install --target=m68k-elf --disable-multilib -#make -j $(nproc) -#make install -#set path... - -#set gcc-path in config.toml /gcc/gcc-install/lib - - -# -> set target stuff to m68k-elf - -# install unzip -# https://github.com/llvm/llvm-project/archive/refs/heads/main.zip -# -> llvm-project-main/ -# enable feature [c] for compiler-builtins thingy -# set RUST_COMPILER_RT_ROOT (RUST_COMPILER_RT_ROOT=/build/llvm-project-main/compiler-rt) +RUN cd rust-mega-drive/examples/megapong && m68k-elf-objcopy -O binary out.elf out.md \ No newline at end of file