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
Fortran, cmake based formulae from source w/ Intel ifort installed causes problems #4293
Comments
The formula is responsible for setting the desired FC. Does it not work to
at the beginning of |
@ilovezfs Sure, that would work. But AFAICT, most CMake + Fortran formulae assume that GFortran will be used, since it's the only Fortran compiler currently available in homebrew (unless someone added flang when I wasn't paying attention). The C compiler is always set as Clang by homebrew, why not exert the same level of control and predictability for Fortran? If you show me an easy way to find all formulae with But I really don't see any point in providing users/formula authors with that flexibility when you're already enforcing MPI => open-mpi and the C compiler as clang. |
Unlike the superenv compiler shims, Fortran is going to have to be supplied by a specific dependency in the formula so it makes sense to handle that in the formula. |
If the general consensus is that picking the right Fortran compiler is the formula's responsibility then I will defer to the judgement of the homebrew maintainers. But as a formula contributor, it's not really clear that not doing setting An alternate (better?) approach would be to modify the If it is decided that Formulae are responsible for providing their one |
To be clear, it's the formula's responsibility to set it if needed, which would mean anywhere where CI actually fails without it. I didn't mean to imply that we should be setting everywhere. I favor as little magic as possible on the backend, and given how infrequently it's been necessary to intervene and set FC, going back to set it globally or in std_cmake_args would be an unnecessary step backwards in the direction of unneeded magic. |
Have you actually reported it to CMake upstream to request gfortran take precedence over ifort and been turned away with a won't-fix? That seems like a reasonable request especially given ifort isn't even in PATH during the build. |
It is in the PATH during the build.
The problem will never affect CI or bottled builds (unless someone installs
another Fortran compiler on the ci system).
I don’t really see it as magic if we’re already saying we want GFortran
through the gcc dependency.
What is magic and highly confusing is trying to use a package you installed
with homebrew in the past only to get a cryptic error message about a .mod
file during compilation.
…On Wed, Jun 6, 2018 at 12:20 PM ilovezfs ***@***.***> wrote:
IMO, this it is a bug that CMake defaults to ifort over gfortran, but it
is what it is.
Have you actually reported it to CMake upstream to request gfortran take
precedence over ifort and been turned away with a won't-fix? That seems
like a reasonable request especially given ifort isn't even in PATH during
the build.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4293 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAREPBf09EL99kytT4bQ-wChjojyXF9oks5t6AFFgaJpZM4Uc1OB>
.
|
How? That will only happen if you set it as a dependency in the formula.
Setting an environment variable (or passing extra args) that may or may not be necessary for a successful build based on attempted deductions from a combination of dependencies is pretty magical. |
List of possibly affected should be
modulo false positives for openmp use. |
Oh, I guess if /usr/local/bin is ignored unless a formula dep exists then I am mistaken and CMake is doing some pretty damn magical BS to find ifort. In this case, I think (hope) the CMake devs would be willing to default to the Fortran compiler actually available on the path...
@ilovezfs you rock! If the final ruling on this issue is "won't fix/invalid", then I can go through and check/verify those formulae. In addition, I think we might want to add a note to the formula cookbook documentation in the Fortran section to warn new formula submitters that they may want to take a little extra care if their build system uses both Fortran and CMake. |
/usr/local/bin is never in the PATH during a build (unless you're using --env=std). Instead we use
Yeah. Even putting aside whatever is allowing it to find ifort, and assuming that part is legitimate in CMake world, requesting a gfortran > ifort order of preference upstream would be lovely. |
👍 |
Agreed. I'll await the final ruling on the issue (unless you've already made it) before looking at the formula you've identified and the formula cookbook documentation upgrade. Thanks again. |
@ilovezfs @MikeMcQuaid Can we please reopen this? I have been in touch with upstream, and have determined that this is a result of L193 in def determine_cmake_prefix_path
PATH.new(
keg_only_deps.map(&:opt_prefix),
HOMEBREW_PREFIX.to_s, # line 193
).existing
end The effect of this line is to say to CMake: "Go and throw This is most certain the type of magic one should avoid, and seems to defeat the purpose of the superenv if CMake is going to go ahead and blithely ignore part it. CMake will be picking up every installed package in calls to I have confirmed that removing it from the build environment (by deleting line 193 of I'm going to open a PR to see what happens, and make your lives easier in the event you agree with me that this is a bug in |
Nice catch! |
- `HOMEBREW_PREFIX.to_s` was getting added to the CMake environment variable: `CMAKE_PREFIX_PATH` which causes CMake to look for stuff in: `HOMEBREW_PREFIX.to_s/{bin,lib,share,include,etc,...}` - This can cause Homebrew to pick up alternate fortran compilres if you provie links to them in e.g., `/usr/local/bin` assuming you installed homebrew in the standard location. - This may cause problems with libraries, programs, headers etc. getting picked up that aren't enumerated as formula dependencies. - Fixes Homebrew#4293
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Sorry, I should have time to work on the PR later today.
…On Sun, Jul 1, 2018 at 10:40 AM stale[bot] ***@***.***> wrote:
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4293 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAREPP7WlDei7J85C0R-kE-c-oa93vToks5uCN9igaJpZM4Uc1OB>
.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Please note:
TL;DR:
Please consider setting the
FC
environment variable to point to a brewedgfortran
inside the build environment; without it CMake based builds can stupidly pick upifort
(and other compilers too, probably), happily building your Fortran formula, but then leading to much confusion down the road when you try toUSE module_from_brewed_formula
with brewedgfortran
at a later date.Requested bug report template info:
brew
command and reproduced the problem with multiple formulae? If it's a problem with a single, official formula (not cask) please file this issue at Homebrew/homebrew-core: https://github.com/Homebrew/homebrew-core/issues/new/choose. If it's abrew cask
problem please file this issue at https://github.com/Homebrew/homebrew-cask/issues/new/choose. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.brew update
and can still reproduce the problem?brew doctor
, fixed all issues and can still reproduce the problem?brew config
andbrew doctor
and included their output with your issue?Brew config:
Brew doctor:
To help us debug your issue please explain:
Homebrew sets
FC=/path/to/brewed/gfortran
in the superenv so that CMake doesn't stupidly pick upifort
OR (less preferred) homebrew respects (imports) the users(The latter option is probably pretty error prone and dumb so I'm ruling it out.)$FC
environment variable.brew
commands)/usr/local/Cellar/intel-parallel-studio/2019.0.0
(you can sign up to be a beta tester and get a beta trial version license until they release the production version)brew link intel-parallel-studio
.mod
files from the formula:Obviously,
brew unlink intel-parallel-studio
before building JSON-Fortran with Homebrew solves this issue. But since Fortran compilers are not in general inter-operable, it would be very nice to have Homebrew ensure that packages withdepends_on "gcc"
due to Fortran dependencies actually use gfortran for compilation. For CMake based packages this is not the case due to CMake's quirks.Thanks for you time and for your great work as volunteers. If someone points me in the right direction I'll try to find time to work up a PR that will inject
FC=/path/to/brewed/gfortran
into the build environment.Best,
Zaak
The text was updated successfully, but these errors were encountered: