diff --git a/.github/workflows/m68k.yml b/.github/workflows/m68k.yml index 329d21a25b0..a7cad2df335 100644 --- a/.github/workflows/m68k.yml +++ b/.github/workflows/m68k.yml @@ -37,7 +37,7 @@ jobs: steps: - name: Install packages - run: sudo apt-get install qemu + run: sudo apt-get install qemu qemu-user-static - uses: actions/checkout@v3 @@ -67,6 +67,11 @@ jobs: - name: Setup path to libgccjit run: | sudo dpkg -i gcc-m68k-13.deb + echo "*********************" + ls /usr/bin + echo "*********************" + ls /bin + echo "*********************" ls /lib echo "*********************" ls /usr/lib @@ -114,18 +119,32 @@ jobs: #path: rust #key: ${{ runner.os }}-packages-${{ hashFiles('rust/.git/HEAD') }} + # TODO: reset cross-gcc config file (i.e. try to revert CT_BINUTILS_V_2_37 to CT_BINUTILS_V_2_38). - name: Test build (TODO REMOVE) run: | cat > main.c < int main(void) { printf("Hello, world!"); } EOF mkdir vm sudo mount debian-m68k.img vm - m68k-unknown-linux-gnu-gcc main.c -o vm/home/main + m68k-unknown-linux-gnu-gcc main.c -o main + sudo cp main vm/home/main + sudo cp $(which qemu-m68k-static) vm/usr/bin/ sudo chroot vm/ qemu-m68k-static /home/main + - name: Test libgccjit build (TODO REMOVE) + run: | + export LD_LIBRARY_PATH=/usr/lib + export LIBRARY_PATH=/usr/lib + cd m68k-test + cargo run + cd .. + sudo mv m68k-test/main-m68k vm/home/ + sudo chroot vm/ qemu-m68k-static /home/main-m68k + - name: Build run: | ./y.sh prepare --only-libcore diff --git a/config.sh b/config.sh index 4c888934107..933ca80f9fb 100644 --- a/config.sh +++ b/config.sh @@ -26,10 +26,11 @@ TARGET_TRIPLE="m68k-unknown-linux-gnu" linker='' RUN_WRAPPER='' if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then - if [[ "$TARGET_TRIPLE" == "m68k-unknown-linux-gnu" ]]; then + #if [[ "$TARGET_TRIPLE" == "m68k-unknown-linux-gnu" ]]; then #TARGET_TRIPLE="mips-unknown-linux-gnu" - linker='-Clinker=m68k-linux-gcc' - elif [[ "$TARGET_TRIPLE" == "aarch64-unknown-linux-gnu" ]]; then + #linker='-Clinker=m68k-linux-gcc' + #el + if [[ "$TARGET_TRIPLE" == "aarch64-unknown-linux-gnu" ]]; then # We are cross-compiling for aarch64. Use the correct linker and run tests in qemu. linker='-Clinker=aarch64-linux-gnu-gcc' RUN_WRAPPER='qemu-aarch64 -L /usr/aarch64-linux-gnu' diff --git a/m68k-test/Cargo.lock b/m68k-test/Cargo.lock new file mode 100644 index 00000000000..5a5e22665db --- /dev/null +++ b/m68k-test/Cargo.lock @@ -0,0 +1,32 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "gccjit" +version = "1.0.0" +source = "git+https://github.com/antoyo/gccjit.rs#0b158c68bf7e46732869d90550a98e886dee8858" +dependencies = [ + "gccjit_sys", +] + +[[package]] +name = "gccjit_sys" +version = "0.0.1" +source = "git+https://github.com/antoyo/gccjit.rs#0b158c68bf7e46732869d90550a98e886dee8858" +dependencies = [ + "libc", +] + +[[package]] +name = "libc" +version = "0.2.148" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" + +[[package]] +name = "m68k-test" +version = "0.1.0" +dependencies = [ + "gccjit", +] diff --git a/m68k-test/Cargo.toml b/m68k-test/Cargo.toml new file mode 100644 index 00000000000..b94f6b5bea5 --- /dev/null +++ b/m68k-test/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "m68k-test" +version = "0.1.0" +edition = "2021" + +[dependencies] +gccjit = { git = "https://github.com/antoyo/gccjit.rs" } diff --git a/m68k-test/src/main.rs b/m68k-test/src/main.rs new file mode 100644 index 00000000000..fb5e48c4fc7 --- /dev/null +++ b/m68k-test/src/main.rs @@ -0,0 +1,10 @@ +use gccjit::{Context, FunctionType, OutputKind}; + +fn main() { + let context = Context::default(); + let int_type = context.new_type::(); + let function = context.new_function(None, FunctionType::Exported, int_type, &[], "main", false); + let block = function.new_block("block"); + block.end_with_return(None, context.new_rvalue_from_int(int_type, 0)); + context.compile_to_file(OutputKind::Executable, "main-m68k"); +} diff --git a/src/base.rs b/src/base.rs index 4281eafe620..201aa1c588f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -101,7 +101,7 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: Lock // TODO(antoyo): only set on x86 platforms. //context.add_command_line_option("-masm=intel"); - if !disabled_features.contains("avx") { + if !disabled_features.contains("avx") && tcx.sess.target.arch == "x86_64" { // NOTE: we always enable AVX because the equivalent of llvm.x86.sse2.cmp.pd in GCC for // SSE2 is multiple builtins, so we use the AVX __builtin_ia32_cmppd instead. // FIXME(antoyo): use the proper builtins for llvm.x86.sse2.cmp.pd and similar. diff --git a/src/gcc_util.rs b/src/gcc_util.rs index 0514c9988e0..1248fdcd259 100644 --- a/src/gcc_util.rs +++ b/src/gcc_util.rs @@ -198,9 +198,16 @@ pub fn check_tied_features(sess: &Session, features: &FxHashMap<&str, bool>) -> None } +fn arch_to_gcc(name: &str) -> &str { + match name { + "M68020" => "68020", + _ => name, + } +} + fn handle_native(name: &str) -> &str { if name != "native" { - return name; + return arch_to_gcc(name); } #[cfg(feature="master")]