fortran-lang / fpm

Fortran Package Manager (fpm)
https://fpm.fortran-lang.org
MIT License
883 stars 99 forks source link

Proper Compiler Detection #1086

Open everythingfunctional opened 3 weeks ago

everythingfunctional commented 3 weeks ago

Description

LLVM flang has now officially been renamed from flang-new to flang. Thus the current logic of just checking whether the name of the compiler begins with a specific string is no longer able to distinguish between Classic flang and LLVM flang. We'll need a proper way to determine what compiler we're invoking beyond just checking the name. This will have the added benefit of allowing fpm to work with the Cray compiler wrappers.

Possible Solution

I believe the way CMake does it is to run something through a compiler to see what preprocessor symbols are defined. We could probably do something similar, but there may be a bit of chicken/egg problem if different compilers have different ways of enabling preprocessing.

Additional Information

No response

arjenmarkus commented 3 weeks ago

You could use the compiler_version function. Of course, you would have to try all known compiler names, but you have to do that anyway.

Op do 10 okt 2024 om 15:31 schreef Brad Richardson @.***

:

Description

LLVM flang has now officially been renamed from flang-new to flang. Thus the current logic of just checking whether the name of the compiler begins with a specific string is no longer able to distinguish between Classic flang and LLVM flang. We'll need a proper way to determine what compiler we're invoking beyond just checking the name. This will have the added benefit of allowing fpm to work with the Cray compiler wrappers. Possible Solution

I believe the way CMake does it is to run something through a compiler to see what preprocessor symbols are defined. We could probably do something similar, but there may be a bit of chicken/egg problem if different compilers have different ways of enabling preprocessing. Additional Information

No response

— Reply to this email directly, view it on GitHub https://github.com/fortran-lang/fpm/issues/1086, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN6YRYZKHBAPWAOVF5UAZLZ2Z6SBAVCNFSM6AAAAABPWZVQECVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU3TQOBWGM4TOMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

rouson commented 15 hours ago

@everythingfunctional @arjenmarkus

When I recommended using compiler_version in issue #767 comment 1264961893, @awvwgk responded in comment 1265017260 as follows: "We cannot assume that we can run a program since we might be using a cross-compiler." I just submitted issue #1089 to offer an alternative or intermediate solution that could be simple to implement and addresses @awvwgk's concern.