diff options
author | David Truby <david.truby@arm.com> | 2023-11-15 15:26:43 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-15 15:26:43 +0000 |
commit | 77ecb9a49bb1640684c37f80ffe56bc54dae6502 (patch) | |
tree | 86fea45ebf5d2db847dca1944036b736be248e4c /flang/lib/Frontend/CompilerInvocation.cpp | |
parent | b6f51787f6c8e77143f0aef6b58ddc7c55741d5c (diff) | |
download | llvm-77ecb9a49bb1640684c37f80ffe56bc54dae6502.zip llvm-77ecb9a49bb1640684c37f80ffe56bc54dae6502.tar.gz llvm-77ecb9a49bb1640684c37f80ffe56bc54dae6502.tar.bz2 |
[flang] Add dependent-lib option to flang -fc1 on Windows (#72121)
This patch adds a --dependent-lib option to flang -fc1 on Windows to
embed library link options into the object file. This is needed to
properly select the Windows CRT to link against.
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | flang/lib/Frontend/CompilerInvocation.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 334da3a..cb4f2d6 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -1054,6 +1054,27 @@ static bool parseVScaleArgs(CompilerInvocation &invoc, llvm::opt::ArgList &args, return true; } +static bool parseLinkerOptionsArgs(CompilerInvocation &invoc, + llvm::opt::ArgList &args, + clang::DiagnosticsEngine &diags) { + llvm::Triple triple = llvm::Triple(invoc.getTargetOpts().triple); + + // TODO: support --dependent-lib on other platforms when MLIR supports + // !llvm.dependent.lib + if (args.hasArg(clang::driver::options::OPT_dependent_lib) && + !triple.isOSWindows()) { + const unsigned diagID = + diags.getCustomDiagID(clang::DiagnosticsEngine::Error, + "--dependent-lib is only supported on Windows"); + diags.Report(diagID); + return false; + } + + invoc.getCodeGenOpts().DependentLibs = + args.getAllArgValues(clang::driver::options::OPT_dependent_lib); + return true; +} + bool CompilerInvocation::createFromArgs( CompilerInvocation &res, llvm::ArrayRef<const char *> commandLineArgs, clang::DiagnosticsEngine &diags, const char *argv0) { @@ -1163,6 +1184,8 @@ bool CompilerInvocation::createFromArgs( success &= parseVScaleArgs(res, args, diags); + success &= parseLinkerOptionsArgs(res, args, diags); + // Set the string to be used as the return value of the COMPILER_OPTIONS // intrinsic of iso_fortran_env. This is either passed in from the parent // compiler driver invocation with an environment variable, or failing that |