Merge branch 'master' into merge-2.075

Conflicts:
	runtime/druntime
This commit is contained in:
Martin 2017-10-01 18:28:44 +02:00
commit d7f68dbeb3
28 changed files with 489 additions and 261 deletions

View file

@ -104,18 +104,6 @@ static cl::opt<bool> linkDebugLib(
"link-debuglib", cl::ZeroOrMore,
cl::desc("Link with libraries specified in -debuglib, not -defaultlib"));
#if LDC_LLVM_VER >= 309
static inline llvm::Optional<llvm::Reloc::Model> getRelocModel() {
if (mRelocModel.getNumOccurrences()) {
llvm::Reloc::Model R = mRelocModel;
return R;
}
return llvm::None;
}
#else
static inline llvm::Reloc::Model getRelocModel() { return mRelocModel; }
#endif
// This function exits the program.
void printVersion(llvm::raw_ostream &OS) {
OS << "LDC - the LLVM D compiler (" << global.ldc_version << "):\n";
@ -372,8 +360,7 @@ void parseCommandLine(int argc, char **argv, Strings &sourceFiles,
const_cast<char **>(allArguments.data()),
"LDC - the LLVM D compiler\n");
helpOnly = mCPU == "help" ||
(std::find(mAttrs.begin(), mAttrs.end(), "help") != mAttrs.end());
helpOnly = opts::printTargetFeaturesHelp();
if (helpOnly) {
auto triple = llvm::Triple(cfg_triple);
std::string errMsg;
@ -597,19 +584,12 @@ void parseCommandLine(int argc, char **argv, Strings &sourceFiles,
error(Loc(), "-lib and -shared switches cannot be used together");
}
#if LDC_LLVM_VER >= 309
if (global.params.dll && !mRelocModel.getNumOccurrences()) {
#else
if (global.params.dll && mRelocModel == llvm::Reloc::Default) {
#endif
mRelocModel = llvm::Reloc::PIC_;
}
if (soname.getNumOccurrences() > 0 && !global.params.dll) {
error(Loc(), "-soname can be used only when building a shared library");
}
global.params.hdrStripPlainFunctions = !opts::hdrKeepAllBodies;
global.params.disableRedZone = opts::disableRedZone();
}
void initializePasses() {
@ -1006,7 +986,8 @@ int cppmain(int argc, char **argv) {
}
// Set up the TargetMachine.
if ((m32bits || m64bits) && (!mArch.empty() || !mTargetTriple.empty())) {
const auto arch = getArchStr();
if ((m32bits || m64bits) && (!arch.empty() || !mTargetTriple.empty())) {
error(Loc(), "-m32 and -m64 switches cannot be used together with -march "
"and -mtriple switches");
}
@ -1021,9 +1002,21 @@ int cppmain(int argc, char **argv) {
fatal();
}
auto relocModel = getRelocModel();
#if LDC_LLVM_VER >= 309
if (global.params.dll && !relocModel.hasValue()) {
#else
if (global.params.dll && relocModel == llvm::Reloc::Default) {
#endif
relocModel = llvm::Reloc::PIC_;
}
gTargetMachine = createTargetMachine(
mTargetTriple, mArch, mCPU, mAttrs, bitness, mFloatABI, getRelocModel(),
mCodeModel, codeGenOptLevel(), disableFpElim, disableLinkerStripDead);
mTargetTriple, arch, opts::getCPUStr(), opts::getFeaturesStr(), bitness,
floatABI, relocModel, opts::getCodeModel(), codeGenOptLevel(),
disableLinkerStripDead);
opts::setDefaultMathOptions(gTargetMachine->Options);
#if LDC_LLVM_VER >= 308
static llvm::DataLayout DL = gTargetMachine->createDataLayout();
@ -1044,6 +1037,7 @@ int cppmain(int argc, char **argv) {
global.params.isLP64 = gDataLayout->getPointerSizeInBits() == 64;
global.params.is64bit = triple->isArch64Bit();
global.params.hasObjectiveC = objc_isSupported(*triple);
global.params.dwarfVersion = gTargetMachine->Options.MCOptions.DwarfVersion;
// mscoff enables slightly different handling of interface functions
// in the front end
global.params.mscoff = triple->isKnownWindowsMSVCEnvironment();
@ -1051,8 +1045,6 @@ int cppmain(int argc, char **argv) {
global.obj_ext = "obj";
}
opts::setDefaultMathOptions(*gTargetMachine);
// allocate the target abi
gABI = TargetABI::getTarget();