diff --git a/.github/default_release_notes.md b/.github/default_release_notes.md new file mode 100644 index 0000000..3f2050d --- /dev/null +++ b/.github/default_release_notes.md @@ -0,0 +1,13 @@ +Prebuilt versions of the toolchains. + +To use them, download the appropriate archive and unpack it in your `${HOME}`, +so that the toolchain ends up in (here, for `kindlepw2`) + `${HOME}/x-tools/arm-kindlepw2-linux-gnueabi`. Then add `${HOME}/x-tools/*/bin` +to your `PATH`. + +The `x-compile.sh` script included in this repo can do that (and more) for you. +Using `kindlepw2` as an example toolchain again: +- if you need a persistent custom sysroot (e.g., if you intend to build a full dependency chain): +`source ${PWD}/refs/x-compile.sh kindlepw2 env` +- if you just need a compiler: +`source ${PWD}/refs/x-compile.sh kindlepw2 env bare` diff --git a/.github/workflows/toolchain.yml b/.github/workflows/toolchain.yml index c2b821f..39758ae 100644 --- a/.github/workflows/toolchain.yml +++ b/.github/workflows/toolchain.yml @@ -1,33 +1,79 @@ name: Toolchain +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true on: [push, pull_request, workflow_dispatch] jobs: + toolchain: - runs-on: ubuntu-20.04 + + runs-on: ubuntu-latest + container: + image: koreader/kobase:0.4.0-22.04 strategy: + fail-fast: false matrix: - tc: [kindle, kindle5, kindlepw2, kindlehf, kobo, kobov4, kobov5, nickel, remarkable, cervantes, pocketbook, bookeen] + tc: [kindle, kindle5, kindlepw2, kindlehf, kobo, kobov4, kobov5, nickel, remarkable, remarkable-aarch64, cervantes, pocketbook, bookeen] steps: - - name: Check out Git repository + - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 submodules: recursive - - name: Install Deps - run: sudo apt-get install build-essential autoconf automake bison flex gawk libtool libtool-bin libncurses-dev curl file git gperf help2man texinfo unzip wget + - name: Install deps + run: | + sudo apt-get update + sudo apt-get install --no-install-recommends -y bison flex gawk gperf help2man libncurses-dev libtool-bin rsync texinfo - - name: gen-tc + - name: Generate toolchain run: ./gen-tc.sh ${{ matrix.tc }} - - name: tar + - name: Tar artifacts run: tar -C ~ -czf ${{ matrix.tc }}.tar.gz x-tools - - name: Uploading artifacts + - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: ${{ matrix.tc }} path: ${{ matrix.tc }}.tar.gz + + release: + + if: ${{ !cancelled() && startsWith(github.ref, 'refs/tags/') }} + needs: toolchain + + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: artifacts + + - name: Create release + env: + GH_TOKEN: ${{ github.token }} + run: | + # Check if release already exists. + gh release list --json name,tagName,isDraft,createdAt,publishedAt | jq --color-output --exit-status --raw-output '.[] | select(.tagName == "${{ github.ref_name }}") | if .tagName == "" then halt_error end' || + # And create it if it does not. + gh release create '${{ github.ref_name }}' --draft --notes-file .github/default_release_notes.md --title 'koxtoolchain ${{ github.ref_name }}' --verify-tag + + - name: Upload release artifacts + env: + GH_TOKEN: ${{ github.token }} + run: gh release upload '${{ github.ref_name }}' artifacts/* --clobber diff --git a/gen-tc.sh b/gen-tc.sh index acb36fd..ccb57ec 100755 --- a/gen-tc.sh +++ b/gen-tc.sh @@ -181,4 +181,4 @@ case $1 in echo "${HELP_MSG}" exit 1 ;; -esac +esac \ No newline at end of file diff --git a/refs/x-compile.sh b/refs/x-compile.sh index da3bde8..bd401b5 100755 --- a/refs/x-compile.sh +++ b/refs/x-compile.sh @@ -52,6 +52,9 @@ case ${1} in remarkable | reMarkable | Remarkable ) KINDLE_TC="REMARKABLE" ;; + remarkable-aarch64 ) + KINDLE_TC="REMARKABLE_AARCH64" + ;; pocketbook | pb | PB ) KINDLE_TC="PB" ;; @@ -625,6 +628,70 @@ case ${KINDLE_TC} in DEVICE_USERSTORE="/home/root" ;; + REMARKABLE_AARCH64 ) + ARCH_FLAGS="-march=armv8-a+crc+crypto -mtune=cortex-a53" + CROSS_TC="aarch64-remarkable-linux-gnu" + TC_BUILD_DIR="${HOME}/Kindle/CrossTool/Build_${KINDLE_TC}" + + # Export it for our CMakeCross TC file + export CROSS_TC + export TC_BUILD_DIR + + export CROSS_PREFIX="${CROSS_TC}-" + export PATH="${HOME}/x-tools/${CROSS_TC}/bin:${PATH}" + + ## NOTE: Upstream is (currently) using GCC 7.3, so we have no potential C++ ABI issue to take care of :) + + BASE_CFLAGS="-O3 -ffast-math ${ARCH_FLAGS} -pipe -fomit-frame-pointer -frename-registers -fweb -flto=${AUTO_JOBS} -fuse-linker-plugin" + NOLTO_CFLAGS="-O3 -ffast-math ${ARCH_FLAGS} -pipe -fomit-frame-pointer -frename-registers -fweb" + ## Here be dragons! + RICE_CFLAGS="-O3 -ffast-math -ftree-vectorize -funroll-loops ${ARCH_FLAGS} -pipe -fomit-frame-pointer -frename-registers -fweb -flto=${AUTO_JOBS} -fuse-linker-plugin" + + ## NOTE: Check if LTO still horribly breaks some stuff... + ## NOTE: See https://gcc.gnu.org/gcc-4.9/changes.html for the notes about building LTO-enabled static libraries... (gcc-ar/gcc-ranlib) + ## NOTE: And see https://gcc.gnu.org/gcc-5/changes.html to rejoice because we don't have to care about broken build-systems with mismatched compile/link time flags anymore :). + export AR="${CROSS_TC}-gcc-ar" + export RANLIB="${CROSS_TC}-gcc-ranlib" + export NM="${CROSS_TC}-gcc-nm" + ## NOTE: Also, BOLO for packages thant link with $(CC) $(LDFLAGS) (ie. without CFLAGS). This is BAD. One (dirty) workaround if you can't fix the package is to append CFLAGS to the end of LDFLAGS... :/ + ## NOTE: ... although GCC 5 should handle this in a transparent & sane manner, so, yay :). + #BASE_CFLAGS="${NOLTO_CFLAGS}" + export CFLAGS="${BASE_CFLAGS}" + export CXXFLAGS="${BASE_CFLAGS}" + # NOTE: Use -isystem instead of -I to make sure GMP doesn't do crazy stuff... (FIXME: -idirafter sounds more correct for our use-case, though...) + BASE_CPPFLAGS="-isystem${TC_BUILD_DIR}/include" + export CPPFLAGS="${BASE_CPPFLAGS}" + BASE_LDFLAGS="-L${TC_BUILD_DIR}/lib -Wl,-O1 -Wl,--as-needed" + # NOTE: Dirty LTO workaround (cf. earlier). All hell might break loose if we tweak CFLAGS for some packages... + #BASE_LDFLAGS="${BASE_CFLAGS} ${BASE_LDFLAGS}" + export LDFLAGS="${BASE_LDFLAGS}" + + # NOTE: We're no longer using the gold linker by default... + # FIXME: Because for some mysterious reason, gold + LTO leads to an unconditional dynamic link against libgcc_s (uless -static-libgcc is passed, of course). + export CTNG_LD_IS="bfd" + + ## NOTE: We jump through terrible hoops to counteract libtool's stripping of 'unknown' or 'harmful' FLAGS... (cf. https://www.gnu.org/software/libtool/manual/html_node/Stripped-link-flags.html) + ## That's a questionable behavior that is bound to screw up LTO in fun and interesting ways, at the very least on the performance aspect of things... + ## Store those in the right format here, and apply patches or tricks to anything using libtool, because of course it's a syntax that gcc doesn't know about, so we can't simply put it in the global LDFLAGS.... -_-". + ## And since autotools being autotools, it's used in various completely idiosyncratic ways, we can't always rely on simply overriding AM_LDFLAGS... + ## NOTE: Hopefully, GCC 5's smarter LTO handling means we don't have to care about that anymore... :). + export XC_LINKTOOL_CFLAGS="-Wc,-ffast-math -Wc,-fomit-frame-pointer -Wc,-frename-registers -Wc,-fweb" + + BASE_HACKDIR="${SVN_ROOT}/Configs/trunk/Kindle/rM_aarch64_Hacks" + + # We always rely on the native pkg-config, with custom search paths + BASE_PKG_CONFIG="pkg-config" + export PKG_CONFIG="${BASE_PKG_CONFIG}" + BASE_PKG_CONFIG_LIBDIR="${TC_BUILD_DIR}/lib/pkgconfig" + export PKG_CONFIG_PATH="" + export PKG_CONFIG_LIBDIR="${BASE_PKG_CONFIG_LIBDIR}" + + ## CMake is hell. + export CMAKE="cmake -DCMAKE_TOOLCHAIN_FILE=${SCRIPTS_BASE_DIR}/CMakeCross.txt -DCMAKE_INSTALL_PREFIX=${TC_BUILD_DIR}" + + DEVICE_USERSTORE="/home/root" + ;; + PB ) # NOTE: The TC itself is built in ARM mode, otherwise glibc 2.9 doesn't build (fails with a "r15 not allowed here" assembler error on csu/libc-start.o during the early multilib start-files step). # AFAICT, the official SDK doesn't make a specific choice on that front (i.e., it passes neither -marm not -mthumb. That usually means ARM)...