mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.64k stars 1.64k forks source link

meson cannot understand supported standards of flang on termux (android) #11633

Open Arniiiii opened 1 year ago

Arniiiii commented 1 year ago

Describe the bug meson cannot understand supported standards of flang on termux (android)

To Reproduce install termux ( download from github https://github.com/termux/termux-app/releases ) then in termux:

pkg install python python-pip flang
git clone scipy
git clone meson
cd meson
pip install ./
cd ../scipy
FC=flang-new meson setup build --prefix=$PWD/build-install

i got a lot of stuff in console and then there was path to such log: https://bpa.st/SWLEC

Expected behavior I guess it should stop not at point

linker stderr:

-----
Detecting LLD linker via: flang-new -Wl,-v
linker stdout:
LLD 15.0.7 (compatible with GNU linkers)

linker stderr:
ld.lld: error: undefined symbol: _QQmain
>>> referenced by Fortran_main.c
>>>               Fortran_main.c.o:(main) in archive /data/data/com.termux/files/usr/lib/libFortran_main.a
flang-new: error: linker command failed with exit code 1 (use -v to see invocation)

I guess the reason why is that meson tries to get some info using flang-new -Wl,-v, but it should be something like flang-new -w -v but i'm not sure. I guess so because:

~ $ flang-new -Wl,-v                                    LLD 16.0.0 (compatible with GNU linkers)
ld.lld: error: undefined symbol: _QQEnvironmentDefaults
>>> referenced by Fortran_main.c
>>>               Fortran_main.c.o:(main) in archive /data/data/com.termux/files/usr/lib/libFortran_main.a      >>> referenced by Fortran_main.c
>>>               Fortran_main.c.o:(main) in archive /data/data/com.termux/files/usr/lib/libFortran_main.a

ld.lld: error: undefined symbol: _QQmain                >>> referenced by Fortran_main.c
>>>               Fortran_main.c.o:(main) in archive /data/data/com.termux/files/usr/lib/libFortran_main.a      flang-new: error: linker command failed with exit code 1 (use -v to see invocation)
~ $ flang-new -Wl -v
flang-new version 16.0.0
Target: aarch64-unknown-linux-android24                 Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin       Found candidate GCC installation: /data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/6.5.0           Found candidate GCC installation: /data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/8.3.0           Selected GCC installation: /data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/8.3.0
Candidate multilib: .;@m64                              Selected multilib: .;@m64
flang-new: warning: argument unused during compilation: '-Wl'

Maybe the problem is somewhere there: https://github.com/mesonbuild/meson/blob/master/mesonbuild/compilers/fortran.py

system parameters termux, android, a samsung phone meson -- git version and all below i guess ( tried with another previous... ) ninja ( in the case it doesn't matter, but 1.11.1 )

eli-schwartz commented 1 year ago

I guess the reason why is that meson tries to get some info using flang-new -Wl,-v, but it should be something like flang-new -w -v but i'm not sure. Maybe the problem is somewhere there: https://github.com/mesonbuild/meson/blob/master/mesonbuild/compilers/fortran.py

As discussed in https://github.com/scipy/scipy/issues/18203.

Probably, the reason is that Meson currently doesn't have support for flang-new. Only for https://github.com/flang-compiler/flang

rgommers commented 1 month ago

There's still a bug to be fixed here: fortran_std=legacy isn't handled correctly for classic flang, and therefore builds that use it break for no reason. It's also not handled correctly for AMD's Fortran compiler (based on Flang), says the bug report at https://github.com/spack/spack/pull/46922.

I think if it's known that a compiler has support for F77 but doesn't accept -std=legacy, then the right thing to do is to drop the -std argument completely (optionally emit a warning?).