Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into sym-1.37.x
Browse files Browse the repository at this point in the history
  • Loading branch information
kinke committed Mar 4, 2024
2 parents 098eed3 + 3eb3190 commit c8253b7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
# LDC master

#### Big news
- Frontend, druntime and Phobos are at version [2.107.1](https://dlang.org/changelog/2.107.0.html). (#4563, #4577, #4587)

#### Platform support

#### Bug fixes

# LDC 1.37.0 (2024-03-03)

#### Big news
- Frontend, druntime and Phobos are at version [2.107.1](https://dlang.org/changelog/2.107.0.html). (#4563, #4577, #4587)

#### Bug fixes
- Fix if-statement elision on constant true/false condition. (#4556, #4559)

# LDC 1.36.0 (2024-01-06)

#### Big news
Expand Down
42 changes: 24 additions & 18 deletions driver/tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,30 @@ std::string getProgram(const char *fallbackName,

std::string getGcc(std::vector<std::string> &additional_args,
const char *fallback) {
// In case $CC contains spaces split it into a command and arguments
std::string cc = env::get("CC");
if (cc.empty())
return getProgram(fallback, &gcc);

// $CC is set so fallback doesn't matter anymore.
if (cc.find(' ') == cc.npos)
return getProgram(cc.c_str(), &gcc);

llvm::StringRef sr(cc);
llvm::SmallVector<llvm::StringRef, 8> args;
sr.split(args, ' ', /*MaxSplit=*/-1, /*keepEmpty=*/false);

// args[0] == CC command, args[1..] = CLI options
additional_args.reserve(additional_args.size() + args.size() - 1);
for (size_t i = 1; i < args.size(); i ++)
additional_args.emplace_back(args[i].str());
return getProgram(args[0].str().c_str(), &gcc);
#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");
if (cc.empty())
return getProgram(fallback, &gcc);

// $CC is set so fallback doesn't matter anymore.
if (cc.find(' ') == cc.npos)
return getProgram(cc.c_str(), &gcc);

llvm::StringRef sr(cc);
llvm::SmallVector<llvm::StringRef, 8> args;
sr.split(args, ' ', /*MaxSplit=*/-1, /*keepEmpty=*/false);

// args[0] == CC command, args[1..] = CLI options
additional_args.reserve(additional_args.size() + args.size() - 1);
for (size_t i = 1; i < args.size(); i ++)
additional_args.emplace_back(args[i].str());
return getProgram(args[0].str().c_str(), &gcc);
#endif
}

////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit c8253b7

Please sign in to comment.