Remove LDC-specific global.obj_ext_alt

No functional changes intended.
This commit is contained in:
Martin 2016-08-28 20:10:01 +02:00
parent 60a3accffd
commit 41fb7830df
7 changed files with 24 additions and 38 deletions

View file

@ -240,7 +240,6 @@ struct Global
const(char)* obj_ext; const(char)* obj_ext;
version(IN_LLVM) version(IN_LLVM)
{ {
const(char)* obj_ext_alt;
const(char)* ll_ext; const(char)* ll_ext;
const(char)* bc_ext; const(char)* bc_ext;
const(char)* s_ext; const(char)* s_ext;
@ -324,7 +323,6 @@ version(IN_LLVM)
bc_ext = "bc"; bc_ext = "bc";
s_ext = "s"; s_ext = "s";
obj_ext = "o"; obj_ext = "o";
obj_ext_alt = "obj";
} }
else else
{ {

View file

@ -236,7 +236,6 @@ struct Global
const char *mars_ext; const char *mars_ext;
const char *obj_ext; const char *obj_ext;
#if IN_LLVM #if IN_LLVM
const char *obj_ext_alt;
const char *ll_ext; const char *ll_ext;
const char *bc_ext; const char *bc_ext;
const char *s_ext; const char *s_ext;

View file

@ -1248,26 +1248,20 @@ extern (C++) int mars_mainBody(ref Strings files, ref Strings libmodules,
{ {
/* Deduce what to do with a file based on its extension /* Deduce what to do with a file based on its extension
*/ */
version (IN_LLVM)
{
if (FileName.equals(ext, global.obj_ext) ||
(TARGET_WINDOS && FileName.equals(ext, global.obj_ext_alt)))
{
global.params.objfiles.push(files[i]);
continue;
}
// Detect LLVM bitcode files on commandline
if (FileName.equals(ext, global.bc_ext)) {
global.params.bitcodeFiles.push(files[i]);
continue;
}
}
else
{
if (FileName.equals(ext, global.obj_ext)) if (FileName.equals(ext, global.obj_ext))
{ {
global.params.objfiles.push(files[i]); global.params.objfiles.push(files[i]);
version (IN_LLVM) {} else
{
libmodules.push(files[i]); libmodules.push(files[i]);
}
continue;
}
version (IN_LLVM)
{
// Detect LLVM bitcode files on commandline
if (FileName.equals(ext, global.bc_ext)) {
global.params.bitcodeFiles.push(files[i]);
continue; continue;
} }
} }

View file

@ -91,9 +91,7 @@ CodeGenerator::~CodeGenerator() {
const char *oname; const char *oname;
const char *filename; const char *filename;
if ((oname = global.params.exefile) || (oname = global.params.objname)) { if ((oname = global.params.exefile) || (oname = global.params.objname)) {
filename = FileName::forceExt( filename = FileName::forceExt(oname, global.obj_ext);
oname, global.params.targetTriple->isOSWindows() ? global.obj_ext_alt
: global.obj_ext);
if (global.params.objdir) { if (global.params.objdir) {
filename = filename =
FileName::combine(global.params.objdir, FileName::name(filename)); FileName::combine(global.params.objdir, FileName::name(filename));

View file

@ -71,16 +71,11 @@ public:
} }
}; };
const char *cacheObjectExtension() {
return global.params.targetTriple->isOSWindows() ? global.obj_ext_alt
: global.obj_ext;
}
void storeCacheFileName(llvm::StringRef cacheObjectHash, void storeCacheFileName(llvm::StringRef cacheObjectHash,
llvm::SmallString<128> &filePath) { llvm::SmallString<128> &filePath) {
filePath = opts::ir2objCacheDir; filePath = opts::ir2objCacheDir;
llvm::sys::path::append(filePath, llvm::Twine("ircache_") + cacheObjectHash + llvm::sys::path::append(filePath, llvm::Twine("ircache_") + cacheObjectHash +
"." + cacheObjectExtension()); "." + global.obj_ext);
} }
} }

View file

@ -608,8 +608,10 @@ static void parseCommandLine(int argc, char **argv, Strings &sourceFiles,
} else if (strcmp(ext, global.s_ext) == 0) { } else if (strcmp(ext, global.s_ext) == 0) {
global.params.output_s = OUTPUTFLAGset; global.params.output_s = OUTPUTFLAGset;
autofound = true; autofound = true;
} else if (strcmp(ext, global.obj_ext) == 0 || } else if (strcmp(ext, global.obj_ext) == 0 || strcmp(ext, "obj") == 0) {
strcmp(ext, global.obj_ext_alt) == 0) { // global.obj_ext hasn't been corrected yet for MSVC targets as we first
// need the command line to figure out the target...
// so treat both 'o' and 'obj' extensions as object files
global.params.output_o = OUTPUTFLAGset; global.params.output_o = OUTPUTFLAGset;
autofound = true; autofound = true;
} else { } else {
@ -1089,6 +1091,8 @@ int cppmain(int argc, char **argv) {
// mscoff enables slightly different handling of interface functions // mscoff enables slightly different handling of interface functions
// in the front end // in the front end
global.params.mscoff = triple->isKnownWindowsMSVCEnvironment(); global.params.mscoff = triple->isKnownWindowsMSVCEnvironment();
if (global.params.mscoff)
global.obj_ext = "obj";
} }
// allocate the target abi // allocate the target abi
@ -1108,7 +1112,8 @@ int cppmain(int argc, char **argv) {
} }
Strings libmodules; Strings libmodules;
return mars_mainBody(files, libmodules, createStaticLib, createSharedLib, staticFlag); return mars_mainBody(files, libmodules, createStaticLib, createSharedLib,
staticFlag);
} }
void codegenModules(Modules &modules) { void codegenModules(Modules &modules) {

View file

@ -86,9 +86,6 @@ void buildTargetFiles(Module *m, bool singleObj, bool library) {
if (!m->objfile) { if (!m->objfile) {
const char *objname = library ? nullptr : global.params.objname; const char *objname = library ? nullptr : global.params.objname;
if (global.params.output_o) { if (global.params.output_o) {
const char *extension = global.params.targetTriple->isOSWindows()
? global.obj_ext_alt
: global.obj_ext;
llvm::SmallString<128> tempFilename; // must outlive buildFilePath call llvm::SmallString<128> tempFilename; // must outlive buildFilePath call
if (global.params.run) { if (global.params.run) {
using namespace llvm; using namespace llvm;
@ -99,21 +96,21 @@ void buildTargetFiles(Module *m, bool singleObj, bool library) {
std::error_code EC; std::error_code EC;
if (global.params.objdir) { if (global.params.objdir) {
// Prepend with path to form absolute filename. // Prepend with path to form absolute filename.
EC = sys::fs::createUniqueFile(Twine(global.params.objdir) + EC = sys::fs::createUniqueFile(
sys::path::get_separator() + Twine(global.params.objdir) + sys::path::get_separator() +
tmpname + "-%%%%%%%." + extension, tmpname + "-%%%%%%%." + global.obj_ext,
tempFilename); tempFilename);
} else { } else {
// Uses current dir as base for file. // Uses current dir as base for file.
EC = sys::fs::createUniqueFile( EC = sys::fs::createUniqueFile(
Twine(tmpname) + "-%%%%%%%." + extension, tempFilename); Twine(tmpname) + "-%%%%%%%." + global.obj_ext, tempFilename);
} }
if (!EC) { if (!EC) {
objname = tempFilename.c_str(); objname = tempFilename.c_str();
} }
} }
m->objfile = m->buildFilePath(objname, global.params.objdir, extension, m->objfile = m->buildFilePath(objname, global.params.objdir,
library, fqnNames); global.obj_ext, library, fqnNames);
} else if (global.params.output_bc) { } else if (global.params.output_bc) {
m->objfile = m->buildFilePath(objname, global.params.objdir, m->objfile = m->buildFilePath(objname, global.params.objdir,
global.bc_ext, library, fqnNames); global.bc_ext, library, fqnNames);