llvm6: CodeModel::{JIT,}Default no longer exists
LLVM has since removed the `CodeModel::Default` enum value in favor of an `Optional` implementationg throughout LLVM. Let's mirror the same change in Rust and update the various bindings we call accordingly. Removed in llvm-mirror/llvm@9aafb854c
This commit is contained in:
@@ -320,8 +320,8 @@ pub struct TargetOptions {
|
|||||||
/// Relocation model to use in object file. Corresponds to `llc
|
/// Relocation model to use in object file. Corresponds to `llc
|
||||||
/// -relocation-model=$relocation_model`. Defaults to "pic".
|
/// -relocation-model=$relocation_model`. Defaults to "pic".
|
||||||
pub relocation_model: String,
|
pub relocation_model: String,
|
||||||
/// Code model to use. Corresponds to `llc -code-model=$code_model`. Defaults to "default".
|
/// Code model to use. Corresponds to `llc -code-model=$code_model`.
|
||||||
pub code_model: String,
|
pub code_model: Option<String>,
|
||||||
/// TLS model to use. Options are "global-dynamic" (default), "local-dynamic", "initial-exec"
|
/// TLS model to use. Options are "global-dynamic" (default), "local-dynamic", "initial-exec"
|
||||||
/// and "local-exec". This is similar to the -ftls-model option in GCC/Clang.
|
/// and "local-exec". This is similar to the -ftls-model option in GCC/Clang.
|
||||||
pub tls_model: String,
|
pub tls_model: String,
|
||||||
@@ -483,7 +483,7 @@ impl Default for TargetOptions {
|
|||||||
only_cdylib: false,
|
only_cdylib: false,
|
||||||
executables: false,
|
executables: false,
|
||||||
relocation_model: "pic".to_string(),
|
relocation_model: "pic".to_string(),
|
||||||
code_model: "default".to_string(),
|
code_model: None,
|
||||||
tls_model: "global-dynamic".to_string(),
|
tls_model: "global-dynamic".to_string(),
|
||||||
disable_redzone: false,
|
disable_redzone: false,
|
||||||
eliminate_frame_pointer: true,
|
eliminate_frame_pointer: true,
|
||||||
@@ -736,7 +736,7 @@ impl Target {
|
|||||||
key!(only_cdylib, bool);
|
key!(only_cdylib, bool);
|
||||||
key!(executables, bool);
|
key!(executables, bool);
|
||||||
key!(relocation_model);
|
key!(relocation_model);
|
||||||
key!(code_model);
|
key!(code_model, optional);
|
||||||
key!(tls_model);
|
key!(tls_model);
|
||||||
key!(disable_redzone, bool);
|
key!(disable_redzone, bool);
|
||||||
key!(eliminate_frame_pointer, bool);
|
key!(eliminate_frame_pointer, bool);
|
||||||
|
|||||||
@@ -299,12 +299,11 @@ pub enum RelocMode {
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub enum CodeModel {
|
pub enum CodeModel {
|
||||||
Other,
|
Other,
|
||||||
Default,
|
|
||||||
JITDefault,
|
|
||||||
Small,
|
Small,
|
||||||
Kernel,
|
Kernel,
|
||||||
Medium,
|
Medium,
|
||||||
Large,
|
Large,
|
||||||
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// LLVMRustDiagnosticKind
|
/// LLVMRustDiagnosticKind
|
||||||
|
|||||||
@@ -68,8 +68,7 @@ pub const RELOC_MODEL_ARGS : [(&'static str, llvm::RelocMode); 7] = [
|
|||||||
("ropi-rwpi", llvm::RelocMode::ROPI_RWPI),
|
("ropi-rwpi", llvm::RelocMode::ROPI_RWPI),
|
||||||
];
|
];
|
||||||
|
|
||||||
pub const CODE_GEN_MODEL_ARGS : [(&'static str, llvm::CodeModel); 5] = [
|
pub const CODE_GEN_MODEL_ARGS: &[(&str, llvm::CodeModel)] = &[
|
||||||
("default", llvm::CodeModel::Default),
|
|
||||||
("small", llvm::CodeModel::Small),
|
("small", llvm::CodeModel::Small),
|
||||||
("kernel", llvm::CodeModel::Kernel),
|
("kernel", llvm::CodeModel::Kernel),
|
||||||
("medium", llvm::CodeModel::Medium),
|
("medium", llvm::CodeModel::Medium),
|
||||||
@@ -170,20 +169,23 @@ pub fn target_machine_factory(sess: &Session)
|
|||||||
let ffunction_sections = sess.target.target.options.function_sections;
|
let ffunction_sections = sess.target.target.options.function_sections;
|
||||||
let fdata_sections = ffunction_sections;
|
let fdata_sections = ffunction_sections;
|
||||||
|
|
||||||
let code_model_arg = match sess.opts.cg.code_model {
|
let code_model_arg = sess.opts.cg.code_model.as_ref().or(
|
||||||
Some(ref s) => &s,
|
sess.target.target.options.code_model.as_ref(),
|
||||||
None => &sess.target.target.options.code_model,
|
);
|
||||||
};
|
|
||||||
|
|
||||||
let code_model = match CODE_GEN_MODEL_ARGS.iter().find(
|
let code_model = match code_model_arg {
|
||||||
|&&arg| arg.0 == code_model_arg) {
|
Some(s) => {
|
||||||
Some(x) => x.1,
|
match CODE_GEN_MODEL_ARGS.iter().find(|arg| arg.0 == s) {
|
||||||
_ => {
|
Some(x) => x.1,
|
||||||
sess.err(&format!("{:?} is not a valid code model",
|
_ => {
|
||||||
code_model_arg));
|
sess.err(&format!("{:?} is not a valid code model",
|
||||||
sess.abort_if_errors();
|
code_model_arg));
|
||||||
bug!();
|
sess.abort_if_errors();
|
||||||
|
bug!();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
None => llvm::CodeModel::None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let singlethread = sess.target.target.options.singlethread;
|
let singlethread = sess.target.target.options.singlethread;
|
||||||
|
|||||||
@@ -23,9 +23,14 @@
|
|||||||
#include "llvm/Support/FileSystem.h"
|
#include "llvm/Support/FileSystem.h"
|
||||||
#include "llvm/Support/Host.h"
|
#include "llvm/Support/Host.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Target/TargetSubtargetInfo.h"
|
|
||||||
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
|
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
|
||||||
|
|
||||||
|
#if LLVM_VERSION_GE(6, 0)
|
||||||
|
#include "llvm/CodeGen/TargetSubtargetInfo.h"
|
||||||
|
#else
|
||||||
|
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if LLVM_VERSION_GE(4, 0)
|
#if LLVM_VERSION_GE(4, 0)
|
||||||
#include "llvm/Transforms/IPO/AlwaysInliner.h"
|
#include "llvm/Transforms/IPO/AlwaysInliner.h"
|
||||||
#include "llvm/Transforms/IPO/FunctionImport.h"
|
#include "llvm/Transforms/IPO/FunctionImport.h"
|
||||||
@@ -210,20 +215,15 @@ extern "C" bool LLVMRustHasFeature(LLVMTargetMachineRef TM,
|
|||||||
|
|
||||||
enum class LLVMRustCodeModel {
|
enum class LLVMRustCodeModel {
|
||||||
Other,
|
Other,
|
||||||
Default,
|
|
||||||
JITDefault,
|
|
||||||
Small,
|
Small,
|
||||||
Kernel,
|
Kernel,
|
||||||
Medium,
|
Medium,
|
||||||
Large,
|
Large,
|
||||||
|
None,
|
||||||
};
|
};
|
||||||
|
|
||||||
static CodeModel::Model fromRust(LLVMRustCodeModel Model) {
|
static CodeModel::Model fromRust(LLVMRustCodeModel Model) {
|
||||||
switch (Model) {
|
switch (Model) {
|
||||||
case LLVMRustCodeModel::Default:
|
|
||||||
return CodeModel::Default;
|
|
||||||
case LLVMRustCodeModel::JITDefault:
|
|
||||||
return CodeModel::JITDefault;
|
|
||||||
case LLVMRustCodeModel::Small:
|
case LLVMRustCodeModel::Small:
|
||||||
return CodeModel::Small;
|
return CodeModel::Small;
|
||||||
case LLVMRustCodeModel::Kernel:
|
case LLVMRustCodeModel::Kernel:
|
||||||
@@ -360,7 +360,6 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
|
|||||||
bool TrapUnreachable,
|
bool TrapUnreachable,
|
||||||
bool Singlethread) {
|
bool Singlethread) {
|
||||||
|
|
||||||
auto CM = fromRust(RustCM);
|
|
||||||
auto OptLevel = fromRust(RustOptLevel);
|
auto OptLevel = fromRust(RustOptLevel);
|
||||||
auto RM = fromRust(RustReloc);
|
auto RM = fromRust(RustReloc);
|
||||||
|
|
||||||
@@ -399,6 +398,13 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
|
|||||||
Options.ThreadModel = ThreadModel::Single;
|
Options.ThreadModel = ThreadModel::Single;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LLVM_VERSION_GE(6, 0)
|
||||||
|
Optional<CodeModel::Model> CM;
|
||||||
|
#else
|
||||||
|
CodeModel::Model CM = CodeModel::Model::Default;
|
||||||
|
#endif
|
||||||
|
if (RustCM != LLVMRustCodeModel::None)
|
||||||
|
CM = fromRust(RustCM);
|
||||||
TargetMachine *TM = TheTarget->createTargetMachine(
|
TargetMachine *TM = TheTarget->createTargetMachine(
|
||||||
Trip.getTriple(), RealCPU, Feature, Options, RM, CM, OptLevel);
|
Trip.getTriple(), RealCPU, Feature, Options, RM, CM, OptLevel);
|
||||||
return wrap(TM);
|
return wrap(TM);
|
||||||
|
|||||||
Reference in New Issue
Block a user