From 11b1696039ca6db20269fa75a758ab25f23320de Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 20 Dec 2023 22:04:32 +0100 Subject: [PATCH] Fix #118: support older CPUs (#119) --- .circleci/config.yml | 25 ++++++------------------- CHANGELOG.md | 4 ++++ bb/tasks.clj | 4 +++- script/install-graalvm | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 20 deletions(-) create mode 100755 script/install-graalvm diff --git a/.circleci/config.yml b/.circleci/config.yml index 99d7b42..3788ff0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -83,7 +83,7 @@ jobs: working_directory: ~/repo environment: LEIN_ROOT: "true" - GRAALVM_HOME: /home/circleci/graalvm-ce-java11-22.3.0 + GRAALVM_HOME: /home/circleci/graalvm-21.0.1 DEPS_CLJ_PLATFORM: linux # used in release script # BABASHKA_TEST_ENV: native steps: @@ -114,13 +114,7 @@ jobs: sudo apt-get -y install gcc g++ zlib1g-dev - run: name: Download GraalVM - command: | - cd ~ - if ! [ -d graalvm-ce-java11-22.3.0 ]; then - curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java11-linux-amd64-22.3.0.tar.gz - tar xzf graalvm-ce-java11-linux-amd64-22.3.0.tar.gz - fi - "$GRAALVM_HOME/bin/gu" install native-image || true + command: script/install-graalvm - run: name: Build binary command: | @@ -137,7 +131,7 @@ jobs: - save_cache: paths: - ~/.m2 - - ~/graalvm-ce-java11-22.3.0 + - ~/graalvm key: linux-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }} - store_artifacts: path: /tmp/release @@ -146,7 +140,7 @@ jobs: macos: xcode: "14.0.0" environment: - GRAALVM_HOME: /Users/distiller/graalvm-ce-java11-22.3.0/Contents/Home + GRAALVM_HOME: /Users/distiller/graalvm-21.0.1/Contents/Home DEPS_CLJ_PLATFORM: macos # used in release script steps: - checkout @@ -168,14 +162,7 @@ jobs: .circleci/script/install-leiningen - run: name: Download GraalVM - command: | - cd ~ - ls -la - if ! [ -d graalvm-ce-java11-22.3.0 ]; then - curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java11-darwin-amd64-22.3.0.tar.gz - tar xzf graalvm-ce-java11-darwin-amd64-22.3.0.tar.gz - fi - "$GRAALVM_HOME/bin/gu" install native-image || true + command: script/install-graalvm - run: name: Build binary command: | @@ -192,7 +179,7 @@ jobs: - save_cache: paths: - ~/.m2 - - ~/graalvm-ce-java11-22.3.0 + - ~/graalvm key: mac-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }} - store_artifacts: path: /tmp/release diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dc3dc9..38347fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ DEPS_CLJ_TOOLS_VERSION=1.11.1.1165 bb clojure [deps.clj](https://github.com/borkdude/deps.clj): a faithful port of the clojure CLI bash script to Clojure +## Unreleased + +- Support older CPUs for native-image builds + ## 1.11.1.1429 - Catch up with CLI `1.11.1.1429` diff --git a/bb/tasks.clj b/bb/tasks.clj index 774d80f..46ea566 100644 --- a/bb/tasks.clj +++ b/bb/tasks.clj @@ -37,6 +37,8 @@ "--no-fallback" "--verbose" "--no-server" - "-J-Xmx3g")) + "-J-Xmx3g" + "-march=compatibility" + "-O1")) (p/shell lein "clean") (p/shell "./deps" "-Spath" "-Sdeps" "{:deps {borkdude/deps.clj {:mvn/version \"0.0.1\"}}}"))) diff --git a/script/install-graalvm b/script/install-graalvm new file mode 100755 index 0000000..0a6d97b --- /dev/null +++ b/script/install-graalvm @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +set -euo pipefail + +INSTALL_DIR="${1:-$HOME}" + +GRAALVM_VERSION="${GRAALVM_VERSION:-21.0.1}" + +GRAALVM_PLATFORM=$DEPS_CLJ_PLATFORM + +case "${DEPS_CLJ_ARCH:-}" in + aarch64) + GRAALVM_ARCH="aarch64" + ;; + *) + GRAALVM_ARCH="x64" + ;; +esac + +GRAALVM_DIR_NAME="graalvm-$GRAALVM_VERSION" +GRAALVM_FILENAME="graalvm-jdk-${GRAALVM_VERSION}_${GRAALVM_PLATFORM}-${GRAALVM_ARCH}_bin.tar.gz" +DOWNLOAD_URL="https://download.oracle.com/graalvm/21/archive/${GRAALVM_FILENAME}" + +pushd "$INSTALL_DIR" >/dev/null + +if ! [ -d "$GRAALVM_DIR_NAME" ]; then + echo "Downloading GraalVM $GRAALVM_PLATFORM-$GRAALVM_ARCH-$GRAALVM_VERSION on '$PWD'..." + echo "$DOWNLOAD_URL" + curl -LO "$DOWNLOAD_URL" + ls -la + mkdir "$GRAALVM_DIR_NAME" + tar xzvf "$GRAALVM_FILENAME" -C "$GRAALVM_DIR_NAME" --strip-components 1 + ls -la "$GRAALVM_DIR_NAME" +fi + +popd >/dev/null