# HG changeset patch # User Benjamin Kramer # Date 1247851400 -7200 # Node ID 8863cf7236e67df107ba9156c8c203f216ce2dc8 # Parent 21d691518d82bd5181b42e522d6270360f42ad4f We need to parse mArch ourselves now Build fix for LLVM r75890 diff -r 21d691518d82 -r 8863cf7236e6 gen/cl_options.cpp --- a/gen/cl_options.cpp Wed Jul 15 23:01:51 2009 +0200 +++ b/gen/cl_options.cpp Fri Jul 17 19:23:20 2009 +0200 @@ -205,8 +205,7 @@ cl::value_desc("filename")); -cl::opt > mArch("march", +cl::opt mArch("march", cl::desc("Architecture to generate code for:")); cl::opt m32bits("m32", diff -r 21d691518d82 -r 8863cf7236e6 gen/cl_options.h --- a/gen/cl_options.h Wed Jul 15 23:01:51 2009 +0200 +++ b/gen/cl_options.h Fri Jul 17 19:23:20 2009 +0200 @@ -6,8 +6,6 @@ #include #include -#include "llvm/Support/RegistryParser.h" -#include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Support/CommandLine.h" namespace opts { @@ -37,8 +35,7 @@ extern cl::list versions; extern cl::opt moduleDepsFile; - extern cl::opt > mArch; + extern cl::opt mArch; extern cl::opt m32bits; extern cl::opt m64bits; extern cl::opt mCPU; diff -r 21d691518d82 -r 8863cf7236e6 gen/main.cpp --- a/gen/main.cpp Wed Jul 15 23:01:51 2009 +0200 +++ b/gen/main.cpp Fri Jul 17 19:23:20 2009 +0200 @@ -12,7 +12,7 @@ #include "llvm/Target/SubtargetFeature.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" -#include "llvm/Target/TargetMachineRegistry.h" +#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetSelect.h" #include @@ -397,7 +397,7 @@ // check -m32/64 sanity if (m32bits && m64bits) error("cannot use both -m32 and -m64 options"); - else if ((m32bits || m64bits) && (mArch != 0 || !mTargetTriple.empty())) + else if ((m32bits || m64bits) && (!mArch.empty() || !mTargetTriple.empty())) error("-m32 and -m64 switches cannot be used together with -march and -mtriple switches"); if (global.errors) fatal(); @@ -415,7 +415,7 @@ // did the user override the target triple? if (mTargetTriple.empty()) { - if (mArch != 0) + if (!mArch.empty()) { error("you must specify a target triple as well with -mtriple when using the -march option"); fatal(); @@ -437,9 +437,9 @@ LDC_TARGETS #undef LLVM_TARGET - const llvm::Target *theTarget; + const llvm::Target *theTarget = NULL; // Check whether the user has explicitly specified an architecture to compile for. - if (mArch == 0) + if (mArch.empty()) { std::string Err; theTarget = llvm::TargetRegistry::getClosestStaticTargetForModule(mod, Err); @@ -451,7 +451,21 @@ } else { - theTarget = &mArch->TheTarget; + for (llvm::TargetRegistry::iterator it = llvm::TargetRegistry::begin(), + ie = llvm::TargetRegistry::end(); it != ie; ++it) + { + if (mArch == it->getName()) + { + theTarget = &*it; + break; + } + } + + if (!theTarget) + { + error("invalid target '%s'", mArch.c_str()); + fatal(); + } } // Package up features to be passed to target/subtarget