Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Sep 28, 2023
1 parent a62dc39 commit c0681ba
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 5 deletions.
23 changes: 21 additions & 2 deletions .github/workflows/m68k.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 <<EOF
#include <stdio.h>
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
Expand Down
2 changes: 1 addition & 1 deletion config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN_WRAPPER=''
if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
if [[ "$TARGET_TRIPLE" == "m68k-unknown-linux-gnu" ]]; then
#TARGET_TRIPLE="mips-unknown-linux-gnu"
linker='-Clinker=m68k-linux-gcc'
#linker='-Clinker=m68k-linux-gcc'
elif [[ "$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'
Expand Down
32 changes: 32 additions & 0 deletions m68k-test/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions m68k-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "m68k-test"
version = "0.1.0"
edition = "2021"

[dependencies]
gccjit = { git = "https://github.com/antoyo/gccjit.rs" }
10 changes: 10 additions & 0 deletions m68k-test/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use gccjit::{Context, FunctionType, OutputKind};

fn main() {
let context = Context::default();
let int_type = context.new_type::<i32>();
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");
}
2 changes: 1 addition & 1 deletion src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 8 additions & 1 deletion src/gcc_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down

0 comments on commit c0681ba

Please sign in to comment.