fortran-lang / stdlib

Fortran Standard Library
https://stdlib.fortran-lang.org
MIT License
1.05k stars 164 forks source link

Build system assumes lfortran broken because of -m32 flag (?) #693

Open barracuda156 opened 1 year ago

barracuda156 commented 1 year ago

Description

I was writing a portfile for stdlib anew, since being on a different machine, and did not specify gfortran; CMake build script opportunistically picked lfortran (which is fine after all), but decided it is broken because of unexpected flags :)

-- The Fortran compiler identification is unknown
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - failed
-- Check for working Fortran compiler: /opt/local/bin/lfortran
-- Check for working Fortran compiler: /opt/local/bin/lfortran - broken
CMake Error at /opt/local/share/cmake-3.26/Modules/CMakeTestFortranCompiler.cmake:59 (message):
  The Fortran compiler

    "/opt/local/bin/lfortran"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_fortran-stdlib/fortran-stdlib/work/build/CMakeFiles/CMakeScratch/TryCompile-ZI3iIZ

    Run Build Command(s):/opt/local/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_74af9/fast && /usr/bin/make  -f CMakeFiles/cmTC_74af9.dir/build.make CMakeFiles/cmTC_74af9.dir/build
    Building Fortran object CMakeFiles/cmTC_74af9.dir/testFortranCompiler.f.o
    /opt/local/bin/lfortran   -pipe -Os -m32  -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_fortran-stdlib/fortran-stdlib/work/build/CMakeFiles/CMakeScratch/TryCompile-ZI3iIZ/testFortranCompiler.f -o CMakeFiles/cmTC_74af9.dir/testFortranCompiler.f.o
    The following arguments were not expected: -m32 -Os -pipe
    Run with --help for more information.
    make[1]: *** [CMakeFiles/cmTC_74af9.dir/testFortranCompiler.f.o] Error 109
    make: *** [cmTC_74af9/fast] Error 2

While I did not use lfortran for real-life tasks yet, it passes its own tests fine, so definitely not broken.

Expected Behaviour

Perhaps build system should be aware of 32-bit platforms.

Version of stdlib

Github

Platform and Architecture

macOS 10.6 ppc

Additional Information

gcc 12.2.0

jvdp1 commented 1 year ago

this issue seems to be more related to LFortran than stdlib. @certik are you aware of such issue with LFortran?

certik commented 1 year ago

I've noticed this as well, that cmake picks lfortran over gfortran, I think it shouldn't do that. The LFortran bug here is that it can't compile stdlib yet. The CMake bug is that it can't call lfortran properly in all cases yet, that's something we need to fix in cmake itself.