Skip to content

Commit

Permalink
Merge pull request #16 from ckormanyos/mingw64_recipe_for_gcc12
Browse files Browse the repository at this point in the history
Fix #13 via x86_64-w64-mingw32 recipe avr-gcc
  • Loading branch information
ckormanyos authored Dec 25, 2023
2 parents 425e310 + c89e799 commit 7876a1c
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/avr-gcc-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: update-buiild-essentials
- name: update-build-essentials
run: sudo apt install xz-utils autoconf texinfo
- name: avr-gcc-010-make-prereq_binutils
run: |
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Design goals:
- Provide a non-trivial test of the newly-built toolchain(s) based on a real-world project.
- Support cyclic monthly build of modern, evolving GCC branch(es) and trunk.
- Publish the build artifacts directly from the Workflow-Run(s) on GHA.
- Provide a [shell script recipe](./avr-gcc-100-12.3.0_x86_64-w64-mingw32.sh) for local build of `avr-gcc` on `x86_64-w64-mingw32` host. This does not run on GHA at the moment, but can be executed locally.

## Workflow-Run

Expand All @@ -44,5 +45,6 @@ This project is distributed under [The Unlicense](./UNLICENSE).

Limitations:
- At the moment, the Workflow-Run builds `avr-gcc` for the _host_ `x86_64-linux-gnu` only. Cross-host compilation for `x86_64-w64-mingw32` does not work.
- A [shell script recipe](./avr-gcc-100-12.3.0_x86_64-w64-mingw32.sh) for local build of `avr-gcc` on `x86_64-w64-mingw32` host. It does not run on GHA at the moment, but can be executed locally.

This work has been inspired by a similar project: [`ZakKemble/avr-gcc-build`](https://github.com/ZakKemble/avr-gcc-build).
28 changes: 28 additions & 0 deletions avr-gcc-100-12.3.0_x86_64-w64-mingw32.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff -ru gcc-12.3.0/gcc/system.h gcc-12.3.0_new/gcc/system.h
--- gcc-12.3.0/gcc/system.h 2023-05-08 14:14:40.077167400 +0200
+++ gcc-12.3.0_new/gcc/system.h 2023-12-24 12:49:49.854090800 +0100
@@ -777,16 +777,18 @@

/* Redefine abort to report an internal error w/o coredump, and
reporting the location of the error in the source file. */
-extern void fancy_abort (const char *, int, const char *)
- ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
-#define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__)
+extern void fancy_abort(const char *, int, const char *) __attribute__((noreturn, cold));
+
+__attribute__((noreturn, cold))
+static inline void fancy_abort_patch(void) { for(;;) { ; } }
+
+#define abort() fancy_abort_patch()

/* Use gcc_assert(EXPR) to test invariants. */
#if ENABLE_ASSERT_CHECKING
-#define gcc_assert(EXPR) \
- ((void)(!(EXPR) ? fancy_abort (__FILE__, __LINE__, __FUNCTION__), 0 : 0))
+#define gcc_assert(EXPR) ((void)(!(EXPR) ? 1 : 0))
#elif (GCC_VERSION >= 4005)
-#define gcc_assert(EXPR) \
+#define gcc_assert(EXPR) \
((void)(__builtin_expect (!(EXPR), 0) ? __builtin_unreachable (), 0 : 0))
#else
/* Include EXPR, so that unused variable warnings do not occur. */
152 changes: 152 additions & 0 deletions avr-gcc-100-12.3.0_x86_64-w64-mingw32.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#!/usr/bin/env bash
#
# Copyright Christopher Kormanyos 2023.
# Distributed under The Unlicense.
#

SCRIPT_PATH=$(readlink -f "$BASH_SOURCE")
SCRIPT_DIR=$(dirname "$SCRIPT_PATH")


# echo 'install necessary packages and build tools'
# pacman -S --needed --noconfirm wget make patch git mingw-w64-ucrt-x86_64-gcc texinfo bzip2 xz autoconf automake python unzip


echo 'clean gcc_build directory'
rm -rf gcc_build | true


echo 'make and enter gcc_build directory'
mkdir $SCRIPT_DIR/gcc_build


cd $SCRIPT_DIR/gcc_build
cp ../avr-gcc-100-12.3.0_x86_64-w64-mingw32.patch .


cd $SCRIPT_DIR/gcc_build
echo 'get tar-balls'
wget --no-check-certificate https://ftp.gnu.org/gnu/libiconv/libiconv-1.17.tar.gz
wget --no-check-certificate https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz
wget --no-check-certificate https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.xz
wget --no-check-certificate https://ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz
wget --no-check-certificate https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.15.tar.bz2
wget --no-check-certificate https://gcc.gnu.org/pub/gcc/infrastructure/cloog-0.18.1.tar.gz
wget --no-check-certificate https://ftp.gnu.org/gnu/binutils/binutils-2.41.tar.xz
wget --no-check-certificate https://ftp.gnu.org/gnu/gcc/gcc-12.3.0/gcc-12.3.0.tar.xz


cd $SCRIPT_DIR/gcc_build
echo 'build libiconv'
tar -xf libiconv-1.17.tar.gz
mkdir objdir-libiconv-1.17
cd objdir-libiconv-1.17
../libiconv-1.17/configure --prefix=/usr/local/libiconv-1.17 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --enable-static --disable-shared
make --job=6
make install


cd $SCRIPT_DIR/gcc_build
echo 'build gmp'
tar -xf gmp-6.3.0.tar.xz
mkdir objdir-gmp-6.3.0
cd objdir-gmp-6.3.0
../gmp-6.3.0/configure --prefix=/usr/local/gmp-6.3.0 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --enable-static --disable-shared
make --jobs=6
make install


cd $SCRIPT_DIR/gcc_build
echo 'build mpfr'
tar -xf mpfr-4.2.1.tar.xz
mkdir objdir-mpfr-4.2.1
cd objdir-mpfr-4.2.1
../mpfr-4.2.1/configure --prefix=/usr/local/mpfr-4.2.1 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --enable-static --disable-shared --with-gmp=/usr/local/gmp-6.3.0
make --jobs=6
make install


cd $SCRIPT_DIR/gcc_build
echo 'build mpc'
tar -xf mpc-1.3.1.tar.gz
mkdir objdir-mpc-1.3.1
cd objdir-mpc-1.3.1
../mpc-1.3.1/configure --prefix=/usr/local/mpc-1.3.1 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --enable-static --disable-shared --with-gmp=/usr/local/gmp-6.3.0 --with-mpfr=/usr/local/mpfr-4.2.1
make --jobs=6
make install


cd $SCRIPT_DIR/gcc_build
echo 'build isl'
tar -xjf isl-0.15.tar.bz2
mkdir objdir-isl-0.15
cd objdir-isl-0.15
../isl-0.15/configure --prefix=/usr/local/isl-0.15 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --enable-static --disable-shared --with-gmp=/usr/local/gmp-6.3.0
make --jobs=6
make install


cd $SCRIPT_DIR/gcc_build
echo 'build cloog'
tar -xf cloog-0.18.1.tar.gz
mkdir objdir-cloog-0.18.1
cd objdir-cloog-0.18.1
../cloog-0.18.1/configure --prefix=/usr/local/cloog-0.18.1 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --enable-static --disable-shared --with-isl=/usr/local/isl-0.15 --with-gmp=/usr/local/gmp-6.3.0
make --jobs=6
make install


cd $SCRIPT_DIR/gcc_build
echo 'build binutils'
tar -xf binutils-2.41.tar.xz
mkdir objdir-binutils-2.41-avr-gcc-12.3.0
cd objdir-binutils-2.41-avr-gcc-12.3.0
../binutils-2.41/configure --prefix=/usr/local/gcc-12.3.0-avr --target=avr --enable-languages=c,c++ --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --with-pkgversion='Built by ckormanyos/real-time-cpp' --enable-static --disable-shared --disable-libada --disable-libssp --disable-nls --enable-mingw-wildcard --with-gnu-as --with-dwarf2 --with-isl=/usr/local/isl-0.15 --with-cloog=/usr/local/cloog-0.18.1 --with-gmp=/usr/local/gmp-6.3.0 --with-mpfr=/usr/local/mpfr-4.2.1 --with-mpc=/usr/local/mpc-1.3.1 --with-libiconv-prefix=/usr/local/libiconv-1.17 --disable-werror
make --jobs=6
make install


#
# Notes on patch of GCC-12.3.0
#

# How do you make the patch?
# diff -ru gcc-12.3.0/ gcc-12.3.0_new/ > avr-gcc-100-12.3.0_x86_64-w64-mingw32.patch

# How do you apply the patch?
# patch -p0 < avr-gcc-100-12.3.0_x86_64-w64-mingw32.patch


cd $SCRIPT_DIR/gcc_build
echo 'build gcc'
tar -xf gcc-12.3.0.tar.xz
patch -p0 < avr-gcc-100-12.3.0_x86_64-w64-mingw32.patch
mkdir objdir-gcc-12.3.0-avr
cd objdir-gcc-12.3.0-avr
../gcc-12.3.0/configure --prefix=/usr/local/gcc-12.3.0-avr --target=avr --enable-languages=c,c++ --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --with-pkgversion='Built by ckormanyos/real-time-cpp' --enable-static --disable-shared --disable-libada --disable-libssp --disable-nls --enable-mingw-wildcard --with-gnu-as --with-dwarf2 --with-isl=/usr/local/isl-0.15 --with-cloog=/usr/local/cloog-0.18.1 --with-gmp=/usr/local/gmp-6.3.0 --with-mpfr=/usr/local/mpfr-4.2.1 --with-mpc=/usr/local/mpc-1.3.1 --with-libiconv-prefix=/usr/local/libiconv-1.17
make --jobs=6
make install


cd $SCRIPT_DIR/gcc_build
echo 'clone and bootstrap avr-libc'
git clone -b main --depth 1 https://github.com/avrdudes/avr-libc.git ./avr-libc
rm -f avr-libc/tests/simulate/time/aux.c
cd avr-libc
./bootstrap


cd $SCRIPT_DIR/gcc_build
echo 'add avr-gcc path'
PATH=/usr/local/gcc-12.3.0-avr/bin:"$PATH"
export PATH
CC=""
export CC


cd $SCRIPT_DIR/gcc_build
echo 'build avr-libc'
cd objdir-gcc-12.3.0-avr
../avr-libc/configure --prefix=/usr/local/gcc-12.3.0-avr --build=x86_64-w64-mingw32 --host=avr --enable-static --disable-shared
make --jobs=6
make install

0 comments on commit 7876a1c

Please sign in to comment.