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

meson can't figure out the correct linker for flang #10778

Closed
andyfaff opened this issue Sep 4, 2022 · 2 comments · Fixed by #12305
Closed

meson can't figure out the correct linker for flang #10778

andyfaff opened this issue Sep 4, 2022 · 2 comments · Fixed by #12305
Labels
compilers dynamic linkers Dynamic linkers (ld, link, lld-link, etc) language:fortran OS:windows Winodows OS specific issues

Comments

@andyfaff
Copy link

andyfaff commented Sep 4, 2022

Describe the bug
When building the SciPy package with msvc and flang (installed using conda) meson can't detect which linker should be used for flang. @eli-schwartz

To Reproduce
This reproducer assumes that the scipy repo is already cloned.

conda create -n test python=3.10
conda activate test
mamba install clangdev flang lld
set cc=clang-cl
set cxx=clang-cl
pip install meson ninja cython numpy pybind11 pythran
meson build

Output Error message:

(test) H:\programming\scipy>meson build
The Meson build system
Version: 0.63.2
Source dir: \\filer\home\anz\programming\scipy
Build dir: \\filer\home\anz\programming\scipy\build
Build type: native build
Project name: SciPy
Project version: 1.10.0.dev0
C compiler for the host machine: clang-cl (clang-cl 11.0.1)
C linker for the host machine: lld-link lld-link 11.1.0
C++ compiler for the host machine: clang-cl (clang-cl 11.0.1)
C++ linker for the host machine: lld-link lld-link 11.1.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C supports arguments -Wno-unused-but-set-variable: NO
Compiler for C supports arguments -Wno-unused-function: YES
Compiler for C supports arguments -Wno-conversion: YES
Compiler for C supports arguments -Wno-misleading-indentation: YES
Compiler for C supports arguments -Wno-incompatible-pointer-types: YES
Library m found: NO

\\filer\home\anz\programming\scipy\meson.build:55:0: ERROR: Unable to detect linker for compiler `flang -Wl,--version`
stdout:
stderr: flang: error: no input files

It seems that flang -Wl,--version does not furnish the details that meson would like.

If cl is used as the c-compiler then the problem still occurs:

(test) set cc=
(test) set cxx=
(test) H:\programming\scipy>meson build
The Meson build system
Version: 0.63.2
Source dir: \\filer\home\anz\programming\scipy
Build dir: \\filer\home\anz\programming\scipy\build
Build type: native build
Project name: SciPy
Project version: 1.10.0.dev0
C compiler for the host machine: cl (msvc 19.29.30145 "Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30145 for x64")
C linker for the host machine: link link 14.29.30145.0
C++ compiler for the host machine: cl (msvc 19.29.30145 "Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30145 for x64")
C++ linker for the host machine: link link 14.29.30145.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C supports arguments -Wno-unused-but-set-variable: NO
Compiler for C supports arguments -Wno-unused-function: NO
Compiler for C supports arguments -Wno-conversion: NO
Compiler for C supports arguments -Wno-misleading-indentation: NO
Compiler for C supports arguments -Wno-incompatible-pointer-types: NO
Library m found: NO

\\filer\home\anz\programming\scipy\meson.build:55:0: ERROR: Unable to detect linker for compiler `flang -Wl,--version`
stdout:
stderr: flang: error: no input files

Expected behavior
meson should detect which linker is being used by flang.

system parameters
*This is a native build

  • Windows 10
  • Python 3.10 installed by conda
  • meson version 0.63.2
  • ninja version 1.10.2.git.kitware.jobserver-1
@eli-schwartz eli-schwartz added OS:windows Winodows OS specific issues compilers dynamic linkers Dynamic linkers (ld, link, lld-link, etc) language:fortran labels Sep 4, 2022
@rgommers
Copy link
Contributor

rgommers commented Oct 4, 2022

Some more context, from scipy/scipy#16956 (comment):

[@eli-schwartz] Some linkers, like Windows link.exe, are run directly -- and Meson handles that in guess_win_linker().

[@rgommers] In the compiler detection logic, it seems like flang only occurs once, and it uses guess_nix_linker:

if 'flang' in out or 'clang' in out:
linker = guess_nix_linker(env,
compiler, FlangFortranCompiler, version, for_machine)
return FlangFortranCompiler(

Perhaps the MSVC + Flang combo is unexpected there.

@h-vetinari
Copy link
Contributor

I think I hit this, and solved it with some pointers from @eli-schwartz. I'l open a PR. Note though that the flang 11 you get from conda-forge is still the "classic" flang, not the new llvm-based one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compilers dynamic linkers Dynamic linkers (ld, link, lld-link, etc) language:fortran OS:windows Winodows OS specific issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants