Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Test gdb update 12.1 #19

Draft
wants to merge 39 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ecd7b9c
Add gdb
networkfusion Jan 24, 2023
1cdd94b
Move step to ensure quicker test result.
networkfusion Jan 24, 2023
5286f6a
Fix workflow?
networkfusion Jan 24, 2023
351d17c
Force build?
networkfusion Jan 24, 2023
498d37d
Fix build
networkfusion Jan 24, 2023
ffeb517
Checkout extras repo
networkfusion Jan 24, 2023
24d20d6
Fix yaml
networkfusion Jan 24, 2023
e1a974d
Fix variable and ensure fail
networkfusion Jan 24, 2023
99cb71e
Fix script?
networkfusion Jan 24, 2023
3214d4e
Further fix script
networkfusion Jan 24, 2023
622231c
Try latest version of GDB
networkfusion Jan 24, 2023
493d15b
Add expat
networkfusion Jan 25, 2023
c17d40d
Add gmp source to gdb
networkfusion Jan 25, 2023
c79a210
Revert GDB version
networkfusion Jan 25, 2023
dd282df
add static flag
networkfusion Jan 25, 2023
78ef366
Fix static?
networkfusion Jan 26, 2023
5f8669f
Improve GDB build
networkfusion Jan 26, 2023
662a28d
use install strip
networkfusion Jan 26, 2023
f7bd151
Use static flag
networkfusion Jan 26, 2023
df225d7
Remove strip - it did not work.
networkfusion Jan 26, 2023
4bae6e2
Add sudo to remove
networkfusion Jan 26, 2023
515eac6
Revert to ld static.
networkfusion Jan 26, 2023
6ce8ba7
Use expat
networkfusion Jan 26, 2023
84e4913
try different package for expat
networkfusion Jan 26, 2023
5f7fbcf
Add extra dependencies
networkfusion Jan 26, 2023
1d642c6
revert mingw gmp dependency
networkfusion Jan 26, 2023
3f763fb
Further attempt
networkfusion Jan 26, 2023
40e0ef0
try pacman
networkfusion Jan 26, 2023
66dc536
work on requirements
networkfusion Jan 27, 2023
51d337e
Fix script
networkfusion Jan 27, 2023
5200af9
Further fix script
networkfusion Jan 27, 2023
8703f40
try without explicit gmp
networkfusion Jan 27, 2023
00f49c7
further try
networkfusion Jan 27, 2023
244074d
Fix gmp
networkfusion Jan 27, 2023
690d684
Correct build path
networkfusion Jan 27, 2023
2e12eae
Improve system configure
networkfusion Jan 27, 2023
176c33d
add zlib
networkfusion Jan 27, 2023
bffaa32
try system flags
networkfusion Jan 27, 2023
05c880e
Add mingw zlib
networkfusion Jan 27, 2023
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
55 changes: 44 additions & 11 deletions .github/workflows/build-toolchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ on:
branches:
- main
- master
pull_request:
workflow_dispatch:
pull_request:
workflow_dispatch:

jobs:
build-toolchain:
Expand All @@ -27,6 +27,7 @@ jobs:
mpc-version: ${{ steps.gcc-version-generator.outputs.MPC_VERSION }}
mpfr-version: ${{ steps.gcc-version-generator.outputs.MPFR_VERSION }}
make-version: ${{ steps.gcc-version-generator.outputs.MAKE_VERSION }}
gdb-version: ${{ steps.gcc-version-generator.outputs.GDB_VERSION }}
strategy:
fail-fast: false
matrix:
Expand All @@ -45,13 +46,18 @@ jobs:
sudo apt-get install texinfo
sudo apt-get install libmpc-dev
sudo apt-get install squashfs-tools
sudo apt-get install libgmp-dev
sudo apt-get install libexpat-dev
# If there are other dependencies, we should add them here and make sure the documentation is updated!
continue-on-error: true

- name: Install x-compile system build dependencies
if: ${{ matrix.target-platform == 'Windows-x86_64' }}
run: |
sudo apt-get install -y mingw-w64
sudo apt-get install -y libz-mingw-w64-dev
# sudo apt-get install -y mingw-w64-expat
# sudo apt-get install -y mingw-w64-gmp
# If there are other dependencies, we should add them here and make sure the documentation is updated!

# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-ruby
Expand All @@ -77,6 +83,12 @@ jobs:
repository: dragonminded/libdragon
fetch-depth: 1 # we only require the last check-in, unless we want to create a changelog.

- name: Checkout Extra Code
uses: actions/checkout@v3
with:
fetch-depth: 1 # we only require the last check-in, unless we want to create a changelog.
path: extras

# Cache and restore dependencies instead of downloading them to increase build speed.
# Expires after 7 days.
- uses: actions/cache@v3
Expand All @@ -97,20 +109,32 @@ jobs:
echo "GMP_VERSION=$(grep -Po 'GMP_V=\K[^"]*' ./tools/build-toolchain.sh)" >> $GITHUB_OUTPUT
echo "MPC_VERSION=$(grep -Po 'MPC_V=\K[^"]*' ./tools/build-toolchain.sh)" >> $GITHUB_OUTPUT
echo "MPFR_VERSION=$(grep -Po 'MPFR_V=\K[^"]*' ./tools/build-toolchain.sh)" >> $GITHUB_OUTPUT
# TODO: this version is set explicitly. We need to fix!
# TODO: these versions are set explicitly. We need to fix!
echo "MAKE_VERSION=4.4" >> $GITHUB_OUTPUT
echo "GDB_VERSION=10.2" >> $GITHUB_OUTPUT
continue-on-error: false

- name: Build N64 MIPS GCC toolchain for ${{ matrix.target-platform }}
- name: Build Extras for ${{ matrix.target-platform }}
run: |
# required for newlib (as not the default?!)
export PATH="$PATH:${{ runner.temp }}/${{ env.Build_Directory }}"
cd ./tools/
sudo N64_INST=${{ runner.temp }}/${{ env.Build_Directory }} HOST=${{ matrix.host }} MAKE_V=${{ matrix.makefile-version }} ./build-toolchain.sh
echo Building extras like GDB
cd ${{ github.workspace }}/extras
chmod +x build-extras.sh
sudo N64_INST=${{ runner.temp }}/${{ env.Build_Directory }} HOST=${{ matrix.host }} GDB_V=${{ env.gdb_version }} ./build-extras.sh
sudo rm -rf ${{ runner.temp }}/${{ env.Build_Directory }}/share
# continue-on-error: true
env:
gdb_version: 12.1 # 12.1 requires further investigation due to GMP.

echo Remove un-necessary content
rm -rf ${N64_INST}/share/locale/*
continue-on-error: true
# - name: Build N64 MIPS GCC toolchain for ${{ matrix.target-platform }}
# run: |
# # required for newlib (as not the default?!)
# export PATH="$PATH:${{ runner.temp }}/${{ env.Build_Directory }}"
# cd ./tools/
# sudo N64_INST=${{ runner.temp }}/${{ env.Build_Directory }} HOST=${{ matrix.host }} MAKE_V=${{ matrix.makefile-version }} ./build-toolchain.sh

# echo Remove un-necessary content
# rm -rf ${N64_INST}/share/locale/*
# continue-on-error: true

# https://fpm.readthedocs.io/en/v1.15.0/getting-started.html
# TODO: add --deb-changelog with versions (like we do in release)
Expand Down Expand Up @@ -141,6 +165,7 @@ jobs:
$Package_Name-env.sh=/etc/profile.d/$Package_Name-env.sh

echo Generating rpm package
# It might be possible to convert using something like `fpm -s deb -t rpm $Package_Name.deb which could make things easier!
fpm \
-t rpm \
-s dir \
Expand All @@ -167,6 +192,12 @@ jobs:
Package_Url: https://github.com/n64-tools/
Package_Maintainer: N64-Tool Contributers

# - name: Test Debian package
# if: ${{ matrix.target-platform == 'Linux-x86_64' }}
# uses: ./.github/workflows/package-integratrion-tests-debian.yml
# secrets:
# token: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Windows-x86_64 Build Artifact
if: ${{ matrix.target-platform == 'Windows-x86_64' }}
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -231,6 +262,7 @@ jobs:
CHANGELOG_TEXT+='</br>'
CHANGELOG_TEXT+="Also generates Windows toolchain dependencies:</br>"
CHANGELOG_TEXT+=" * MAKEFILE: V${{ needs.build-toolchain.outputs.make-version }}</br>"
CHANGELOG_TEXT+=" * GDB: V${{ needs.build-toolchain.outputs.gdb-version }}</br>"
CHANGELOG_TEXT+='</br>'
echo "$CHANGELOG_TEXT" > ${{ github.workspace }}/CHANGELOG

Expand Down Expand Up @@ -259,6 +291,7 @@ jobs:
LICENSE.txt
INSTALLATION.txt

# TODO: this does not (currently) update the body of the release notes!
- name: Generate latest Release
if: startsWith(github.ref, 'refs/heads/master') # Actually, should we only do it on a tag?! if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/package-integratrion-tests-debian.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright (c) N64-Tools, NetworkFusion and contributers 2023
# See LICENSE file in the project root for full license information.

name: Test Debian Package

on:
workflow_call:

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Download package
run: |
# Download the generated package to the runner
echo "Downloading package..."
wget -O package.deb https://github.com/n64-tools/gcc-toolchain-mips64/releases/download/latest/gcc-toolchain-mips64_n64-tools-x86_64.deb

# - name: Install package dry run
# run: |
# # Install the package
# echo "Installing package dry run..."
# sudo dpkg --dry-run -i package.deb

- name: Install package
run: |
# Install the package
echo "Installing package..."
sudo dpkg -i package.deb

- name: Debug environment variables
run: |
# ls /etc/profile.d/
# reload the user profile so we dont have to restart.
source /etc/profile.d/gcc-toolchain-mips64_n64-tools-env.sh
# echo "Checking environment vars..."
printenv

# - name: Check dependencies
# run: |
# # Check the package's dependencies and ensure they are satisfied
# echo "Checking dependencies..."
# dpkg-checkbuilddeps

- uses: actions/checkout@v3
with:
fetch-depth: 1 # Using a shallow checkout. Change to `0` if a full fetch is required.

- name: Run functional tests (build libdragon)
run: |
# Run functional tests
echo "Running functional tests..."
# FIXME: temp add a local environment variable, until we can get the global one to work. (debug test)
# probably an issue with the build.sh script!
export N64_INST=/opt/gcc-toolchain-mips64_n64-tools
# FIXME: currently get issues with install location permissions.
#./build.sh
make libdragon

- name: Uninstall package
run: |
# Uninstall the package and check for any issues or leftovers
# FIXME: the package does not un-install!
echo "Uninstalling package..."
sudo dpkg -r gcc-toolchain-mips64_n64-tools

# - name: Check results
# run: |
# # Check the results of the tests
# echo "Checking results..."
# grep "FAILED" test_results.txt
# if [ $? -eq 0 ]; then exit 1; fi
129 changes: 129 additions & 0 deletions build-extras.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#! /bin/bash
# N64 MIPS GCC toolchain build/install script for Unix distributions
# (c) 2023 NetworkFusion.
# See the root folder for license information.

# Bash strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'

# Check that N64_INST is defined
if [ -z "${N64_INST-}" ]; then
echo "N64_INST environment variable is not defined."
echo "Please define N64_INST and point it to the requested installation directory"
exit 1
fi

# Path where the toolchain will be built.
BUILD_PATH="${BUILD_PATH:-toolchain}"

# Defines the build system variables to allow cross compilation.
BUILD=${BUILD:-""}
HOST=${HOST:-""}
TARGET=${TARGET:-mips64-elf}

# Set N64_INST before calling the script to change the default installation directory path
INSTALL_PATH="${N64_INST}"
# Set PATH for newlib to compile using GCC for MIPS N64 (pass 1)
export PATH="$PATH:$INSTALL_PATH/bin"

# Determine how many parallel Make jobs to run based on CPU count
JOBS="${JOBS:-$(getconf _NPROCESSORS_ONLN)}"
JOBS="${JOBS:-1}" # If getconf returned nothing, default to 1

# Dependency source libs (Versions)
# GMP_V=6.2.1
# EXPAT_V=2.5.0

# Check if a command-line tool is available: status 0 means "yes"; status 1 means "no"
command_exists () {
(command -v "$1" >/dev/null 2>&1)
return $?
}

# Create build path and enter it
mkdir -p "$BUILD_PATH"
cd "$BUILD_PATH"

# Download the file URL using wget or curl (depending on which is installed)
download () {
if command_exists wget ; then wget -c "$1"
elif command_exists curl ; then curl -LO "$1"
else
echo "Install wget or curl to download toolchain sources" 1>&2
return 1
fi
}


# Create build path and enter it
mkdir -p "$BUILD_PATH"
cd "$BUILD_PATH"

# Dependency downloads and unpack
test -f "gdb-$GDB_V.tar.gz" || download "https://ftp.gnu.org/gnu/gdb/gdb-$GDB_V.tar.gz"
test -d "gdb-$GDB_V" || tar -xzf "gdb-$GDB_V.tar.gz"

# if [ "$GMP_V" != "" ]; then
# test -f "gmp-$GMP_V.tar.bz2" || download "https://ftp.gnu.org/gnu/gmp/gmp-$GMP_V.tar.bz2"
# test -d "gmp-$GMP_V" || tar -xf "gmp-$GMP_V.tar.bz2" # note: no .gz download file currently available
# pushd "gdb-$GDB_V"
# ln -sf ../"gmp-$GMP_V" "gmp"
# popd
# fi

# if [ "$EXPAT_V" != "" ]; then
# test -f "expat-$EXPAT_V.tar.gz" || download "https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-$EXPAT_V.tar.gz"
# test -d "expat-$EXPAT_V" || tar -xf "expat-$EXPAT_V.tar.gz"
# pushd "gdb-$GDB_V"
# ln -sf ../"expat-$EXPAT_V" "expat"
# popd
# fi

if [ "$HOST" == "" ]; then
HOST="$BUILD"
fi


if [ "$BUILD" == "$HOST" ]; then
# Standard cross.
CROSS_PREFIX=$INSTALL_PATH
else
# Canadian cross.
# The standard BUILD->TARGET cross-compiler will be installed into a separate prefix, as it is not
# part of the distribution.
mkdir -p cross_prefix
CROSS_PREFIX="$(cd "$(dirname -- "cross_prefix")" >/dev/null; pwd -P)/$(basename -- "cross_prefix")"
PATH="$CROSS_PREFIX/bin:$PATH"
export PATH

# Instead, the HOST->TARGET cross-compiler can be installed into the final installation path
CANADIAN_PREFIX=$INSTALL_PATH
fi

if [ "$GDB_V" != "" ]; then
pushd "gdb-$GDB_V"
#
./configure \
--prefix="$INSTALL_PATH" \
--build="$BUILD" \
--host="$HOST" \
--target=mips64-elf \
--with-cpu=mips64vr4300 \
--disable-werror \
--with-system-zlib \
--with-system-gmp \
--with-system-expat \
LDFLAGS=-static

make -j "$JOBS"
make install || sudo make install || su -c "make install"
popd
fi

# Final message
echo
echo "***********************************************"
echo "Libdragon toolchain extras correctly built and installed"
echo "Installation directory: \"${N64_INST}\""
echo "Build directory: \"${BUILD_PATH}\" (can be removed now)"