Index: tools/driver/driver.cpp =================================================================== --- tools/driver/driver.cpp +++ tools/driver/driver.cpp @@ -209,20 +209,24 @@ static void insertTargetAndModeArgs(const ParsedClangName &NameParts, SmallVectorImpl &ArgVector, std::set &SavedStrings) { - // Put target and mode arguments at the start of argument list so that - // arguments specified in command line could override them. Avoid putting - // them at index 0, as an option like '-cc1' must remain the first. - auto InsertionPoint = ArgVector.begin(); - if (InsertionPoint != ArgVector.end()) - ++InsertionPoint; - if (NameParts.DriverMode) { + // Put target and mode arguments at the start of argument list so that + // arguments specified in command line could override them. Avoid putting + // them at index 0, as an option like '-cc1' must remain the first. + auto InsertionPoint = ArgVector.begin(); + if (InsertionPoint != ArgVector.end()) + ++InsertionPoint; + // Add the mode flag to the arguments. ArgVector.insert(InsertionPoint, GetStableCStr(SavedStrings, NameParts.DriverMode)); } if (NameParts.TargetIsValid) { + auto InsertionPoint = ArgVector.begin(); + if (InsertionPoint != ArgVector.end()) + ++InsertionPoint; + const char *arr[] = {"-target", GetStableCStr(SavedStrings, NameParts.TargetPrefix)}; ArgVector.insert(InsertionPoint, std::begin(arr), std::end(arr));