Skip to content

Commit

Permalink
base: Fix for GCC14 and use m68k-elf- tool prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
keirf committed Jan 5, 2025
1 parent 0b189c6 commit 37dafcd
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: actions/cache@v3
with:
path: ~/cross
key: ${{ runner.os }}-${{ env.BINUTILS_RELEASE }}-${{ env.GCC_RELEASE }}
key: ${{ runner.os }}-${{ env.BINUTILS_RELEASE }}-${{ env.GCC_RELEASE }}-2

- name: Build toolchain
if: steps.cache-toolchain.outputs.cache-hit != 'true'
Expand All @@ -53,14 +53,14 @@ jobs:
tar xf vasm.tar.gz
tar xf vlink.tar.gz
cd binutils-${BINUTILS_RELEASE}
./configure --prefix=$MDIR --target=m68k-unknown-elf
./configure --prefix=$MDIR --target=m68k-elf
make ${MAKE_OPTS}
make install
cd ../gcc-${GCC_RELEASE}
sed -i 's/--check/-c/g' contrib/download_prerequisites
./contrib/download_prerequisites
mkdir ../gcc-build && cd ../gcc-build
../gcc-${GCC_RELEASE}/configure --prefix=$MDIR --target=m68k-unknown-elf --enable-languages=c --disable-libssp
../gcc-${GCC_RELEASE}/configure --prefix=$MDIR --target=m68k-elf --enable-languages=c --disable-libssp
make ${MAKE_OPTS}
make install
cd ../vasm
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
uses: actions/cache@v3
with:
path: ~/cross
key: ${{ runner.os }}-${{ env.BINUTILS_RELEASE }}-${{ env.GCC_RELEASE }}
key: ${{ runner.os }}-${{ env.BINUTILS_RELEASE }}-${{ env.GCC_RELEASE }}-2

- name: Build toolchain
if: steps.cache-toolchain.outputs.cache-hit != 'true'
Expand All @@ -56,14 +56,14 @@ jobs:
tar xf vasm.tar.gz
tar xf vlink.tar.gz
cd binutils-${BINUTILS_RELEASE}
./configure --prefix=$MDIR --target=m68k-unknown-elf
./configure --prefix=$MDIR --target=m68k-elf
make ${MAKE_OPTS}
make install
cd ../gcc-${GCC_RELEASE}
sed -i 's/--check/-c/g' contrib/download_prerequisites
./contrib/download_prerequisites
mkdir ../gcc-build && cd ../gcc-build
../gcc-${GCC_RELEASE}/configure --prefix=$MDIR --target=m68k-unknown-elf --enable-languages=c --disable-libssp
../gcc-${GCC_RELEASE}/configure --prefix=$MDIR --target=m68k-elf --enable-languages=c --disable-libssp
make ${MAKE_OPTS}
make install
cd ../vasm
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ use `rjnorthrow/atk:v1.10`.
### Build From Source (Manual Method)

Requires a GCC cross-compiler toolchain targetting
`m68k-unknown-elf`. I recommend binutils-2.28 and gcc-7.1.0, built
`m68k-elf`. I recommend binutils-2.34 and gcc-9.3.0, built
with the following configuration lines on a Linux host or VM (note these are
not exhaustive toolchain build instructions!):
```
../binutils-2.28/configure --prefix=/path/to/install --target=m68k-unknown-elf
../gcc-7.1.0/configure --prefix=/path/to/install --target=m68k-unknown-elf --enable-languages=c --disable-libssp
../binutils-2.34/configure --prefix=/path/to/install --target=m68k-elf
../gcc-9.3.0/configure --prefix=/path/to/install --target=m68k-elf --enable-languages=c --disable-libssp
```

Note that `/path/to/install/bin` must be on your PATH both when building
Expand Down
6 changes: 3 additions & 3 deletions base/Rules.mk
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# GNU Make cross-dev build rules
# Tested cross-dev setups (gcc/binutils) (*=recommended):
# 4.9.2/2.24, 5.3.0/2.26, 7.1.0/2.28, 9.3.0/2.34*
# Target is m68k-unknown-elf
# 4.9.2/2.24, 5.3.0/2.26, 7.1.0/2.28, 9.3.0/2.34*, 14.2.0/2.43.1
# Target is m68k-elf

TOOL_PREFIX = m68k-unknown-elf-
TOOL_PREFIX = m68k-elf-
CC = $(TOOL_PREFIX)gcc
OBJCOPY = $(TOOL_PREFIX)objcopy
PYTHON = python3
Expand Down
12 changes: 9 additions & 3 deletions base/amiga.ld
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
ENTRY(start)

PHDRS
{
/* Define as RW^X to avoid a linker warning */
text PT_LOAD FLAGS(6);
}

SECTIONS
{
SUPER_SP = 0x40000;
Expand All @@ -15,7 +21,7 @@ SECTIONS
*(.rodata*)
. = ALIGN(4);
_etext = .;
}
} :text

.data : {
. = ALIGN(4);
Expand All @@ -24,7 +30,7 @@ SECTIONS
*(.data*)
. = ALIGN(4);
_edat = .;
}
} :text

.bss : {
. = ALIGN(4);
Expand All @@ -34,7 +40,7 @@ SECTIONS
. = ALIGN(4);
_ebss = .;
_end = .;
}
} :text

/DISCARD/ : {
*(.eh_frame)
Expand Down
3 changes: 3 additions & 0 deletions base/inc/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#define barrier() asm volatile("" ::: "memory")

/* Suppresses unwanted arroy-bounds compiler warnings. */
#define arrayptr_launder(x) ({ typeof(x) _x; asm("":"=r"(_x):"0"(x)); _x; })

#ifndef offsetof
#define offsetof(a,b) __builtin_offsetof(a,b)
#endif
Expand Down
5 changes: 3 additions & 2 deletions testkit/crash.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ struct frame {
/* Fix up one 68000 unrecoverable fault handler. */
static void fixup_68000(void *new_fn, volatile uint32_t *vec)
{
uint32_t old_fn = *vec;
volatile uint32_t *_vec = arrayptr_launder(vec);
uint32_t old_fn = *_vec;
/* Search for the JMP instruction in the shim handler, and patch it. */
uint16_t *p = new_fn;
while (*p != 0x4ef9) p++;
*(uint32_t *)(p+1) = old_fn;
/* Install our shim handler. */
*vec = (uint32_t)new_fn;
*_vec = (uint32_t)new_fn;
}

/* 68000 (only) has weird stack formats for unrecoverable faults. These cause
Expand Down
4 changes: 2 additions & 2 deletions testkit/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,15 +424,15 @@ static void memcheck_direct_scan(void)
for (i = 0; i < 27; i++) {
if (aliased_slots & (1u << i))
continue;
p = (volatile uint16_t *)&s[0] + (i << 18);
p = (volatile uint16_t *)arrayptr_launder(&s[0]) + (i << 18);
p[0] = 0x5555;
p[1<<17] = 0xaaaa;
if ((p[0] != 0x5555) || (p[1<<17] != 0xaaaa)) {
p[0] = p[1<<17] = 0;
continue;
}
for (j = 0; j < i; j++) {
q = (volatile uint16_t *)s + (j << 18);
q = (volatile uint16_t *)arrayptr_launder(&s[0]) + (j << 18);
if ((ram_slots & (1u << j)) && (*q == 0x5555))
break;
}
Expand Down

0 comments on commit 37dafcd

Please sign in to comment.