From a0feac6cf46e4035affd75220db70694861fc564 Mon Sep 17 00:00:00 2001 From: theofficialgman <28281419+theofficialgman@users.noreply.github.com> Date: Tue, 18 Jul 2023 19:33:21 -0400 Subject: [PATCH 1/2] feat: add armv7l and arm64 bionic based cross compiled builds --- README.md | 4 ++- bin/build.sh | 2 ++ recipes/arm64-glibc-227/Dockerfile | 36 ++++++++++++++++++++++++ recipes/arm64-glibc-227/run.sh | 36 ++++++++++++++++++++++++ recipes/arm64-glibc-227/should-build.sh | 10 +++++++ recipes/armv7l-glibc-227/Dockerfile | 36 ++++++++++++++++++++++++ recipes/armv7l-glibc-227/run.sh | 36 ++++++++++++++++++++++++ recipes/armv7l-glibc-227/should-build.sh | 10 +++++++ 8 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 recipes/arm64-glibc-227/Dockerfile create mode 100755 recipes/arm64-glibc-227/run.sh create mode 100755 recipes/arm64-glibc-227/should-build.sh create mode 100644 recipes/armv7l-glibc-227/Dockerfile create mode 100755 recipes/armv7l-glibc-227/run.sh create mode 100755 recipes/armv7l-glibc-227/should-build.sh diff --git a/README.md b/README.md index f209b45..4a64836 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,11 @@ This list of officially supported platforms is available in the Node.js [BUILDIN ## Builds * **linux-x64-musl**: Linux x64 binaries compiled against [musl libc](https://www.musl-libc.org/) version 1.1.20. Primarily useful for users of Alpine Linux 3.9 and later. Linux x64 with musl is considered "Experimental" by Node.js but the Node.js test infrastructure includes some Alpine test servers so support is generally good. These Node.js builds require the `libstdc++` package to be installed on Alpine Linux, which is not installed by default. You can add this by running `apk add libstdc++`. -* **linux-x64-glibc-217**: Linux x64, compiled with glibc 2.17 to support [older Linux distros](https://en.wikipedia.org/wiki/Glibc#Version_history), QNAP QTS 4.x and 5.x, and Synology DSM 7, and other environments where a newer glibc is unavailable. + * **linux-x64-glibc-217**: Linux x64, compiled with glibc 2.17 to support [older Linux distros](https://en.wikipedia.org/wiki/Glibc#Version_history), QNAP QTS 4.x and 5.x, and Synology DSM 7, and other environments where a newer glibc is unavailable. * **linux-x86**: Linux x86 (32-bit) binaries compiled against libc 2.17, similar to the way the official [linux-x64 binaries are produced](https://github.com/nodejs/node/blob/master/BUILDING.md#official-binary-platforms-and-toolchains). 32-bit Linux binaries were dropped for Node.js 10 and 32-bit support is now considered "Experimental". * **linux-armv6l**: Linux ARMv6 binaries, cross-compiled on Ubuntu 16.04 with a [custom GCC 6 toolchain](https://github.com/rvagg/rpi-newer-crosstools) (for Node.js versions earlier than 16) or Ubuntu 18.04 with a [custom GCC 8 toolchain](https://github.com/rvagg/rpi-newer-crosstools) (for Node.js 16 and later) in a similar manner to the official linux-armv7l binaries. Binaries are optimized for `armv6zk` which is suitable for Raspberry Pi devices (1, 1+ and Zero in particular). ARMv6 binaries were dropped from Node.js 12 and ARMv6 support is now considered "Experimental". + * **linux-armv7l-glibc-227**: Linux ARMv7 binaries, cross-compiled on Ubuntu 18.04 with the default GCC-8. + * **linux-arm64-glibc-227**: Linux ARM64 binaries, cross-compiled on Ubuntu 18.04 with the default GCC-8. * **riscv64**: Linux riscv64 (RISC-V), cross compiled on Ubuntu 20.04 with the toolchain which the Adoptium project uses (for now...). Built with --openssl-no-asm (Should be with --with-intl=none but that gets overriden) * **loong64**: Linux loong64 (LoongArch64), cross compiled on Ubuntu 20.04 with the toolchain. diff --git a/bin/build.sh b/bin/build.sh index aca23d3..c896dca 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -13,6 +13,8 @@ recipes=" \ x86 \ musl \ armv6l \ + armv7l-glibc-227 \ + arm64-glibc-227 \ x64-glibc-217 \ x64-pointer-compression \ x64-usdt \ diff --git a/recipes/arm64-glibc-227/Dockerfile b/recipes/arm64-glibc-227/Dockerfile new file mode 100644 index 0000000..7716fbb --- /dev/null +++ b/recipes/arm64-glibc-227/Dockerfile @@ -0,0 +1,36 @@ +FROM ubuntu:18.04 + +ARG GID=1000 +ARG UID=1000 + +RUN addgroup --gid $GID node \ + && adduser --gid $GID --uid $UID --disabled-password --gecos node node + +RUN apt-get update \ + && apt-get dist-upgrade -y \ + && apt-get update \ + && apt-get install -y \ + git \ + curl \ + gcc-8 \ + g++-8 \ + gcc-8-aarch64-linux-gnu \ + g++-8-aarch64-linux-gnu \ + binutils-aarch64-linux-gnu \ + libstdc++-8-dev-amd64-cross \ + linux-libc-dev-arm64-cross linux-libc-dev-amd64-cross \ + make \ + python3 \ + python3-distutils \ + ccache \ + xz-utils + +COPY --chown=node:node run.sh /home/node/run.sh + +VOLUME /home/node/.ccache +VOLUME /out +VOLUME /home/node/node.tar.xz + +USER node + +ENTRYPOINT [ "/home/node/run.sh" ] diff --git a/recipes/arm64-glibc-227/run.sh b/recipes/arm64-glibc-227/run.sh new file mode 100755 index 0000000..5c73952 --- /dev/null +++ b/recipes/arm64-glibc-227/run.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +set -e +set -x + +release_urlbase="$1" +disttype="$2" +customtag="$3" +datestring="$4" +commit="$5" +fullversion="$6" +source_url="$7" +config_flags= + +cd /home/node + +tar -xf node.tar.xz +cd "node-${fullversion}" + +export CC_host="ccache gcc-8" +export CXX_host="ccache g++-8" +export CC="ccache aarch64-linux-gnu-gcc-8" +export CXX="ccache aarch64-linux-gnu-g++-8" + +make -j$(getconf _NPROCESSORS_ONLN) binary V= \ + DESTCPU="arm64" \ + ARCH="arm64" \ + VARIATION="" \ + DISTTYPE="$disttype" \ + CUSTOMTAG="$customtag" \ + DATESTRING="$datestring" \ + COMMIT="$commit" \ + RELEASE_URLBASE="$release_urlbase" \ + CONFIG_FLAGS="$config_flags" + +mv node-*.tar.?z /out/ diff --git a/recipes/arm64-glibc-227/should-build.sh b/recipes/arm64-glibc-227/should-build.sh new file mode 100755 index 0000000..2453d49 --- /dev/null +++ b/recipes/arm64-glibc-227/should-build.sh @@ -0,0 +1,10 @@ +#!/bin/bash -xe + +__dirname=$1 +fullversion=$2 + +. ${__dirname}/_decode_version.sh + +decode "$fullversion" + +test "$major" -ge "18" diff --git a/recipes/armv7l-glibc-227/Dockerfile b/recipes/armv7l-glibc-227/Dockerfile new file mode 100644 index 0000000..80b5096 --- /dev/null +++ b/recipes/armv7l-glibc-227/Dockerfile @@ -0,0 +1,36 @@ +FROM ubuntu:18.04 + +ARG GID=1000 +ARG UID=1000 + +RUN addgroup --gid $GID node \ + && adduser --gid $GID --uid $UID --disabled-password --gecos node node + +RUN apt-get update \ + && apt-get dist-upgrade -y \ + && apt-get update \ + && apt-get install -y \ + git \ + curl \ + gcc-8 \ + g++-8 \ + gcc-8-arm-linux-gnueabihf \ + g++-8-arm-linux-gnueabihf \ + binutils-arm-linux-gnueabihf \ + lib32stdc++-8-dev libstdc++-8-dev-amd64-cross libstdc++-8-dev-x32-cross libx32stdc++-8-dev libstdc++-8-dev-i386-cross \ + linux-libc-dev-armhf-cross linux-libc-dev-amd64-cross linux-libc-dev-x32-cross linux-libc-dev-i386-cross \ + make \ + python3 \ + python3-distutils \ + ccache \ + xz-utils + +COPY --chown=node:node run.sh /home/node/run.sh + +VOLUME /home/node/.ccache +VOLUME /out +VOLUME /home/node/node.tar.xz + +USER node + +ENTRYPOINT [ "/home/node/run.sh" ] diff --git a/recipes/armv7l-glibc-227/run.sh b/recipes/armv7l-glibc-227/run.sh new file mode 100755 index 0000000..d0f901d --- /dev/null +++ b/recipes/armv7l-glibc-227/run.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +set -e +set -x + +release_urlbase="$1" +disttype="$2" +customtag="$3" +datestring="$4" +commit="$5" +fullversion="$6" +source_url="$7" +config_flags= + +cd /home/node + +tar -xf node.tar.xz +cd "node-${fullversion}" + +export CC_host="ccache gcc-8 -m32" +export CXX_host="ccache g++-8 -m32" +export CC="ccache arm-linux-gnueabihf-gcc-8" +export CXX="ccache arm-linux-gnueabihf-g++-8" + +make -j$(getconf _NPROCESSORS_ONLN) binary V= \ + DESTCPU="arm" \ + ARCH="armv7l" \ + VARIATION="" \ + DISTTYPE="$disttype" \ + CUSTOMTAG="$customtag" \ + DATESTRING="$datestring" \ + COMMIT="$commit" \ + RELEASE_URLBASE="$release_urlbase" \ + CONFIG_FLAGS="$config_flags" + +mv node-*.tar.?z /out/ diff --git a/recipes/armv7l-glibc-227/should-build.sh b/recipes/armv7l-glibc-227/should-build.sh new file mode 100755 index 0000000..2453d49 --- /dev/null +++ b/recipes/armv7l-glibc-227/should-build.sh @@ -0,0 +1,10 @@ +#!/bin/bash -xe + +__dirname=$1 +fullversion=$2 + +. ${__dirname}/_decode_version.sh + +decode "$fullversion" + +test "$major" -ge "18" From c45cc02db8c1ccc99b56f099c929770db6abf52a Mon Sep 17 00:00:00 2001 From: theofficialgman <28281419+theofficialgman@users.noreply.github.com> Date: Tue, 18 Jul 2023 19:58:21 -0400 Subject: [PATCH 2/2] add patch until upstream arm64 cross compilation is fixed see https://github.com/nodejs/node/pull/45756 --- recipes/arm64-glibc-227/run.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/recipes/arm64-glibc-227/run.sh b/recipes/arm64-glibc-227/run.sh index 5c73952..b40a10d 100755 --- a/recipes/arm64-glibc-227/run.sh +++ b/recipes/arm64-glibc-227/run.sh @@ -17,6 +17,40 @@ cd /home/node tar -xf node.tar.xz cd "node-${fullversion}" +# see https://github.com/nodejs/node/pull/45756 +cat << "EOF" > correct-cflags.patch +diff --git a/configure.py b/configure.py +index a6dae354d4233..e2bb9dce12795 100755 +--- a/configure.py ++++ b/configure.py +@@ -1247,9 +1247,7 @@ def configure_node(o): + + o['variables']['want_separate_host_toolset'] = int(cross_compiling) + +- # Enable branch protection for arm64 + if target_arch == 'arm64': +- o['cflags']+=['-msign-return-address=all'] + o['variables']['arm_fpu'] = options.arm_fpu or 'neon' + + if options.node_snapshot_main is not None: +diff --git a/node.gyp b/node.gyp +index 448cb8a8c7cd4..6cec024ffe722 100644 +--- a/node.gyp ++++ b/node.gyp +@@ -109,6 +109,9 @@ + }, + + 'conditions': [ ++ ['target_arch=="arm64"', { ++ 'cflags': ['-msign-return-address=all'], # Pointer authentication. ++ }], + ['OS in "aix os400"', { + 'ldflags': [ + '-Wl,-bnoerrmsg', +EOF +git apply correct-cflags.patch --verbose +rm -f correct-cflags.patch + export CC_host="ccache gcc-8" export CXX_host="ccache g++-8" export CC="ccache aarch64-linux-gnu-gcc-8"