Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The gfortran toolchain does not recognize arm64 architectures #5116

Closed
jbloino opened this issue May 18, 2024 · 2 comments
Closed

The gfortran toolchain does not recognize arm64 architectures #5116

jbloino opened this issue May 18, 2024 · 2 comments
Labels
Milestone

Comments

@jbloino
Copy link

jbloino commented May 18, 2024

Xmake Version

2.9.1

Operating System Version and Architecture

macOS Sonoma 14.4.1, Apple M3 Pro

Describe Bug

Trying to compile a program written in Fortran through xmake using GFortran provided by homebrew (package gcc, version of gfortran 14.1.0) gives the following error:

error: gfortran: error: unrecognized command-line option '-m32'

Expected Behavior

Compilation runs smoothly.

Project Configuration

Fortran source file (hello.f90)

program hello
    print *, 'hello'
end program hello

xmake.lua:

target("hello")
    add_files("hello.f90")

commands:

xmake f --toolchain=gfortran
xmake

Additional Information and Error Logs

The problem is the -m32 flag. Forcing x86_64 architecture avoids the problem.

The problem seems to be (at least in part) in toolchains/gfortran/xmake.lua, which only recognizes "x86_64", and "x64", while I think the native Apple architecture should be internally recognized as arm64.
I tried to create an alternate toolchain by copying the content of xmake.lua and adding "arm64" to have:
local march = toolchain:is_arch("x86_64", "x64", "arm64") and "-m64" or "-m32"
The -m64 compilation flag was then added but it seems that some other process still added -m32, so both flags ended up being present and the compilation failed.

Note: compiling the source file above hello.f90 simply with gfortran hello.f90 or gfortran -m64 hello.f90 gives no error.

Looking at the gcc toolchain for comparison, this problem may affect other build processes, since "arm64" was not present there too.

@jbloino jbloino added the bug label May 18, 2024
@waruqi
Copy link
Member

waruqi commented May 18, 2024

try xmake update -s dev

@waruqi waruqi added this to the v2.9.2 milestone May 18, 2024
@jbloino
Copy link
Author

jbloino commented May 18, 2024

It works perfectly, thank you so much!

@jbloino jbloino closed this as completed May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants