Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GNU autoconf based build script and Github Actions CI #5

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
name: Toolchain build
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install build-essential build-essential texinfo \
flex bison libmpfr-dev libgmp-dev libmpc-dev zip libdebuginfod-dev \
gcc-mingw-w64 g++-mingw-w64

- name: Build Linux
run: |
mkdir build-linux
cd build-linux
export CFLAGS="-O2"
export CXXFLAGS="-O2"
export LDFLAGS="-static -s"
../configure --prefix /opt/gcc/linux
make -j$(nproc)

- name: Build Win32
run: |
cd build-linux/build-newlib
make install prefix=/opt/gcc/win32
cd ../..
mkdir build-win32
cd build-win32
export CFLAGS="-O2"
export CXXFLAGS="-O2"
export LDFLAGS="-static -s"
../configure --prefix /opt/gcc/win32 --with-host=x86_64-w64-mingw32
make -j$(nproc) stamps/build-binutils-tc
export PATH="/opt/gcc/linux/bin:$PATH"
make -j$(nproc) stamps/build-gcc-stage2-only

- name: Package
run: |
cd /opt/gcc/linux
zip -r9 ../linux.zip .
cd /opt/gcc/win32
zip -r9 ../win32.zip .

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: tricore-gcc-artifacts
path: /opt/gcc/*.zip
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release

on:
release:
types: [published]
workflow_dispatch:

jobs:
build:
name: Publish Release artifacts
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Extract commit SHA
shell: bash
run: |
echo "SHORT_SHA=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"

- name: Download artifacts from latest workflow
uses: dawidd6/action-download-artifact@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build.yml
branch: ${{ github.event.release.target_commitish }}
workflow_conclusion: success
skip_unpack: false

- name: Rename build artifacts
run: |
mv tricore-gcc-artifacts/linux.zip tricore-gcc-11.3.1-${{ env.SHORT_SHA }}-linux.zip
mv tricore-gcc-artifacts/win32.zip tricore-gcc-11.3.1-${{ env.SHORT_SHA }}-win32.zip

- name: Push release artifacts
uses: softprops/action-gh-release@v2
with:
files: |
*.zip
11 changes: 3 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Build folder
BUILD

# Install folder
INSTALL

# Log folder
LOG
autom4te.cache
configure~
BUILD
226 changes: 226 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
srcdir := @abs_top_srcdir@
builddir := @abs_top_builddir@
INSTALL_DIR := @prefix@

BINUTILS_SRCDIR := @with_binutils_src@
NEWLIB_SRCDIR := @with_newlib_src@
GCC_SRCDIR := @with_gcc_src@

CONFIGURE_HOST = @configure_host@

all: stamps/build-gcc-stage2

clean-binutils-tc:
rm -rf build-binutils-tc stamps/build-binutils-tc

clean-binutils-mcs:
rm -rf build-binutils-mcs stamps/build-binutils-mcs

clean-gcc-stage1:
rm -rf build-gcc-stage1 stamps/build-gcc-stage1

clean-newlib:
rm -rf build-newlib stamps/build-newlib

clean-gcc-stage2:
rm -rf build-gcc-stage2 stamps/build-gcc-stage2

clean-gcc-stage2-only:
rm -rf build-gcc-stage2-only stamps/build-gcc-stage2-only

clean:
rm -rf build-* stamps

stamps/install-deps: $(GCC_SRCDIR)
if test -f $</contrib/download_prerequisites; then cd $< && ./contrib/download_prerequisites; fi
mkdir -p $(dir $@) && touch $@

stamps/build-binutils-mcs: $(BINUTILS_SRCDIR)
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
--target=mcs-elf \
--program-prefix=mcs-elf- \
--prefix=$(INSTALL_DIR) \
$(CONFIGURE_HOST) \
--disable-threads \
--enable-nls \
--disable-itcl \
--disable-tk \
--disable-tcl \
--disable-winsup \
--disable-gdbtk \
--disable-libgui \
--disable-rda \
--disable-sid \
--disable-sim \
--disable-gdb \
--disable-newlib \
--disable-libgloss \
--disable-test-suite \
--enable-checking=release \
--with-gnu-ld \
--with-gnu-as \
--disable-werror
$(MAKE) -C $(notdir $@)
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@

stamps/build-binutils-tc: $(BINUTILS_SRCDIR) stamps/build-binutils-mcs
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
--target=tricore-elf \
--enable-targets=mcs-elf \
--program-prefix=tricore-elf- \
--prefix=$(INSTALL_DIR) \
$(CONFIGURE_HOST) \
--disable-threads \
--enable-nls \
--disable-itcl \
--disable-tk \
--disable-tcl \
--disable-winsup \
--disable-gdbtk \
--disable-libgui \
--disable-rda \
--disable-sid \
--disable-sim \
--disable-gdb \
--disable-newlib \
--disable-libgloss \
--disable-test-suite \
--enable-checking=release \
--with-gnu-ld \
--with-gnu-as \
--disable-werror
$(MAKE) -C $(notdir $@)
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@

stamps/build-gcc-stage1: $(GCC_SRCDIR) stamps/install-deps stamps/build-binutils-tc
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
CFLAGS_FOR_TARGET='-g -O2 -gdwarf-3' \
CXXFLAGS_FOR_TARGET='-g -O2 -gdwarf-3' \
--target=tricore-elf \
--prefix=$(INSTALL_DIR) \
--enable-lib32 \
--disable-lib64 \
--enable-languages=c,c++ \
--enable-libstdcxx-debug-flags='-gdwarf-3 -g -O0 -D_GLIBCXX_ASSERTIONS' \
--enable-c99 \
--enable-long-long \
--enable-checking \
--enable-nls \
--enable-static \
--disable-threads \
--disable-shared \
--with-headers=yes \
--with-newlib=yes \
--enable-mingw-wildcard \
--disable-libstdcxx-pch \
--enable-newlib-elix-level=3 \
--enable-newlib-io-long-long \
--disable-newlib-supplied-syscalls \
--disable-libssp \
--disable-test-suite
$(MAKE) -C $(notdir $@) all-gcc
$(MAKE) -C $(notdir $@) install-gcc
mkdir -p $(dir $@) && touch $@

stamps/build-newlib: $(NEWLIB_SRCDIR) stamps/build-gcc-stage1
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
CC_FOR_TARGET=$(INSTALL_DIR)/bin/tricore-elf-gcc \
CXX_FOR_TARGET=$(INSTALL_DIR)/bin/tricore-elf-c++ \
GCC_FOR_TARGET=$(INSTALL_DIR)/bin/tricore-elf-gcc \
AR_FOR_TARGET=$(INSTALL_DIR)/bin/tricore-elf-ar \
AS_FOR_TARGET=$(INSTALL_DIR)/bin/tricore-elf-as \
LD_FOR_TARGET=$(INSTALL_DIR)/bin/tricore-elf-ld \
NM_FOR_TARGET=$(INSTALL_DIR)/bin/tricore-elf-nm \
OBJDUMP_FOR_TARGET=$(INSTALL_DIR)/bin/tricore-elf-objdump \
RANLIB_FOR_TARGET=$(INSTALL_DIR)/bin/tricore-elf-ranlib \
STRIP_FOR_TARGET=$(INSTALL_DIR)/bin/tricore-elf-strip \
READELF_FOR_TARGET=$(INSTALL_DIR)/bin/tricore-elf-readelf \
CFLAGS_FOR_TARGET='-g -gdwarf-3 -O2 -ffunction-sections -mfast-div -fno-common' \
CXXFLAGS_FOR_TARGET='-g -gdwarf-3 -O2 -ffunction-sections -mfast-div -fno-common' \
--target=tricore-elf \
--prefix=$(INSTALL_DIR) \
--host=i686-w64-mingw32 \
--build=i686-pc-mingw32
$(MAKE) -C $(notdir $@) all
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@

stamps/build-gcc-stage2: $(GCC_SRCDIR) stamps/install-deps stamps/build-newlib
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && PATH=$(INSTALL_DIR)/bin:$$PATH $</configure \
CFLAGS_FOR_TARGET='-g -gdwarf-3 -O2 -ffast-math -ffunction-sections -mfast-div -fno-common -mno-eabi-bitfield-limit' \
CPPFLAGS_FOR_TARGET='-g -gdwarf-3 -O2 -ffast-math -ffunction-sections -mfast-div -fno-common -mno-eabi-bitfield-limit' \
--target=tricore-elf \
--enable-lib32 \
--disable-lib64 \
--prefix=$(INSTALL_DIR) \
$(CONFIGURE_HOST) \
--enable-languages=c,c++ \
--enable-libstdcxx-debug-flags='-gdwarf-3 -g -O0 -D_GLIBCXX_ASSERTIONS' \
--enable-c99 \
--enable-long-long \
--enable-checking \
--enable-nls \
--enable-static \
--disable-threads \
--disable-shared \
--with-headers=yes \
--with-gnu-ld \
--with-gnu-as \
--with-newlib=yes \
--enable-mingw-wildcard \
--disable-libstdcxx-pch \
--enable-newlib-elix-level=3 \
--enable-newlib-io-long-long \
--disable-newlib-supplied-syscalls \
--disable-libssp \
--disable-test-suite
$(MAKE) -C $(notdir $@) all
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@

stamps/build-gcc-stage2-only: $(GCC_SRCDIR) stamps/install-deps
rm -rf $@ $(notdir $@)
mkdir $(notdir $@)
cd $(notdir $@) && $</configure \
CFLAGS_FOR_TARGET='-g -gdwarf-3 -O2 -ffast-math -ffunction-sections -mfast-div -fno-common -mno-eabi-bitfield-limit' \
CPPFLAGS_FOR_TARGET='-g -gdwarf-3 -O2 -ffast-math -ffunction-sections -mfast-div -fno-common -mno-eabi-bitfield-limit' \
--target=tricore-elf \
--enable-lib32 \
--disable-lib64 \
--prefix=$(INSTALL_DIR) \
$(CONFIGURE_HOST) \
--enable-languages=c,c++ \
--enable-libstdcxx-debug-flags='-gdwarf-3 -g -O0 -D_GLIBCXX_ASSERTIONS' \
--enable-c99 \
--enable-long-long \
--enable-checking \
--enable-nls \
--enable-static \
--disable-threads \
--disable-shared \
--with-headers=yes \
--with-gnu-ld \
--with-gnu-as \
--with-newlib=yes \
--enable-mingw-wildcard \
--disable-libstdcxx-pch \
--enable-newlib-elix-level=3 \
--enable-newlib-io-long-long \
--disable-newlib-supplied-syscalls \
--disable-libssp \
--disable-test-suite
$(MAKE) -C $(notdir $@) all
$(MAKE) -C $(notdir $@) install
mkdir -p $(dir $@) && touch $@
Loading