mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-14 07:09:50 +03:00
Strip path when inferring exe/lib name from first object file
This is what DMD does and crucial for `ldmd2 -od=objects foo.d` with relative -od path (and no -of). The object file path will be `objects/foo.o[bj]`. As it's relative, LDC used to prepend the objects dir (again) in LDMD mode, resulting in the inferred executable file name `objects/objects/foo[.exe]`. So while this is a breaking change, it fixes DMD compatibility of LDMD and makes a lot of sense for 'pure' LDC too IMO (use the first object's file name, replace the extension and save it in the working dir, not in the directory containing the first object file). This fixes the dmd-testsuite regressions with relative RESULTS_DIR and a few long-standing non-fatal dmd-testsuite errors (failing file removals).
This commit is contained in:
parent
0896d38d2d
commit
fd9c1d1b72
2 changed files with 10 additions and 9 deletions
|
@ -60,9 +60,10 @@ static std::string getOutputName() {
|
|||
}
|
||||
|
||||
// Infer output name from first object file.
|
||||
std::string result = global.params.objfiles.dim
|
||||
? FileName::removeExt(global.params.objfiles[0])
|
||||
: "a.out";
|
||||
std::string result =
|
||||
global.params.objfiles.dim
|
||||
? FileName::removeExt(FileName::name(global.params.objfiles[0]))
|
||||
: "a.out";
|
||||
|
||||
if (sharedLib && !triple.isWindowsMSVCEnvironment())
|
||||
result = "lib" + result;
|
||||
|
@ -72,9 +73,8 @@ static std::string getOutputName() {
|
|||
// after execution. Make sure the name does not collide with other files
|
||||
// from other processes by creating a unique filename.
|
||||
llvm::SmallString<128> tempFilename;
|
||||
auto EC = llvm::sys::fs::createTemporaryFile(FileName::name(result.c_str()),
|
||||
extension ? extension : "",
|
||||
tempFilename);
|
||||
auto EC = llvm::sys::fs::createTemporaryFile(
|
||||
result, extension ? extension : "", tempFilename);
|
||||
if (!EC)
|
||||
result = tempFilename.str();
|
||||
} else if (extension) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue