Windows: Don't split CC into command + arguments separated by spaces (#4590)

This commit is contained in:
Martin Kinkelin 2024-03-02 08:33:40 +01:00 committed by GitHub
parent 42153ca24b
commit 75c4ef8adb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -78,7 +78,12 @@ std::string getProgram(const char *fallbackName,
std::string getGcc(std::vector<std::string> &additional_args, std::string getGcc(std::vector<std::string> &additional_args,
const char *fallback) { const char *fallback) {
// In case $CC contains spaces split it into a command and arguments #ifdef _WIN32
// spaces in $CC are to be expected on Windows
// (e.g., `C:\Program Files\LLVM\bin\clang-cl.exe`)
return getProgram(fallback, &gcc, "CC");
#else
// Posix: in case $CC contains spaces split it into a command and arguments
std::string cc = env::get("CC"); std::string cc = env::get("CC");
if (cc.empty()) if (cc.empty())
return getProgram(fallback, &gcc); return getProgram(fallback, &gcc);
@ -96,6 +101,7 @@ std::string getGcc(std::vector<std::string> &additional_args,
for (size_t i = 1; i < args.size(); i ++) for (size_t i = 1; i < args.size(); i ++)
additional_args.emplace_back(args[i].str()); additional_args.emplace_back(args[i].str());
return getProgram(args[0].str().c_str(), &gcc); return getProgram(args[0].str().c_str(), &gcc);
#endif
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////