From 6ab5f60966fcac0f2c009e864de169d129dd2e4b Mon Sep 17 00:00:00 2001 From: Janne Valkealahti Date: Tue, 7 May 2024 09:16:21 +0100 Subject: [PATCH] Force compatibility machine target - We're mostly getting issues with macos runners where -march=compatibility looks to work better but is not automatically set depending which cpu arch is in use. - Backport #1064 --- .github/workflows/e2e.yml | 10 ++++++++++ .../springframework/shell/gradle/SamplePlugin.java | 12 +++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 64333c25f..d6cb37a62 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -25,6 +25,11 @@ jobs: musl: true name: Compile ${{ matrix.nickname }} steps: + - name: macos info + if: runner.os == 'macOS' + shell: bash + run: | + sysctl machdep.cpu - uses: actions/checkout@v3 - uses: graalvm/setup-graalvm@v1 with: @@ -79,6 +84,11 @@ jobs: nickname: linux name: E2E ${{ matrix.os }} steps: + - name: macos info + if: runner.os == 'macOS' + shell: bash + run: | + sysctl machdep.cpu - uses: actions/checkout@v3 - uses: actions/setup-java@v3 with: diff --git a/buildSrc/src/main/java/org/springframework/shell/gradle/SamplePlugin.java b/buildSrc/src/main/java/org/springframework/shell/gradle/SamplePlugin.java index b8270005d..dff49c71a 100644 --- a/buildSrc/src/main/java/org/springframework/shell/gradle/SamplePlugin.java +++ b/buildSrc/src/main/java/org/springframework/shell/gradle/SamplePlugin.java @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 the original author or authors. + * Copyright 2022-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ */ package org.springframework.shell.gradle; +import java.util.ArrayList; + import org.graalvm.buildtools.gradle.NativeImagePlugin; import org.graalvm.buildtools.gradle.dsl.GraalVMExtension; import org.gradle.api.Plugin; @@ -74,10 +76,14 @@ private void customizeNative(Project project) { private void configureGraalVmExtension(Project project) { GraalVMExtension extension = project.getExtensions().getByType(GraalVMExtension.class); + ArrayList options = new ArrayList(); if (isEnabled(project, MUSL)) { - extension.getBinaries().getByName(NativeImagePlugin.NATIVE_MAIN_EXTENSION).buildArgs("--static", - "--libc=musl"); + options.add("--static"); + options.add("--libc=musl"); } + // force compatibility as detection i.e. in macos runners is flaky + options.add("-march=compatibility"); + extension.getBinaries().getByName(NativeImagePlugin.NATIVE_MAIN_EXTENSION).buildArgs(options.toArray()); } private boolean isEnabled(Project project, String property) {