mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-05 01:20:51 +03:00
Fixed choosing default target machine without needing to link in targets.
This commit is contained in:
parent
88f9ca75ad
commit
f411df11e3
3 changed files with 13 additions and 30 deletions
16
dmd/mars.c
16
dmd/mars.c
|
@ -41,9 +41,6 @@
|
|||
|
||||
void getenv_setargv(const char *envvar, int *pargc, char** *pargv);
|
||||
|
||||
// llvmdc
|
||||
void findDefaultTarget();
|
||||
|
||||
Global global;
|
||||
|
||||
Global::Global()
|
||||
|
@ -753,7 +750,18 @@ int main(int argc, char *argv[])
|
|||
bool allowForceEndianness = false;
|
||||
|
||||
if (global.params.llvmArch == 0) {
|
||||
findDefaultTarget();
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
global.params.llvmArch = "x86-64";
|
||||
#elif defined(__i386__) || defined(_M_IX86)
|
||||
global.params.llvmArch = "x86";
|
||||
#elif defined(__ppc__) || defined(_M_PPC)
|
||||
if (global.params.is64bit)
|
||||
global.params.llvmArch = "ppc64";
|
||||
else
|
||||
global.params.llvmArch = "ppc32";
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
}
|
||||
|
||||
if (strcmp(global.params.llvmArch,"x86")==0) {
|
||||
|
|
|
@ -1483,23 +1483,6 @@ LLConstant* DtoTypeInfoOf(Type* type, bool base)
|
|||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void findDefaultTarget()
|
||||
{
|
||||
std::string err_str;
|
||||
const llvm::TargetMachineRegistry::entry* e = llvm::TargetMachineRegistry::getClosestTargetForJIT(err_str);
|
||||
if (e == 0)
|
||||
{
|
||||
error("Failed to find a default target machine: %s", err_str.c_str());
|
||||
fatal();
|
||||
}
|
||||
else
|
||||
{
|
||||
global.params.llvmArch = const_cast<char*>(e->Name);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LLValue* DtoBoolean(Loc& loc, DValue* dval)
|
||||
{
|
||||
Type* dtype = dval->getType()->toBasetype();
|
||||
|
|
|
@ -95,15 +95,7 @@ void Module::genobjfile(int multiobj)
|
|||
ir.module->setTargetTriple(target_triple);
|
||||
ir.module->setDataLayout(global.params.data_layout);
|
||||
|
||||
// heavily inspired by tools/llc/llc.cpp:200-230
|
||||
const llvm::TargetMachineRegistry::entry* targetEntry;
|
||||
std::string targetError;
|
||||
targetEntry = llvm::TargetMachineRegistry::getClosestStaticTargetForModule(*ir.module, targetError);
|
||||
assert(targetEntry && "Failed to find a static target for module");
|
||||
std::auto_ptr<llvm::TargetMachine> targetPtr(targetEntry->CtorFn(*ir.module, "")); // TODO: replace "" with features
|
||||
assert(targetPtr.get() && "Could not allocate target machine!");
|
||||
llvm::TargetMachine &targetMachine = *targetPtr.get();
|
||||
gTargetData = targetMachine.getTargetData();
|
||||
gTargetData = new llvm::TargetData(global.params.data_layout);
|
||||
|
||||
// debug info
|
||||
if (global.params.symdebug) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue