================
@@ -1534,9 +1539,29 @@ int main(int Argc, char **Argv) {
const OptTable &Tbl = getOptTable();
BumpPtrAllocator Alloc;
StringSaver Saver(Alloc);
- auto Args = Tbl.parseArgs(Argc, Argv, OPT_INVALID, Saver, [&](StringRef Err)
{
- reportError(createStringError(Err));
- });
+ SmallVector<const char *, 0> ArgStrings;
+ cl::expandResponseFiles(Argc, Argv, /*EnvVar=*/nullptr, Saver, ArgStrings);
+
+ // link.exe does not accept GNU -l or -L. The Clang driver already
+ // rewrites -lfoo as foo.lib and -L<dir> as -libpath:<dir>. Parsing those
+ // options here would read -link as library "ink" and split -LTCG into "-L"
+ // and "TCG". The host triple selects the visible options, so it is read
+ // before parsing.
+ std::string HostTriple = sys::getDefaultTargetTriple();
+ for (StringRef Arg : ArgStrings) {
+ if (Arg.consume_front("--host-triple="))
+ HostTriple = Arg.str();
+ }
+ unsigned VisibilityMask = DefaultVis;
+ if (!llvm::Triple(HostTriple).isWindowsMSVCEnvironment())
+ VisibilityMask |= GNULinkerVis;
+
+ unsigned MissingArgIndex, MissingArgCount;
+ auto Args = Tbl.ParseArgs(ArgStrings, MissingArgIndex, MissingArgCount,
----------------
dotrucvi wrote:
Thank you @srividya-sundaram for catching this! I moved the host-triple check
and the parse into 1 helper, `parseWrapperArgs`, and call it from both places.
https://github.com/llvm/llvm-project/pull/243300
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits