Make PIC optional for compilers

This commit is contained in:
Syrus
2020-05-19 16:56:56 -07:00
parent 78aa07fe57
commit ae8dcfcb27
10 changed files with 50 additions and 30 deletions

View File

@@ -37,6 +37,8 @@ pub struct CraneliftConfig {
/// The verifier assures that the generated Cranelift IR is valid.
pub enable_verifier: bool,
enable_pic: bool,
/// The optimization levels when optimizing the IR.
pub opt_level: OptLevel,
@@ -52,6 +54,7 @@ impl CraneliftConfig {
enable_nan_canonicalization: false,
enable_verifier: false,
opt_level: OptLevel::Speed,
enable_pic: false,
features,
target,
}
@@ -124,7 +127,9 @@ impl CraneliftConfig {
.enable("avoid_div_traps")
.expect("should be valid flag");
flags.enable("is_pic").expect("should be a valid flag");
if self.enable_pic {
flags.enable("is_pic").expect("should be a valid flag");
}
// Invert cranelift's default-on verification to instead default off.
let enable_verifier = if self.enable_verifier {
@@ -174,6 +179,10 @@ impl CompilerConfig for CraneliftConfig {
&self.features
}
fn enable_pic(&mut self) {
self.enable_pic = true;
}
/// Gets the target that we will use for compiling
/// the WebAssembly module
fn target(&self) -> &Target {