@@ -591,6 +591,14 @@ std::optional<StringRef> LinkerDriver::findLibIfNew(StringRef filename) {
591591 return path;
592592}
593593
594+ void LinkerDriver::setMachine (MachineTypes machine) {
595+ assert (ctx.config .machine == IMAGE_FILE_MACHINE_UNKNOWN);
596+ assert (machine != IMAGE_FILE_MACHINE_UNKNOWN);
597+
598+ ctx.config .machine = machine;
599+ addWinSysRootLibSearchPaths ();
600+ }
601+
594602void LinkerDriver::detectWinSysRoot (const opt::InputArgList &Args) {
595603 IntrusiveRefCntPtr<vfs::FileSystem> VFS = vfs::getRealFileSystem ();
596604
@@ -1887,10 +1895,10 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
18871895 {
18881896 llvm::TimeTraceScope timeScope2 (" Machine arg" );
18891897 if (auto *arg = args.getLastArg (OPT_machine)) {
1890- config-> machine = getMachineType (arg->getValue ());
1891- if (config-> machine == IMAGE_FILE_MACHINE_UNKNOWN)
1898+ MachineTypes machine = getMachineType (arg->getValue ());
1899+ if (machine == IMAGE_FILE_MACHINE_UNKNOWN)
18921900 Fatal (ctx) << " unknown /machine argument: " << arg->getValue ();
1893- addWinSysRootLibSearchPaths ( );
1901+ setMachine (machine );
18941902 }
18951903 }
18961904
@@ -2298,8 +2306,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
22982306 // not we assume x64.
22992307 if (config->machine == IMAGE_FILE_MACHINE_UNKNOWN) {
23002308 Warn (ctx) << " /machine is not specified. x64 is assumed" ;
2301- config->machine = AMD64;
2302- addWinSysRootLibSearchPaths ();
2309+ setMachine (AMD64);
23032310 }
23042311 config->wordsize = config->is64 () ? 8 : 4 ;
23052312
0 commit comments