├── .gitignore ├── .gitlab-ci.yml ├── README.md ├── build-crosstool-ng.sh ├── build.sh ├── download-and-prepare.sh ├── extract-version.sh ├── packaging ├── binutils-pru │ └── debian │ │ ├── changelog │ │ ├── compat │ │ ├── control │ │ ├── copyright │ │ ├── format │ │ ├── rules │ │ ├── source │ │ └── format │ │ └── watch └── gcc-pru │ └── debian │ ├── changelog │ ├── compat │ ├── control │ ├── copyright │ ├── format │ ├── rules │ ├── source │ └── format │ └── watch └── testing ├── BUILDBOT.md ├── README.md ├── buildbot-arm.sh ├── buildbot-avr.sh ├── buildbot-lib.sh ├── buildbot-pru.sh ├── buildbot-riscv_rv32ec.sh ├── buildbot-sync.sh ├── clpru.sh ├── compare-all-sizes.py ├── crontest.sh ├── gcc-test-host.sh ├── interop ├── Makefile ├── argpack │ ├── Makefile │ ├── gcc-main.c │ ├── out │ │ └── ti-mod.o │ ├── shared.h │ └── ti-mod.c ├── cxx-basic │ ├── Makefile │ ├── gcc-main.cxx │ ├── out │ │ └── ti-mod.o │ ├── shared.hxx │ └── ti-mod.cxx ├── fp │ ├── Makefile │ ├── gcc-main.c │ ├── out │ │ └── ti-mod.o │ ├── shared.h │ └── ti-mod.c ├── largeargs │ ├── Makefile │ ├── gcc-main.c │ ├── out │ │ └── ti-mod.o │ ├── shared.h │ └── ti-mod.c ├── relocs │ ├── Makefile │ ├── gcc-main.c │ ├── out │ │ └── ti-mod.o │ ├── shared.h │ └── ti-mod.c ├── retval │ ├── Makefile │ ├── gcc-main.c │ ├── out │ │ └── ti-mod.o │ ├── shared.h │ └── ti-mod.c ├── test.h ├── testcore.inc └── varargs │ ├── Makefile │ ├── gcc-main.c │ ├── out │ └── ti-mod.o │ ├── shared.h │ └── ti-mod.c ├── logdir2bunsen.sh ├── manual-build-arm.sh ├── manual-build-avr.sh ├── manual-build-pru.sh ├── manual-build-riscv.sh ├── manual-build-x86_64.sh ├── manual-test-aarch64_linux.sh ├── manual-test-avr.sh ├── manual-test-cris.sh ├── manual-test-pru.sh └── manual-test-riscv_rv32ec.sh /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | cscope 3 | cscope.out 4 | .*.sw? 5 | 6 | src/ 7 | build/ 8 | packaging-build/ 9 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | image: robertcnelson/beagle-devscripts-debian-12-arm64:latest 2 | # https://git.beagleboard.org/beagleboard/ci-docker-images 3 | 4 | # To test the artifacts of this CI pipeline: 5 | # $ sudo sh -c "echo 'deb [trusted=yes] https://beagleboard.beagleboard.io/gnupru stable main' > /etc/apt/sources.list.d/gnupru.list" 6 | # $ sudo apt update 7 | # $ sudo apt install gcc-pru gnuprumcu 8 | 9 | 10 | before_script: 11 | - apt-get update -qq && apt-get install -y -qq build-essential libmpfr-dev libgmp-dev libmpc-dev texinfo libncurses5-dev bison flex texinfo wget bison flex gettext debhelper tar findutils autotools-dev dh-autoreconf zlib1g-dev lsb-release git 12 | 13 | pages: 14 | tags: 15 | - docker-aarch64-ci 16 | stage: build 17 | script: 18 | - echo ----------------------- Download sources ----------------------- 19 | - ./download-and-prepare.sh 20 | - echo ----------------------- Package Binutils ----------------------- 21 | - echo "binutils-pru ($(./extract-version.sh binutils)-0.$(LANG=C date +%Y%m%d)~bookworm) bookworm; urgency=low" > ./packaging/binutils-pru/debian/changelog 22 | - echo "" >> ./packaging/binutils-pru/debian/changelog 23 | - echo " * ci build of $CI_PROJECT_URL" >> ./packaging/binutils-pru/debian/changelog 24 | - echo "" >> ./packaging/binutils-pru/debian/changelog 25 | - echo " -- $GITLAB_USER_NAME <$GITLAB_USER_EMAIL> $(LANG=C date -R)" >> ./packaging/binutils-pru/debian/changelog 26 | - echo "" >> ./packaging/binutils-pru/debian/changelog 27 | - mkdir -p packaging-build/binutils-pru 28 | - pushd packaging-build/binutils-pru 29 | - tar --strip-components=1 -xaf ../../src/binutils-gdb.tar.gz 30 | - cp -Rfp ../../packaging/binutils-pru/debian/ . 31 | - debuild -i -us -uc -b 32 | - popd 33 | - dpkg -i ./packaging-build/binutils-pru_*.deb 34 | - echo ----------------------- Package GCC ----------------------- 35 | - echo "gcc-pru ($(./extract-version.sh gcc)-0.$(LANG=C date +%Y%m%d)~bookworm) bookworm; urgency=low" > ./packaging/gcc-pru/debian/changelog 36 | - echo "" >> ./packaging/gcc-pru/debian/changelog 37 | - echo " * ci build of $CI_PROJECT_URL" >> ./packaging/gcc-pru/debian/changelog 38 | - echo "" >> ./packaging/gcc-pru/debian/changelog 39 | - echo " -- $GITLAB_USER_NAME <$GITLAB_USER_EMAIL> $(LANG=C date -R)" >> ./packaging/gcc-pru/debian/changelog 40 | - echo "" >> ./packaging/gcc-pru/debian/changelog 41 | - mkdir -p packaging-build/gcc-pru 42 | - pushd packaging-build/gcc-pru 43 | - tar --strip-components=1 -xaf ../../src/gcc.tar.gz 44 | - tar -xaf ../../src/newlib-cygwin.tar.gz 45 | - mv newlib-*/libgloss newlib-*/newlib . 46 | - rm -fr newlib-* 47 | - cp -Rfp ../../packaging/gcc-pru/debian/ . 48 | - debuild -i -us -uc -b 49 | - popd 50 | - dpkg -i ./packaging-build/gcc-pru_*.deb 51 | - echo ----------------------- Package Gnuprumcu ----------------------- 52 | - mkdir -p packaging-build/gnuprumcu 53 | - pushd packaging-build/gnuprumcu 54 | - tar --strip-components=1 -xaf ../../src/gnuprumcu.tar.gz 55 | - echo "gnuprumcu ($(cd ../../; ./extract-version.sh gnuprumcu)-0.$(LANG=C date +%Y%m%d)~bookworm) bookworm; urgency=low" > ./debian/changelog 56 | - echo "" >> ./debian/changelog 57 | - echo " * ci build of $CI_PROJECT_URL" >> ./debian/changelog 58 | - echo "" >> ./debian/changelog 59 | - echo " -- $GITLAB_USER_NAME <$GITLAB_USER_EMAIL> $(LANG=C date -R)" >> ./debian/changelog 60 | - echo "" >> ./debian/changelog 61 | - sed -i -e 's@--prefix=/usr/lib@--prefix=/usr/lib/gnupru@g' ./debian/rules 62 | - debuild -i -us -uc -b 63 | - popd 64 | - dpkg -i ./packaging-build/gnuprumcu_*.deb 65 | - echo ----------------------- Publish ----------------------- 66 | - mkdir -p ./public/dists/stable/main/binary-arm64/ 67 | - mkdir -p ./public/pool/ 68 | - cp -v ./packaging-build/*.deb ./public/pool/ || true 69 | - cp -v ./packaging-build/*.build ./public/ || true 70 | - cp -v ./packaging-build/*.buildinfo ./public/ || true 71 | - cd ./public ; dpkg-scanpackages ./pool/ | gzip > ./dists/stable/main/binary-arm64/Packages.gz || true ; cd ../ 72 | - apindex public 73 | artifacts: 74 | when: on_success 75 | paths: 76 | - public 77 | 78 | test-compile-examples: 79 | tags: 80 | - docker-aarch64-ci 81 | stage: test 82 | dependencies: 83 | - pages 84 | script: 85 | - dpkg -i ./public/pool/{binutils-pru,gcc-pru,gnuprumcu}_*.deb 86 | - git clone --depth=1 https://github.com/dinuxbg/pru-gcc-examples 87 | - cd pru-gcc-examples/ 88 | - make check-build 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![build status](https://git.beagleboard.org/beagleboard/gnupru/badges/master/pipeline.svg) 2 | 3 | # Port of GNU GCC and Binutils for the TI PRU I/O processor. 4 | 5 | ## Table Of Contents 6 | 7 | * [Introduction](#introduction) 8 | * [Examples](#examples) 9 | * [Getting The Cross Toolchain](#getting-the-cross-toolchain) 10 | * [Installing On Beagleboard Debian](#installing-on-beagleboard-debian) 11 | * [Prebuilt Tarballs](#prebuilt-tarballs) 12 | * [Building Using Crosstool-ng](#building-using-crosstool-ng) 13 | * [Building From Sources](#building-from-sources) 14 | * [Acknowledgements](#acknowledgements) 15 | 16 | ## Introduction 17 | 18 | This is a collection of documentation and build scripts for the GNU toolchain targeting the [PRU](https://beagleboard.org/pru) I/O CPU. PRU cores present in TI Sitara AM33xx and later SoCs are supported. 19 | 20 | Support for older PRU core versions is not planned. 21 | 22 | A simulator is used to execute the GCC C regression [test suite](./testing/README.md). Results are posted daily to https://gcc.gnu.org/pipermail/gcc-testresults/ . 23 | 24 | Bug reports should be filed in https://github.com/dinuxbg/gnupru/issues . For general questions please use https://forum.beagleboard.org/ . 25 | 26 | This project has no relation to the TI PRU C compiler. ABI differences between GCC PRU and TI PRU C are tracked in https://github.com/dinuxbg/gnupru/wiki 27 | 28 | ## Examples 29 | 30 | There are several examples to get started: 31 | * Assorted small examples: https://github.com/dinuxbg/pru-gcc-examples 32 | * BeagleMic PDM microphone array: https://gitlab.com/dinuxbg/beaglemic 33 | * GCC port of the TI PRU training: https://github.com/dinuxbg/pru-software-support-package . Make sure to read ReadMe-GCC.txt. 34 | 35 | ## Getting The Cross Toolchain 36 | 37 | Several methods to acquire the PRU cross toolchain are listed below, ordered by most convenient first. 38 | 39 | ### Installing On Arm64 Debian 40 | 41 | If you are running an arm64 Debian (for example [Beagleboard Debian Image](https://beagleboard.org/latest-images)), then installation is simple: 42 | 43 | sudo sh -c "echo 'deb [trusted=yes] https://beagleboard.beagleboard.io/debian-'`lsb_release --release --short`'-gnupru stable main' > /etc/apt/sources.list.d/gnupru.list" 44 | sudo apt update 45 | sudo apt install gcc-pru gnuprumcu 46 | 47 | ### Prebuilt Tarballs 48 | 49 | Latest [releases](https://github.com/dinuxbg/gnupru/releases/latest) provide prebuilt tarballs for several hosts: `amd64` Linux, `armhf` Linux, Windows. Simply download, untar and use them when: 50 | 51 | * You want to cross-compile PRU firmware from `amd64` Linux or Windows host. 52 | * You are using an `armhf` distribution other than [Beagleboard Debian Image](https://beagleboard.org/latest-images). 53 | 54 | *Note for maintainers: These prebuilt release tarballs are prepared using the `build-crosstool-ng.sh` script.* 55 | 56 | ### Building Using Crosstool-ng 57 | 58 | Recently [crosstool-ng](https://github.com/crosstool-ng/crosstool-ng) acquired pru support. Provided you build top-of-tree `crosstool-ng`, you should be able to: 59 | 60 | $ ct-ng pru 61 | $ ct-ng build 62 | $ PATH=$HOME/x-tools/pru-elf/bin:$PATH 63 | 64 | ### Building From Sources 65 | 66 | The custom build scripts are should work on any recent Linux distro. They are intended to be simple enough, so that they can act as a documentation how to cross-compile a toolchain. They intentionally lack some features: 67 | 68 | * Downloaded source tarballs are **not** verified. 69 | * Host binaries are not stripped, leading to bigger host executables sizes. Target firmware size is not affected, though! 70 | * Code complexity is kept at only about 100 lines of simple `BASH` statements. 71 | 72 | Users may find that [Beagleboard Debian Packages](#installing-on-beagleboard-debian), or [prebuilt releases](#prebuilt-tarballs) or [crosstool-ng](#building-using-crosstool-ng) are instead more suitable for production. 73 | 74 | You'll need some prerequisites. For a Debian host: 75 | 76 | sudo apt-get install build-essential libmpfr-dev libgmp-dev libmpc-dev texinfo libncurses5-dev bison flex texinfo 77 | 78 | Alternatively, for a Fedora host: 79 | 80 | sudo dnf install @development-tools g++ mpfr-devel gmp-devel libmpc-devel texinfo texinfo-tex texlive-cm-super* texlive-ec ncurses-devel bison flex 81 | 82 | Then it should be a simple matter of: 83 | 84 | export PREFIX=$HOME/bin/pru-gcc # Define where to install the toolchain 85 | ./download-and-prepare.sh # Download and prepare the sources 86 | ./build.sh # Build 87 | 88 | ## Acknowledgements 89 | 90 | * GCC/Binutils Nios2 port was taken as a base for the PRU port. 91 | -------------------------------------------------------------------------------- /build-crosstool-ng.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Script to build pru-elf cross toolchains for several 4 | # hosts, using crosstool-ng. 5 | 6 | set -e 7 | 8 | die() 9 | { 10 | echo "ERROR: $@" 11 | exit 1 12 | } 13 | 14 | [ $# != 1 ] && die "Usage: $0 VERSION" 15 | VERSION=${1} 16 | shift 17 | 18 | # Work in the current directory. 19 | WORKSPACE=`pwd` 20 | 21 | # Where to get CT from. 22 | CT_GIT=https://github.com/dinuxbg/crosstool-ng 23 | CT_TAG=gnupru-${VERSION} 24 | 25 | CT=${WORKSPACE}/opt/bin/ct-ng 26 | 27 | #============================================================================= 28 | clean() 29 | { 30 | # sudo rm -fr $HOME/x-tools/* 31 | rm -fr .build 32 | rm -f build.log 33 | rm -f .config 34 | rm -fr opt 35 | } 36 | 37 | #============================================================================= 38 | # Build crosstool-ng. 39 | build_crosstool_ng() 40 | { 41 | if ! test -d crosstool-ng 42 | then 43 | git clone ${CT_GIT} crosstool-ng 44 | fi 45 | pushd crosstool-ng 46 | # Use the ASIS special version for development purposes. 47 | if [ "x${VERSION}" != "xASIS" ] 48 | then 49 | git checkout ${CT_TAG} 50 | fi 51 | popd 52 | 53 | pushd crosstool-ng 54 | ./bootstrap 55 | ./configure --prefix=${WORKSPACE}/opt/ 56 | make -j`nproc` 57 | make install 58 | popd 59 | } 60 | 61 | 62 | #============================================================================= 63 | 64 | # Replace the EXE symbolic links with equivalent 65 | # BAT files. For example, remove: 66 | # pru-gcc.exe -> pru-elf-gcc.exe 67 | # and replace with a BAT file calling the original: 68 | # pru-gcc.bat 69 | convert_symlink_to_bat() 70 | { 71 | local dst=${1} 72 | local src=`realpath ${1}` 73 | local tool=`basename ${dst} .exe | cut -c5-` 74 | local new_dst=`dirname ${dst}`/`basename ${dst} .exe`.bat 75 | rm -f ${dst} 76 | echo "pru-elf-${tool}.exe %*" > ${new_dst} 77 | } 78 | 79 | # Remove the given symbolic link, and replace it 80 | # with a copy of the real file. 81 | dup_symlink_to_file() 82 | { 83 | local dst=${1} 84 | local src=`realpath ${1}` 85 | rm -f ${dst} 86 | cp -f ${src} ${dst} 87 | } 88 | 89 | # Build and install GNU make for Windows. 90 | build_install_make.exe() 91 | { 92 | # Find the latest source package. Should have been 93 | # downloaded by previous crosstool-ng builds. 94 | local make_tar=`realpath $HOME/src/make-* | sort -n | tail -1` 95 | local builddir=`mktemp -d` 96 | pushd ${builddir} 97 | tar xaf ${make_tar} 98 | pushd make* 99 | # TODO - GNU make 4.4 has implicit function declarations. 100 | # TODO - GNU make 4.4 has invalid declaration for getenv 101 | # Remove the custom CFLAGS for the next version. 102 | ./configure --host=x86_64-w64-mingw32 CFLAGS='-O2 -Wno-implicit-function-declaration -std=gnu17' 103 | make -j${nproc} 104 | cp make.exe $HOME/x-tools/HOST-x86_64-w64-mingw32/pru-elf/bin/ 105 | popd 106 | popd 107 | rm -fr ${builddir} 108 | } 109 | 110 | build_mingw() 111 | { 112 | # If binfmt is enabled for Wine EXEs, then some toolchain 113 | # configure scripts get confused. Disable binfmt. 114 | test -f /proc/sys/fs/binfmt_misc/status || sudo mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc 115 | echo 0 | sudo tee /proc/sys/fs/binfmt_misc/status 116 | 117 | # Build mingw host toolchain. 118 | ${CT} x86_64-w64-mingw32 119 | ${CT} build 120 | 121 | # Canadian cross compile. 122 | ${CT} x86_64-w64-mingw32,pru 123 | # We must use the mingw we just built. 124 | PATH=$HOME/x-tools/x86_64-w64-mingw32/bin/:$PATH ${CT} build 125 | 126 | # Crosstool-ng does not install the necessary runtime DLLs. Let's manually copy them. 127 | # https://github.com/crosstool-ng/crosstool-ng/issues/1869 128 | chmod +w $HOME/x-tools/HOST-x86_64-w64-mingw32/pru-elf/bin/ 129 | cp $HOME/x-tools/x86_64-w64-mingw32/x86_64-w64-mingw32/sysroot/usr/x86_64-w64-mingw32/bin/libwinpthread-1.dll $HOME/x-tools/HOST-x86_64-w64-mingw32/pru-elf/bin/ 130 | chmod +w $HOME/x-tools/HOST-x86_64-w64-mingw32/pru-elf/libexec/gcc/pru-elf/* 131 | cp $HOME/x-tools/x86_64-w64-mingw32/x86_64-w64-mingw32/sysroot/usr/x86_64-w64-mingw32/bin/libwinpthread-1.dll $HOME/x-tools/HOST-x86_64-w64-mingw32/pru-elf/libexec/gcc/pru-elf/*/ 132 | 133 | # The 7za+Windows combination does not support symbolic links. Perform workarounds. 134 | chmod -R +w $HOME/x-tools/HOST-x86_64-w64-mingw32/pru-elf/ 135 | find $HOME/x-tools/HOST-x86_64-w64-mingw32/pru-elf -type l -a -iname "*.exe" | while read F; do convert_symlink_to_bat ${F}; done 136 | find $HOME/x-tools/HOST-x86_64-w64-mingw32/pru-elf -type l -a -iname "*.dll" | while read F; do dup_symlink_to_file ${F}; done 137 | 138 | # Install GNU make executable in the release tarball, for user's convenience. 139 | PATH=$HOME/x-tools/x86_64-w64-mingw32/bin/:$PATH build_install_make.exe 140 | 141 | # Finally - we can package. 142 | pushd $HOME/x-tools/HOST-x86_64-w64-mingw32/ 143 | 7za a -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on ${WORKSPACE}/pru-elf-${VERSION}.windows.EXPERIMENTAL.7z pru-elf/ 144 | popd 145 | } 146 | 147 | build_arm() 148 | { 149 | local tarname=pru-elf-${VERSION}.arm.tar 150 | 151 | ${CT} arm-unknown-linux-gnueabihf 152 | ${CT} build 153 | ${CT} arm-unknown-linux-gnueabihf,pru 154 | PATH=$HOME/x-tools/arm-unknown-linux-gnueabihf/bin/:$PATH ${CT} build 155 | 156 | rm -f ${tarname}* 157 | tar -C $HOME/x-tools/HOST-arm-unknown-linux-gnueabihf/ -caf ${tarname} pru-elf 158 | xz -9 ${tarname} 159 | } 160 | 161 | build_x86() 162 | { 163 | local tarname=pru-elf-${VERSION}.amd64.tar 164 | 165 | ${CT} x86_64-unknown-linux-gnu 166 | ${CT} build 167 | ${CT} x86_64-unknown-linux-gnu,pru 168 | PATH=$HOME/x-tools/x86_64-unknown-linux-gnu/bin/:$PATH ${CT} build 169 | 170 | rm -f ${tarname}* 171 | tar -C $HOME/x-tools/HOST-x86_64-unknown-linux-gnu/ -caf ${tarname} pru-elf 172 | xz -9 ${tarname} 173 | } 174 | 175 | #============================================================================= 176 | build_crosstool_ng 177 | build_arm 178 | build_x86 179 | build_mingw 180 | 181 | echo "" 182 | echo SUCCESS 183 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Sample script to build the GCC PRU toolchain. 4 | # 5 | # Note: Keep it simple! Don't write a crostool-ng clone. Instead focus on 6 | # documenting the necessary build steps, while simultaneously producing 7 | # a functional cross-toolchain binary release. 8 | # 9 | # For example, following features are lacking on purpose: 10 | # - Downloaded source tarballs are not verified. 11 | # - Host binaries are not stripped. 12 | 13 | MAINDIR=`pwd` 14 | SRC=`pwd`/src 15 | BUILD=`pwd`/build 16 | 17 | die() 18 | { 19 | echo ERROR: $@ 20 | exit 1 21 | } 22 | 23 | build_binutils() 24 | { 25 | cd $BUILD/binutils-gdb 26 | $SRC/binutils-gdb/configure --target=pru --prefix=$PREFIX --disable-nls --with-bugurl="https://github.com/dinuxbg/gnupru/issues" --disable-gdb || die Could not configure Binutils 27 | make -j`nproc` || die Could not build Binutils 28 | make install || die Could not install Binutils 29 | } 30 | 31 | 32 | build_gcc_pass() 33 | { 34 | PASS=$1 35 | EXTRA_ARGS=$2 36 | cd $BUILD/gcc 37 | $SRC/gcc/configure --target=pru --prefix=$PREFIX --disable-nls --with-newlib --with-bugurl="https://github.com/dinuxbg/gnupru/issues" $EXTRA_ARGS || die Could not configure GCC pass$PASS 38 | make -j`nproc` || die Could not build GCC pass$PASS 39 | make install || die Could not install GCC pass$PASS 40 | } 41 | 42 | build_newlib() 43 | { 44 | cd $BUILD/newlib-cygwin 45 | $SRC/newlib-cygwin/configure --target=pru --prefix=$PREFIX --disable-newlib-fvwrite-in-streamio --enable-newlib-nano-formatted-io --disable-newlib-multithread || die Could not configure Newlib 46 | make -j`nproc` || die Could not build Newlib 47 | make install || die Could not install Newlib 48 | } 49 | 50 | build_gnuprumcu() 51 | { 52 | cd $BUILD/gnuprumcu 53 | $SRC/gnuprumcu/configure --host=pru --prefix=$PREFIX || die Could not configure gnuprumcu 54 | make -j`nproc` || die Could not build gnuprumcu 55 | make install || die Could not install gnuprumcu 56 | } 57 | 58 | RETDIR=`pwd` 59 | 60 | export PATH=$PREFIX/bin:$PATH 61 | 62 | [ -d $SRC ] || die $SRC does not exist. Please run ./download-and-prepare.sh 63 | [ -z "$PREFIX" ] && die Please \"export PREFIX=...\" to define where to install the toolchain 64 | mkdir -p $PREFIX 65 | [ -d "$PREFIX" ] || die Could not create installation target directory "$PREFIX" 66 | mkdir -p $BUILD/gcc 67 | mkdir -p $BUILD/binutils-gdb 68 | mkdir -p $BUILD/newlib-cygwin 69 | mkdir -p $BUILD/gnuprumcu 70 | 71 | # Configure, build and install. 72 | build_binutils 73 | build_gcc_pass 1 "--without-headers --enable-languages=c" 74 | build_newlib 75 | build_gcc_pass 2 "--enable-languages=c,c++" 76 | build_gnuprumcu 77 | 78 | cd $RETDIR 79 | 80 | echo Done. 81 | -------------------------------------------------------------------------------- /download-and-prepare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Sample script to download vanilla upstream projects. 4 | 5 | # Official packages to download. 6 | GCC_URL=http://ftpmirror.gnu.org/gcc/gcc-15.1.0/gcc-15.1.0.tar.xz 7 | BINUTILS_URL=http://ftpmirror.gnu.org/binutils/binutils-2.44.tar.bz2 8 | NEWLIB_URL=http://sourceware.org/pub/newlib/newlib-4.5.0.20241231.tar.gz 9 | GNUPRUMCU_URL=https://github.com/dinuxbg/gnuprumcu/releases/download/v0.9.7/gnuprumcu-0.9.7.tar.gz 10 | 11 | MAINDIR=`pwd` 12 | SRC=`pwd`/src 13 | 14 | die() 15 | { 16 | echo ERROR: $@ 17 | exit 1 18 | } 19 | 20 | prepare_source_tarball() 21 | { 22 | local PRJ=$1 23 | local URL=$2 24 | 25 | # Do not download if already available. 26 | gzip --test $SRC/"$PRJ".tar.gz && return 0 27 | 28 | wget $URL -O $SRC/"$PRJ".tar.gz || die "failed to download $URL" 29 | mkdir -p "${SRC}/${PRJ}" 30 | pushd "${SRC}/${PRJ}" 31 | tar --strip-components=1 -xaf "${SRC}/${PRJ}.tar.gz" || die "failed to extract ${PRJ}.tar.gz" 32 | popd 33 | } 34 | 35 | RETDIR=`pwd` 36 | 37 | [ -d $SRC ] && die Incremental builds not supported. Cleanup and retry, e.g. 'git clean -fdx' 38 | mkdir -p $SRC 39 | 40 | # Checkout baseline. 41 | prepare_source_tarball binutils-gdb $BINUTILS_URL 42 | prepare_source_tarball gcc $GCC_URL 43 | prepare_source_tarball newlib-cygwin $NEWLIB_URL 44 | prepare_source_tarball gnuprumcu $GNUPRUMCU_URL 45 | 46 | cd $RETDIR 47 | 48 | echo Done. 49 | -------------------------------------------------------------------------------- /extract-version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Pattern works for binutils, GCC and gnuprumcu release filenames. 4 | grep -o "${1}-[0-9\.]\+[0-9]" download-and-prepare.sh | head -1 | cut -f2- -d- 5 | -------------------------------------------------------------------------------- /packaging/binutils-pru/debian/changelog: -------------------------------------------------------------------------------- 1 | binutils-pru (2.44) bookworm; urgency=low 2 | 3 | * Binutils 2.44. 4 | 5 | -- Dimitar Dimitrov Thu, 29 May 2025 21:14:12 +0200 6 | 7 | binutils-pru (2.41-0bbbio0~bookworm+20230804) bookworm; urgency=low 8 | 9 | * Bump to mainline version 2.41. 10 | 11 | -- Robert Nelson Fri, 04 Aug 2023 16:16:41 -0500 12 | 13 | binutils-pru (2.41) bullseye; urgency=low 14 | 15 | * Binutils 2.41. 16 | 17 | -- Dimitar Dimitrov Mon, 31 Jul 2023 21:14:12 +0200 18 | 19 | binutils-pru (2.38) bullseye; urgency=low 20 | 21 | * Binutils 2.38 official release. 22 | 23 | -- Dimitar Dimitrov Sun, 13 Feb 2022 15:24:12 +0200 24 | 25 | binutils-pru (2.37.50.g2749ac13) bullseye; urgency=low 26 | 27 | * Binutils 2.37.50, mainline commit 2749ac133972d027fe9482acc81f6e88c4f36812. 28 | * Fix handling of .pri_irq_map section. 29 | * Fix .resource_table section alignment for AM64x SoCs. 30 | 31 | -- Dimitar Dimitrov Sun, 12 Dec 2021 20:54:12 +0200 32 | 33 | binutils-pru (2.34) bullseye; urgency=low 34 | 35 | * Bump to mainline version 2.34. 36 | 37 | -- Dimitar Dimitrov Wed, 18 Mar 2020 20:54:12 +0200 38 | 39 | binutils-pru (2.30.51.20180310) stretch; urgency=medium 40 | 41 | * ld: Switched relocations to be more compatible with TI's toolchain. YOU MUST RECOMPILE ALL YOUR SOURCE FILES - object files from old and new binutils cannot be linked together. 42 | * Rebased to latest baseline. 43 | 44 | -- Dimitar Dimitrov Mon, 12 Mar 2018 20:54:12 +0200 45 | 46 | binutils-pru (2.28.51.20170102) jessie; urgency=medium 47 | 48 | * A few fixes for 32-bit hosts. 49 | 50 | -- Dimitar Dimitrov Mon, 02 Jan 2017 11:45:54 +0200 51 | 52 | binutils-pru (2.28.51.20161231) jessie; urgency=medium 53 | 54 | * ld: Switched relocations to be more compatible with TI's toolchain. YOU MUST RECOMPILE ALL YOUR SOURCE FILES - object files from old and new binutils cannot be linked together. 55 | * gas: Added WBC and WBS pseudo ops to GAS. 56 | * gas: Added optional & prefix for addressed registers 57 | * gas/ld: Removed %hi/%lo/%hi_rlz assembler constructs and instead implemented LDI32 pseudo instruction. 58 | * gas: Switched to r3.w2 as Return Address Register for the call and ret pseudos. 59 | * gas: Added %label() construct to allow disambiguating register from label JMP operands. 60 | 61 | -- Dimitar Dimitrov Sat, 31 Dec 2016 10:44:41 +0200 62 | 63 | binutils-pru (2.27.51.20160801-0rcnee0~bpo80+20160802+1) jessie; urgency=low 64 | 65 | * Rebuild for repos.rcn-ee.com 66 | 67 | -- Robert Nelson Tue, 02 Aug 2016 08:12:03 -0500 68 | 69 | binutils-pru (2.27.51.20160801) unstable; urgency=medium 70 | 71 | * Small fixes to the debian package. 72 | 73 | -- Dimitar Dimitrov Mon, 01 Aug 2016 23:17:39 +0300 74 | 75 | binutils-pru (2.27.51.20160725) unstable; urgency=medium 76 | 77 | * Small fixes to the debian package 78 | 79 | -- Dimitar Dimitrov Fri, 29 Jul 2016 23:36:58 +0300 80 | 81 | binutils-pru (2.27.51.20160724) unstable; urgency=medium 82 | 83 | * Update to gnupru release 2016.07-beta-rc1 84 | 85 | -- Dimitar Dimitrov Sun, 24 Jul 2016 17:02:58 +0300 86 | 87 | binutils-pru (2.25.51.20150928) unstable; urgency=high 88 | 89 | * Initial package for PRU binutils. 90 | 91 | -- Dimitar Dimitrov Mon, 28 Sep 2015 13:21:34 +0200 92 | -------------------------------------------------------------------------------- /packaging/binutils-pru/debian/compat: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /packaging/binutils-pru/debian/control: -------------------------------------------------------------------------------- 1 | Source: binutils-pru 2 | Section: devel 3 | Priority: extra 4 | Maintainer: Dimitar Dimitrov 5 | Standards-Version: 4.1.3 6 | Build-Depends: 7 | bison 8 | , flex 9 | , gettext 10 | , texinfo 11 | , binutils (>= 2.9.5.0.12) 12 | , gcc (>= 2.95.2) 13 | , debhelper (>= 10) 14 | , tar (>= 1.13.18) 15 | , bzip2 16 | , findutils(>=4.2.31) 17 | 18 | Package: binutils-pru 19 | Section: devel 20 | Architecture: any 21 | Priority: extra 22 | Depends: ${shlibs:Depends}, ${misc:Depends} 23 | Description: Binary utilities supporting TI's PRU targets 24 | The programs in this package are used to manipulate binary and object 25 | files that may have been created for TI's PRU architecture. 26 | This package is primarily intended for PRU developers and 27 | cross-compilers. 28 | -------------------------------------------------------------------------------- /packaging/binutils-pru/debian/copyright: -------------------------------------------------------------------------------- 1 | This is a debian pakcage of the GNU assembler, linker, and binary 2 | utilities compiled for cross develoopment for the TI's PRU I/O processor. 3 | 4 | 5 | GNU Binutils is Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 6 | 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software 7 | Foundation, Inc. 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 22 | MA 02110-1301, USA. */ 23 | 24 | On Debian GNU/Linux systems, the complete text of the GNU General 25 | Public License can be found in `/usr/share/common-licenses/GPL' 26 | and `/usr/share/common-licenses/LGPL'. 27 | 28 | The binutils manuals and associated documentation are also Copyright 29 | (C) Free Software Foundation, Inc. They are distributed under the GNU 30 | Free Documentation License Version 1.3 or any later version published 31 | by the Free Software Foundation, with no Invariant Sections, with no 32 | with no Front-Cover Texts, and with no Back-Cover Texts. 33 | On Debian GNU/Linux systems, the complete text of the GFDL can be found 34 | in `/usr/share/common-licenses/GFDL'. 35 | -------------------------------------------------------------------------------- /packaging/binutils-pru/debian/format: -------------------------------------------------------------------------------- 1 | 1.0 2 | -------------------------------------------------------------------------------- /packaging/binutils-pru/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # See debhelper(7) (uncomment to enable) 3 | # output every command that modifies files on the build system. 4 | #export DH_VERBOSE = 1 5 | 6 | 7 | # Install to /usr/lib/gnupru, and create symlinks in /usr/bin to 8 | # the real executables. 9 | 10 | %: 11 | dh $@ 12 | 13 | override_dh_auto_configure: 14 | dh_auto_configure -- \ 15 | --target=pru \ 16 | --disable-gdb \ 17 | --disable-sim \ 18 | --disable-libctf \ 19 | --disable-nls \ 20 | --prefix=/usr/lib/gnupru \ 21 | 22 | BINUTILS_EXECUTABLES=addr2line ar as c++filt elfedit gprof ld ld.bfd nm objcopy objdump ranlib readelf size strings strip 23 | 24 | override_dh_install: 25 | dh_install 26 | mkdir -p debian/binutils-pru/usr/bin 27 | for i in $(BINUTILS_EXECUTABLES); do ln -s /usr/lib/gnupru/bin/pru-$$i debian/binutils-pru/usr/bin/pru-$$i ; done 28 | 29 | # No need for autoreconf. 30 | # Besides, binutils insists on using the obsolete 2.69 version. 31 | override_dh_autoreconf: 32 | -------------------------------------------------------------------------------- /packaging/binutils-pru/debian/source/format: -------------------------------------------------------------------------------- 1 | 1.0 2 | -------------------------------------------------------------------------------- /packaging/binutils-pru/debian/watch: -------------------------------------------------------------------------------- 1 | # Example watch control file for uscan 2 | # Rename this file to "watch" and then you can run the "uscan" command 3 | # to check for upstream updates and more. 4 | # See uscan(1) for format 5 | 6 | # Compulsory line, this is a version 4 file 7 | version=4 8 | 9 | # PGP signature mangle, so foo.tar.gz has foo.tar.gz.sig 10 | #opts="pgpsigurlmangle=s%$%.sig%" 11 | 12 | # HTTP site (basic) 13 | https://ftp.gnu.org/gnu/binutils/ \ 14 | binutils-([\d\.]+)\.tar\.gz debian uupdate 15 | 16 | # Uncomment to examine an FTP server 17 | #ftp://ftp.example.com/pub/gnuprumcu-(.*)\.tar\.gz debian uupdate 18 | 19 | # SourceForge hosted projects 20 | # http://sf.net/gnuprumcu/ gnuprumcu-(.*)\.tar\.gz debian uupdate 21 | 22 | # GitHub hosted projects 23 | #opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%-$1.tar.gz%" \ 24 | # https://github.com//gnuprumcu/tags \ 25 | # (?:.*?/)?v?(\d[\d.]*)\.tar\.gz debian uupdate 26 | 27 | # Direct Git 28 | # opts="mode=git" https://gitlab.com/dinuxbg/gnuprumcu.git \ 29 | # refs/tags/v([\d\.]+) debian uupdate 30 | -------------------------------------------------------------------------------- /packaging/gcc-pru/debian/changelog: -------------------------------------------------------------------------------- 1 | gcc-pru (15.1.0) bookworm; urgency=low 2 | 3 | * Bump to GCC mainline 15.1.0 4 | 5 | -- Dimitar Dimitrov Thu, 29 May 2025 22:59:11 +0200 6 | 7 | gcc-pru (13.2.0-0bbbio0~bookworm+20230804) bookworm; urgency=low 8 | 9 | * Rebuild for repos.rcn-ee.com 10 | 11 | -- Robert Nelson Fri, 04 Aug 2023 20:21:19 -0500 12 | 13 | gcc-pru (13.2.0) bullseye; urgency=low 14 | 15 | * Bump to GCC mainline 13.2.0 16 | 17 | -- Dimitar Dimitrov Mon, 31 Jul 2023 22:59:11 +0200 18 | 19 | gcc-pru (12.0.RC.gaeedb00a1a) bullseye; urgency=low 20 | 21 | * Bump to GCC mainline commit aeedb00a1ae2ccd10b1a5f00ff466081aeadb54b. 22 | 23 | -- Dimitar Dimitrov Sun, 12 Dec 2021 21:59:11 +0200 24 | 25 | gcc-pru (10-20200315) bullseye; urgency=medium 26 | 27 | * Switch to mainline snapshot version. 28 | 29 | -- Dimitar Dimitrov Wed, 18 Mar 2020 20:59:11 +0200 30 | 31 | gcc-pru (8.0.1.20180310) stretch; urgency=medium 32 | 33 | * GCC PRU port has been overhauled to better support TI ABI. 34 | * When linking object files from GCC and TI toolchains, you must use the -mabi=ti option. 35 | 36 | -- Dimitar Dimitrov Mon, 12 Mar 2018 20:59:11 +0200 37 | 38 | gcc-pru (8.0.0.20170530) stretch; urgency=medium 39 | 40 | * Optimized arithmetic shift right. Fixes github issue #25. 41 | 42 | -- Dimitar Dimitrov Thu, 21 Sep 2017 21:48:38 +0300 43 | 44 | gcc-pru (7.0.0.20161219) jessie; urgency=medium 45 | 46 | * Fixed invalid-syntax assembler generation on 32bit hosts. 47 | * Removed leading underscore for symbols for better TI ABI compatibility. 48 | 49 | -- Dimitar Dimitrov Sat, 31 Dec 2016 10:50:00 +0200 50 | 51 | gcc-pru (7.0.0.20160801) unstable; urgency=medium 52 | 53 | * Switch to native packaging format. 54 | 55 | -- Dimitar Dimitrov Mon, 01 Aug 2016 23:15:14 +0300 56 | 57 | gcc-pru (7.0.0.20160724) unstable; urgency=medium 58 | 59 | * Small fixes to the debian package. 60 | 61 | -- Dimitar Dimitrov Fri, 29 Jul 2016 23:36:58 +0300 62 | 63 | gcc-pru (7.0.0-pru-20160724) unstable; urgency=medium 64 | 65 | * Update to gnupru release 2016.07-beta-rc1 66 | 67 | -- Dimitar Dimitrov Sun, 24 Jul 2016 17:05:46 +0300 68 | 69 | gcc-pru (6.0.0-pru-20151121) unstable; urgency=medium 70 | 71 | * Initial package for PRU GCC. 72 | 73 | -- Dimitar Dimitrov Sat, 21 Nov 2015 22:24:20 +0200 74 | -------------------------------------------------------------------------------- /packaging/gcc-pru/debian/compat: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /packaging/gcc-pru/debian/control: -------------------------------------------------------------------------------- 1 | Source: gcc-pru 2 | Section: devel 3 | Priority: extra 4 | Maintainer: Dimitar Dimitrov 5 | Standards-Version: 4.1.3 6 | Build-Depends: 7 | m4 8 | , libtool 9 | , bzip2 10 | , binutils-pru (>= 2.41) 11 | , bison 12 | , flex 13 | , gettext 14 | , texinfo 15 | , zlib1g-dev 16 | , debhelper (>= 10) 17 | , tar (>= 1.13.18) 18 | , libmpfr-dev 19 | , lsb-release 20 | , patchutils 21 | , libmpc-dev 22 | , dpkg (>= 1.16.2) 23 | , dh-autoreconf 24 | 25 | Package: gcc-pru 26 | Architecture: any 27 | Section: devel 28 | Priority: extra 29 | Depends: ${shlibs:Depends}, ${misc:Depends}, binutils-pru (>= 2.41) 30 | Provides: c-compiler-pru 31 | Recommends: gnuprumcu 32 | Suggests: task-c-devel, gcc-doc (>= 4:4.8), gcc (>= 4:4.8) 33 | Description: GNU C compiler (cross compiler for pru) 34 | This is the GNU C compiler, a fairly portable optimizing compiler which 35 | supports multiple languages. This package includes support for C. 36 | -------------------------------------------------------------------------------- /packaging/gcc-pru/debian/copyright: -------------------------------------------------------------------------------- 1 | This is a debian pakcage of the GNU gcc compiler compiled as a PRU 2 | crosscompiler. It is created from the unofficial PRU port from: 3 | 4 | http://github.com/dinuxbg/gnupru 5 | 6 | GCC is Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 7 | 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 8 | 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 9 | 10 | GCC is free software; you can redistribute it and/or modify it under 11 | the terms of the GNU General Public License as published by the Free 12 | Software Foundation; either version 3, or (at your option) any later 13 | version. 14 | 15 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY 16 | WARRANTY; without even the implied warranty of MERCHANTABILITY or 17 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 18 | for more details. 19 | 20 | Files that have exception clauses are licensed under the terms of the 21 | GNU General Public License; either version 3, or (at your option) any 22 | later version. 23 | 24 | On Debian GNU/Linux systems, the complete text of the GNU General 25 | Public License is in `/usr/share/common-licenses/GPL', version 3 of this 26 | license in `/usr/share/common-licenses/GPL-3'. 27 | -------------------------------------------------------------------------------- /packaging/gcc-pru/debian/format: -------------------------------------------------------------------------------- 1 | 1.0 2 | -------------------------------------------------------------------------------- /packaging/gcc-pru/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # See debhelper(7) (uncomment to enable) 3 | # output every command that modifies files on the build system. 4 | #export DH_VERBOSE = 1 5 | 6 | # TODO - check with upstream why libcpp build fails with 7 | # tightened options. 8 | export DEB_BUILD_MAINT_OPTIONS=hardening=-format,-fortify nocheck nodoc 9 | 10 | # Install to /usr/lib/gnupru, and create symlinks in /usr/bin to 11 | # the real executables. 12 | 13 | %: 14 | dh $@ --builddirectory=build 15 | 16 | override_dh_auto_configure: 17 | dh_auto_configure -- \ 18 | --target=pru \ 19 | --disable-nls \ 20 | --with-newlib \ 21 | --enable-languages=c,c++ \ 22 | --prefix=/usr/lib/gnupru 23 | 24 | GCC_EXECUTABLES=c++ cpp g++ gcc lto-dump gcc-ar gcc-nm gcc-ranlib 25 | 26 | # TODO - remove the following line once libgloss installation is fixed! 27 | override_dh_auto_install: 28 | mkdir -p debian/gcc-pru/usr/lib/gnupru/pru/lib 29 | dh_auto_install 30 | 31 | override_dh_install: 32 | dh_install 33 | # Put symbolic links to the real executables in /usr/bin. 34 | mkdir -p debian/gcc-pru/usr/bin 35 | for i in $(GCC_EXECUTABLES); do ln -s /usr/lib/gnupru/bin/pru-$$i debian/gcc-pru/usr/bin/pru-$$i ; done 36 | 37 | # No need for autoreconf. 38 | # Besides, gcc insists on using the obsolete 2.69 version. 39 | override_dh_autoreconf: 40 | true 41 | 42 | # GCC'c testsuite is enormous, and requires special setup. Skip it. 43 | override_dh_auto_test: 44 | true 45 | -------------------------------------------------------------------------------- /packaging/gcc-pru/debian/source/format: -------------------------------------------------------------------------------- 1 | 1.0 2 | -------------------------------------------------------------------------------- /packaging/gcc-pru/debian/watch: -------------------------------------------------------------------------------- 1 | # Example watch control file for uscan 2 | # Rename this file to "watch" and then you can run the "uscan" command 3 | # to check for upstream updates and more. 4 | # See uscan(1) for format 5 | 6 | # Compulsory line, this is a version 4 file 7 | version=4 8 | 9 | # PGP signature mangle, so foo.tar.gz has foo.tar.gz.sig 10 | #opts="pgpsigurlmangle=s%$%.sig%" 11 | 12 | # HTTP site (basic) 13 | # TODO - how to fix subdirectory path checks? 14 | https://ftp.gnu.org/gnu/gcc/gcc-13.2.0/ \ 15 | gcc-([\d\.]+)\.tar\.gz debian uupdate 16 | 17 | # Uncomment to examine an FTP server 18 | #ftp://ftp.example.com/pub/gnuprumcu-(.*)\.tar\.gz debian uupdate 19 | 20 | # SourceForge hosted projects 21 | # http://sf.net/gnuprumcu/ gnuprumcu-(.*)\.tar\.gz debian uupdate 22 | 23 | # GitHub hosted projects 24 | #opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%-$1.tar.gz%" \ 25 | # https://github.com//gnuprumcu/tags \ 26 | # (?:.*?/)?v?(\d[\d.]*)\.tar\.gz debian uupdate 27 | 28 | # Direct Git 29 | # opts="mode=git" https://gitlab.com/dinuxbg/gnuprumcu.git \ 30 | # refs/tags/v([\d\.]+) debian uupdate 31 | -------------------------------------------------------------------------------- /testing/BUILDBOT.md: -------------------------------------------------------------------------------- 1 | # Naive Build Bot For GCC Cross Toolchain Testing 2 | 3 | # Goals 4 | 1. Automatically establish a workspace. First run of the bot should just work, without lengthy download and "mkdir/cd" instructions. 5 | 2. Download, build and test all parts of the toolchain - binutils, GCC, libc, simulator. 6 | 3. Optionally download needed sources. Daily builds need to test top-of-tree, whereas tracking regressions require manually provided source tree. 7 | 4. Optionally run binutils/gcc/libc tests and save the logs. 8 | 5. Detect regressions since the last run. 9 | 6. Optionally send emails for test results and/or regressions. 10 | 7. Support multiple targets in a single workspace. This save disk space. 11 | 12 | # Non-Goals 13 | 1. Stick to simple shell scripts. Reuse gcc/contrib scripts for log analysis. 14 | 2. No dashboards, UI, remote worker machines, or docker containers. 15 | 16 | # Mail Configuration 17 | The ```Mail``` command line tool must be present and configured to be able to send email. Buildbot sends test summaries and regression reports via email. 18 | 19 | Example for Debian: 20 | 21 | sudo apt install mailx 22 | vim ~/.mailrc 23 | # Fill-in your SMTP configuration. 24 | 25 | # Installation 26 | See the crontest.sh for an example script that you execute from a crontab job. 27 | 28 | # Phases Of The BuildBot 29 | 30 | ## Setup 31 | Each top-level script starts with loading helper library functions and calling bb_init_workspace and bb_init_builddir. 32 | 33 | . `dirname ${0}`/buildbot-lib.sh 34 | bb_init_workspace ${@} 35 | bb_init_builddir ${@} 36 | 37 | 38 | ## Start 39 | Actual work starts from the top-level script with: 40 | 41 | bb_daily_build 42 | 43 | ## Update Sources 44 | TODO 45 | 46 | ## GCC Version Update 47 | For top-of-tree GCC, we need to call ```./contrib/gcc_update``` in order to embed a readable version in gcc test restuls. 48 | 49 | ## AVR Dejagnu Setup 50 | TODO 51 | 52 | ## Config And Build Binutils 53 | TODO 54 | 55 | ## Config And Build GCC - Stage 1 56 | TODO 57 | 58 | ## Config And Build Newlib 59 | TODO 60 | 61 | ## Config And Build GCC - Stage 2 62 | TODO 63 | 64 | ## Build Simulator 65 | TODO 66 | 67 | ## Run Tests 68 | TODO 69 | 70 | ## Gather Log Files 71 | TODO 72 | 73 | ## Optionally Email Results 74 | TODO 75 | 76 | ## Optionally Email Regressions, If Found 77 | TODO 78 | 79 | # References 80 | 1. The proper full-featured [GCC buildbot](https://github.com/LinkiTools/gcc-buildbot/). 81 | 2. Avrtest [project](https://sourceforge.net/p/winavr/code/HEAD/tree/trunk/avrtest/). 82 | 3. AVR testing [notes](https://lists.gnu.org/archive/html/avr-gcc-list/2009-09/msg00016.html). 83 | 4. Generic GCC testing [notes](https://gcc.gnu.org/wiki/Testing_GCC). 84 | -------------------------------------------------------------------------------- /testing/README.md: -------------------------------------------------------------------------------- 1 | # Testing the pru-gcc toolchain 2 | 3 | Regression testing is one of the methods to avoid [Compiler Writer's Deadly Sin #13](https://gcc.gnu.org/wiki/DeadlySins). 4 | 5 | Listed below are instructions to setup the necessary environment and to run regression tests for the PRU GNU toolchain. 6 | 7 | ## Table Of Contents 8 | * [Setting Up The Environment](#setting-up-the-environment) 9 | * [DejaGnu Configuration](#dejagnu-configuration) 10 | * [The BuildBot Scripts](#the-buildbot-scripts) 11 | * [Internals Of Cross-Toolchain Testing](#internals-of-cross-toolchain-testing) 12 | * [Binutils](#binutils) 13 | * [GCC](#gcc) 14 | * [Comparing builds for test failure regressions](#comparing-builds-for-test-failure-regressions) 15 | * [Comparing builds for size regressions](#comparing-builds-for-size-regressions) 16 | * [Checking ABI compatibility](#checking-abi-compatibility) 17 | 18 | ## Setting Up The Environment 19 | ### DejaGnu Configuration 20 | 21 | Install DejaGnu: 22 | 23 | sudo apt-get install dejagnu autogen 24 | 25 | Or, for Fedora: 26 | 27 | sudo dnf install dejagnu autogen 28 | 29 | DejaGnu versions 1.6.3 and later include the necessary PRU simulator configuration. If you have an older version, you can manually download and install the config file: 30 | 31 | wget 'http://git.savannah.gnu.org/gitweb/?p=dejagnu.git;a=blob_plain;f=baseboards/pru-sim.exp;hb=HEAD' -O pru-sim.exp 32 | sudo cp pru-sim.exp /usr/share/dejagnu/baseboards/ 33 | 34 | ## The BuildBot Scripts 35 | 36 | All the steps for testing and finding regressions in PRU toolchain have been automated with a simple set of scripts. See the [BuildBot](./BUILDBOT.md) section for instructions how to run those scripts on your computer. 37 | 38 | Those exact same scripts are used to generate the reports for https://gcc.gnu.org/pipermail/gcc-testresults/ , and also to raise warnings about newly introduced test failures. 39 | 40 | ## Internals Of Cross-Toolchain Testing 41 | 42 | I understand that the [BuildBot](./BUILDBOT.md) set of scripts might be too much `BASH` for some. Below I have captured more human-readable documentation for running cross toolchain regression tests. 43 | 44 | ### Binutils 45 | You need to install pru-gcc via some means, and then do a clean build of binutils. The binutils' configure script requires a pru-gcc to be available when configuring the project, in order to setup the LD tests exercising a target compiler. 46 | 47 | To run the tests go to the binutils build directory and do: 48 | 49 | make check RUNTESTFLAGS=--target_board=pru-sim 50 | 51 | ### GCC 52 | First, newlib must be recompiled in "full" mode. Note that a lot of standard features are stripped by default, in order to save valuable space on the constrained PRU. But for checking compliance, we need them all. Here is an example newlib configuration: 53 | 54 | ../newlib/configure --target=pru --prefix=$HOME/bin/pru-gcc -enable-newlib-io-long-long --enable-newlib-io-long-double --enable-newlib-io-c99-formats 55 | 56 | To execute the GCC C test suite go to the GCC build directory and run: 57 | 58 | make check-gcc-c RUNTESTFLAGS=--target_board=pru-sim 59 | make check-gcc-c++ RUNTESTFLAGS=--target_board=pru-sim 60 | 61 | The full regression test might take over an hour to execute. For development you may also run a small subset of it, e.g.: 62 | 63 | make check-gcc-c RUNTESTFLAGS="--target_board=pru-sim pru.exp=" 64 | 65 | ### Comparing builds for test failure regressions 66 | 67 | Let's say you have built and checked GCC twice - once with an old and then with a new version of GCC sources. The GCC sources include a helpful script to analyse the test results and report tests which passed in the *old* but failed with the *new* version of GCC: 68 | 69 | gcc/contrib/dg-cmp-results.sh "" results-old/gcc.sum results-new/gcc.sum 70 | 71 | ### Comparing builds for size regressions 72 | 73 | First, build and test the reference that we'll compare against: 74 | 75 | cd gcc && git checkout origin/master 76 | BB_BDIR_PREFIX=base-pru ./gnupru/testing/manual-test-pru.sh . 77 | 78 | After that, apply your changes and do the build we'll be testing: 79 | 80 | cd gcc && git checkout my-dev-branch 81 | ./gnupru/testing/manual-build-pru.sh . 82 | 83 | Now do the comparison. Example for size: 84 | 85 | GCC_EXEC_PREFIX=`realpath ./pru-opt/pru/lib`/ ./gnupru/testing/compare-all-sizes.py pru 86 | 87 | ### Checking ABI compatibility 88 | It is possible to run part of the GCC testsuite in an "ABI check" mode. The testsuite will compile object files with different compilers, and then check that functions from one object file can call and get correct return value from the other object file. 89 | 90 | To install, first put the clpru.sh script into your PATH. This wrapper script is needed because TI compiler does not follow the standard command line option interface, that is expected by the GCC testsuite. 91 | 92 | ln -s gnupru/testing/clpru.sh $HOME/bin/ 93 | 94 | To execute the quick GCC ABI regression test suite against the TI toolchain do: 95 | 96 | # Cleanup (important for incremental checks) 97 | find . -name site.exp | xargs rm -f 98 | make check-gcc-c RUNTESTFLAGS="--target_board=pru-sim compat.exp" COMPAT_OPTIONS="[list [list {-O2 -mmcu=sim -mabi=ti -Wl,-lc -Wl,-lgloss -Wl,`pru-gcc -print-libgcc-file-name` -DSKIP_COMPLEX -DSKIP_ATTRIBUTE} {-v3 -O2 --display_error_number --endian=little --hardware_mac=on --symdebug:none -DSKIP_COMPLEX -DSKIP_ATTRIBUTE}]]" ALT_CC_UNDER_TEST=`which clpru.sh` 99 | 100 | # Cleanup and check C++ 101 | find . -name site.exp | xargs rm -f 102 | make check-gcc-c++ RUNTESTFLAGS="--target_board=pru-sim compat.exp" COMPAT_OPTIONS="[list [list {-O2 -mmcu=sim -DSKIP_COMPLEX -DSKIP_ATTRIBUTE} {-v3 -O2 --display_error_number --endian=little --hardware_mac=on --symdebug:none -DSKIP_COMPLEX -DSKIP_ATTRIBUTE}]]" ALT_CC_UNDER_TEST=`which clpru.sh` 103 | 104 | More elaborate ABI test suite can be run by enabling more tests: 105 | 106 | find . -name site.exp | xargs rm -f 107 | make -k check-gcc-c RUNTESTFLAGS="--target_board=pru-sim compat.exp struct-layout-1.exp" COMPAT_OPTIONS="[list [list {-O2 -mmcu=sim -Wl,-lc -Wl,-lgloss -Wl,`pru-gcc -print-libgcc-file-name` -DSKIP_COMPLEX -DSKIP_ATTRIBUTE} {-v 3 -O2 --display_error_number --endian=little --hardware_mac=on --symdebug:none -DSKIP_COMPLEX -DSKIP_ATTRIBUTE}]]" ALT_CC_UNDER_TEST=`which clpru.sh` RUN_ALL_COMPAT_TESTS=1 108 | 109 | A few notes about the options: 110 | * --hardware_mac=on is needed since GCC does not currently support turning off MAC instruction generation. Please let me know if you see a real usecase for this feature, and I may reconsider. 111 | * --symdebug:none is needed since the binutils linker does not yet support the debug relocations output by TI toolchain. 112 | * -mmcu=sim is needed by the GNU LD to provide sufficient memory for test execution. 113 | * The libgcc is forcefully included with -mabi=ti when performing ABI testing. Libgcc as a whole is not really TI ABI compatible, but the parts used by the testsuite are. Multilib is not an option since GCC PRU port does not support some C constructs when -mabi=ti. 114 | * For C++ we do not pass -mabi=ti since the vptr object tables are 4-byte aligned by TI CGT. Current GCC C++ ABI testsuite does not use C function pointers, which allows us to skip -mabi=ti and increase test coverage. 115 | * ABI test case pr83487 is failing due to a bug in TI CGT. See [CODEGEN-4180](https://e2e.ti.com/support/development_tools/compiler/f/343/t/652777) 116 | * ABI test case struct-by-value-22 is failing due to a bug in TI CGT. Stack space is not allocated for a locally defined structure. 117 | 118 | Simplified struct-by-value-22 case: 119 | 120 | extern void tedstvoid(void *); 121 | void test(int n) 122 | { 123 | struct S { char a[n]; } s; 124 | testvoid(&s); 125 | } 126 | 127 | ## See Also 128 | * https://github.com/riscv-collab/riscv-gnu-toolchain 129 | * https://builder.sourceware.org/ 130 | -------------------------------------------------------------------------------- /testing/buildbot-arm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for automatic daily testing of gcc+newlib ToT. 6 | 7 | BB_ARCH=arm 8 | 9 | # Who to send a short regression report to 10 | REGRESSION_RECIPIENTS="dinuxbg@gmail.com" 11 | 12 | # Default full report recipient. Caller can set this 13 | # environment variable to override the default. 14 | true ${SUMMARY_RECIPIENTS:=dinuxbg@gmail.com} 15 | 16 | 17 | bb_daily_target_test() 18 | { 19 | local PREV_BUILD_TAG=${1} 20 | local BUILD_TAG=${2} 21 | 22 | bb_clean 23 | 24 | # Build binutils 25 | bb_config binutils "--disable-gdb --target=arm-none-eabi" 26 | bb_make binutils "-j`nproc`" 27 | bb_make binutils "install" 28 | # Check binutils without a target C compiler. All tests must pass. 29 | bb_make binutils "-j`nproc` check RUNTESTFLAGS=--target_board=arm-sim" 30 | 31 | export PATH=${PREFIX}/bin:${PATH} 32 | 33 | # GCC pass 1: no libc yet 34 | bb_config gcc "--target=arm-none-eabi --with-newlib --without-headers --enable-languages=c --enable-checking=yes,rtl --disable-libssp" 35 | bb_make gcc "-j`nproc`" 36 | bb_make gcc "install" 37 | 38 | # Libc 39 | bb_config newlib "--target=arm-none-eabi --enable-newlib-io-long-long --enable-newlib-io-long-double --enable-newlib-io-c99-formats" 40 | bb_make newlib "-j`nproc`" 41 | bb_make newlib "install" 42 | 43 | # GCC pass 2: full feature set 44 | bb_config gcc "--target=arm-none-eabi --with-newlib --enable-languages=c,c++ --enable-checking=yes,rtl" 45 | bb_make gcc "-j`nproc`" 46 | bb_make gcc "install" 47 | 48 | # Test newlib 49 | bb_make newlib "-j`nproc` check RUNTESTFLAGS=--target_board=arm-sim" 50 | 51 | # Test GCC 52 | bb_make gcc "-j`nproc` check-gcc-c RUNTESTFLAGS=--target_board=arm-sim" 53 | bb_make gcc "-j`nproc` check-gcc-c++ RUNTESTFLAGS=--target_board=arm-sim" 54 | 55 | # Build binutils again - this time with a C compiler present. 56 | bb_make binutils "distclean" 57 | bb_config binutils "--disable-gdb --target=arm-none-eabi" 58 | bb_make binutils "-j`nproc`" 59 | bb_make binutils "install" 60 | # Check binutils with a target C compiler. Some tests may fail. 61 | bb_make --ignore-errors binutils "-j`nproc` check RUNTESTFLAGS=--target_board=arm-sim" 62 | 63 | # Save all the logs 64 | bb_gather_log_files ${BUILD_TAG} 65 | 66 | # Send to real mailing list, 67 | pushd ${WORKSPACE}/arm-gcc-build || error "failed to enter arm-gcc-build" 68 | ../gcc/contrib/test_summary -m ${SUMMARY_RECIPIENTS} | sh 69 | popd 70 | 71 | bb_check_for_regressions ${PREV_BUILD_TAG} ${BUILD_TAG} 72 | } 73 | 74 | 75 | . `dirname ${0}`/buildbot-lib.sh 76 | 77 | bb_init_workspace ${@} 78 | bb_init_builddir ${@} 79 | 80 | bb_daily_build 81 | -------------------------------------------------------------------------------- /testing/buildbot-avr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for automatic daily testing of gcc+avrlibc ToT. 6 | 7 | BB_ARCH=avr 8 | 9 | # Who to send a short regression report to 10 | REGRESSION_RECIPIENTS="dinuxbg@gmail.com" 11 | 12 | # Default full report recipient. Caller can set this 13 | # environment variable to override the default. 14 | true ${SUMMARY_RECIPIENTS:=dinuxbg@gmail.com} 15 | 16 | 17 | bb_daily_target_test() 18 | { 19 | local PREV_BUILD_TAG=${1} 20 | local BUILD_TAG=${2} 21 | 22 | bb_clean 23 | 24 | bb_record_git_heads binutils gcc avrlibc atest 25 | 26 | # Setup avrtest, per: 27 | # https://sourceforge.net/p/winavr/code/HEAD/tree/trunk/avrtest/ 28 | # https://lists.gnu.org/archive/html/avr-gcc-list/2009-09/msg00016.html 29 | export DEJAGNU=${PREFIX}/dejagnurc 30 | mkdir -p `dirname ${DEJAGNU}` 31 | echo "# WARNING - automatically generated!" > ${DEJAGNU} 32 | echo "set avrtest_dir \"${WORKSPACE}/atest\"" >> ${DEJAGNU} 33 | echo "set avrlibc_include_dir \"${PREFIX}/avr/include\"" >> ${DEJAGNU} 34 | echo 'set boards_dir {}' >> ${DEJAGNU} 35 | echo 'lappend boards_dir "${avrtest_dir}/dejagnuboards"' >> ${DEJAGNU} 36 | 37 | # Build binutils 38 | bb_config binutils "--disable-gdb --target=avr" 39 | bb_make binutils "-j`nproc`" 40 | bb_make binutils "install" 41 | 42 | export PATH=${PREFIX}/bin:${PATH} 43 | 44 | bb_config gcc "--target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2" 45 | bb_make gcc "-j`nproc`" 46 | bb_make gcc "install" 47 | 48 | # Libc 49 | (cd ${WORKSPACE}/avrlibc && ./bootstrap) || error "failed to bootstrap avr-libc source" 50 | bb_config avrlibc '--host=avr' 51 | bb_make avrlibc "-j`nproc`" 52 | bb_make avrlibc "install" 53 | 54 | # avrtest 55 | bb_source_command atest "make" 56 | 57 | # Get the simulator under PATH. Needed for gcc test suite. 58 | export PATH=${WORKSPACE}/atest:${PATH} 59 | 60 | # Test binutils. Do not let random test case failures to mark 61 | # the entire build as bad. 62 | bb_config binutils "--disable-gdb --target=avr" 63 | bb_make binutils "-j`nproc`" 64 | bb_make binutils "install" 65 | bb_make --ignore-errors binutils "-k check RUNTESTFLAGS=--target_board=atmega128-sim" 66 | 67 | # Test GCC 68 | bb_make gcc "-j`nproc` check-gcc-c RUNTESTFLAGS=--target_board=atmega128-sim" 69 | bb_make gcc "-j`nproc` check-gcc-c++ RUNTESTFLAGS=--target_board=atmega128-sim" 70 | 71 | # Save all the logs 72 | bb_gather_log_files ${BUILD_TAG} 73 | 74 | # Send to real mailing list, 75 | pushd ${WORKSPACE}/avr-gcc-build || error "failed to enter avr-gcc-build" 76 | 77 | # Don't spam GCC testresults mailing list for what is probably a local setup issue. 78 | [ `grep '^FAIL:' gcc/testsuite/gcc/gcc.sum | wc -l` -gt 1000 ] && error "too many C failures" 79 | [ `grep '^FAIL:' gcc/testsuite/g++/g++.sum | wc -l` -gt 12000 ] && error "too many C++ failures" 80 | 81 | # Without libstdc++, we end up with thousands of spurious FAILS. 82 | # Enabling libstdc++ is non-trivial for AVR, so to spare GCC mailing 83 | # servers from megabytes of spurious failures, simply remove them. 84 | # 85 | # We simply track regressions for C++. 86 | local AVR_KNOWN_FAILURES=${LOGDIR}/avr-known-failures 87 | [ -f $AVR_KNOWN_FAILURES ] || grep '^\(UNSUPPORTED\|FAIL\):' ${LOGDIR}/${BUILD_TAG}/g++.sum | awk '{print $2}' > ${AVR_KNOWN_FAILURES} 88 | # Filter out g++.sum 89 | cp gcc/testsuite/g++/g++.sum buildbot-sum-tmp 90 | cat buildbot-sum-tmp | grep -f ${AVR_KNOWN_FAILURES} -v > gcc/testsuite/g++/g++.sum 91 | 92 | echo -e "WARNING: Many C++ failures have been omitted due to lack of libstdc++ on AVR!\nOnly G++ regressions are reported below.\n\n" > avr-warning.txt 93 | ../gcc/contrib/test_summary -p avr-warning.txt -m ${SUMMARY_RECIPIENTS} | sh 94 | popd 95 | 96 | bb_check_for_regressions ${PREV_BUILD_TAG} ${BUILD_TAG} 97 | } 98 | 99 | 100 | . `dirname ${0}`/buildbot-lib.sh 101 | 102 | bb_init_workspace ${@} 103 | bb_init_builddir ${@} 104 | 105 | bb_daily_build 106 | -------------------------------------------------------------------------------- /testing/buildbot-lib.sh: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-3.0-or-later 2 | 3 | # Simple automation helpers for daily testing of GNU toolchain. 4 | # 5 | # List of global variables: 6 | # WORKSPACE 7 | # LOGDIR 8 | # PREFIX 9 | 10 | # Print error and exit. 11 | error() 12 | { 13 | echo "ERROR: $@" 14 | exit 1 15 | } 16 | 17 | # Print a large sign in log. 18 | print_stage() 19 | { 20 | echo "*******************************************************************************" 21 | echo "*" 22 | echo "* $@" 23 | echo "*" 24 | echo "*******************************************************************************" 25 | } 26 | 27 | # Clone if needed, and update a GIT project to latest upstream. 28 | # PRJ : Which GIT project to update. 29 | # URL : Which URL to use for initial clone. 30 | # BRANCH : Which upstream branch to checkout. 31 | bb_update_source() 32 | { 33 | local PRJ=${1} 34 | local URL=${2} 35 | local BRANCH=${3:-master} 36 | local P 37 | local C 38 | 39 | print_stage "Updating GIT source tree for ${PRJ}" 40 | 41 | pushd ${WORKSPACE} 42 | 43 | [ -d "${PRJ}" ] || git clone ${URL} ${PRJ} || error "initial ${URL} clone failed" 44 | 45 | pushd ${PRJ} || error "cannot enter ${PRJ}" 46 | git remote prune origin || error "failed to prune remote" 47 | git am --abort 48 | git merge --abort 49 | git rebase --abort 50 | git reset --hard HEAD 51 | git clean -f -d -x 52 | git fetch origin || error "failed to sync ${PRJ}" 53 | git checkout origin/${BRANCH} || error "failed to checkout ${PRJ}" 54 | 55 | popd 56 | popd 57 | } 58 | 59 | # Record the GIT commit HEADs of the given projects. 60 | # PRJ1 PRJ2 ... : Which GIT projects to update. 61 | bb_record_git_heads() 62 | { 63 | local PRJ 64 | local C 65 | 66 | while [ $# != 0 ] 67 | do 68 | PRJ=${1} 69 | shift 70 | pushd ${WORKSPACE}/${PRJ} || error "cannot enter ${PRJ}" 71 | C=`git rev-parse HEAD` 72 | echo "${PRJ} ${C}" >> ${LOGDIR}/${BUILD_TAG}/versions.txt 73 | popd 74 | done 75 | } 76 | 77 | # Prepare tree for release, and write proper versioning info. 78 | # 79 | # Follow contrib/gcc_update's behaviour for filling in version 80 | # information in places the test and build systems expect it. 81 | # 82 | # BRANCH : gcc branch we have checked out 83 | bb_gcc_touch_source_tree() 84 | { 85 | local BRANCH=${1} 86 | local C 87 | 88 | pushd ${WORKSPACE}/gcc || error "failed to enter gcc" 89 | 90 | LC_ALL=C ./contrib/gcc_update origin -r `git rev-parse HEAD` 91 | 92 | popd 93 | } 94 | 95 | # Clean workspace for the currently selected target. 96 | bb_clean() 97 | { 98 | print_stage "Cleaning all projects" 99 | local BDIR 100 | for BDIR in `ls -d ${WORKSPACE}/${BB_BDIR_PREFIX}-*-build` 101 | do 102 | rm -fr ${BDIR} 103 | done 104 | rm -fr ${PREFIX} 105 | } 106 | 107 | # Invoke the ./configure script for project PRJ. Rest of function arguments 108 | # are passed on to configure. 109 | bb_config() 110 | { 111 | local PRJ="${1}" 112 | shift 113 | local CONFIG_PARAMS="$@" 114 | local CONFIGURE 115 | 116 | print_stage "Configuring ${PRJ} with parameters \"${CONFIG_PARAMS}\"" 117 | mkdir -p ${WORKSPACE}/${BB_BDIR_PREFIX}-${PRJ}-build 118 | pushd ${WORKSPACE}/${BB_BDIR_PREFIX}-${PRJ}-build || error "failed to mkdir $${BB_BDIR_PREFIX}-{PRJ}-build" 119 | 120 | # HACK: Workaround bug in newlib testsuite's build system. 121 | # See: https://sourceware.org/ml/newlib/2011/msg00457.html 122 | CONFIGURE=`realpath ${WORKSPACE}/${PRJ}/configure` 123 | 124 | ${CONFIGURE} --prefix=${PREFIX} ${CONFIG_PARAMS} || error "Could not configure ${PRJ}" 125 | 126 | popd 127 | } 128 | 129 | # Invoke "make" in the build directory for the already-configured 130 | # given project. 131 | # 132 | # Rest of function arguments are passed on to "make". 133 | bb_make() 134 | { 135 | local IGNORE_ERRORS=false 136 | [ "${1}" = "--ignore-errors" ] && { IGNORE_ERRORS=true; shift; } 137 | local PRJ="${1}" 138 | shift 139 | local MAKE_PARAMS="$@" 140 | 141 | print_stage "Invoking make for ${PRJ} with parameters \"${MAKE_PARAMS}\"" 142 | mkdir -p ${WORKSPACE}/${BB_BDIR_PREFIX}-${PRJ}-build 143 | pushd ${WORKSPACE}/${BB_BDIR_PREFIX}-${PRJ}-build || error "missing ${BB_BDIR_PREFIX}-${PRJ}-build" 144 | 145 | make ${MAKE_PARAMS} || { [ ${IGNORE_ERRORS} = false ] && error "Could not make ${PRJ}"; } 146 | 147 | popd 148 | } 149 | 150 | # Some projects have weird in-tree build rules. 151 | # 152 | # Use this helper function to execute arbitrary commands in the 153 | # given project's source directory. 154 | bb_source_command() 155 | { 156 | local PRJ="${1}" 157 | shift 158 | local CMDS="$@" 159 | 160 | print_stage "Running custom command \"${CMDS}\" in project ${PRJ}" 161 | pushd ${WORKSPACE}/${PRJ} || error "missing ${PRJ}" 162 | 163 | ${CMDS} || error "Could not build ${PRJ}" 164 | 165 | popd 166 | } 167 | 168 | # Run the embench-iot for code size. 169 | bb_run_embench() 170 | { 171 | local PRJ=embench 172 | local EMBENCH_SRC=${WORKSPACE}/embench 173 | 174 | print_stage "Runnimg embench-iot ${PRJ} with parameters \"${@}\"" 175 | mkdir -p ${WORKSPACE}/${BB_BDIR_PREFIX}-${PRJ}-build 176 | pushd ${EMBENCH_SRC} 177 | 178 | # For now, let's not treat embench errors as fatal. 179 | scons \ 180 | --config-dir=examples/native/size/ \ 181 | --build-dir=${WORKSPACE}/${BB_BDIR_PREFIX}-${PRJ}-build \ 182 | gsf=1 \ 183 | "${@}" 184 | 185 | ./benchmark_size.py --builddir ${WORKSPACE}/${BB_BDIR_PREFIX}-${PRJ}-build --absolute > ${WORKSPACE}/${BB_BDIR_PREFIX}-${PRJ}-build/embench.report 186 | 187 | popd 188 | } 189 | 190 | # Generate email subject string for a detected test case regression. 191 | regression_email_subject() 192 | { 193 | local LOGFILE=${1} 194 | 195 | local TARGET=`cat ${LOGFILE} | awk '/Target is/ {print $3; exit}'` 196 | 197 | echo "[BUILDBOT] Regression detected for ${TARGET}" 198 | } 199 | 200 | # Send email for a detected test case regression. 201 | bb_email_regression() 202 | { 203 | local BUILD_TAG=${1} 204 | local LOGFILE=${LOGDIR}/${BUILD_TAG}/regression.log 205 | 206 | print_stage "Sending email for detected regression." 207 | 208 | # Note: Usually you want to install heirloom-mailx, instead of relying 209 | # on the bsd-mailx default package. 210 | 211 | cat ${LOGFILE} | Mail -s "`regression_email_subject ${LOGFILE}`" ${REGRESSION_RECIPIENTS} 212 | } 213 | 214 | # Send an email for a detected build failure. 215 | bb_email_build_failure() 216 | { 217 | local BUILD_TAG=${1} 218 | local LOGFILE=${2} 219 | 220 | # Do not call print_stage here. 221 | # Output is not being collected to build log at this stage. 222 | zcat ${LOGFILE} | tail -200 | Mail -s "[BUILDBOT] Build ${BUILD_TAG} failed" ${REGRESSION_RECIPIENTS} 223 | } 224 | 225 | # Gather all log files from all build directories and place 226 | # them in the dedicated log directory for this particular test run. 227 | # 228 | # We are interested in all *.sum and their *.log counterparts. 229 | # *.log files are compressed to save space. 230 | bb_gather_log_files() 231 | { 232 | local BUILD_TAG=${1} 233 | local F 234 | 235 | print_stage "Gathering log files" 236 | 237 | find `ls -d ${WORKSPACE}/${BB_BDIR_PREFIX}-*-build` -name "*.sum" | while read F 238 | do 239 | cp ${F} ${LOGDIR}/${BUILD_TAG}/ || error "failed to copy ${F}" 240 | local L=`dirname ${F}`/`basename ${F} .sum`.log 241 | cp ${L} ${LOGDIR}/${BUILD_TAG}/ || error "failed to copy ${L}" 242 | gzip -9 ${LOGDIR}/${BUILD_TAG}/`basename ${L}` 243 | done 244 | find `ls -d ${WORKSPACE}/${BB_BDIR_PREFIX}-*-build` -name "*.report" | while read F 245 | do 246 | cp ${F} ${LOGDIR}/${BUILD_TAG}/ || error "failed to copy ${F}" 247 | done 248 | } 249 | 250 | # Call this after all sum files have been collected into the 251 | # daily build's log directory. 252 | # 253 | # Function invokes GCC's contrib scripts to check summary files 254 | # between last good run and current run, so that test case regressions 255 | # can be detected. 256 | bb_check_for_regressions() 257 | { 258 | local PREV_BUILD_TAG=${1} 259 | local BUILD_TAG=${2} 260 | 261 | print_stage "Checking log files for regressions since the last run" 262 | 263 | # Compare to previous build. If there are regressions, send an email. 264 | ( local sum 265 | for sum in ${LOGDIR}/${BUILD_TAG}/*.sum 266 | do 267 | echo "========================= `basename ${sum} .sum` =========================" 268 | ${WORKSPACE}/gcc/contrib/dg-cmp-results.sh "" \ 269 | ${LOGDIR}/${PREV_BUILD_TAG}/`basename ${sum}` \ 270 | ${sum} 271 | done 272 | ) > ${LOGDIR}/${BUILD_TAG}/regression.log 273 | grep '.*->.*: .*' ${LOGDIR}/${BUILD_TAG}/regression.log && bb_email_regression ${BUILD_TAG} 274 | return 0 275 | } 276 | 277 | # This must be the first called function from the main script. 278 | # It initializes the current test run directory and sets 279 | # the environment. 280 | bb_init_workspace() 281 | { 282 | [ $# == 1 ] || error "usage: $0 " 283 | 284 | WORKSPACE=`realpath "${1}"` 285 | [ -d "$WORKSPACE" ] || error "$WORKSPACE is not a directory" 286 | } 287 | 288 | # This must be the second called function from the main script. 289 | # It initializes the current test run directory and sets 290 | # the environment. 291 | bb_init_builddir() 292 | { 293 | [ $# == 1 ] || error "usage: $0 " 294 | 295 | [ -z ${BB_ARCH} ] && error "Please define BB_ARCH" 296 | BB_BDIR_PREFIX=${BB_BDIR_PREFIX:-${BB_ARCH}} 297 | 298 | PREFIX=${PREFIX:-${WORKSPACE}/${BB_ARCH}-opt} 299 | mkdir -p ${PREFIX} 300 | LOGDIR=${LOGDIR:-${WORKSPACE}/${BB_ARCH}-logs} 301 | mkdir -p ${LOGDIR} 302 | } 303 | 304 | # Call this from the main script to do the actual build, test and report. 305 | bb_daily_build() 306 | { 307 | cd $WORKSPACE 308 | 309 | local BUILD_TAG=`date +%Y%m%d-%H%M` 310 | mkdir -p ${LOGDIR}/${BUILD_TAG} || error "failed to create log directory for ${BUILD_TAG}" 311 | 312 | # Check what is the previous one. 313 | # First time let's compare with ourselves. 314 | local PREV_BUILD_TAG=`cd ${LOGDIR} && dirname $( { ls */pass 2>/dev/null || echo ${BUILD_TAG}/pass ; } | sort | tail -1)` 315 | [ -z ${PREV_BUILD_TAG} ] && error "failed to determine previous successful build" 316 | 317 | # Execute in a subshell in order to catch build errors and send an email. 318 | ( set -x; set -o pipefail; time bb_daily_target_test ${PREV_BUILD_TAG} ${BUILD_TAG} |& gzip - >${LOGDIR}/${BUILD_TAG}/build.log.gz ) 2>/dev/null 319 | ST=$? 320 | [ "${ST}" = "0" ] || bb_email_build_failure ${BUILD_TAG} ${LOGDIR}/${BUILD_TAG}/build.log.gz 321 | [ "${ST}" = "0" ] && touch ${LOGDIR}/${BUILD_TAG}/pass 322 | 323 | # Also add it to the Bunsen GIT. Make it optional, for now. 324 | local LOGDIR_BASE=`basename ${LOGDIR}` 325 | local BUNSEN_TAG=`echo ${LOGDIR_BASE} | sed -e 's@\([a-z0-9_-]\+\)-logs@\1@g'` 326 | ${WORKSPACE}/gnupru/testing/logdir2bunsen.sh ${BUNSEN_TAG} ${WORKSPACE}/buildbot-logs.git ${LOGDIR}/${BUILD_TAG} || echo "FAILED TO PUSH TO BUNSEN GIT" 327 | 328 | exit ${ST} 329 | } 330 | -------------------------------------------------------------------------------- /testing/buildbot-pru.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for automatic daily testing of gcc+newlib ToT. 6 | 7 | BB_ARCH=pru 8 | 9 | # Who to send a short regression report to 10 | REGRESSION_RECIPIENTS="dinuxbg@gmail.com" 11 | 12 | # Default full report recipient. Caller can set this 13 | # environment variable to override the default. 14 | true ${SUMMARY_RECIPIENTS:=dinuxbg@gmail.com} 15 | 16 | 17 | bb_daily_target_test() 18 | { 19 | local PREV_BUILD_TAG=${1} 20 | local BUILD_TAG=${2} 21 | 22 | bb_clean 23 | 24 | bb_record_git_heads binutils gcc newlib 25 | 26 | # Build binutils 27 | bb_config binutils "--disable-gdb --target=pru" 28 | bb_make binutils "-j`nproc`" 29 | bb_make binutils "install" 30 | # Check binutils without a target C compiler. All tests must pass. 31 | bb_make binutils "-j`nproc` check RUNTESTFLAGS=--target_board=pru-sim" 32 | 33 | export PATH=${PREFIX}/bin:${PATH} 34 | 35 | # GCC pass 1: no libc yet 36 | bb_config gcc "--target=pru --with-newlib --without-headers --enable-languages=c --enable-checking=yes,rtl" 37 | bb_make gcc "-j`nproc`" 38 | bb_make gcc "install" 39 | 40 | # Libc 41 | bb_config newlib "--target=pru --enable-newlib-io-long-long --enable-newlib-io-long-double --enable-newlib-io-c99-formats" 42 | bb_make newlib "-j`nproc`" 43 | bb_make newlib "install" 44 | 45 | # GCC pass 2: full feature set 46 | bb_config gcc "--target=pru --with-newlib --enable-languages=c,c++ --enable-checking=yes,rtl" 47 | bb_make gcc "-j`nproc`" 48 | bb_make gcc "install" 49 | 50 | # Make sure documentation is still in order 51 | bb_make gcc "pdf" 52 | 53 | # Test newlib 54 | bb_make newlib "-j`nproc` check RUNTESTFLAGS=--target_board=pru-sim" 55 | 56 | # Test GCC 57 | bb_make gcc "-j`nproc` check-gcc-c RUNTESTFLAGS=--target_board=pru-sim" 58 | bb_make gcc "-j`nproc` check-gcc-c++ RUNTESTFLAGS=--target_board=pru-sim" 59 | 60 | # Build binutils again - this time with a C compiler present. 61 | bb_make binutils "distclean" 62 | bb_config binutils "--disable-gdb --target=pru" 63 | bb_make binutils "-j`nproc`" 64 | bb_make binutils "install" 65 | # Check binutils with a target C compiler. Some tests may fail. 66 | bb_make --ignore-errors binutils "-j`nproc` check RUNTESTFLAGS=--target_board=pru-sim" 67 | 68 | bb_run_embench cc=pru-gcc cflags="-Oz -flto -std=c17" ldflags="" user_libs="m" 69 | 70 | # Save all the logs 71 | bb_gather_log_files ${BUILD_TAG} 72 | 73 | # Don't spam GCC testresults mailing list for what is probably a local setup issue. 74 | [ `grep '^FAIL:' ${WORKSPACE}/pru-gcc-build/gcc/testsuite/gcc/gcc.sum | wc -l` -gt 1000 ] && error "too many C failures" 75 | [ `grep '^FAIL:' ${WORKSPACE}/pru-gcc-build/gcc/testsuite/g++/g++.sum | wc -l` -gt 3000 ] && error "too many C++ failures" 76 | 77 | # Send to real mailing list, 78 | pushd ${WORKSPACE}/pru-gcc-build || error "failed to enter pru-gcc-build" 79 | ../gcc/contrib/test_summary -m ${SUMMARY_RECIPIENTS} | sh 80 | popd 81 | 82 | bb_check_for_regressions ${PREV_BUILD_TAG} ${BUILD_TAG} 83 | } 84 | 85 | 86 | . `dirname ${0}`/buildbot-lib.sh 87 | 88 | bb_init_workspace ${@} 89 | bb_init_builddir ${@} 90 | 91 | bb_daily_build 92 | -------------------------------------------------------------------------------- /testing/buildbot-riscv_rv32ec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for automatic daily testing of gcc+newlib ToT. 6 | 7 | BB_ARCH=riscv_rv32ec 8 | 9 | BB_GCC_TARGET_OPTIONS="--target=riscv32-none-elf --with-multilib-generator=rv32ec-ilp32e-- --with-abi=ilp32e --with-arch=rv32ec" 10 | 11 | # Who to send a short regression report to 12 | REGRESSION_RECIPIENTS="dinuxbg@gmail.com" 13 | 14 | # Default full report recipient. Caller can set this 15 | # environment variable to override the default. 16 | true ${SUMMARY_RECIPIENTS:=dinuxbg@gmail.com} 17 | 18 | 19 | bb_daily_target_test() 20 | { 21 | local PREV_BUILD_TAG=${1} 22 | local BUILD_TAG=${2} 23 | 24 | bb_clean 25 | 26 | bb_record_git_heads binutils gcc newlib 27 | 28 | # Setup testing for RV32EC 29 | export DEJAGNU=${PREFIX}/dejagnurc 30 | mkdir -p `dirname ${DEJAGNU}` 31 | echo "# WARNING - automatically generated!" > ${DEJAGNU} 32 | echo "lappend boards_dir \"${PREFIX}\"" >> ${DEJAGNU} 33 | echo "set_board_info sim,options \"--model RV32EC\"" > ${PREFIX}/riscv-rv32ec-sim.exp 34 | echo "set_board_info cflags \" --specs=sim.specs [libgloss_include_flags] [newlib_include_flags]\"" >> ${PREFIX}/riscv-rv32ec-sim.exp 35 | echo "load_base_board_description \"riscv-sim\"" >> ${PREFIX}/riscv-rv32ec-sim.exp 36 | 37 | echo "gcc ${GCC_TOT}" >> ${LOGDIR}/${BUILD_TAG}/versions.txt 38 | echo "binutils ${BINUTILS_TOT}" >> ${LOGDIR}/${BUILD_TAG}/versions.txt 39 | echo "newlib ${NEWLIB_TOT}" >> ${LOGDIR}/${BUILD_TAG}/versions.txt 40 | 41 | # Build binutils 42 | # TODO - re-enable sim building 43 | bb_config binutils "--disable-gdb --disable-sim --target=riscv32-none-elf" 44 | bb_make binutils "-j`nproc`" 45 | bb_make binutils "install" 46 | # Check binutils without a target C compiler. All tests must pass. 47 | # TODO 48 | # bb_make binutils "-j`nproc` check RUNTESTFLAGS=--target_board=riscv-rv32ec-sim" 49 | 50 | export PATH=${PREFIX}/bin:${PATH} 51 | 52 | # GCC pass 1: no libc yet 53 | bb_config gcc "${BB_GCC_TARGET_OPTIONS} --with-newlib --without-headers --enable-languages=c --disable-libssp --enable-checking=yes,rtl" 54 | bb_make gcc "-j`nproc`" 55 | bb_make gcc "install" 56 | 57 | # Libc 58 | bb_config newlib "${BB_GCC_TARGET_OPTIONS} --enable-newlib-io-long-long --enable-newlib-io-long-double --enable-newlib-io-c99-formats" 59 | bb_make newlib "-j`nproc`" 60 | bb_make newlib "install" 61 | 62 | # GCC pass 2: full feature set 63 | bb_config gcc "${BB_GCC_TARGET_OPTIONS} --with-newlib --enable-languages=c,c++ --disable-libssp --enable-checking=yes,rtl" 64 | bb_make gcc "-j`nproc`" 65 | bb_make gcc "install" 66 | 67 | # Make sure documentation is still in order 68 | bb_make gcc "pdf" 69 | 70 | # Test newlib 71 | bb_make newlib "-j`nproc` check RUNTESTFLAGS=--target_board=riscv-rv32ec-sim" 72 | 73 | # Test GCC 74 | bb_make gcc "-j`nproc` check-gcc-c RUNTESTFLAGS=--target_board=riscv-rv32ec-sim" 75 | bb_make gcc "-j`nproc` check-gcc-c++ RUNTESTFLAGS=--target_board=riscv-rv32ec-sim" 76 | 77 | # Build binutils again - this time with a C compiler present. 78 | bb_make binutils "distclean" 79 | # TODO - re-enable sim building 80 | bb_config binutils "--disable-gdb --disable-sim --target=riscv32-none-elf" 81 | bb_make binutils "-j`nproc`" 82 | bb_make binutils "install" 83 | # Check binutils with a target C compiler. Some tests may fail. 84 | bb_make --ignore-errors binutils "-j`nproc` check RUNTESTFLAGS=--target_board=riscv-rv32ec-sim" 85 | 86 | bb_run_embench cc=riscv32-none-elf-gcc cflags="-Oz -flto -std=c17 -march=rv32ec -mabi=ilp32e" ldflags="" user_libs="m" 87 | 88 | # Save all the logs 89 | bb_gather_log_files ${BUILD_TAG} 90 | 91 | # Don't spam GCC testresults mailing list for what is probably a local setup issue. 92 | [ `grep '^FAIL:' ${WORKSPACE}/riscv_rv32ec-gcc-build/gcc/testsuite/gcc/gcc.sum | wc -l` -gt 1000 ] && error "too many C failures" 93 | [ `grep '^FAIL:' ${WORKSPACE}/riscv_rv32ec-gcc-build/gcc/testsuite/g++/g++.sum | wc -l` -gt 2000 ] && error "too many C++ failures" 94 | 95 | # Send to real mailing list, 96 | pushd ${WORKSPACE}/riscv_rv32ec-gcc-build || error "failed to enter riscv_rv32ec-gcc-build" 97 | ../gcc/contrib/test_summary -m ${SUMMARY_RECIPIENTS} | sh 98 | popd 99 | 100 | bb_check_for_regressions ${PREV_BUILD_TAG} ${BUILD_TAG} 101 | } 102 | 103 | 104 | . `dirname ${0}`/buildbot-lib.sh 105 | 106 | bb_init_workspace ${@} 107 | bb_init_builddir ${@} 108 | 109 | bb_daily_build 110 | -------------------------------------------------------------------------------- /testing/buildbot-sync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for automatic update of the source trees. 6 | 7 | BINUTILS_URL=https://github.com/bminor/binutils-gdb 8 | GCC_URL=https://github.com/mirrors/gcc 9 | NEWLIB_URL=https://github.com/bminor/newlib 10 | AVRLIBC_URL=https://github.com/avrdudes/avr-libc 11 | ATEST_URL=https://github.com/sprintersb/atest 12 | EMBENCH_IOT_URL=https://github.com/embench/embench-iot 13 | 14 | true ${GCC_BRANCH:=master} 15 | 16 | # Who to send a short regression report to 17 | REGRESSION_RECIPIENTS="dinuxbg@gmail.com" 18 | 19 | # Default full report recipient. Caller can set this 20 | # environment variable to override the default. 21 | true ${SUMMARY_RECIPIENTS:=dinuxbg@gmail.com} 22 | 23 | 24 | bb_daily_update_sources() 25 | { 26 | bb_update_source binutils ${BINUTILS_URL} 27 | bb_update_source gcc ${GCC_URL} ${GCC_BRANCH} 28 | bb_update_source newlib ${NEWLIB_URL} 29 | bb_update_source avrlibc ${AVRLIBC_URL} main 30 | bb_update_source atest ${ATEST_URL} 31 | bb_update_source embench ${EMBENCH_IOT_URL} embench-2.0-branch 32 | 33 | # Write conforming versioning info. 34 | bb_gcc_touch_source_tree ${GCC_BRANCH} 35 | } 36 | 37 | 38 | . `dirname ${0}`/buildbot-lib.sh 39 | 40 | bb_init_workspace ${@} 41 | 42 | bb_daily_update_sources 43 | -------------------------------------------------------------------------------- /testing/clpru.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Frontend to the proprietary TI compiler. Used for invoking 6 | # the GCC ABI checking test suite. 7 | 8 | die() 9 | { 10 | echo "ERROR: $@" 11 | exit 1 12 | } 13 | 14 | if [ -n ${PRU_CGT} ] 15 | then 16 | EXEC=${PRU_CGT}/bin/clpru 17 | else 18 | EXEC=`which clpru` 19 | fi 20 | 21 | # Some CGT installations cannot find their own syspath. Go figure. 22 | # So help clpru to find its header files, instead of bothering 23 | # the user with extra options. 24 | EXEC=`realpath ${EXEC}` 25 | [ -x ${EXEC} ] || die "${EXEC} is not executable" 26 | EXEC_DIR=`dirname ${EXEC}` 27 | INCDIR=`realpath ${EXEC_DIR}/../include` 28 | 29 | # Convert arguments from "Regular Unix" to "TI" naming. Go figure. 30 | # Hopefully no argument contains spaces. 31 | ARGS= 32 | while [ $# != 0 ] 33 | do 34 | case ${1} in 35 | -o) ARGS="${ARGS} --output_file";; 36 | --version) ARGS="${ARGS} --compiler_revision"; echo -n 'TI clpru ';; 37 | -w) ARGS="${ARGS} --no_warnings";; 38 | -fdiagnostics-color=*) ;; 39 | -Wno-complain-wrong-lang) ;; 40 | -fdiagnostics-plain-output) ;; 41 | -mmcu=sim) ;; 42 | -Wno-abi) ;; 43 | -Wno-psabi) ;; # Why DejaGnu even passes this flag? 44 | -fno-diagnostics-show-caret) ;; 45 | -fno-diagnostics-show-line-numbers) ;; 46 | -fdiagnostics-urls=never) ;; 47 | *) ARGS="${ARGS} ${1}";; 48 | esac 49 | shift 50 | done 51 | 52 | # Zero-length arrays are ok, don't complain. 53 | EXTRA_ARGS=--diag_suppress=1231 54 | 55 | # Remove spurious newlines to satisfy DejaGnu (PR other/69006). 56 | ${EXEC} ${ARGS} ${EXTRA_ARGS} -I${INCDIR} | sed -e '/^$/d' 57 | -------------------------------------------------------------------------------- /testing/compare-all-sizes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Simple script to compare object text segment sizes between a baseline 4 | # reference GCC build and a test GCC build. 5 | # 6 | # This script has been heavily influenced by contrib/compare-all-files from 7 | # GCC's sources. 8 | 9 | import sys 10 | import os 11 | import argparse 12 | import shutil 13 | import re 14 | import tempfile 15 | import subprocess 16 | 17 | # TODO - add support for per-target options variants. 18 | 19 | """ Unified portal for user messages. """ 20 | class Logger: 21 | def __init__(self): 22 | self.verbose = False 23 | self.progress = False 24 | self.nlines = 0 25 | self.linei = 0 26 | 27 | def i(self, str): 28 | print(str) 29 | 30 | def e(self, str): 31 | print(str) 32 | 33 | def vraw(self, str): 34 | if self.verbose: 35 | sys.stdout.write(str) 36 | sys.stdout.flush() 37 | 38 | def v(self, str): 39 | if self.verbose: 40 | print(str) 41 | 42 | def progress_step(self, teststr): 43 | if self.progress: 44 | bar = ['-', '\\', '|', '/' ] 45 | 46 | sys.stdout.write(" \r") 47 | fmtvals = (bar[self.linei % 4], (self.linei * 100) / self.nlines, teststr) 48 | sys.stdout.write("[%s][%2d%%] %s, " % fmtvals) 49 | self.linei += 1 50 | sys.stdout.flush() 51 | 52 | log = Logger() 53 | 54 | """ Represent one test from target testsuite. """ 55 | class TargetTest: 56 | # TODO - cache the base size to avoid repetitive invocation. 57 | # TODO - perhaps invoke $target-size right from Dejagnu itself and 58 | # here just scan the output? 59 | def __init__(self, target, triplet, line): 60 | self.target = target 61 | self.triplet = triplet 62 | 63 | self.bline = line 64 | self.pline = line.replace("base-" + self.target + "-gcc-build", 65 | self.target + "-gcc-build") 66 | 67 | """ Calculate text segment size. """ 68 | def calc_text_size(self, line): 69 | handle, tmpname = tempfile.mkstemp() 70 | os.close(handle) 71 | 72 | line = line + " -o " + tmpname 73 | log.v("executing: " + line) 74 | ignored = subprocess.run(line.split(), check=True, capture_output=True) 75 | 76 | szout = subprocess.run( [ self.triplet + "-size", "-A", tmpname ], 77 | text=True, capture_output=True, check=True, 78 | universal_newlines=True).stdout 79 | 80 | try: 81 | os.unlink(tmpname) 82 | except: 83 | log.v("failed to remove " + tmpname) 84 | 85 | for s in szout.splitlines(): 86 | items = s.split() 87 | if items[0] == ".text": 88 | return int(items[1]) 89 | 90 | return None 91 | 92 | """ Run the test and return text sizes for base and tested toolchains. """ 93 | def test(self): 94 | try: 95 | bsz = self.calc_text_size(self.bline) 96 | except: 97 | bsz = -1 98 | try: 99 | psz = self.calc_text_size(self.pline) 100 | except: 101 | psz = -1 102 | return bsz, psz 103 | 104 | """ Collection of per-target size statistics. """ 105 | class SizeStats: 106 | def __init__(self): 107 | self.tests = [] 108 | self.n = 0 109 | self.bfails = 0 110 | self.pfails = 0 111 | self.best = sys.maxsize 112 | self.worst = -sys.maxsize + 1 113 | self.cumulative_diff = 0 114 | self.cumulative_base_size = 0 115 | 116 | """ Extract the source file name from test execution command line. """ 117 | def line2testname(self, line): 118 | m = re.search('testsuite/[a-zA-Z0-9_./-]+\.c($|[ ])', line) 119 | if m: 120 | return m.group(0) 121 | else: 122 | return '' 123 | 124 | """ 125 | Dump CSV table for all collected tests. 126 | Table is sorted per size difference (first columnt). 127 | """ 128 | def dump_csv(self, target, full_report): 129 | with open(target + "-size-comparison.csv", "w") as f: 130 | for e in sorted(self.tests, key=lambda row: row[0]): 131 | if (full_report or e[0] != 0): 132 | f.write(str(e[0]) + ", " 133 | + str(e[1]) + ", " 134 | + str(e[2]) + ", " 135 | + e[3] + ", \"" + e[4] + "\",\n" ) 136 | 137 | """ Dump short summary of data collected so far. """ 138 | def dump_stats(self): 139 | log.i("") 140 | log.i("best text diff: {0:d}".format(self.best)) 141 | log.i("worst text diff: {0:d}".format(self.worst)) 142 | log.i("avg text diff: {0:f}".format((self.cumulative_diff / self.n))) 143 | 144 | """ Record a failure to build with base toolchain. """ 145 | def add_bfail(self): 146 | self.bfails += 1 147 | self.progress_step() 148 | 149 | """ Record a failure to build with DUT toolchain. """ 150 | def add_pfail(self): 151 | self.pfails += 1 152 | self.progress_step() 153 | 154 | """ Add one more test entry to our database. """ 155 | def add(self, bsz, psz, line): 156 | name = self.line2testname(line) 157 | 158 | log.vraw("\rbase: {0:8d}, tested: {1:8d}, {2} ".format(bsz, psz, name)) 159 | 160 | self.tests.append( (psz - bsz, bsz, psz, name, line) ) 161 | self.cumulative_base_size += bsz 162 | self.n += 1 163 | diff = psz - bsz; 164 | self.cumulative_diff += diff 165 | if self.best > diff: 166 | self.best = diff 167 | if self.worst < diff: 168 | self.worst = diff 169 | self.progress_step() 170 | 171 | def progress_step(self): 172 | log.progress_step("best: %d, worst: %d, bfails: %d, pfails: %d" % (self.best, self.worst, self.bfails, self.pfails)) 173 | 174 | """ Represent one target we're doing size comparison for. """ 175 | class Target: 176 | def __init__(self, target, full_report=False): 177 | self.target = target 178 | self.full_report = full_report 179 | self.triplet = "unknown-unknown-unknown" 180 | self.stats = SizeStats() 181 | self.lines = [] 182 | self.nlines = 0 183 | self.patterns_to_remove = [ 184 | [ "^Executing on host: ", "" ], 185 | [ " *\(timeout.*", "" ], 186 | # Several consecutive -fdump options could occur, 187 | # so to avoid overlap do not terminate with a space. 188 | [ " -fdump[-a-z0-9_]*", "" ], 189 | [ " -S ", " -c " ], 190 | [ " -{1,2}save-temps ", " " ], 191 | [ " -o [^ ]*", " -frandom-seed=0 " ] ] 192 | self.stropts_to_remove = [ 193 | " -fverbose-asm ", 194 | " -flto ", 195 | " -frtl-abstract-sequences ", 196 | " -da " ] 197 | 198 | """ Get target triplet. """ 199 | def get_triplet(self): 200 | xgcc = "./" + self.target + "-gcc-build/gcc/xgcc" 201 | return subprocess.run( [ xgcc, "-dumpmachine" ], 202 | text=True, capture_output=True, check=True, 203 | universal_newlines=True).stdout.strip() 204 | 205 | """ Process a single line from DejaGnu log file. """ 206 | def process_line(self, line): 207 | # First, filter only the lines containing compiler commands. 208 | if not line.startswith("Executing on host: "): 209 | return 210 | if "xgcc -B" not in line: 211 | return 212 | if " -E " in line or " -g" in line or " -print-prog-name=" in line: 213 | return 214 | if " -print-file-name=" in line or " -print-multi-directory " in line: 215 | return 216 | if " -print-multi-lib" in line: 217 | return 218 | # Is O0 interesting when comparing sizes? 219 | if " -O0 " in line: 220 | return 221 | 222 | for restr in self.patterns_to_remove: 223 | p = re.compile(restr[0]) 224 | line = p.sub(restr[1], line, 0) 225 | 226 | for opt in self.stropts_to_remove: 227 | line = line.replace(opt, " ") 228 | 229 | self.lines.append(line) 230 | self.nlines += 1 231 | 232 | def target_size_tool_available(self): 233 | ret = subprocess.run( [ self.triplet + "-size", "--version"] ) 234 | if ret.returncode == 0: 235 | return True 236 | else: 237 | return False 238 | 239 | def execute_test_line(self, line): 240 | t = TargetTest(self.target, self.triplet, line) 241 | bsz, psz = t.test() 242 | 243 | if bsz > 0: 244 | """ base test is good """ 245 | if psz < 0: 246 | log.e("\nbase passed, but tested gcc failed: " + line) 247 | self.stats.add_pfail() 248 | else: 249 | self.stats.add(bsz, psz, line) 250 | else: 251 | self.stats.add_bfail() 252 | 253 | """ Run the size comparison test for this particular target. """ 254 | def test(self): 255 | self.triplet = self.get_triplet() 256 | log.i("Testing target {0} , triplet {1}".format(self.target, self.triplet)) 257 | 258 | base_dir = "base-" + self.target + "-gcc-build/gcc/testsuite/gcc" 259 | tested_dir = self.target + "-gcc-build/gcc/testsuite/gcc" 260 | 261 | if not self.target_size_tool_available(): 262 | log.e("Cannot execute " + self.triplet + "-size") 263 | return 1 264 | 265 | os.makedirs(tested_dir, exist_ok=True) 266 | if not os.path.exists(os.path.join(tested_dir, "gcc.dg-struct-layout-1")): 267 | shutil.copytree(os.path.join(base_dir, "gcc.dg-struct-layout-1"), 268 | os.path.join(tested_dir, "gcc.dg-struct-layout-1")) 269 | 270 | log.i("Scanning the log file...") 271 | with open(os.path.join(base_dir, "gcc.log"), "r") as f: 272 | #ii = 0; 273 | for l in f: 274 | #ii += 1 275 | #if (ii > 5000): 276 | # break 277 | self.process_line(l.strip()) 278 | 279 | log.i("Executing and comparing test cases...") 280 | log.nlines = self.nlines 281 | for l in self.lines: 282 | # TODO - use https://docs.python.org/3/library/concurrent.futures.html 283 | self.execute_test_line(l) 284 | 285 | self.stats.dump_stats() 286 | self.stats.dump_csv(target=self.target, full_report=self.full_report) 287 | 288 | return 0 289 | 290 | 291 | def main(): 292 | parser = argparse.ArgumentParser() 293 | parser.add_argument("--verbose", help="print verbosely while executing", 294 | action="store_true") 295 | parser.add_argument("--progress", help="print progress status during execution", 296 | action="store_true") 297 | parser.add_argument("--full-report", help="include all tests in final CSV, even with same size", 298 | action="store_true") 299 | parser.add_argument("target", help="target to run comparison for") 300 | args = parser.parse_args() 301 | 302 | log.verbose = args.verbose 303 | log.progress = args.progress 304 | t = Target(target=args.target, full_report=args.full_report); 305 | 306 | sys.exit(t.test()) 307 | 308 | # Main body 309 | if __name__ == '__main__': 310 | main() 311 | -------------------------------------------------------------------------------- /testing/crontest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Put it in an empty directory and invoke it from crontab. Example: 6 | # 0 8 * * * /home/user/testbot-workspace/crontest.sh 7 | 8 | 9 | renice +10 $$ 2>/dev/null 1>/dev/null 10 | 11 | cd `dirname ${0}` 12 | 13 | # For testing 14 | export SUMMARY_RECIPIENTS=dinuxbg@gmail.com 15 | 16 | # For real. 17 | # export SUMMARY_RECIPIENTS=gcc-testresults@gcc.gnu.org 18 | 19 | 20 | # On every second Sunday... 21 | if [ x`date +%u` = x7 -a x$((`date +%U` % 2)) = x0 ] 22 | then 23 | # Test AVR and PRU on all active branches. 24 | GCC_BRANCH=releases/gcc-12 ./gnupru/testing/buildbot-sync.sh . 25 | LOGDIR=`pwd`/avr-gcc-12-logs ./gnupru/testing/buildbot-avr.sh . 26 | LOGDIR=`pwd`/pru-gcc-12-logs ./gnupru/testing/buildbot-pru.sh . 27 | 28 | GCC_BRANCH=releases/gcc-13 ./gnupru/testing/buildbot-sync.sh . 29 | LOGDIR=`pwd`/avr-gcc-13-logs ./gnupru/testing/buildbot-avr.sh . 30 | LOGDIR=`pwd`/pru-gcc-13-logs ./gnupru/testing/buildbot-pru.sh . 31 | 32 | GCC_BRANCH=releases/gcc-14 ./gnupru/testing/buildbot-sync.sh . 33 | LOGDIR=`pwd`/avr-gcc-14-logs ./gnupru/testing/buildbot-avr.sh . 34 | LOGDIR=`pwd`/pru-gcc-14-logs ./gnupru/testing/buildbot-pru.sh . 35 | 36 | GCC_BRANCH=releases/gcc-15 ./gnupru/testing/buildbot-sync.sh . 37 | LOGDIR=`pwd`/avr-gcc-15-logs ./gnupru/testing/buildbot-avr.sh . 38 | LOGDIR=`pwd`/pru-gcc-15-logs ./gnupru/testing/buildbot-pru.sh . 39 | LOGDIR=`pwd`/riscv_rv32ec-gcc-15-logs ./gnupru/testing/buildbot-riscv_rv32ec.sh . 40 | 41 | ./gnupru/testing/buildbot-sync.sh . 42 | ./gnupru/testing/buildbot-avr.sh . 43 | ./gnupru/testing/buildbot-riscv_rv32ec.sh . 44 | 45 | rm -fr avr-*-build riscv32-*-build arm-*-build riscv_rv32ec-*-build 46 | fi 47 | 48 | # Test PRU everyday. 49 | ./gnupru/testing/buildbot-sync.sh . 50 | ./gnupru/testing/buildbot-pru.sh . 51 | -------------------------------------------------------------------------------- /testing/gcc-test-host.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for automatic testing host for GCC regressions. 6 | 7 | die() 8 | { 9 | echo "ERROR: $@" 10 | exit 1 11 | } 12 | 13 | [ $# != 2 ] && die "Usage: $0 " 14 | 15 | COMMITID_VANILLA=${1} 16 | COMMITID_PATCHED=${2} 17 | 18 | BUILD_VANILLA=`pwd`/tmp/host-build-vanilla 19 | BUILD_PATCHED=`pwd`/tmp/host-build-patched 20 | SRC=`pwd`/gcc 21 | LOGDIR=`pwd`/logs 22 | 23 | rm -fr ${BUILD_VANILLA} ${BUILD_PATCHED} 24 | mkdir -p ${BUILD_VANILLA} ${BUILD_PATCHED} $LOGDIR 25 | 26 | build_test_gcc() 27 | { 28 | local BUILDDIR=${1} 29 | shift 30 | local TAG=${1} 31 | 32 | local PREFIX=$HOME/bin/host-${TAG} 33 | rm -fr ${PREFIX} 34 | cd ${BUILDDIR} || die 35 | ${SRC}/configure --disable-multilib --enable-languages=c,c++ --prefix=${PREFIX} || die 36 | make -j$(nproc) || die 37 | make install 38 | find . -name site.exp | xargs rm -f 39 | make -j$(nproc) check-gcc-c || die 40 | find . -name site.exp | xargs rm -f 41 | make -j$(nproc) check-gcc-c++ || die 42 | local FILES="gcc/testsuite/gcc/gcc.log gcc/testsuite/gcc/gcc.sum gcc/testsuite/g++/g++.log gcc/testsuite/g++/g++.sum" 43 | for i in ${FILES} 44 | do 45 | cp "${i}" "${LOGDIR}/`basename ${i}`-${TAG}" 46 | done 47 | } 48 | 49 | 50 | DATETAG=`date +%Y%m%d%H%M` 51 | GITTAG_VANILLA=$(cd ${SRC} && git rev-parse --short ${COMMITID_VANILLA}) 52 | GITTAG_PATCHED=$(cd ${SRC} && git rev-parse --short ${COMMITID_PATCHED}) 53 | 54 | cd ${SRC} && git reset --hard ${COMMITID_VANILLA} 55 | build_test_gcc ${BUILD_VANILLA} ${DATETAG}-${GITTAG_VANILLA}-host-vanilla 56 | cd ${SRC} && git reset --hard ${COMMITID_PATCHED} 57 | build_test_gcc ${BUILD_PATCHED} ${DATETAG}-${GITTAG_PATCHED}-host-patched 58 | 59 | # TODO - re-enable 60 | #rm -fr ${BUILD_VANILLA} ${BUILD_PATCHED} 61 | -------------------------------------------------------------------------------- /testing/interop/Makefile: -------------------------------------------------------------------------------- 1 | 2 | TESTDIRS := $(dir $(wildcard */Makefile)) 3 | 4 | all: 5 | $(foreach D,$(TESTDIRS),make -C $(D) && ) true 6 | @echo SUCCESS 7 | 8 | # Check the testsuite itself on a host. Implies that there 9 | # are no architecture-specific tests. 10 | selftest: 11 | $(foreach D,$(TESTDIRS),make -C $(D) selftest && ) true 12 | 13 | 14 | .PHONY: all selftest 15 | -------------------------------------------------------------------------------- /testing/interop/argpack/Makefile: -------------------------------------------------------------------------------- 1 | include ../testcore.inc 2 | -------------------------------------------------------------------------------- /testing/interop/argpack/gcc-main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "shared.h" 8 | #include "test.h" 9 | 10 | int gcc_func_argpack1(signed char a1, short a2, int a3, signed char a4, long a5, 11 | signed char a6, short a7, short a8, short a9, short a10, 12 | signed char a11, signed char a12, signed char a13, 13 | signed char a14, signed char a15, signed char a16, 14 | long a17, signed char a18, signed char a19, int a20, 15 | signed char a21) 16 | { 17 | CHECK(a1 == 1); 18 | CHECK(a2 == -2); 19 | CHECK(a3 == 3); 20 | CHECK(a4 == -4); 21 | CHECK(a5 == 5); 22 | CHECK(a6 == -6); 23 | CHECK(a7 == 7); 24 | CHECK(a8 == -8); 25 | CHECK(a9 == 9); 26 | CHECK(a10 == -10); 27 | CHECK(a11 == 11); 28 | CHECK(a12 == -12); 29 | CHECK(a13 == 13); 30 | CHECK(a14 == -14); 31 | CHECK(a15 == 15); 32 | CHECK(a16 == -16); 33 | CHECK(a17 == 17); 34 | CHECK(a18 == -18); 35 | CHECK(a19 == 19); 36 | CHECK(a20 == -20); 37 | CHECK(a21 == 21); 38 | 39 | return 0; 40 | } 41 | 42 | int main(void) 43 | { 44 | ti_func_argpack1(31, -32, 33, -34, 35, -36, 37, -38, 39, -40, 41, 45 | -42, 43, -44, 45, -46, 47, -48, 49, -50, 51); 46 | ti_func_check_argpack1(); 47 | 48 | return EXIT_SUCCESS; 49 | } 50 | -------------------------------------------------------------------------------- /testing/interop/argpack/out/ti-mod.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinuxbg/gnupru/e6a0bad94ae3c5633a0b13bb1726b2d49837739d/testing/interop/argpack/out/ti-mod.o -------------------------------------------------------------------------------- /testing/interop/argpack/shared.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int gcc_func_argpack1(signed char a1, short a2, int a3, signed char a4, long a5, 5 | signed char a6, short a7, short a8, short a9, short a10, 6 | signed char a11, signed char a12, signed char a13, 7 | signed char a14, signed char a15, signed char a16, 8 | long a17, signed char a18, signed char a19, int a20, 9 | signed char a21); 10 | 11 | int ti_func_argpack1(signed char a1, short a2, int a3, signed char a4, long a5, 12 | signed char a6, short a7, short a8, short a9, short a10, 13 | signed char a11, signed char a12, signed char a13, 14 | signed char a14, signed char a15, signed char a16, 15 | long a17, signed char a18, signed char a19, int a20, 16 | signed char a21); 17 | 18 | int ti_func_check_argpack1(void); 19 | -------------------------------------------------------------------------------- /testing/interop/argpack/ti-mod.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "shared.h" 4 | #include "test.h" 5 | 6 | int ti_func_argpack1(signed char a1, short a2, int a3, signed char a4, long a5, 7 | signed char a6, short a7, short a8, short a9, short a10, 8 | signed char a11, signed char a12, signed char a13, 9 | signed char a14, signed char a15, signed char a16, 10 | long a17, signed char a18, signed char a19, int a20, 11 | signed char a21) 12 | { 13 | CHECK(a1 == 31); 14 | CHECK(a2 == -32); 15 | CHECK(a3 == 33); 16 | CHECK(a4 == -34); 17 | CHECK(a5 == 35); 18 | CHECK(a6 == -36); 19 | CHECK(a7 == 37); 20 | CHECK(a8 == -38); 21 | CHECK(a9 == 39); 22 | CHECK(a10 == -40); 23 | CHECK(a11 == 41); 24 | CHECK(a12 == -42); 25 | CHECK(a13 == 43); 26 | CHECK(a14 == -44); 27 | CHECK(a15 == 45); 28 | CHECK(a16 == -46); 29 | CHECK(a17 == 47); 30 | CHECK(a18 == -48); 31 | CHECK(a19 == 49); 32 | CHECK(a20 == -50); 33 | CHECK(a21 == 51); 34 | 35 | return 0; 36 | } 37 | 38 | int ti_func_check_argpack1(void) 39 | { 40 | gcc_func_argpack1(1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, 41 | -14, 15, -16, 17, -18, 19, -20, 21); 42 | return 0; 43 | } 44 | 45 | 46 | -------------------------------------------------------------------------------- /testing/interop/cxx-basic/Makefile: -------------------------------------------------------------------------------- 1 | 2 | PRU_CGT ?= /usr/share/ti/cgt-pru 3 | 4 | OUT := out 5 | TARGET := test 6 | 7 | TESTCASE := $(shell basename `pwd`) 8 | 9 | COMMON_CXXFLAGS := -DTESTCASE=\"$(TESTCASE)\" -I../ 10 | 11 | TI_CXXFLAGS := -v3 -O2 --display_error_number --endian=little --hardware_mac=on 12 | TI_CXXFLAGS += -I$(PRU_CGT)/include 13 | # TODO - GNU LD PRU port does not yet support debug REL relocations. 14 | TI_CXXFLAGS += --symdebug:none 15 | GCC_CXXFLAGS := -O1 -g -Wall -Wextra -mmcu=sim 16 | GCC_LDFLAGS := 17 | 18 | all: $(OUT)/$(TARGET) 19 | pru-run $< 20 | @echo PASS: $(TESTCASE) 21 | 22 | $(OUT): 23 | mkdir $(OUT) 24 | 25 | $(OUT)/ti-mod.o: ti-mod.cxx $(OUT) $(wildcard *.hxx) 26 | $(PRU_CGT)/bin/clpru $(TI_CXXFLAGS) $(COMMON_CXXFLAGS) -fe $@ $< 27 | 28 | $(OUT)/gcc-main.o: gcc-main.cxx $(OUT) $(wildcard *.hxx) 29 | pru-g++ $(GCC_CXXFLAGS) $(COMMON_CXXFLAGS) -c -o $@ $< 30 | 31 | $(OUT)/$(TARGET): $(OUT)/ti-mod.o $(OUT)/gcc-main.o 32 | pru-g++ $(GCC_CXXFLAGS) $(COMMON_CXXFLAGS) $(GCC_LDFLAGS) $^ -o $@ 33 | 34 | clean: 35 | rm -fr $(OUT) 36 | 37 | $(OUT)/selftest-host: ti-mod.cxx gcc-main.cxx | $(OUT) $(wildcard *.hxx) 38 | g++ -O2 -Wall -Wextra $(COMMON_CXXFLAGS) $^ -o $@ 39 | 40 | selftest: $(OUT)/selftest-host 41 | ./$< 42 | @echo PASS:host: $(TESTCASE) 43 | 44 | .PHONY: clean selftest 45 | -------------------------------------------------------------------------------- /testing/interop/cxx-basic/gcc-main.cxx: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "shared.hxx" 8 | #include "test.h" 9 | 10 | 11 | int main(void) 12 | { 13 | A a; 14 | b::B b; 15 | 16 | CHECK(a.test1(0x101202, 0x303404) == 0x505606); 17 | CHECK(b.test1(0x707808, 0x909a0a) == 0x10b0c0c0); 18 | 19 | return EXIT_SUCCESS; 20 | } 21 | -------------------------------------------------------------------------------- /testing/interop/cxx-basic/out/ti-mod.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinuxbg/gnupru/e6a0bad94ae3c5633a0b13bb1726b2d49837739d/testing/interop/cxx-basic/out/ti-mod.o -------------------------------------------------------------------------------- /testing/interop/cxx-basic/shared.hxx: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | class A { 5 | public: 6 | int a; 7 | char b; 8 | int c; 9 | virtual int test1(int pa, int pb); 10 | }; 11 | 12 | namespace b { 13 | class B : public A { 14 | public: 15 | int d; 16 | virtual int test1(int pa, int pb); 17 | }; 18 | }; 19 | -------------------------------------------------------------------------------- /testing/interop/cxx-basic/ti-mod.cxx: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "shared.hxx" 4 | #include "test.h" 5 | 6 | int A::test1(int pa, int pb) 7 | { 8 | CHECK(pa == 0x101202); 9 | CHECK(pb == 0x303404); 10 | return 0x505606; 11 | } 12 | int b::B::test1(int pa, int pb) 13 | { 14 | CHECK(pa == 0x707808); 15 | CHECK(pb == 0x909a0a); 16 | return 0x10b0c0c0; 17 | } 18 | -------------------------------------------------------------------------------- /testing/interop/fp/Makefile: -------------------------------------------------------------------------------- 1 | GCC_LDFLAGS += -lm 2 | include ../testcore.inc 3 | -------------------------------------------------------------------------------- /testing/interop/fp/gcc-main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "shared.h" 4 | #include "test.h" 5 | 6 | int gcc_func1(float a, float b, float c) 7 | { 8 | CHECK(!isnan(a)); 9 | CHECK(!isinf(b)); 10 | CHECK(trunc(c) == 5); 11 | return 0; 12 | } 13 | 14 | int main(void) 15 | { 16 | ti_func1(3.3, 4.4, 5.5); 17 | 18 | return EXIT_SUCCESS; 19 | } 20 | -------------------------------------------------------------------------------- /testing/interop/fp/out/ti-mod.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinuxbg/gnupru/e6a0bad94ae3c5633a0b13bb1726b2d49837739d/testing/interop/fp/out/ti-mod.o -------------------------------------------------------------------------------- /testing/interop/fp/shared.h: -------------------------------------------------------------------------------- 1 | 2 | int gcc_func1(float a, float b, float c); 3 | 4 | int ti_func1(float a, float b, float c); 5 | -------------------------------------------------------------------------------- /testing/interop/fp/ti-mod.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "shared.h" 4 | #include "test.h" 5 | 6 | int ti_func1(float a, float b, float c) 7 | { 8 | CHECK(!isnan(a)); 9 | CHECK(!isinf(b)); 10 | CHECK(trunc(c) == 5); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /testing/interop/largeargs/Makefile: -------------------------------------------------------------------------------- 1 | include ../testcore.inc 2 | -------------------------------------------------------------------------------- /testing/interop/largeargs/gcc-main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "shared.h" 8 | #include "test.h" 9 | 10 | int gcc_func1(signed char a1, short a2, int a3, signed char a4, long a5, 11 | struct big1 b1, 12 | signed char a6, short a7, short a8, short a9, short a10, 13 | struct big2 b2, 14 | signed char a11, signed char a12, signed char a13, 15 | struct big3 b3, 16 | signed char a14, signed char a15, signed char a16, 17 | long a17, signed char a18, signed char a19, int a20, 18 | signed char a21) 19 | { 20 | unsigned int i; 21 | int j, k; 22 | 23 | CHECK(a1 == 1); 24 | CHECK(a2 == -2); 25 | CHECK(a3 == 3); 26 | CHECK(a4 == -4); 27 | CHECK(a5 == 5); 28 | CHECK(a6 == -6); 29 | CHECK(a7 == 7); 30 | CHECK(a8 == -8); 31 | CHECK(a9 == 9); 32 | CHECK(a10 == -10); 33 | CHECK(a11 == 11); 34 | CHECK(a12 == -12); 35 | CHECK(a13 == 13); 36 | CHECK(a14 == -14); 37 | CHECK(a15 == 15); 38 | CHECK(a16 == -16); 39 | CHECK(a17 == 17); 40 | CHECK(a18 == -18); 41 | CHECK(a19 == 19); 42 | CHECK(a20 == -20); 43 | CHECK(a21 == 21); 44 | 45 | CHECK(b1.a[0] == 101); 46 | CHECK(b1.a[1] == -102); 47 | 48 | CHECK(b2.a[0] == 201); 49 | CHECK(b2.a[1] == -202); 50 | CHECK(b2.a[2] == 203); 51 | 52 | for (i = 0, j = 1, k = 301; i < ARRAY_SIZE(b3.a); i++, j = -1 * j, k++) { 53 | CHECK(b3.a[i] == j * k); 54 | } 55 | return 0; 56 | } 57 | 58 | int gcc_func2(long long a1, long long a2, long long a3, long long a4, 59 | long long a5, long long a6, long long a7, long long a8, 60 | long long a9, long long a10, long long a11, long long a12, 61 | long long a13, long long a14, long long a15, long long a16) 62 | { 63 | CHECK(a1 == 10); 64 | CHECK(a2 == -20); 65 | CHECK(a3 == 30); 66 | CHECK(a4 == -40); 67 | CHECK(a5 == 50); 68 | CHECK(a6 == -60); 69 | CHECK(a7 == 70); 70 | CHECK(a8 == -80); 71 | CHECK(a9 == 90); 72 | CHECK(a10 == -100); 73 | CHECK(a11 == 110); 74 | CHECK(a12 == -120); 75 | CHECK(a13 == 130); 76 | CHECK(a14 == -140); 77 | CHECK(a15 == 150); 78 | CHECK(a16 == -160); 79 | 80 | return 0; 81 | } 82 | 83 | int main(void) 84 | { 85 | struct big1 b1 = { .a = {101, -102}, }; 86 | struct big2 b2 = { .a = {201, -202, 203}, }; 87 | struct big3 b3; 88 | unsigned int i; 89 | int j, k; 90 | 91 | for (i = 0, j = 1, k = 301; i < ARRAY_SIZE(b3.a); i++, j = -1 * j, k++) { 92 | b3.a[i] = j * k; 93 | } 94 | 95 | ti_func1(1, -2, 3, -4, 5, b1, -6, 7, -8, 9, -10, 96 | b2, 11, -12, 13, 97 | b3, -14, 15, -16, 17, -18, 19, -20, 21); 98 | ti_func_check2(); 99 | ti_func2(10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 100 | 110, -120, 130, -140, 150, -160); 101 | ti_func_check1(); 102 | 103 | return EXIT_SUCCESS; 104 | } 105 | -------------------------------------------------------------------------------- /testing/interop/largeargs/out/ti-mod.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinuxbg/gnupru/e6a0bad94ae3c5633a0b13bb1726b2d49837739d/testing/interop/largeargs/out/ti-mod.o -------------------------------------------------------------------------------- /testing/interop/largeargs/shared.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | struct big1 { 5 | int a[2]; 6 | }; 7 | 8 | struct big2 { 9 | int a[3]; 10 | }; 11 | 12 | struct big3 { 13 | int a[64]; 14 | }; 15 | 16 | int gcc_func1(signed char a1, short a2, int a3, signed char a4, long a5, 17 | struct big1 b1, 18 | signed char a6, short a7, short a8, short a9, short a10, 19 | struct big2 b2, 20 | signed char a11, signed char a12, signed char a13, 21 | struct big3 b3, 22 | signed char a14, signed char a15, signed char a16, 23 | long a17, signed char a18, signed char a19, int a20, 24 | signed char a21); 25 | 26 | int gcc_func2(long long a1, long long a2, long long a3, long long a4, 27 | long long a5, long long a6, long long a7, long long a8, 28 | long long a9, long long a10, long long a11, long long a12, 29 | long long a13, long long a14, long long a15, long long a16); 30 | 31 | int ti_func1(signed char a1, short a2, int a3, signed char a4, long a5, 32 | struct big1 b1, 33 | signed char a6, short a7, short a8, short a9, short a10, 34 | struct big2 b2, 35 | signed char a11, signed char a12, signed char a13, 36 | struct big3 b3, 37 | signed char a14, signed char a15, signed char a16, 38 | long a17, signed char a18, signed char a19, int a20, 39 | signed char a21); 40 | 41 | int ti_func2(long long a1, long long a2, long long a3, long long a4, 42 | long long a5, long long a6, long long a7, long long a8, 43 | long long a9, long long a10, long long a11, long long a12, 44 | long long a13, long long a14, long long a15, long long a16); 45 | 46 | int ti_func_check1(void); 47 | int ti_func_check2(void); 48 | -------------------------------------------------------------------------------- /testing/interop/largeargs/ti-mod.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "shared.h" 4 | #include "test.h" 5 | 6 | int ti_func1(signed char a1, short a2, int a3, signed char a4, long a5, 7 | struct big1 b1, 8 | signed char a6, short a7, short a8, short a9, short a10, 9 | struct big2 b2, 10 | signed char a11, signed char a12, signed char a13, 11 | struct big3 b3, 12 | signed char a14, signed char a15, signed char a16, 13 | long a17, signed char a18, signed char a19, int a20, 14 | signed char a21) 15 | { 16 | unsigned int i; 17 | int j, k; 18 | 19 | CHECK(a1 == 1); 20 | CHECK(a2 == -2); 21 | CHECK(a3 == 3); 22 | CHECK(a4 == -4); 23 | CHECK(a5 == 5); 24 | CHECK(a6 == -6); 25 | CHECK(a7 == 7); 26 | CHECK(a8 == -8); 27 | CHECK(a9 == 9); 28 | CHECK(a10 == -10); 29 | CHECK(a11 == 11); 30 | CHECK(a12 == -12); 31 | CHECK(a13 == 13); 32 | CHECK(a14 == -14); 33 | CHECK(a15 == 15); 34 | CHECK(a16 == -16); 35 | CHECK(a17 == 17); 36 | CHECK(a18 == -18); 37 | CHECK(a19 == 19); 38 | CHECK(a20 == -20); 39 | CHECK(a21 == 21); 40 | 41 | CHECK(b1.a[0] == 101); 42 | CHECK(b1.a[1] == -102); 43 | 44 | CHECK(b2.a[0] == 201); 45 | CHECK(b2.a[1] == -202); 46 | CHECK(b2.a[2] == 203); 47 | 48 | for (i = 0, j = 1, k = 301; i < ARRAY_SIZE(b3.a); i++, j = -1 * j, k++) { 49 | CHECK(b3.a[i] == j * k); 50 | } 51 | return 0; 52 | } 53 | 54 | int ti_func2(long long a1, long long a2, long long a3, long long a4, 55 | long long a5, long long a6, long long a7, long long a8, 56 | long long a9, long long a10, long long a11, long long a12, 57 | long long a13, long long a14, long long a15, long long a16) 58 | { 59 | CHECK(a1 == 10); 60 | CHECK(a2 == -20); 61 | CHECK(a3 == 30); 62 | CHECK(a4 == -40); 63 | CHECK(a5 == 50); 64 | CHECK(a6 == -60); 65 | CHECK(a7 == 70); 66 | CHECK(a8 == -80); 67 | CHECK(a9 == 90); 68 | CHECK(a10 == -100); 69 | CHECK(a11 == 110); 70 | CHECK(a12 == -120); 71 | CHECK(a13 == 130); 72 | CHECK(a14 == -140); 73 | CHECK(a15 == 150); 74 | CHECK(a16 == -160); 75 | 76 | return 0; 77 | } 78 | 79 | int ti_func_check1(void) 80 | { 81 | struct big1 b1 = { .a = {101, -102}, }; 82 | struct big2 b2 = { .a = {201, -202, 203}, }; 83 | struct big3 b3; 84 | unsigned int i; 85 | int j, k; 86 | 87 | for (i = 0, j = 1, k = 301; i < ARRAY_SIZE(b3.a); i++, j = -1 * j, k++) { 88 | b3.a[i] = j * k; 89 | } 90 | 91 | gcc_func1(1, -2, 3, -4, 5, b1, -6, 7, -8, 9, -10, 92 | b2, 11, -12, 13, 93 | b3, -14, 15, -16, 17, -18, 19, -20, 21); 94 | 95 | return 0; 96 | } 97 | 98 | int ti_func_check2(void) 99 | { 100 | gcc_func2(10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 101 | 110, -120, 130, -140, 150, -160); 102 | 103 | return 0; 104 | } 105 | -------------------------------------------------------------------------------- /testing/interop/relocs/Makefile: -------------------------------------------------------------------------------- 1 | include ../testcore.inc 2 | -------------------------------------------------------------------------------- /testing/interop/relocs/gcc-main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "shared.h" 8 | #include "test.h" 9 | 10 | static volatile void * volatile ti_relocs[3] = { &ti_u32, &ti_u16, &ti_u8 }; 11 | 12 | uint32_t gcc_u32 = 0xccbbeedd; 13 | uint16_t gcc_u16 = 0x4532; 14 | uint8_t gcc_u8 = 0x25; 15 | 16 | uint32_t gcc_array16[1024]; 17 | uint32_t gcc_array32[1024]; 18 | 19 | uint64_t gcc_func_arg1(uint32_t arg1) 20 | { 21 | return arg1 | ((uint64_t)arg1 + 1) << 32; 22 | } 23 | 24 | uint32_t gcc_func_arg3(uint32_t arg1, uint32_t arg2, uint32_t arg3) 25 | { 26 | return arg1 + (arg2 >> 1) + (arg3 >> 2); 27 | } 28 | 29 | uint32_t gcc_func_arg4(uint32_t n, uint32_t arg1, uint32_t arg2, 30 | uint32_t arg3, uint32_t arg4) 31 | { 32 | uint32_t s = 0; 33 | 34 | while (n--) { 35 | uint64_t tmp = gcc_func_arg1(arg1); 36 | 37 | s += tmp & 0xffffffff; 38 | s += tmp >> 32; 39 | s += gcc_func_arg3(arg2, arg3, arg4); 40 | } 41 | 42 | return s; 43 | } 44 | 45 | 46 | int main(void) 47 | { 48 | const uint32_t ARG1 = 0x54321; 49 | const uint32_t ARG2 = 0x12345678; 50 | const uint32_t ARG3 = 0xaabbccdd; 51 | const uint32_t ARG4 = 0x0; 52 | 53 | uint32_t ti_result, gcc_result; 54 | 55 | ti_result = ti_func_arg4(10, ARG1, ARG2, ARG3, ARG4); 56 | gcc_result = ti_func_arg4(10, ARG1, ARG2, ARG3, ARG4); 57 | 58 | printf("TI: 0x%08"PRIx32", GCC: 0x%08"PRIx32"\n", ti_result, gcc_result); 59 | 60 | CHECK (gcc_u32 == *(uint32_t*)ti_relocs[0]); 61 | CHECK (gcc_u16 == *(uint16_t*)ti_relocs[1]); 62 | CHECK (gcc_u8 == *(uint8_t*)ti_relocs[2]); 63 | CHECK (ti_result == gcc_result); 64 | CHECK (ti_ptr16 == &gcc_array16[678]); 65 | CHECK (ti_ptr32 == &gcc_array32[123]); 66 | 67 | printf("SUCCESS\n"); 68 | return EXIT_SUCCESS; 69 | } 70 | -------------------------------------------------------------------------------- /testing/interop/relocs/out/ti-mod.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinuxbg/gnupru/e6a0bad94ae3c5633a0b13bb1726b2d49837739d/testing/interop/relocs/out/ti-mod.o -------------------------------------------------------------------------------- /testing/interop/relocs/shared.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | uint64_t gcc_func_arg1(uint32_t arg1); 5 | uint32_t gcc_func_arg3(uint32_t arg1, uint32_t arg2, uint32_t arg3); 6 | 7 | uint32_t ti_func_arg4(uint32_t n, uint32_t arg1, uint32_t arg2, 8 | uint32_t arg3, uint32_t arg4); 9 | 10 | extern uint32_t ti_u32; 11 | extern uint16_t ti_u16; 12 | extern uint8_t ti_u8; 13 | extern uint32_t *ti_ptr16; 14 | extern uint32_t *ti_ptr32; 15 | extern uint32_t gcc_array16[1024]; 16 | extern uint32_t gcc_array32[1024]; 17 | 18 | -------------------------------------------------------------------------------- /testing/interop/relocs/ti-mod.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "shared.h" 5 | 6 | uint32_t ti_u32 = 0xccbbeedd; 7 | uint16_t ti_u16 = 0x4532; 8 | uint8_t ti_u8 = 0x25; 9 | 10 | uint32_t *ti_ptr16 = &gcc_array16[678]; 11 | uint32_t *ti_ptr32 = &gcc_array32[123]; 12 | 13 | uint32_t ti_func_arg4(uint32_t n, uint32_t arg1, uint32_t arg2, 14 | uint32_t arg3, uint32_t arg4) 15 | { 16 | uint32_t s = 0; 17 | 18 | while (n--) { 19 | uint64_t tmp = gcc_func_arg1(arg1); 20 | 21 | s += tmp & 0xffffffff; 22 | s += tmp >> 32; 23 | s += gcc_func_arg3(arg2, arg3, arg4); 24 | } 25 | 26 | return s; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /testing/interop/retval/Makefile: -------------------------------------------------------------------------------- 1 | include ../testcore.inc 2 | -------------------------------------------------------------------------------- /testing/interop/retval/gcc-main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "shared.h" 8 | #include "test.h" 9 | 10 | 11 | struct big1 gcc_func1(signed char a1, short a2, int a3) 12 | { 13 | struct big1 b1 = { .a = {101, -102}, }; 14 | CHECK(a1 == 1); 15 | CHECK(a2 == -2); 16 | CHECK(a3 == 3); 17 | return b1; 18 | } 19 | 20 | struct big2 gcc_func2(signed char a1, short a2, int a3) 21 | { 22 | struct big2 b2 = { .a = {201, -202, 203}, }; 23 | CHECK(a1 == 1); 24 | CHECK(a2 == -2); 25 | CHECK(a3 == 3); 26 | return b2; 27 | } 28 | 29 | struct big3 gcc_func3(signed char a1, short a2, int a3) 30 | { 31 | struct big3 b3; 32 | unsigned int i; 33 | int j, k; 34 | 35 | CHECK(a1 == 1); 36 | CHECK(a2 == -2); 37 | CHECK(a3 == 3); 38 | 39 | for (i = 0, j = 1, k = 301; i < ARRAY_SIZE(b3.a); i++, j = -1 * j, k++) { 40 | b3.a[i] = j * k; 41 | } 42 | 43 | return b3; 44 | } 45 | 46 | int gcc_func_check1(void) 47 | { 48 | struct big1 b1; 49 | 50 | b1 = ti_func1(1, -2, 3); 51 | CHECK(b1.a[0] == 401); 52 | CHECK(b1.a[1] == -402); 53 | 54 | return 0; 55 | } 56 | 57 | int gcc_func_check2(void) 58 | { 59 | struct big2 b2; 60 | 61 | b2 = ti_func2(1, -2, 3); 62 | CHECK(b2.a[0] == 501); 63 | CHECK(b2.a[1] == -502); 64 | CHECK(b2.a[2] == 503); 65 | 66 | return 0; 67 | } 68 | 69 | int gcc_func_check3(void) 70 | { 71 | struct big3 b3; 72 | unsigned int i; 73 | int j, k; 74 | 75 | b3 = ti_func3(1, -2, 3); 76 | for (i = 0, j = 1, k = 601; i < ARRAY_SIZE(b3.a); i++, j = -1 * j, k++) { 77 | CHECK(b3.a[i] == j * k); 78 | } 79 | 80 | return 0; 81 | } 82 | 83 | int main(void) 84 | { 85 | gcc_func_check1(); 86 | ti_func_check3(); 87 | gcc_func_check2(); 88 | ti_func_check1(); 89 | gcc_func_check3(); 90 | ti_func_check2(); 91 | 92 | return EXIT_SUCCESS; 93 | } 94 | -------------------------------------------------------------------------------- /testing/interop/retval/out/ti-mod.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinuxbg/gnupru/e6a0bad94ae3c5633a0b13bb1726b2d49837739d/testing/interop/retval/out/ti-mod.o -------------------------------------------------------------------------------- /testing/interop/retval/shared.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | struct big1 { 5 | int a[2]; 6 | }; 7 | 8 | struct big2 { 9 | int a[3]; 10 | }; 11 | 12 | struct big3 { 13 | int a[64]; 14 | }; 15 | 16 | struct big1 gcc_func1(signed char a1, short a2, int a3); 17 | struct big2 gcc_func2(signed char a1, short a2, int a3); 18 | struct big3 gcc_func3(signed char a1, short a2, int a3); 19 | 20 | struct big1 ti_func1(signed char a1, short a2, int a3); 21 | struct big2 ti_func2(signed char a1, short a2, int a3); 22 | struct big3 ti_func3(signed char a1, short a2, int a3); 23 | 24 | int ti_func_check1(void); 25 | int ti_func_check2(void); 26 | int ti_func_check3(void); 27 | -------------------------------------------------------------------------------- /testing/interop/retval/ti-mod.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "shared.h" 4 | #include "test.h" 5 | 6 | struct big1 ti_func1(signed char a1, short a2, int a3) 7 | { 8 | struct big1 b1 = { .a = {401, -402}, }; 9 | CHECK(a1 == 1); 10 | CHECK(a2 == -2); 11 | CHECK(a3 == 3); 12 | return b1; 13 | } 14 | 15 | struct big2 ti_func2(signed char a1, short a2, int a3) 16 | { 17 | struct big2 b2 = { .a = {501, -502, 503}, }; 18 | CHECK(a1 == 1); 19 | CHECK(a2 == -2); 20 | CHECK(a3 == 3); 21 | return b2; 22 | } 23 | 24 | struct big3 ti_func3(signed char a1, short a2, int a3) 25 | { 26 | struct big3 b3; 27 | unsigned int i; 28 | int j, k; 29 | 30 | CHECK(a1 == 1); 31 | CHECK(a2 == -2); 32 | CHECK(a3 == 3); 33 | 34 | for (i = 0, j = 1, k = 601; i < ARRAY_SIZE(b3.a); i++, j = -1 * j, k++) { 35 | b3.a[i] = j * k; 36 | } 37 | 38 | return b3; 39 | } 40 | 41 | int ti_func_check1(void) 42 | { 43 | struct big1 b1; 44 | 45 | b1 = gcc_func1(1, -2, 3); 46 | CHECK(b1.a[0] == 101); 47 | CHECK(b1.a[1] == -102); 48 | 49 | return 0; 50 | } 51 | 52 | int ti_func_check2(void) 53 | { 54 | struct big2 b2; 55 | 56 | b2 = gcc_func2(1, -2, 3); 57 | CHECK(b2.a[0] == 201); 58 | CHECK(b2.a[1] == -202); 59 | CHECK(b2.a[2] == 203); 60 | 61 | return 0; 62 | } 63 | 64 | int ti_func_check3(void) 65 | { 66 | struct big3 b3; 67 | unsigned int i; 68 | int j, k; 69 | 70 | b3 = gcc_func3(1, -2, 3); 71 | for (i = 0, j = 1, k = 301; i < ARRAY_SIZE(b3.a); i++, j = -1 * j, k++) { 72 | CHECK(b3.a[i] == j * k); 73 | } 74 | 75 | return 0; 76 | } 77 | 78 | -------------------------------------------------------------------------------- /testing/interop/test.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0])) 6 | 7 | #define CHECK(B) \ 8 | do { \ 9 | if (!(B)) { \ 10 | printf("FAIL: %s: %s:%d\n", \ 11 | TESTCASE, \ 12 | __FILE__, \ 13 | __LINE__); \ 14 | exit(EXIT_FAILURE); \ 15 | } \ 16 | } while (0) 17 | 18 | #if defined(TESTCASE_GCCMOD) 19 | #define FNAME_SELF(N) gcc_ ## N 20 | #define FNAME_PEER(N) ti_ ## N 21 | #else 22 | #define FNAME_SELF(N) ti_ ## N 23 | #define FNAME_PEER(N) gcc_ ## N 24 | #endif 25 | -------------------------------------------------------------------------------- /testing/interop/testcore.inc: -------------------------------------------------------------------------------- 1 | 2 | PRU_CGT ?= /usr 3 | 4 | OUT := out 5 | TARGET := test 6 | 7 | TESTCASE := $(shell basename `pwd`) 8 | 9 | COMMON_CFLAGS := -DTESTCASE=\"$(TESTCASE)\" -I../ 10 | 11 | TI_CFLAGS := -v3 -O2 --display_error_number --endian=little --hardware_mac=on 12 | TI_CFLAGS += -I$(PRU_CGT)/include 13 | # TODO - GNU LD PRU port does not yet support debug REL relocations. 14 | TI_CFLAGS += --symdebug:none 15 | 16 | # Do not put mabi=ti here. We need stdlib to execute 17 | # the tests. We also want to exercise large return values 18 | # when a result is not ignored. Tests have been carefully 19 | # designed to walk the fine line. 20 | # 21 | # But we need some of the option activated by mabi=ti, like 22 | # -mno-relax that guards against missing PRU_S10_PCREL relocations 23 | # in code produced by TI toolchain. 24 | GCC_CFLAGS += -O1 -g -Wall -Wextra -mmcu=sim 25 | GCC_LDFLAGS += -mno-relax 26 | 27 | all: $(OUT)/$(TARGET) 28 | pru-run $< 29 | @echo PASS: $(TESTCASE) 30 | 31 | $(OUT): 32 | mkdir -p $(OUT) 33 | 34 | $(OUT)/ti-mod.o: ti-mod.c $(OUT) $(wildcard *.h) 35 | $(PRU_CGT)/bin/clpru $(TI_CFLAGS) $(COMMON_CFLAGS) -fe $@ $< 36 | 37 | $(OUT)/gcc-main.o: gcc-main.c $(OUT) $(wildcard *.h) 38 | pru-gcc $(GCC_CFLAGS) $(COMMON_CFLAGS) -c -o $@ $< 39 | 40 | $(OUT)/$(TARGET): $(OUT)/ti-mod.o $(OUT)/gcc-main.o 41 | pru-gcc $(GCC_CFLAGS) $(COMMON_CFLAGS) $^ $(GCC_LDFLAGS) -o $@ 42 | 43 | clean: 44 | rm -fr $(OUT) 45 | 46 | $(OUT)/selftest-host: ti-mod.c gcc-main.c | $(OUT) $(wildcard *.h) 47 | gcc -O2 -Wall -Wextra -lm $(COMMON_CFLAGS) $^ -o $@ 48 | 49 | selftest: $(OUT)/selftest-host 50 | ./$< 51 | @echo PASS:host: $(TESTCASE) 52 | 53 | .PHONY: clean selftest 54 | -------------------------------------------------------------------------------- /testing/interop/varargs/Makefile: -------------------------------------------------------------------------------- 1 | include ../testcore.inc 2 | -------------------------------------------------------------------------------- /testing/interop/varargs/gcc-main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "shared.h" 9 | #include "test.h" 10 | 11 | 12 | struct big1 gcc_func1(signed char a1, ...) 13 | { 14 | va_list ap; 15 | struct big1 b1 = { .a = {101, -102}, }; 16 | struct big2 b2; 17 | 18 | CHECK(a1 == 1); 19 | 20 | va_start(ap, a1); 21 | CHECK(va_arg(ap, int) == -2); 22 | CHECK(va_arg(ap, long long) == 0x3132333435363738ll); 23 | b2 = va_arg(ap, struct big2); 24 | CHECK(b2.a[0] == 1801); 25 | CHECK(b2.a[1] == -1802); 26 | CHECK(b2.a[2] == 1803); 27 | va_end(ap); 28 | 29 | return b1; 30 | } 31 | 32 | struct big2 gcc_func2(int a1, int a2, signed char a3, signed char a4, ...) 33 | { 34 | va_list ap; 35 | struct big2 b2 = { .a = {201, -202, 203}, }; 36 | CHECK(a1 == 1); 37 | CHECK(a2 == -2); 38 | CHECK(a3 == 3); 39 | CHECK(a4 == -4); 40 | 41 | va_start(ap, a4); 42 | CHECK(va_arg(ap, int) == 5); 43 | CHECK(va_arg(ap, int) == -6); 44 | CHECK(va_arg(ap, int) == 7); 45 | CHECK(va_arg(ap, long long) == 0x4182838485868788ll); 46 | CHECK(va_arg(ap, int) == -8); 47 | va_end(ap); 48 | 49 | return b2; 50 | } 51 | 52 | struct big3 gcc_func3(signed char a1, int a2, ...) 53 | { 54 | va_list ap; 55 | struct big2 b2; 56 | struct big3 b3; 57 | unsigned int i; 58 | int j, k; 59 | 60 | CHECK(a1 == 1); 61 | CHECK(a2 == -2); 62 | 63 | for (i = 0, j = 1, k = 301; i < ARRAY_SIZE(b3.a); i++, j = -1 * j, k++) { 64 | b3.a[i] = j * k; 65 | } 66 | 67 | va_start(ap, a2); 68 | CHECK(va_arg(ap, int) == 3); 69 | CHECK(va_arg(ap, long long) == 0x5091929394959697ll); 70 | b2 = va_arg(ap, struct big2); 71 | CHECK(b2.a[0] == 1901); 72 | CHECK(b2.a[1] == -1902); 73 | CHECK(b2.a[2] == 1903); 74 | CHECK(va_arg(ap, int) == -444); 75 | va_end(ap); 76 | 77 | return b3; 78 | } 79 | 80 | int gcc_func_check1(void) 81 | { 82 | struct big1 b1; 83 | struct big2 b2 = { .a = { 801, -802, 803 }, }; 84 | 85 | b1 = ti_func1(1, -2, 0x12345678a0b0c0d0ll, b2); 86 | CHECK(b1.a[0] == 401); 87 | CHECK(b1.a[1] == -402); 88 | 89 | return 0; 90 | } 91 | 92 | int gcc_func_check2(void) 93 | { 94 | struct big2 b2; 95 | 96 | b2 = ti_func2(1, -2, 3, -4, 5, -6, 7, 0x1020304050607080ll, -8); 97 | CHECK(b2.a[0] == 501); 98 | CHECK(b2.a[1] == -502); 99 | CHECK(b2.a[2] == 503); 100 | 101 | return 0; 102 | } 103 | 104 | int gcc_func_check3(void) 105 | { 106 | struct big2 b2 = { .a = { 901, -902, 903 }, }; 107 | struct big3 b3; 108 | unsigned int i; 109 | int j, k; 110 | 111 | b3 = ti_func3(11, -22, 33, 0x12345678a0b0c0d0ll, b2, -44); 112 | for (i = 0, j = 1, k = 601; i < ARRAY_SIZE(b3.a); i++, j = -1 * j, k++) { 113 | CHECK(b3.a[i] == j * k); 114 | } 115 | 116 | return 0; 117 | } 118 | 119 | int main(void) 120 | { 121 | gcc_func_check1(); 122 | ti_func_check3(); 123 | gcc_func_check2(); 124 | ti_func_check1(); 125 | gcc_func_check3(); 126 | ti_func_check2(); 127 | 128 | return EXIT_SUCCESS; 129 | } 130 | -------------------------------------------------------------------------------- /testing/interop/varargs/out/ti-mod.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinuxbg/gnupru/e6a0bad94ae3c5633a0b13bb1726b2d49837739d/testing/interop/varargs/out/ti-mod.o -------------------------------------------------------------------------------- /testing/interop/varargs/shared.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | struct big1 { 5 | int a[2]; 6 | }; 7 | 8 | struct big2 { 9 | int a[3]; 10 | }; 11 | 12 | struct big3 { 13 | int a[64]; 14 | }; 15 | 16 | struct big1 gcc_func1(signed char a1, ...); 17 | struct big2 gcc_func2(int a1, int a2, signed char a3, signed char a4, ...); 18 | struct big3 gcc_func3(signed char a1, int a2, ...); 19 | 20 | struct big1 ti_func1(signed char a1, ...); 21 | struct big2 ti_func2(int a1, int a2, signed char a3, signed char a4, ...); 22 | struct big3 ti_func3(signed char a1, int a2, ...); 23 | 24 | int ti_func_check1(void); 25 | int ti_func_check2(void); 26 | int ti_func_check3(void); 27 | -------------------------------------------------------------------------------- /testing/interop/varargs/ti-mod.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "shared.h" 5 | #include "test.h" 6 | 7 | struct big1 ti_func1(signed char a1, ...) 8 | { 9 | va_list ap; 10 | struct big2 b2; 11 | struct big1 b1 = { .a = {401, -402}, }; 12 | CHECK(a1 == 1); 13 | 14 | va_start(ap, a1); 15 | CHECK(va_arg(ap, int) == -2); 16 | CHECK(va_arg(ap, long long) == 0x12345678a0b0c0d0ll); 17 | b2 = va_arg(ap, struct big2); 18 | CHECK(b2.a[0] == 801); 19 | CHECK(b2.a[1] == -802); 20 | CHECK(b2.a[2] == 803); 21 | va_end(ap); 22 | 23 | return b1; 24 | } 25 | 26 | struct big2 ti_func2(int a1, int a2, signed char a3, signed char a4, ...) 27 | { 28 | va_list ap; 29 | struct big2 b2 = { .a = {501, -502, 503}, }; 30 | CHECK(a1 == 1); 31 | CHECK(a2 == -2); 32 | CHECK(a3 == 3); 33 | CHECK(a4 == -4); 34 | 35 | va_start(ap, a4); 36 | CHECK(va_arg(ap, int) == 5); 37 | CHECK(va_arg(ap, int) == -6); 38 | CHECK(va_arg(ap, int) == 7); 39 | CHECK(va_arg(ap, long long) == 0x1020304050607080ll); 40 | CHECK(va_arg(ap, int) == -8); 41 | va_end(ap); 42 | 43 | return b2; 44 | } 45 | 46 | struct big3 ti_func3(signed char a1, int a2, ...) 47 | { 48 | va_list ap; 49 | struct big3 b3; 50 | struct big2 b2; 51 | unsigned int i; 52 | int j, k; 53 | 54 | CHECK(a1 == 11); 55 | CHECK(a2 == -22); 56 | 57 | for (i = 0, j = 1, k = 601; i < ARRAY_SIZE(b3.a); i++, j = -1 * j, k++) { 58 | b3.a[i] = j * k; 59 | } 60 | 61 | va_start(ap, a2); 62 | CHECK(va_arg(ap, int) == 33); 63 | CHECK(va_arg(ap, long long) == 0x12345678a0b0c0d0ll); 64 | b2 = va_arg(ap, struct big2); 65 | CHECK(b2.a[0] == 901); 66 | CHECK(b2.a[1] == -902); 67 | CHECK(b2.a[2] == 903); 68 | CHECK(va_arg(ap, int) == -44); 69 | va_end(ap); 70 | 71 | return b3; 72 | } 73 | 74 | int ti_func_check1(void) 75 | { 76 | struct big1 b1; 77 | struct big2 b2 = { .a = { 1801, -1802, 1803 }, }; 78 | 79 | b1 = gcc_func1(1, -2, 0x3132333435363738ll, b2); 80 | CHECK(b1.a[0] == 101); 81 | CHECK(b1.a[1] == -102); 82 | 83 | return 0; 84 | } 85 | 86 | int ti_func_check2(void) 87 | { 88 | struct big2 b2; 89 | 90 | b2 = gcc_func2(1, -2, 3, -4, 5, -6, 7, 0x4182838485868788ll, -8); 91 | CHECK(b2.a[0] == 201); 92 | CHECK(b2.a[1] == -202); 93 | CHECK(b2.a[2] == 203); 94 | 95 | return 0; 96 | } 97 | 98 | int ti_func_check3(void) 99 | { 100 | struct big2 b2 = { .a = { 1901, -1902, 1903 }, }; 101 | struct big3 b3; 102 | unsigned int i; 103 | int j, k; 104 | 105 | b3 = gcc_func3(1, -2, 3, 0x5091929394959697ll, b2, -444); 106 | for (i = 0, j = 1, k = 301; i < ARRAY_SIZE(b3.a); i++, j = -1 * j, k++) { 107 | CHECK(b3.a[i] == j * k); 108 | } 109 | 110 | return 0; 111 | } 112 | -------------------------------------------------------------------------------- /testing/logdir2bunsen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Given a list of Buildbot Logdir directories, convert them 4 | # to Bunsen [1] tags. Bunsen offers an order of magnitude 5 | # more efficient storage, and more. 6 | # 7 | # [1] git://sourceware.org/git/bunsen.git 8 | 9 | die() 10 | { 11 | echo "ERROR: $@" 12 | exit 1 13 | } 14 | 15 | [ $# -gt 2 ] || die "Usage: $0 TAG GIT-URL LOGDIRS..." 16 | 17 | TAG=${1} 18 | shift 19 | DST=`realpath ${1}` 20 | shift 21 | 22 | [ -d "${DST}" ] || die "${DST} not found. Please create with 'git init --bare'" 23 | which t-upload-git-push >/dev/null || die "Bunsen not found in PATH!" 24 | 25 | LOGDIRS=`realpath $@` 26 | 27 | pushd `mktemp -d` 28 | for d in ${LOGDIRS} 29 | do 30 | rm -f * 31 | cp "${d}"/* . 32 | [ -f pass ] || continue 33 | 34 | # For some reason testrun.log was sometimes kept. 35 | # Remove as it is duplicate of testrun.log.gz. 36 | rm -f testrun.log 37 | 38 | gunzip *.gz 39 | DATE_TAG=`basename "${d}"` 40 | t-upload-git-push "${DST}" bb/${TAG}/${DATE_TAG} *.log *.sum versions.txt 41 | 42 | rm -f * 43 | done 44 | popd 45 | -------------------------------------------------------------------------------- /testing/manual-build-arm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for manual building of gcc+newlib ToT. 6 | # 7 | # It is assumed that source directories are already setup, and 8 | # desired HEADs are checked out. 9 | 10 | BB_ARCH=arm 11 | 12 | # Do not send any email for this session 13 | Mail() 14 | { 15 | true 16 | } 17 | 18 | bb_daily_target_test() 19 | { 20 | local PREV_BUILD_TAG=${1} 21 | local BUILD_TAG=${2} 22 | 23 | bb_clean 24 | 25 | bb_record_git_heads binutils gcc newlib 26 | 27 | # Build binutils 28 | bb_config binutils "--disable-gdb --target=arm-none-eabi" 29 | bb_make binutils "-j`nproc`" 30 | bb_make binutils "install" 31 | 32 | export PATH=${PREFIX}/bin:${PATH} 33 | 34 | # GCC pass 1: no libc yet 35 | bb_config gcc "--target=arm-none-eabi --with-newlib --without-headers --enable-languages=c --enable-checking=yes,rtl --disable-libssp" 36 | bb_make gcc "-j`nproc`" 37 | bb_make gcc "install" 38 | 39 | # Libc 40 | bb_config newlib "--target=arm-none-eabi --enable-newlib-io-long-long --enable-newlib-io-long-double --enable-newlib-io-c99-formats" 41 | bb_make newlib "-j`nproc`" 42 | bb_make newlib "install" 43 | 44 | # GCC pass 2: full feature set 45 | bb_config gcc "--target=arm-none-eabi --with-newlib --enable-languages=c,c++ --enable-checking=yes,rtl --disable-libssp" 46 | bb_make gcc "-j`nproc`" 47 | bb_make gcc "install" 48 | 49 | # Make sure documentation is still in order 50 | # bb_make gcc "pdf" 51 | 52 | # Save all the logs 53 | bb_gather_log_files ${BUILD_TAG} 54 | } 55 | 56 | 57 | . `dirname ${0}`/buildbot-lib.sh 58 | 59 | bb_init_workspace ${@} 60 | bb_init_builddir ${@} 61 | 62 | bb_daily_build 63 | -------------------------------------------------------------------------------- /testing/manual-build-avr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for manual building of local gcc+avr-libc. 6 | 7 | BB_ARCH=avr 8 | 9 | REGRESSION_RECIPIENTS="dinuxbg@gmail.com" 10 | 11 | # Do not send any email for this session 12 | Mail() 13 | { 14 | true 15 | } 16 | 17 | bb_daily_target_test() 18 | { 19 | local PREV_BUILD_TAG=${1} 20 | local BUILD_TAG=${2} 21 | 22 | bb_clean 23 | 24 | bb_record_git_heads binutils gcc avrlibc atest 25 | 26 | # Build binutils 27 | bb_config binutils "--disable-gdb --target=avr" 28 | bb_make binutils "-j`nproc`" 29 | bb_make binutils "install" 30 | 31 | export PATH=${PREFIX}/bin:${PATH} 32 | 33 | bb_config gcc "--target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2" 34 | bb_make gcc "-j`nproc`" 35 | bb_make gcc "install" 36 | 37 | # Libc 38 | (cd ${WORKSPACE}/avrlibc && ./bootstrap) || error "failed to bootstrap avr-libc source" 39 | bb_config avrlibc '--host=avr' 40 | bb_make avrlibc "-j`nproc`" 41 | bb_make avrlibc "install" 42 | } 43 | 44 | 45 | . `dirname ${0}`/buildbot-lib.sh 46 | 47 | bb_init_workspace ${@} 48 | bb_init_builddir ${@} 49 | 50 | bb_daily_build 51 | -------------------------------------------------------------------------------- /testing/manual-build-pru.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for manual building of gcc+newlib ToT. 6 | # 7 | # It is assumed that source directories are already setup, and 8 | # desired HEADs are checked out. 9 | 10 | BB_ARCH=pru 11 | 12 | # Do not send any email for this session 13 | Mail() 14 | { 15 | true 16 | } 17 | 18 | bb_daily_target_test() 19 | { 20 | local PREV_BUILD_TAG=${1} 21 | local BUILD_TAG=${2} 22 | 23 | bb_clean 24 | 25 | bb_record_git_heads binutils gcc newlib 26 | 27 | # Build binutils 28 | bb_config binutils "--disable-gdb --target=pru" 29 | bb_make binutils "-j`nproc`" 30 | bb_make binutils "install" 31 | 32 | export PATH=${PREFIX}/bin:${PATH} 33 | 34 | # GCC pass 1: no libc yet 35 | bb_config gcc "--target=pru --with-newlib --without-headers --enable-languages=c --enable-checking=yes,rtl" 36 | bb_make gcc "-j`nproc`" 37 | bb_make gcc "install" 38 | 39 | # Libc 40 | bb_config newlib "--target=pru --enable-newlib-io-long-long --enable-newlib-io-long-double --enable-newlib-io-c99-formats" 41 | bb_make newlib "-j`nproc`" 42 | bb_make newlib "install" 43 | 44 | # GCC pass 2: full feature set 45 | bb_config gcc "--target=pru --with-newlib --enable-languages=c,c++,rust --enable-checking=yes,rtl" 46 | bb_make gcc "-j`nproc`" 47 | bb_make gcc "install" 48 | 49 | # Make sure documentation is still in order 50 | bb_make gcc "pdf" 51 | 52 | # Save all the logs 53 | bb_gather_log_files ${BUILD_TAG} 54 | } 55 | 56 | 57 | . `dirname ${0}`/buildbot-lib.sh 58 | 59 | bb_init_workspace ${@} 60 | bb_init_builddir ${@} 61 | 62 | bb_daily_build 63 | -------------------------------------------------------------------------------- /testing/manual-build-riscv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for manual building of gcc+newlib ToT. 6 | # 7 | # It is assumed that source directories are already setup, and 8 | # desired HEADs are checked out. 9 | 10 | BB_ARCH=riscv 11 | 12 | BTARGET=riscv-none-elf 13 | 14 | # Do not send any email for this session 15 | Mail() 16 | { 17 | true 18 | } 19 | 20 | bb_daily_target_test() 21 | { 22 | local PREV_BUILD_TAG=${1} 23 | local BUILD_TAG=${2} 24 | 25 | bb_clean 26 | 27 | bb_record_git_heads binutils gcc newlib 28 | 29 | # Build binutils 30 | bb_config binutils "--disable-gdb --target=${BTARGET}" 31 | bb_make binutils "-j`nproc`" 32 | bb_make binutils "install" 33 | 34 | export PATH=${PREFIX}/bin:${PATH} 35 | 36 | # GCC pass 1: no libc yet 37 | bb_config gcc "--target=${BTARGET} --with-newlib --without-headers --enable-languages=c --enable-checking=yes,rtl --disable-libssp" 38 | bb_make gcc "-j`nproc`" 39 | bb_make gcc "install" 40 | 41 | # Libc 42 | bb_config newlib "--target=${BTARGET} --enable-newlib-io-long-long --enable-newlib-io-long-double --enable-newlib-io-c99-formats" 43 | bb_make newlib "-j`nproc`" 44 | bb_make newlib "install" 45 | 46 | # GCC pass 2: full feature set 47 | bb_config gcc "--target=${BTARGET} --with-newlib --enable-languages=c,c++ --enable-checking=yes,rtl --disable-libssp" 48 | bb_make gcc "-j`nproc`" 49 | bb_make gcc "install" 50 | 51 | # Make sure documentation is still in order 52 | # bb_make gcc "pdf" 53 | 54 | # Save all the logs 55 | bb_gather_log_files ${BUILD_TAG} 56 | } 57 | 58 | 59 | . `dirname ${0}`/buildbot-lib.sh 60 | 61 | bb_init_workspace ${@} 62 | bb_init_builddir ${@} 63 | 64 | bb_daily_build 65 | -------------------------------------------------------------------------------- /testing/manual-build-x86_64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for manual building of gcc+glibc ToT. 6 | # 7 | # It is assumed that source directories are already setup, and 8 | # desired HEADs are checked out. 9 | 10 | BB_ARCH=x86_64 11 | 12 | BTARGET=x86_64-pc-linux-gnu 13 | 14 | # Do not send any email for this session 15 | Mail() 16 | { 17 | true 18 | } 19 | 20 | bb_daily_target_test() 21 | { 22 | local PREV_BUILD_TAG=${1} 23 | local BUILD_TAG=${2} 24 | 25 | bb_clean 26 | 27 | bb_record_git_heads binutils gcc glibc 28 | 29 | # Build binutils 30 | bb_config binutils "--disable-gdb --target=${BTARGET}" 31 | bb_make binutils "-j`nproc`" 32 | bb_make binutils "install" 33 | 34 | export PATH=${PREFIX}/bin:${PATH} 35 | 36 | # GCC pass 1: no libc yet 37 | bb_config gcc "--target=${BTARGET} --disable-multilib --without-headers --enable-languages=c --enable-checking=yes,rtl --disable-libssp --disable-gcov --with-sysroot=/" 38 | bb_make gcc "-j`nproc`" 39 | bb_make gcc "install" 40 | 41 | # Libc 42 | bb_config glibc "--target=${BTARGET} --disable-multilib" 43 | bb_make glibc "-j`nproc`" 44 | bb_make glibc "install" 45 | 46 | # libiberty complains about changed LDFLAGS. 47 | bb_make gcc "distclean" 48 | 49 | # GCC pass 2: full feature set 50 | bb_config gcc "--target=${BTARGET} --disable-multilib --enable-languages=c,c++ --enable-checking=yes,rtl --disable-libssp --disable-gcov" 51 | bb_make gcc "-j`nproc`" 52 | bb_make gcc "install" 53 | 54 | # Make sure documentation is still in order 55 | # bb_make gcc "pdf" 56 | 57 | # Save all the logs 58 | bb_gather_log_files ${BUILD_TAG} 59 | } 60 | 61 | 62 | . `dirname ${0}`/buildbot-lib.sh 63 | 64 | bb_init_workspace ${@} 65 | bb_init_builddir ${@} 66 | 67 | bb_daily_build 68 | -------------------------------------------------------------------------------- /testing/manual-test-aarch64_linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for manual building and testing of gcc+glibc ToT. 6 | # 7 | # It is assumed that source directories are already setup, and 8 | # desired HEADs are checked out. 9 | # 10 | # The steps to build a cross linux toolchain were obtained from 11 | # https://github.com/riscv-collab/riscv-gnu-toolchain 12 | 13 | BB_ARCH=aarch64_linux 14 | 15 | #CROSS_TARGET=aarch64-unknown-linux-gnu 16 | CROSS_TARGET=armv8l-unknown-linux-gnueabihf 17 | 18 | # Do not send any email for this session 19 | Mail() 20 | { 21 | true 22 | } 23 | 24 | bb_daily_target_test() 25 | { 26 | local PREV_BUILD_TAG=${1} 27 | local BUILD_TAG=${2} 28 | 29 | bb_clean 30 | 31 | bb_record_git_heads binutils gcc glibc 32 | 33 | # Build binutils 34 | bb_config binutils "--disable-gdb --disable-sim --target=${CROSS_TARGET}" 35 | bb_make binutils "-j`nproc`" 36 | bb_make binutils "install" 37 | 38 | export PATH=${PREFIX}/bin:${PATH} 39 | 40 | # GCC pass 1: no libc yet 41 | bb_config gcc "--target=${CROSS_TARGET} --with-newlib --without-headers --disable-shared --disable-threads --enable-languages=c --disable-libatomic --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --disable-bootstrap" 42 | bb_make gcc "-j`nproc`" inhibit-libc=true all-gcc 43 | bb_make gcc "-j`nproc`" inhibit-libc=true install-gcc 44 | bb_make gcc "-j`nproc`" inhibit-libc=true all-target-libgcc 45 | bb_make gcc "-j`nproc`" inhibit-libc=true install-target-libgcc 46 | 47 | # Linux headers 48 | # TODO - how to obtain them "officially"? 49 | bb_config glibc "--target=${CROSS_TARGET} --enable-shared --with-headers=${WORKSPACE}/linux-headers --disable-multilib --enable-kernel=5.0.0" 50 | bb_make glibc "-j`nproc`" 51 | bb_make glibc "install-headers" 52 | 53 | # Libc 54 | bb_config glibc "--target=${CROSS_TARGET} CC=${CROSS_TARGET}-gcc --disable-werror --enable-shared --enable-obsolete-rpc --with-headers=${WORKSPACE}/linux-headers --enable-kernel=5.0.0" 55 | bb_make glibc "-j`nproc`" 56 | bb_make glibc "install" 57 | 58 | # GCC pass 2: full feature set 59 | bb_config gcc "--target=${CROSS_TARGET} --enable-shared --enable-tls --enable-languages=c,c++,fortran --disable-nls --disable-bootstrap" 60 | bb_make gcc "-j`nproc`" 61 | bb_make gcc "install" 62 | 63 | # Test glibc 64 | bb_make glibc "-j`nproc` check RUNTESTFLAGS=--target_board=qemu" 65 | 66 | # Test GCC 67 | bb_make gcc "-j`nproc` check-gcc-c RUNTESTFLAGS=--target_board=qemu" 68 | bb_make gcc "-j`nproc` check-gcc-c++ RUNTESTFLAGS=--target_board=qemu" 69 | 70 | # Save all the logs 71 | bb_gather_log_files ${BUILD_TAG} 72 | } 73 | 74 | 75 | . `dirname ${0}`/buildbot-lib.sh 76 | 77 | bb_init_workspace ${@} 78 | bb_init_builddir ${@} 79 | 80 | bb_daily_build 81 | -------------------------------------------------------------------------------- /testing/manual-test-avr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for manual building and testing of local gcc+avr-libc. 6 | 7 | BB_ARCH=avr 8 | 9 | REGRESSION_RECIPIENTS="dinuxbg@gmail.com" 10 | 11 | # Do not send any email for this session 12 | Mail() 13 | { 14 | true 15 | } 16 | 17 | bb_daily_target_test() 18 | { 19 | local PREV_BUILD_TAG=${1} 20 | local BUILD_TAG=${2} 21 | 22 | bb_clean 23 | 24 | bb_record_git_heads binutils gcc avrlibc atest 25 | 26 | # Setup avrtest, per: 27 | # https://sourceforge.net/p/winavr/code/HEAD/tree/trunk/avrtest/ 28 | # https://lists.gnu.org/archive/html/avr-gcc-list/2009-09/msg00016.html 29 | export DEJAGNU=${PREFIX}/dejagnurc 30 | mkdir -p `dirname ${DEJAGNU}` 31 | echo "# WARNING - automatically generated!" > ${DEJAGNU} 32 | echo "set avrtest_dir \"${WORKSPACE}/atest\"" >> ${DEJAGNU} 33 | echo "set avrlibc_include_dir \"${PREFIX}/avr/include\"" >> ${DEJAGNU} 34 | echo 'set boards_dir {}' >> ${DEJAGNU} 35 | echo 'lappend boards_dir "${avrtest_dir}/dejagnuboards"' >> ${DEJAGNU} 36 | 37 | # Build binutils 38 | bb_config binutils "--disable-gdb --target=avr" 39 | bb_make binutils "-j`nproc`" 40 | bb_make binutils "install" 41 | 42 | export PATH=${PREFIX}/bin:${PATH} 43 | 44 | bb_config gcc "--target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2" 45 | bb_make gcc "-j`nproc`" 46 | bb_make gcc "install" 47 | 48 | # Libc 49 | (cd ${WORKSPACE}/avrlibc && ./bootstrap) || error "failed to bootstrap avr-libc source" 50 | bb_config avrlibc '--host=avr' 51 | bb_make avrlibc "-j`nproc`" 52 | bb_make avrlibc "install" 53 | 54 | # avrtest 55 | bb_source_command atest "make" 56 | 57 | # Get the simulator under PATH. Needed for gcc test suite. 58 | export PATH=${WORKSPACE}/atest:${PATH} 59 | 60 | # Test binutils. Do not let random test case failures to mark 61 | # the entire build as bad. 62 | bb_config binutils "--disable-gdb --target=avr" 63 | bb_make binutils "-j`nproc`" 64 | bb_make binutils "install" 65 | bb_make --ignore-errors binutils "-k check RUNTESTFLAGS=--target_board=atmega128-sim" 66 | 67 | # Test GCC 68 | bb_make gcc "-j`nproc` check-gcc-c RUNTESTFLAGS=--target_board=atmega128-sim" 69 | bb_make gcc "-j`nproc` check-gcc-c++ RUNTESTFLAGS=--target_board=atmega128-sim" 70 | 71 | # Save all the logs 72 | bb_gather_log_files ${BUILD_TAG} 73 | 74 | } 75 | 76 | 77 | . `dirname ${0}`/buildbot-lib.sh 78 | 79 | bb_init_workspace ${@} 80 | bb_init_builddir ${@} 81 | 82 | bb_daily_build 83 | -------------------------------------------------------------------------------- /testing/manual-test-cris.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for manual building and testing of gcc+newlib ToT. 6 | # 7 | # It is assumed that source directories are already setup, and 8 | # desired HEADs are checked out. 9 | 10 | BB_ARCH=cris 11 | 12 | # Do not send any email for this session 13 | Mail() 14 | { 15 | true 16 | } 17 | 18 | bb_daily_target_test() 19 | { 20 | local PREV_BUILD_TAG=${1} 21 | local BUILD_TAG=${2} 22 | 23 | bb_clean 24 | 25 | bb_record_git_heads binutils gcc newlib 26 | 27 | # Build binutils 28 | bb_config binutils "--disable-gdb --target=cris-unknown-elf" 29 | bb_make binutils "-j`nproc`" 30 | bb_make binutils "install" 31 | # Check binutils without a target C compiler. All tests must pass. 32 | bb_make --ignore-errors binutils "-j`nproc` check RUNTESTFLAGS=--target_board=cris-sim" 33 | 34 | export PATH=${PREFIX}/bin:${PATH} 35 | 36 | # GCC pass 1: no libc yet 37 | bb_config gcc "--target=cris-unknown-elf --with-newlib --without-headers --enable-languages=c --disable-nls --disable-libssp" 38 | bb_make gcc "-j`nproc`" 39 | bb_make gcc "install" 40 | 41 | # Libc 42 | bb_config newlib "--target=cris-unknown-elf --enable-newlib-io-long-long --enable-newlib-io-long-double --enable-newlib-io-c99-formats" 43 | bb_make newlib "-j`nproc`" 44 | bb_make newlib "install" 45 | 46 | # GCC pass 2: full feature set 47 | bb_config gcc "--target=cris-unknown-elf --with-newlib --enable-languages=c,c++ --disable-nls --disable-libssp" 48 | bb_make gcc "-j`nproc`" 49 | bb_make gcc "install" 50 | 51 | ## Make sure documentation is still in order 52 | #bb_make gcc "pdf" 53 | 54 | # Test newlib 55 | bb_make --ignore-errors newlib "-j`nproc` check RUNTESTFLAGS=--target_board=cris-sim" 56 | 57 | # Test GCC 58 | bb_make gcc "-j`nproc` check-gcc-c RUNTESTFLAGS=--target_board=cris-sim" 59 | bb_make gcc "-j`nproc` check-gcc-c++ RUNTESTFLAGS=--target_board=cris-sim" 60 | 61 | # Build binutils again - this time with a C compiler present. 62 | bb_make binutils "distclean" 63 | bb_config binutils "--disable-gdb --target=cris-unknown-elf" 64 | bb_make binutils "-j`nproc`" 65 | bb_make binutils "install" 66 | # Check binutils with a target C compiler. Some tests may fail. 67 | bb_make --ignore-errors binutils "-j`nproc` check RUNTESTFLAGS=--target_board=cris-sim" 68 | 69 | # Save all the logs 70 | bb_gather_log_files ${BUILD_TAG} 71 | } 72 | 73 | 74 | . `dirname ${0}`/buildbot-lib.sh 75 | 76 | bb_init_workspace ${@} 77 | bb_init_builddir ${@} 78 | 79 | bb_daily_build 80 | -------------------------------------------------------------------------------- /testing/manual-test-pru.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for manual building and testing of gcc+newlib ToT. 6 | # 7 | # It is assumed that source directories are already setup, and 8 | # desired HEADs are checked out. 9 | 10 | BB_ARCH=pru 11 | 12 | # Do not send any email for this session 13 | Mail() 14 | { 15 | true 16 | } 17 | 18 | bb_daily_target_test() 19 | { 20 | local PREV_BUILD_TAG=${1} 21 | local BUILD_TAG=${2} 22 | 23 | bb_clean 24 | 25 | bb_record_git_heads binutils gcc newlib 26 | 27 | # Build binutils 28 | bb_config binutils "--disable-gdb --target=pru" 29 | bb_make binutils "-j`nproc`" 30 | bb_make binutils "install" 31 | # Check binutils without a target C compiler. All tests must pass. 32 | bb_make binutils "-j`nproc` check RUNTESTFLAGS=--target_board=pru-sim" 33 | 34 | export PATH=${PREFIX}/bin:${PATH} 35 | 36 | # GCC pass 1: no libc yet 37 | bb_config gcc "--target=pru --with-newlib --without-headers --enable-languages=c --enable-checking=yes,rtl" 38 | bb_make gcc "-j`nproc`" 39 | bb_make gcc "install" 40 | 41 | # Libc 42 | bb_config newlib "--target=pru --enable-newlib-io-long-long --enable-newlib-io-long-double --enable-newlib-io-c99-formats" 43 | bb_make newlib "-j`nproc`" 44 | bb_make newlib "install" 45 | 46 | # GCC pass 2: full feature set 47 | bb_config gcc "--target=pru --with-newlib --enable-languages=c,c++ --enable-checking=yes,rtl" 48 | bb_make gcc "-j`nproc`" 49 | bb_make gcc "install" 50 | 51 | # Make sure documentation is still in order 52 | bb_make gcc "pdf" 53 | 54 | # Test newlib 55 | bb_make newlib "-j`nproc` check RUNTESTFLAGS=--target_board=pru-sim" 56 | 57 | # Test GCC 58 | bb_make gcc "-j`nproc` check-gcc-c RUNTESTFLAGS=--target_board=pru-sim" 59 | bb_make gcc "-j`nproc` check-gcc-c++ RUNTESTFLAGS=--target_board=pru-sim" 60 | 61 | # Build binutils again - this time with a C compiler present. 62 | bb_make binutils "distclean" 63 | bb_config binutils "--disable-gdb --target=pru" 64 | bb_make binutils "-j`nproc`" 65 | bb_make binutils "install" 66 | # Check binutils with a target C compiler. Some tests may fail. 67 | bb_make --ignore-errors binutils "-j`nproc` check RUNTESTFLAGS=--target_board=pru-sim" 68 | 69 | bb_run_embench cc=pru-gcc cflags="-Oz -flto -std=c17" ldflags="" user_libs="m" 70 | 71 | # Save all the logs 72 | bb_gather_log_files ${BUILD_TAG} 73 | } 74 | 75 | 76 | . `dirname ${0}`/buildbot-lib.sh 77 | 78 | bb_init_workspace ${@} 79 | bb_init_builddir ${@} 80 | 81 | bb_daily_build 82 | -------------------------------------------------------------------------------- /testing/manual-test-riscv_rv32ec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Simple script for manual building and testing of gcc+newlib ToT. 6 | # 7 | # It is assumed that source directories are already setup, and 8 | # desired HEADs are checked out. 9 | 10 | BB_ARCH=riscv_rv32ec 11 | 12 | BB_GCC_TARGET_OPTIONS="--target=riscv32-none-elf --with-multilib-generator=rv32ec-ilp32e-- --with-abi=ilp32e --with-arch=rv32ec" 13 | 14 | # Do not send any email for this session 15 | Mail() 16 | { 17 | true 18 | } 19 | 20 | bb_daily_target_test() 21 | { 22 | local PREV_BUILD_TAG=${1} 23 | local BUILD_TAG=${2} 24 | 25 | bb_clean 26 | 27 | bb_record_git_heads binutils gcc newlib 28 | 29 | # Setup testing for RV32EC 30 | export DEJAGNU=${PREFIX}/dejagnurc 31 | mkdir -p `dirname ${DEJAGNU}` 32 | echo "# WARNING - automatically generated!" > ${DEJAGNU} 33 | echo "lappend boards_dir \"${PREFIX}\"" >> ${DEJAGNU} 34 | echo "set_board_info sim,options \"--model RV32EC\"" > ${PREFIX}/riscv-rv32ec-sim.exp 35 | echo "set_board_info cflags \" --specs=sim.specs [libgloss_include_flags] [newlib_include_flags]\"" >> ${PREFIX}/riscv-rv32ec-sim.exp 36 | echo "load_base_board_description \"riscv-sim\"" >> ${PREFIX}/riscv-rv32ec-sim.exp 37 | 38 | # Build binutils 39 | # TODO - re-enable sim building 40 | bb_config binutils "--disable-gdb --disable-sim --target=riscv32-none-elf" 41 | bb_make binutils "-j`nproc`" 42 | bb_make binutils "install" 43 | # Check binutils without a target C compiler. All tests must pass. 44 | # TODO 45 | # bb_make binutils "-j`nproc` check RUNTESTFLAGS=--target_board=riscv-rv32ec-sim" 46 | 47 | export PATH=${PREFIX}/bin:${PATH} 48 | 49 | # GCC pass 1: no libc yet 50 | bb_config gcc "${BB_GCC_TARGET_OPTIONS} --with-newlib --without-headers --enable-languages=c --disable-libssp --enable-checking=yes,rtl" 51 | bb_make gcc "-j`nproc`" 52 | bb_make gcc "install" 53 | 54 | # Libc 55 | bb_config newlib "${BB_GCC_TARGET_OPTIONS} --enable-newlib-io-long-long --enable-newlib-io-long-double --enable-newlib-io-c99-formats" 56 | bb_make newlib "-j`nproc`" 57 | bb_make newlib "install" 58 | 59 | # GCC pass 2: full feature set 60 | bb_config gcc "${BB_GCC_TARGET_OPTIONS} --with-newlib --enable-languages=c,c++ --disable-libssp --enable-checking=yes,rtl" 61 | bb_make gcc "-j`nproc`" 62 | bb_make gcc "install" 63 | 64 | # Make sure documentation is still in order 65 | bb_make gcc "pdf" 66 | 67 | # Test newlib 68 | bb_make newlib "-j`nproc` check RUNTESTFLAGS=--target_board=riscv-rv32ec-sim" 69 | 70 | # Test GCC 71 | bb_make gcc "-j`nproc` check-gcc-c RUNTESTFLAGS=--target_board=riscv-rv32ec-sim" 72 | bb_make gcc "-j`nproc` check-gcc-c++ RUNTESTFLAGS=--target_board=riscv-rv32ec-sim" 73 | 74 | # Build binutils again - this time with a C compiler present. 75 | bb_make binutils "distclean" 76 | # TODO - re-enable sim building 77 | bb_config binutils "--disable-gdb --disable-sim --target=riscv32-none-elf" 78 | bb_make binutils "-j`nproc`" 79 | bb_make binutils "install" 80 | # Check binutils with a target C compiler. Some tests may fail. 81 | bb_make --ignore-errors binutils "-j`nproc` check RUNTESTFLAGS=--target_board=riscv-rv32ec-sim" 82 | 83 | # Save all the logs 84 | bb_gather_log_files ${BUILD_TAG} 85 | } 86 | 87 | 88 | . `dirname ${0}`/buildbot-lib.sh 89 | 90 | bb_init_workspace ${@} 91 | bb_init_builddir ${@} 92 | 93 | bb_daily_build 94 | --------------------------------------------------------------------------------