diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f3b3828..0644a59 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,14 +13,16 @@ jobs: OS: 'ubuntu-20.04', CFLAGS: '-static -std=gnu89 -m32', HOST: 'i386-pc-linux', - ARCHIVE_NAME: 'mips-gcc-egcs-2.91.66-linux.tar.gz' + ARCHIVE_NAME: 'mips-gcc-egcs-2.91.66-linux.tar.gz', + HOST_GCC: 'gcc' + } + - { + OS: 'macos-13', + CFLAGS: '-DDARWIN -std=gnu89 -Wno-return-type -Wno-error -Wno-implicit-function-declaration', + HOST: 'i386-apple-darwin', + ARCHIVE_NAME: 'mips-gcc-egcs-2.91.66-mac.tar.gz', + HOST_GCC: 'gcc-13' } - # - { - # OS: 'macos-latest', - # CFLAGS: '-DDARWIN -std=gnu89 -Wno-return-type -Wno-error -Wno-implicit-function-declaration', - # HOST: 'i386-apple-darwin', - # ARCHIVE_NAME: 'mips-gcc-egcs-2.91.66-mac.tar.gz' - # } name: Building gcc for ${{ matrix.TARGET.OS }} steps: @@ -35,13 +37,14 @@ jobs: - name: Configure for mips shell: bash run: | - ./configure --target=mips-linux --prefix=/opt/cross --with-gnu-as --disable-gprof --disable-gdb --disable-werror --host=${{ matrix.TARGET.HOST }} --build=${{ matrix.TARGET.HOST }} + CC="${{ matrix.TARGET.HOST_GCC }}" CFLAGS="-Wno-implicit-int" ./configure --target=mips-linux --prefix=/opt/cross --with-gnu-as --disable-gprof --disable-gdb --disable-werror --host=${{ matrix.TARGET.HOST }} --build=${{ matrix.TARGET.HOST }} - name: Make shell: bash run: | # The generated `c-parse.c` is already commited on the repo, so we touch it to avoid regenerating it (trying to build old lex/yacc files with modern tools fails) touch gcc/c-parse.c touch gcc/cp/parse.c + touch gcc/cexp.c make -C gcc CFLAGS="${{ matrix.TARGET.CFLAGS }}" xgcc cc1 cc1plus cpp cccp g++ - name: Test for file diff --git a/config.sub b/config.sub index 75a0a13..3a39187 100755 --- a/config.sub +++ b/config.sub @@ -909,7 +909,7 @@ case $os in | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -uxpv*) + | -mingw32* | -linux-gnu* | -uxpv* | -darwin* ) # Remember, each alternative MUST END IN *, to match a version number. ;; # CYGNUS LOCAL diff --git a/gcc/config.sub b/gcc/config.sub index b491c9f..5fa7564 100755 --- a/gcc/config.sub +++ b/gcc/config.sub @@ -732,7 +732,7 @@ case $os in | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -uxpv* | -beos* ) + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -darwin* ) # Remember, each alternative MUST END IN *, to match a version number. ;; -linux*) diff --git a/gcc/config/i386/xm-darwin.h b/gcc/config/i386/xm-darwin.h new file mode 100644 index 0000000..fa6ae6e --- /dev/null +++ b/gcc/config/i386/xm-darwin.h @@ -0,0 +1,4 @@ +/* Configuration for GCC for Intel i386 or later running macOS as host. */ + +#include +#include "i386/xm-i386.h" \ No newline at end of file diff --git a/gcc/configure b/gcc/configure index 120fff4..8ab9c86 100755 --- a/gcc/configure +++ b/gcc/configure @@ -2851,6 +2851,9 @@ for machine in $build $host $target; do # Next line turned off because both 386BSD and BSD/386 use GNU ld. # use_collect2=yes ;; + i[34567]86-apple-darwin) #macOS + xm_file=i386/xm-darwin.h + ;; i[34567]86-*-freebsdelf*) tm_file="i386/i386.h i386/att.h linux.h i386/freebsd-elf.h i386/perform.h" # On FreeBSD, the headers are already ok, except for math.h. diff --git a/libiberty/strerror.c b/libiberty/strerror.c index 644cc75..5fdc354 100644 --- a/libiberty/strerror.c +++ b/libiberty/strerror.c @@ -460,6 +460,13 @@ static int num_error_names = 0; static int sys_nerr; static const char **sys_errlist; +#elif defined(DARWIN) + +// macOS added 'const' to these declarations, and clang complains if they are otherwise +extern const int sys_nerr; +extern const char *sys_errlist[]; + + #else extern int sys_nerr; @@ -468,6 +475,7 @@ extern char *sys_errlist[]; #endif + /* NAME