From cfaf6451838f0817ad53eab16d639361aa63e2ec Mon Sep 17 00:00:00 2001 From: Slavomir Kucera Date: Tue, 19 Mar 2024 16:55:07 +0100 Subject: [PATCH] try s390x build --- .github/workflows/CI.yml | 37 ++++++++++++++++++- .../vscode-hlasmplugin/src/serverFactory.ts | 1 + scripts/config.linux_s390x.sh | 3 ++ scripts/emulation.linux_s390x.sh | 14 +++++++ scripts/prereq.linux_s390x.sh | 3 ++ scripts/test-runner.linux_s390x.sh | 3 ++ scripts/toolchain.linux_s390x.sh | 36 ++++++++++++++++++ 7 files changed, 95 insertions(+), 2 deletions(-) create mode 100755 scripts/config.linux_s390x.sh create mode 100755 scripts/emulation.linux_s390x.sh create mode 100755 scripts/prereq.linux_s390x.sh create mode 100755 scripts/test-runner.linux_s390x.sh create mode 100755 scripts/toolchain.linux_s390x.sh diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 19e6f0429..28fd4eb67 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -20,6 +20,7 @@ on: - master - development - release-next + - ci_s390x_build pull_request: branches: - master @@ -183,14 +184,32 @@ jobs: path: toolchain.tar.gz key: ${{ hashFiles('scripts/toolchain.linux_arm64.sh') }} lookup-only: true - - name: Build image + - name: Build toolchain if: steps.cache.outputs.cache-hit != 'true' run: ./scripts/toolchain.linux_arm64.sh + s390x-linux-musl: + name: Build Linux S390X toolchain + runs-on: ubuntu-22.04 + container: alpine:3.19 + steps: + - uses: actions/checkout@v4 + - name: Install TAR + run: apk add tar + - uses: actions/cache@v4 + id: cache + with: + path: toolchain.tar.gz + key: ${{ hashFiles('scripts/toolchain.linux_s390x.sh') }} + lookup-only: true + - name: Build toolchain + if: steps.cache.outputs.cache-hit != 'true' + run: ./scripts/toolchain.linux_s390x.sh + build-matrix: name: Build runs-on: ${{ matrix.os }} - needs: [generate_grammar, aarch64-linux-musl] + needs: [generate_grammar, aarch64-linux-musl, s390x-linux-musl] strategy: matrix: include: @@ -204,6 +223,11 @@ jobs: container: alpine:3.19 dbg-strip: aarch64-linux-musl-objcopy --only-keep-debug language_server language_server.dbg && aarch64-linux-musl-objcopy --strip-unneeded language_server && aarch64-linux-musl-objcopy --add-gnu-debuglink=language_server.dbg language_server dbg-pattern: build/bin/language_server.dbg + - os: ubuntu-22.04 + native: linux_s390x + container: alpine:3.19 + dbg-strip: s390x-linux-musl-objcopy --only-keep-debug language_server language_server.dbg && s390x-linux-musl-objcopy --strip-unneeded language_server && s390x-linux-musl-objcopy --add-gnu-debuglink=language_server.dbg language_server + dbg-pattern: build/bin/language_server.dbg - os: ubuntu-22.04 native: wasm container: emscripten/emsdk:3.1.46 @@ -299,6 +323,9 @@ jobs: - os: ubuntu-22.04 native: linux_arm64 chmod: true + - os: ubuntu-22.04 + native: linux_s390x + chmod: true - os: windows-2022 native: win32_x64 chmod: false @@ -407,6 +434,11 @@ jobs: with: name: language_server_linux_arm64 path: ${{ env.CLIENT_DIR }}/bin/linux_arm64/ + - name: Download linux language server (s390x) + uses: actions/download-artifact@v4 + with: + name: language_server_linux_s390x + path: ${{ env.CLIENT_DIR }}/bin/linux_s390x/ - name: Download wasm language server uses: actions/download-artifact@v4 with: @@ -432,6 +464,7 @@ jobs: chmod +x ${{ env.CLIENT_DIR }}/bin/darwin_arm64/language_server chmod +x ${{ env.CLIENT_DIR }}/bin/linux_x64/language_server chmod +x ${{ env.CLIENT_DIR }}/bin/linux_arm64/language_server + chmod +x ${{ env.CLIENT_DIR }}/bin/linux_s390x/language_server - name: NPM CI run: npm ci working-directory: ${{ env.CLIENT_DIR }} diff --git a/clients/vscode-hlasmplugin/src/serverFactory.ts b/clients/vscode-hlasmplugin/src/serverFactory.ts index 0bf1e653c..1257d6e11 100644 --- a/clients/vscode-hlasmplugin/src/serverFactory.ts +++ b/clients/vscode-hlasmplugin/src/serverFactory.ts @@ -25,6 +25,7 @@ const supportedNativePlatforms: Readonly<{ [key: string]: string }> = Object.fre 'win32.arm64': 'win32_arm64', 'linux.x64': 'linux_x64', 'linux.arm64': 'linux_arm64', + 'linux.s390x': 'linux_s390x', 'darwin.x64': 'darwin_x64', 'darwin.arm64': 'darwin_arm64', }); diff --git a/scripts/config.linux_s390x.sh b/scripts/config.linux_s390x.sh new file mode 100755 index 000000000..2a2dea4ce --- /dev/null +++ b/scripts/config.linux_s390x.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh +set -e +cmake -G Ninja -DCMAKE_SYSTEM_NAME="Linux" -DCMAKE_C_COMPILER="s390x-linux-musl-gcc" -DCMAKE_CXX_COMPILER="s390x-linux-musl-g++" -DCMAKE_BUILD_TYPE=Release -DDISCOVER_TESTS=Off -DCMAKE_EXE_LINKER_FLAGS="-static -Wl,--gc-sections" -DBUILD_VSIX=Off -DUSE_PRE_GENERATED_GRAMMAR="generated_parser" ../ diff --git a/scripts/emulation.linux_s390x.sh b/scripts/emulation.linux_s390x.sh new file mode 100755 index 000000000..09cccef25 --- /dev/null +++ b/scripts/emulation.linux_s390x.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env sh + +set -e + +sudo apt-get update +sudo apt-get install -y qemu-user + +mkdir -p bin/linux_x64 +cd bin/linux_x64 + +echo '#!/usr/bin/env sh' > language_server +echo 'qemu-s390x "$(dirname "$0")/../linux_arm64/language_server" "$@"' >> language_server + +chmod +x language_server diff --git a/scripts/prereq.linux_s390x.sh b/scripts/prereq.linux_s390x.sh new file mode 100755 index 000000000..8c9351278 --- /dev/null +++ b/scripts/prereq.linux_s390x.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh +set -e +apk update && apk add --no-cache git cmake ninja qemu-s390x tar diff --git a/scripts/test-runner.linux_s390x.sh b/scripts/test-runner.linux_s390x.sh new file mode 100755 index 000000000..305251202 --- /dev/null +++ b/scripts/test-runner.linux_s390x.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh +set -e +qemu-s390x $1 diff --git a/scripts/toolchain.linux_s390x.sh b/scripts/toolchain.linux_s390x.sh new file mode 100755 index 000000000..a7d25073e --- /dev/null +++ b/scripts/toolchain.linux_s390x.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env sh + +set -e + +apk update +apk add git curl g++ bison make patch tar xz + +mkdir /toolchain + +git clone https://github.com/richfelker/musl-cross-make.git + +cd musl-cross-make + +git checkout -f e149c31c48b4f4a4c9349ddf7bc0027b90245afc + +echo "TARGET = s390x-linux-musl" >> config.mak +echo "OUTPUT = /toolchain/" >> config.mak +echo "BINUTILS_VER = 2.41" >> config.mak +echo "GCC_VER = 12.3.0" >> config.mak +echo "DL_CMD = curl -C - -L -o" >> config.mak +echo "COMMON_CONFIG += CFLAGS=\"-fdata-sections -ffunction-sections -O2 -g0\" CXXFLAGS=\"-fdata-sections -ffunction-sections -O2 -g0\"" >> config.mak +echo "BINUTILS_CONFIG = --enable-gprofng=no" >> config.mak + +echo "85d66f058688db1e18545b6c4cf67ecc83d3b7eb *gcc-12.3.0.tar.xz" > hashes/gcc-12.3.0.tar.xz.sha1 +echo "0e008260a958bbd10182ee3384672ae0a310eece *binutils-2.41.tar.xz" > hashes/binutils-2.41.tar.xz.sha1 + +mkdir patches/gcc-12.3.0 +cp patches/gcc-11.2.0/0002-posix_memalign.diff patches/gcc-12.3.0/ + +make -j 8 +make install + +cd .. + +tar czvf toolchain.tar.gz /toolchain +