From cd50f9e3aaef13ea5353a71795a0a293c2e090a5 Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Fri, 10 Jan 2025 22:03:28 +0100 Subject: [PATCH 1/9] Fix kindlehf on PW4 (#46) Uses A9 instead of A7. See and . --- gen-tc.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/gen-tc.sh b/gen-tc.sh index a1e2e80..18a2b92 100755 --- a/gen-tc.sh +++ b/gen-tc.sh @@ -111,43 +111,43 @@ case $1 in kobov5) Build_CT-NG \ https://github.com/NiLuJe/crosstool-ng.git \ - a221b564b965cb3ea79d0145ee3e085d354ed5fa \ + 62fb5946719c24dd38c1f41a35a7f8bdf35462d6 \ "arm-${1}-linux-gnueabihf" ;; kobov4) Build_CT-NG \ https://github.com/NiLuJe/crosstool-ng.git \ - a221b564b965cb3ea79d0145ee3e085d354ed5fa \ + 62fb5946719c24dd38c1f41a35a7f8bdf35462d6 \ "arm-${1}-linux-gnueabihf" ;; kobo) Build_CT-NG \ https://github.com/NiLuJe/crosstool-ng.git \ - a221b564b965cb3ea79d0145ee3e085d354ed5fa \ + 62fb5946719c24dd38c1f41a35a7f8bdf35462d6 \ "arm-${1}-linux-gnueabihf" ;; nickel) Build_CT-NG \ https://github.com/NiLuJe/crosstool-ng.git \ - a221b564b965cb3ea79d0145ee3e085d354ed5fa \ + 62fb5946719c24dd38c1f41a35a7f8bdf35462d6 \ "arm-${1}-linux-gnueabihf" ;; kindlehf) Build_CT-NG \ https://github.com/NiLuJe/crosstool-ng.git \ - a221b564b965cb3ea79d0145ee3e085d354ed5fa \ + 62fb5946719c24dd38c1f41a35a7f8bdf35462d6 \ "arm-${1}-linux-gnueabihf" ;; kindlepw2) Build_CT-NG \ https://github.com/NiLuJe/crosstool-ng.git \ - a221b564b965cb3ea79d0145ee3e085d354ed5fa \ + 62fb5946719c24dd38c1f41a35a7f8bdf35462d6 \ "arm-${1}-linux-gnueabi" ;; kindle5) Build_CT-NG \ https://github.com/NiLuJe/crosstool-ng.git \ - a221b564b965cb3ea79d0145ee3e085d354ed5fa \ + 62fb5946719c24dd38c1f41a35a7f8bdf35462d6 \ "arm-${1}-linux-gnueabi" ;; kindle) @@ -156,20 +156,20 @@ case $1 in Build_CT-NG \ https://github.com/NiLuJe/crosstool-ng.git \ - a221b564b965cb3ea79d0145ee3e085d354ed5fa \ + 62fb5946719c24dd38c1f41a35a7f8bdf35462d6 \ "arm-${1}-linux-gnueabi" unset glibcxx_cv_utimensat ;; remarkable) Build_CT-NG \ https://github.com/NiLuJe/crosstool-ng.git \ - a221b564b965cb3ea79d0145ee3e085d354ed5fa \ + 62fb5946719c24dd38c1f41a35a7f8bdf35462d6 \ "arm-${1}-linux-gnueabihf" ;; cervantes) Build_CT-NG \ https://github.com/NiLuJe/crosstool-ng.git \ - a221b564b965cb3ea79d0145ee3e085d354ed5fa \ + 62fb5946719c24dd38c1f41a35a7f8bdf35462d6 \ "arm-${1}-linux-gnueabi" ;; pocketbook) @@ -178,7 +178,7 @@ case $1 in Build_CT-NG \ https://github.com/NiLuJe/crosstool-ng.git \ - a221b564b965cb3ea79d0145ee3e085d354ed5fa \ + 62fb5946719c24dd38c1f41a35a7f8bdf35462d6 \ "arm-${1}-linux-gnueabi" # Then, pull InkView from the (old) official SDK... # NOTE: See also https://github.com/pocketbook/SDK_6.3.0/tree/5.19/SDK-iMX6/usr/arm-obreey-linux-gnueabi/sysroot/usr/local for newer FWs... @@ -223,7 +223,7 @@ case $1 in bookeen) Build_CT-NG \ https://github.com/NiLuJe/crosstool-ng.git \ - a221b564b965cb3ea79d0145ee3e085d354ed5fa \ + 62fb5946719c24dd38c1f41a35a7f8bdf35462d6 \ "arm-${1}-linux-gnueabi" ;; *) From e810ea18fe6c28279ad6d48c0f0a9fa044c2e33d Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Sat, 19 Apr 2025 02:25:03 +0900 Subject: [PATCH 2/9] Add reMarkable Paper Pro support (#48) --- gen-tc.sh | 7 +++++ refs/x-compile.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/gen-tc.sh b/gen-tc.sh index 18a2b92..70806fd 100755 --- a/gen-tc.sh +++ b/gen-tc.sh @@ -92,6 +92,7 @@ Supported platforms: kobov5 nickel remarkable + remarkable-aarch64 cervantes pocketbook bookeen @@ -166,6 +167,12 @@ case $1 in 62fb5946719c24dd38c1f41a35a7f8bdf35462d6 \ "arm-${1}-linux-gnueabihf" ;; + remarkable-aarch64) + Build_CT-NG \ + https://github.com/NiLuJe/crosstool-ng.git \ + 9d4156d109d22e9b0e8958e56bbbd947cd7ce065 \ + "aarch64-remarkable-linux-gnu" + ;; cervantes) Build_CT-NG \ https://github.com/NiLuJe/crosstool-ng.git \ 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)... From 0a6ed78eb00634198e599f3bf642aa18a32ebc0c Mon Sep 17 00:00:00 2001 From: Noa Himesaka Date: Sun, 20 Apr 2025 00:16:51 +0900 Subject: [PATCH 3/9] feat: build remarkable-aarch64 on workflow too (#49) --- .github/workflows/toolchain.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/toolchain.yml b/.github/workflows/toolchain.yml index 37fd9c3..b6a9ae7 100644 --- a/.github/workflows/toolchain.yml +++ b/.github/workflows/toolchain.yml @@ -8,7 +8,7 @@ jobs: strategy: 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 From 00879109030346ab996fe925301395e261b86e99 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 22 Apr 2025 01:44:50 +0200 Subject: [PATCH 4/9] ci: disable crosstools-ng build progress bar No point in filling-up the logs. --- gen-tc.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gen-tc.sh b/gen-tc.sh index 70806fd..f07a0a0 100755 --- a/gen-tc.sh +++ b/gen-tc.sh @@ -62,6 +62,9 @@ Build_CT-NG() { ct-ng oldconfig ct-ng upgradeconfig ct-ng updatetools + if [ -n "${CI}" ]; then + sed -i 's/^CT_LOG_PROGRESS_BAR=y/CT_LOG_PROGRESS_BAR=n/' .config + fi nice ct-ng build echo "" echo "[INFO ] =================================================================" From f39799d3488bceb7f200f37b584e95dff36edfdd Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 22 Apr 2025 01:44:51 +0200 Subject: [PATCH 5/9] ci: cancel old workflows When building the same ref. --- .github/workflows/toolchain.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/toolchain.yml b/.github/workflows/toolchain.yml index b6a9ae7..2152b8d 100644 --- a/.github/workflows/toolchain.yml +++ b/.github/workflows/toolchain.yml @@ -1,5 +1,9 @@ name: Toolchain +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: [push, pull_request] jobs: From f466ac3a15a25b2c74366c4df44b6fe44e67b0f7 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 22 Apr 2025 01:44:52 +0200 Subject: [PATCH 6/9] ci: disable fail fast --- .github/workflows/toolchain.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/toolchain.yml b/.github/workflows/toolchain.yml index 2152b8d..e96f4e3 100644 --- a/.github/workflows/toolchain.yml +++ b/.github/workflows/toolchain.yml @@ -11,6 +11,7 @@ jobs: runs-on: ubuntu-20.04 strategy: + fail-fast: false matrix: tc: [kindle, kindle5, kindlepw2, kindlehf, kobo, kobov4, kobov5, nickel, remarkable, remarkable-aarch64, cervantes, pocketbook, bookeen] From a319a154af48288b4e41252a896cd46883c349fb Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 22 Apr 2025 01:44:53 +0200 Subject: [PATCH 7/9] ci: switch to building under our docker base image --- .github/workflows/toolchain.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/toolchain.yml b/.github/workflows/toolchain.yml index e96f4e3..fea4280 100644 --- a/.github/workflows/toolchain.yml +++ b/.github/workflows/toolchain.yml @@ -8,7 +8,9 @@ on: [push, pull_request] jobs: toolchain: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest + container: + image: koreader/kobase:0.4.0-22.04 strategy: fail-fast: false @@ -16,18 +18,20 @@ jobs: 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 - - 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 From fdba8ca6e52980359dbe25f2c3ed5bae71c92044 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 10 May 2025 16:33:07 +0200 Subject: [PATCH 8/9] ci: add release job (#54) --- .github/default_release_notes.md | 13 ++++++++++ .github/workflows/toolchain.yml | 42 ++++++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 .github/default_release_notes.md 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 fea4280..2151617 100644 --- a/.github/workflows/toolchain.yml +++ b/.github/workflows/toolchain.yml @@ -7,7 +7,9 @@ concurrency: on: [push, pull_request] jobs: + toolchain: + runs-on: ubuntu-latest container: image: koreader/kobase:0.4.0-22.04 @@ -21,7 +23,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 1 - name: Install deps run: | @@ -34,8 +36,44 @@ jobs: - 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 From a0f009e302c4f7a6c06df01cb8e2904cd411d888 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 10 May 2025 20:47:51 +0200 Subject: [PATCH 9/9] tweak curl / wget options for better feedback (particularly on error) (#55) --- gen-tc.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/gen-tc.sh b/gen-tc.sh index f07a0a0..cbdc547 100755 --- a/gen-tc.sh +++ b/gen-tc.sh @@ -54,18 +54,24 @@ Build_CT-NG() { tmp_str="${tc_target#*-}" TC_BUILD_DIR="${tmp_str%%-*}" [ ! -d "${TC_BUILD_DIR}" ] && mkdir -p "${TC_BUILD_DIR}" + ct_ng=( + ct-ng + # Tweak curl / wget options for better feedback (particularly on error). + curl_silent_opt='' + wget_silent_opt='--progress=dot:mega' + ) pushd "${TC_BUILD_DIR}" - ct-ng distclean + "${ct_ng[@]}" distclean unset CFLAGS CXXFLAGS LDFLAGS - ct-ng "${tc_target}" - ct-ng oldconfig - ct-ng upgradeconfig - ct-ng updatetools + "${ct_ng[@]}" "${tc_target}" + "${ct_ng[@]}" oldconfig + "${ct_ng[@]}" upgradeconfig + "${ct_ng[@]}" updatetools if [ -n "${CI}" ]; then sed -i 's/^CT_LOG_PROGRESS_BAR=y/CT_LOG_PROGRESS_BAR=n/' .config fi - nice ct-ng build + nice "${ct_ng[@]}" build echo "" echo "[INFO ] =================================================================" echo "[INFO ] Build done. Please add $HOME/x-tools/${tc_target}/bin to your PATH."