This is an archive of the discontinued LLVM Phabricator instance.

[clang][flang] Moke the definition of `-module-dir` restricted to Flang
ClosedPublic

Authored by awarzynski on Mar 20 2021, 9:17 AM.

Details

Summary

-module-dir is a Flang specific option and should not be visible in
Clang. This patch adds FlangOnlyOption flag to its definition. This
way Clang will know that it should reject it and skip it when generating
output for clang -help.

The definition of -module-dir is moved next to other Flang options.
As -J is an alias for -module-dir, it has to be moved as well (the
alias cannot be defined before the original option). As gfortran mode
is effectively no longer supported (*), -J is claimed as Flang only
option.

This is a follow-up of a post-commit review for
https://reviews.llvm.org/D95448.

Diff Detail

Event Timeline

awarzynski created this revision.Mar 20 2021, 9:17 AM
awarzynski requested review of this revision.Mar 20 2021, 9:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 20 2021, 9:17 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
awarzynski added a project: Restricted Project.
MaskRay accepted this revision.Mar 20 2021, 10:07 AM

Thanks. I do not know why FlangOption and FC1 Options needs be in clang/include/clang/Driver/Options.td but perhaps that is how things work:)

This revision is now accepted and ready to land.Mar 20 2021, 10:07 AM
arnamoy10 accepted this revision.Mar 20 2021, 12:45 PM

Thank you for reviewing!

Thanks. I do not know why FlangOption and FC1 Options needs be in clang/include/clang/Driver/Options.td but perhaps that is how things work:)

Options.td is where all options for clangDriver (the library) are defined. Since flang is implemented in terms of clangDriver, all options end up here. AFAIK, there is no mechanism to have separate Options.td files for Flang and Clang. But since there is meant to be only one driver library in llvm-project, I think that this is fine. Instead, IMHO, we should aim for producing separate files for e.g. clang -cc1 and flang -fc1 (to have a clearer separation from the compiler and frontend drivers).

The extra flags: FlangOption, FC1Option and FlangOnlyOption, were added to enable _some_ filtering of the options. In particular, for making sure that clang -help doesn't contain any Flang-only options.

Btw, here's an RFC in which I discussed some of these issues.

CC @protze.joachim - this is somewhat related to what you brought up here: https://reviews.llvm.org/D95460.