[pkg-d-commits] [ldc] 07/14: LLVM 3.9: llvm::Reloc::Default was removed.
Matthias Klumpp
mak at moszumanska.debian.org
Sun Apr 23 22:35:54 UTC 2017
This is an automated email from the git hooks/post-receive script.
mak pushed a commit to annotated tag v0.17.2
in repository ldc.
commit b60a1c9e75c9d753afa8926c782ce7a5f31cb2f1
Author: Kai Nacke <kai at redstar.de>
Date: Fri May 20 08:51:04 2016 +0200
LLVM 3.9: llvm::Reloc::Default was removed.
The value is now optional as there is nothing like a default relocation.
(cherry picked from commit de296b90ec44a1e2450b7e2ca0be5698ca3837dd)
---
driver/cl_options.cpp | 4 ++++
driver/main.cpp | 20 +++++++++++++++++++-
driver/targetmachine.cpp | 11 ++++++++++-
driver/targetmachine.h | 10 +++++++++-
4 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/driver/cl_options.cpp b/driver/cl_options.cpp
index 3157cae..6840dd6 100644
--- a/driver/cl_options.cpp
+++ b/driver/cl_options.cpp
@@ -274,10 +274,14 @@ cl::opt<std::string>
cl::opt<llvm::Reloc::Model> mRelocModel(
"relocation-model", cl::desc("Relocation model"),
+#if LDC_LLVM_VER < 309
cl::init(llvm::Reloc::Default),
+#endif
cl::values(
+#if LDC_LLVM_VER < 309
clEnumValN(llvm::Reloc::Default, "default",
"Target default relocation model"),
+#endif
clEnumValN(llvm::Reloc::Static, "static", "Non-relocatable code"),
clEnumValN(llvm::Reloc::PIC_, "pic",
"Fully relocatable, position independent code"),
diff --git a/driver/main.cpp b/driver/main.cpp
index f86bdc6..edc262c 100644
--- a/driver/main.cpp
+++ b/driver/main.cpp
@@ -104,6 +104,20 @@ static cl::opt<bool> staticFlag(
"Create a statically linked binary, including all system dependencies"),
cl::ZeroOrMore);
+#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
+
void printVersion() {
printf("LDC - the LLVM D compiler (%s):\n", global.ldc_version);
printf(" based on DMD %s and LLVM %s\n", global.version,
@@ -505,7 +519,11 @@ static void parseCommandLine(int argc, char **argv, Strings &sourceFiles,
error(Loc(), "-lib and -shared switches cannot be used together");
}
+#if LDC_LLVM_VER >= 309
+ if (createSharedLib && !mRelocModel.getNumOccurrences()) {
+#else
if (createSharedLib && mRelocModel == llvm::Reloc::Default) {
+#endif
mRelocModel = llvm::Reloc::PIC_;
}
@@ -964,7 +982,7 @@ int main(int argc, char **argv) {
}
gTargetMachine = createTargetMachine(
- mTargetTriple, mArch, mCPU, mAttrs, bitness, mFloatABI, mRelocModel,
+ mTargetTriple, mArch, mCPU, mAttrs, bitness, mFloatABI, getRelocModel(),
mCodeModel, codeGenOptLevel(), disableFpElim, disableLinkerStripDead);
#if LDC_LLVM_VER >= 308
diff --git a/driver/targetmachine.cpp b/driver/targetmachine.cpp
index 9336e70..0aa9281 100644
--- a/driver/targetmachine.cpp
+++ b/driver/targetmachine.cpp
@@ -421,7 +421,12 @@ const llvm::Target *lookupTarget(const std::string &arch, llvm::Triple &triple,
llvm::TargetMachine *createTargetMachine(
std::string targetTriple, std::string arch, std::string cpu,
std::vector<std::string> attrs, ExplicitBitness::Type bitness,
- FloatABI::Type floatABI, llvm::Reloc::Model relocModel,
+ FloatABI::Type floatABI,
+#if LDC_LLVM_VER >= 309
+ llvm::Optional<llvm::Reloc::Model> relocModel,
+#else
+ llvm::Reloc::Model relocModel,
+#endif
llvm::CodeModel::Model codeModel, llvm::CodeGenOpt::Level codeGenOptLevel,
bool noFramePointerElim, bool noLinkerStripDead) {
// Determine target triple. If the user didn't explicitly specify one, use
@@ -506,7 +511,11 @@ llvm::TargetMachine *createTargetMachine(
}
// Handle cases where LLVM picks wrong default relocModel
+#if LDC_LLVM_VER >= 309
+ if (!relocModel.hasValue()) {
+#else
if (relocModel == llvm::Reloc::Default) {
+#endif
if (triple.isOSDarwin()) {
// Darwin defaults to PIC (and as of 10.7.5/LLVM 3.1-3.3, TLS use leads
// to crashes for non-PIC code). LLVM doesn't handle this.
diff --git a/driver/targetmachine.h b/driver/targetmachine.h
index 24eed8a..70fc811 100644
--- a/driver/targetmachine.h
+++ b/driver/targetmachine.h
@@ -15,6 +15,9 @@
#ifndef LDC_DRIVER_TARGET_H
#define LDC_DRIVER_TARGET_H
+#if LDC_LLVM_VER >= 309
+#include "llvm/ADT/Optional.h"
+#endif
#include "llvm/Support/CodeGen.h"
#include <string>
#include <vector>
@@ -44,7 +47,12 @@ class TargetMachine;
llvm::TargetMachine *createTargetMachine(
std::string targetTriple, std::string arch, std::string cpu,
std::vector<std::string> attrs, ExplicitBitness::Type bitness,
- FloatABI::Type floatABI, llvm::Reloc::Model relocModel,
+ FloatABI::Type floatABI,
+#if LDC_LLVM_VER >= 309
+ llvm::Optional<llvm::Reloc::Model> relocModel,
+#else
+ llvm::Reloc::Model relocModel,
+#endif
llvm::CodeModel::Model codeModel, llvm::CodeGenOpt::Level codeGenOptLevel,
bool noFramePointerElim, bool noLinkerStripDead);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git
More information about the pkg-d-commits
mailing list