Skip to content

Commit 6ab5f60

Browse files
committed
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
1 parent 477b24b commit 6ab5f60

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

.github/workflows/e2e.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ jobs:
2525
musl: true
2626
name: Compile ${{ matrix.nickname }}
2727
steps:
28+
- name: macos info
29+
if: runner.os == 'macOS'
30+
shell: bash
31+
run: |
32+
sysctl machdep.cpu
2833
- uses: actions/checkout@v3
2934
- uses: graalvm/setup-graalvm@v1
3035
with:
@@ -79,6 +84,11 @@ jobs:
7984
nickname: linux
8085
name: E2E ${{ matrix.os }}
8186
steps:
87+
- name: macos info
88+
if: runner.os == 'macOS'
89+
shell: bash
90+
run: |
91+
sysctl machdep.cpu
8292
- uses: actions/checkout@v3
8393
- uses: actions/setup-java@v3
8494
with:

buildSrc/src/main/java/org/springframework/shell/gradle/SamplePlugin.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022-2023 the original author or authors.
2+
* Copyright 2022-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
1515
*/
1616
package org.springframework.shell.gradle;
1717

18+
import java.util.ArrayList;
19+
1820
import org.graalvm.buildtools.gradle.NativeImagePlugin;
1921
import org.graalvm.buildtools.gradle.dsl.GraalVMExtension;
2022
import org.gradle.api.Plugin;
@@ -74,10 +76,14 @@ private void customizeNative(Project project) {
7476

7577
private void configureGraalVmExtension(Project project) {
7678
GraalVMExtension extension = project.getExtensions().getByType(GraalVMExtension.class);
79+
ArrayList<String> options = new ArrayList<String>();
7780
if (isEnabled(project, MUSL)) {
78-
extension.getBinaries().getByName(NativeImagePlugin.NATIVE_MAIN_EXTENSION).buildArgs("--static",
79-
"--libc=musl");
81+
options.add("--static");
82+
options.add("--libc=musl");
8083
}
84+
// force compatibility as detection i.e. in macos runners is flaky
85+
options.add("-march=compatibility");
86+
extension.getBinaries().getByName(NativeImagePlugin.NATIVE_MAIN_EXTENSION).buildArgs(options.toArray());
8187
}
8288

8389
private boolean isEnabled(Project project, String property) {

0 commit comments

Comments
 (0)