Skip to content

Commit 7ef6f22

Browse files
committed
arm64 compiler fixes
1 parent 2da1bc8 commit 7ef6f22

File tree

8 files changed

+19
-24
lines changed

8 files changed

+19
-24
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jobs:
3333
exclude:
3434
- os: macos-14 # No Intel on MacOS anymore since 2024
3535
toolchain: {compiler: intel, version: '2025.1'}
36+
- os: macos-14 # Intel compiler does not support ARM (macos-14)
37+
toolchain: {compiler: intel, version: '2025.2'}
3638
- os: macos-14 # gcc@10 not available on macos-14 (ARM64)
3739
toolchain: {compiler: gcc, version: 10}
3840
- os: windows-latest # Doesn't pass build and tests yet

ci/test_features.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,8 @@ grep -q "✓ FAST: fast optimization flags found" output.txt || { echo "ERROR: F
207207
grep -q "✓ All compiler flag checks PASSED" output.txt || { echo "ERROR: Expected all checks to pass"; exit 1; }
208208
# Check compiler-specific flags (will depend on detected compiler)
209209
if grep -q "Detected compiler: gfortran" output.txt; then
210-
# Check for either -march=native or -mcpu (Apple Silicon uses -mcpu)
211-
if ! (grep -q "✓ Release: -march=native found" output.txt || grep -q "✓ Release: -mcpu found" output.txt); then
212-
echo "ERROR: gfortran release architecture flag (-march=native or -mcpu) not found"
213-
exit 1
214-
fi
210+
# Check for -mtune flag (portable tuning flag)
211+
grep -q "✓ Release: -mtune found" output.txt || { echo "ERROR: gfortran release flag -mtune not found"; exit 1; }
215212
grep -q "✓ Fast: -ffast-math found" output.txt || { echo "ERROR: gfortran fast flag -ffast-math not found"; exit 1; }
216213
fi
217214
echo "✓ Production profile works"

example_packages/features_demo/fpm.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ release.preprocess.cpp.macros = "RELEASE"
1919

2020
# Compiler-specific features
2121
debug.gfortran.flags = "-Wall -fcheck=bounds"
22-
release.gfortran.flags = "-march=native"
22+
release.gfortran.flags = "-mtune=generic -funroll-loops"
2323

2424
# Platform-specific features
2525
linux.preprocess.cpp.macros = "LINUX_BUILD"

example_packages/features_per_compiler/app/main.f90

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,8 @@ function check_gfortran_flags(options, debug_on, release_on, fast_on, strict_on)
126126
end if
127127

128128
if (release_on) then
129-
! Check for either -march or -mcpu (Apple Silicon uses -mcpu; -match=native may be re-resolved by gcc)
130-
if (.not. (index(options, '-march') > 0 .or. index(options, '-mcpu') > 0)) then
131-
print '(a)', ' ✗ Release: neither -march=native nor -mcpu found'
132-
failed_count = failed_count + 1
133-
else
134-
if (index(options, '-march=native') > 0) then
135-
print '(a)', ' ✓ Release: -march found'
136-
else
137-
print '(a)', ' ✓ Release: -mcpu found'
138-
end if
139-
end if
129+
! Check for -mtune flag (portable tuning flag that works on all platforms)
130+
if (.not. check_flag(options, '-mtune', 'Release', '-mtune')) failed_count = failed_count + 1
140131
if (.not. check_flag(options, '-funroll-loops', 'Release', '-funroll-loops')) failed_count = failed_count + 1
141132
end if
142133

example_packages/features_per_compiler/fpm.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ debug.preprocess.cpp.macros = "DEBUG"
3434

3535
# Release feature with base optimization, then per-compiler extensions
3636
release.flags = "-O3" # Base optimization for ALL compilers (applied first)
37-
release.gfortran.flags = "-march=native -funroll-loops"
37+
release.gfortran.flags = "-mtune=generic -funroll-loops"
3838
release.ifort.flags = "-unroll" # Unix/Linux/macOS Intel
3939
release.ifx.flags = "-unroll" # Intel oneAPI
4040

example_packages/features_with_dependency/fpm.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ linux_specific.preprocess.cpp.macros = ["WITH_DEMO","LINUX_FEATURES"]
3030

3131
# Feature combining compiler and dependency features
3232
gfortran_optimized.gfortran.dependencies.features_demo = { path = "../features_demo", features = ["release", "gfortran"] }
33-
gfortran_optimized.gfortran.flags = "-O3 -march=native"
33+
gfortran_optimized.gfortran.flags = "-O3 -mtune=generic -funroll-loops"
3434
gfortran_optimized.preprocess.cpp.macros = ["WITH_DEMO"]
3535

3636

test/fpm_test/test_features.f90

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ subroutine test_feature_collection_complex(error)
365365
& 'debug.linux.flags = "-DLINUX"', &
366366
& 'debug.windows.ifort.flags = "/DEBUG:FULL"', &
367367
& 'release.flags = "-O3"', &
368-
& 'release.gfortran.flags = "-march=native"'
368+
& 'release.gfortran.flags = "-mtune=generic -funroll-loops"'
369369
close(unit)
370370

371371
call get_package_data(package, temp_file, error)
@@ -1501,7 +1501,7 @@ subroutine test_feature_compiler_flags_integration(error)
15011501
write(unit, '(a)') '[features]'
15021502
write(unit, '(a)') 'debug.gfortran.flags = "-g -Wall -fcheck=bounds"'
15031503
write(unit, '(a)') 'debug.flags = "-g"'
1504-
write(unit, '(a)') 'release.gfortran.flags = "-O3 -march=native"'
1504+
write(unit, '(a)') 'release.gfortran.flags = "-O3 -mtune=generic -funroll-loops"'
15051505
write(unit, '(a)') 'release.flags = "-O2"'
15061506
write(unit, '(a)') ''
15071507
write(unit, '(a)') '[profiles]'
@@ -1575,8 +1575,13 @@ subroutine test_feature_compiler_flags_integration(error)
15751575
return
15761576
end if
15771577

1578-
if (index(model%fortran_compile_flags, "-march=native") == 0) then
1579-
call test_failed(error, "Expected release gfortran flags to contain '-march=native'")
1578+
if (index(model%fortran_compile_flags, "-mtune") == 0) then
1579+
call test_failed(error, "Expected release gfortran flags to contain '-mtune'")
1580+
return
1581+
end if
1582+
1583+
if (index(model%fortran_compile_flags, "-funroll-loops") == 0) then
1584+
call test_failed(error, "Expected release gfortran flags to contain '-funroll-loops'")
15801585
return
15811586
end if
15821587

test/fpm_test/test_manifest.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,7 @@ subroutine test_features_demo_serialization(error)
17621762
& '', &
17631763
& '# Compiler-specific features', &
17641764
& 'debug.gfortran.flags = "-Wall -fcheck=bounds"', &
1765-
& 'release.gfortran.flags = "-march=native"', &
1765+
& 'release.gfortran.flags = "-mtune=generic -funroll-loops"', &
17661766
& '', &
17671767
& '# Platform-specific features', &
17681768
& 'linux.preprocess.cpp.macros = "LINUX_BUILD"', &

0 commit comments

Comments
 (0)