forked from OSchip/llvm-project
[flang][driver] Add support for `-module-suffix`
This option is supported in `f18`, but not yet available in `flang-new`. It is required in order to call `flang-new` from the `flang` bash script. Differential Revision: https://reviews.llvm.org/D103613
This commit is contained in:
parent
35ef4c940b
commit
20bd2142d4
|
@ -4522,6 +4522,9 @@ def fdebug_module_writer : Flag<["-"],"fdebug-module-writer">,
|
|||
def fget_symbols_sources : Flag<["-"], "fget-symbols-sources">, Group<Action_Group>,
|
||||
HelpText<"Dump symbols and their source code locations">;
|
||||
|
||||
def module_suffix : Separate<["-"], "module-suffix">, Group<f_Group>, MetaVarName<"<suffix>">,
|
||||
HelpText<"Use <suffix> as the suffix for module files (the default value is `.mod`)">;
|
||||
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -69,6 +69,8 @@ class CompilerInvocation : public CompilerInvocationBase {
|
|||
// of options.
|
||||
std::string moduleDir_ = ".";
|
||||
|
||||
std::string moduleFileSuffix_ = ".mod";
|
||||
|
||||
bool debugModuleDir_ = false;
|
||||
|
||||
bool warnAsErr_ = false;
|
||||
|
@ -97,6 +99,9 @@ public:
|
|||
std::string &moduleDir() { return moduleDir_; }
|
||||
const std::string &moduleDir() const { return moduleDir_; }
|
||||
|
||||
std::string &moduleFileSuffix() { return moduleFileSuffix_; }
|
||||
const std::string &moduleFileSuffix() const { return moduleFileSuffix_; }
|
||||
|
||||
bool &debugModuleDir() { return debugModuleDir_; }
|
||||
const bool &debugModuleDir() const { return debugModuleDir_; }
|
||||
|
||||
|
@ -129,6 +134,10 @@ public:
|
|||
/// Useful setters
|
||||
void SetModuleDir(std::string &moduleDir) { moduleDir_ = moduleDir; }
|
||||
|
||||
void SetModuleFileSuffix(const char *moduleFileSuffix) {
|
||||
moduleFileSuffix_ = std::string(moduleFileSuffix);
|
||||
}
|
||||
|
||||
void SetDebugModuleDir(bool flag) { debugModuleDir_ = flag; }
|
||||
|
||||
void SetWarnAsErr(bool flag) { warnAsErr_ = flag; }
|
||||
|
|
|
@ -392,6 +392,12 @@ static bool parseSemaArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
|
|||
res.SetDebugModuleDir(true);
|
||||
}
|
||||
|
||||
// -module-suffix
|
||||
if (const auto *moduleSuffix =
|
||||
args.getLastArg(clang::driver::options::OPT_module_suffix)) {
|
||||
res.SetModuleFileSuffix(moduleSuffix->getValue());
|
||||
}
|
||||
|
||||
return diags.getNumErrors() == numErrorsBefore;
|
||||
}
|
||||
|
||||
|
@ -639,5 +645,6 @@ void CompilerInvocation::setSemanticsOpts(
|
|||
semanticsContext_->set_moduleDirectory(moduleDir())
|
||||
.set_searchDirectories(fortranOptions.searchDirectories)
|
||||
.set_warnOnNonstandardUsage(enableConformanceChecks())
|
||||
.set_warningsAreErrors(warnAsErr());
|
||||
.set_warningsAreErrors(warnAsErr())
|
||||
.set_moduleFileSuffix(moduleFileSuffix());
|
||||
}
|
||||
|
|
|
@ -106,6 +106,7 @@
|
|||
! HELP-FC1-NEXT: -help Display available options
|
||||
! HELP-FC1-NEXT: -I <dir> Add directory to the end of the list of include search paths
|
||||
! HELP-FC1-NEXT: -module-dir <dir> Put MODULE files in <dir>
|
||||
! HELP-FC1-NEXT: -module-suffix <suffix> Use <suffix> as the suffix for module files (the default value is `.mod`)
|
||||
! HELP-FC1-NEXT: -nocpp Disable predefined and command line preprocessor macros
|
||||
! HELP-FC1-NEXT: -o <file> Write output to <file>
|
||||
! HELP-FC1-NEXT: -pedantic Warn on language extensions
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
! Tests `-module-suffix` frontend option
|
||||
|
||||
!--------------------------
|
||||
! RUN lines
|
||||
!--------------------------
|
||||
! RUN: rm -rf %t && mkdir -p %t/dir-flang/
|
||||
! RUN: cd %t && %flang_fc1 -fsyntax-only -module-suffix .f18.mod -module-dir %t/dir-flang %s
|
||||
! RUN: ls %t/dir-flang/testmodule.f18.mod && not ls %t/dir-flang/testmodule.mod
|
||||
|
||||
!--------------------------
|
||||
! INPUT
|
||||
!--------------------------
|
||||
module testmodule
|
||||
type::t2
|
||||
end type
|
||||
end
|
Loading…
Reference in New Issue