about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2019-04-04 13:23:42 -0700
committerAlex Crichton <alex@alexcrichton.com>2019-04-04 13:23:42 -0700
commit471db2b84bbeafb128bae8a8a9cf7fed13d2df4f (patch)
treee4a7a4843f5d0fa6e6d0f6e4bbd9419d82334e5c
parent52980d0fb39134a26f73b39b384407e010fc3af5 (diff)
downloadrust-471db2b84bbeafb128bae8a8a9cf7fed13d2df4f.tar.gz
rust-471db2b84bbeafb128bae8a8a9cf7fed13d2df4f.zip
wasm32: Default to a "static" relocation model
LLVM 9 is adding support for a "pic" relocation model for wasm code,
which is quite different than the current model. In order to preserve
the mode of compilation that we have today default to "static" to ensure
that we don't accidentally start creating experimental relocatable
binaries.
-rw-r--r--src/librustc_target/spec/wasm32_base.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/librustc_target/spec/wasm32_base.rs b/src/librustc_target/spec/wasm32_base.rs
index c7e75b4fa09..edaf902c130 100644
--- a/src/librustc_target/spec/wasm32_base.rs
+++ b/src/librustc_target/spec/wasm32_base.rs
@@ -118,6 +118,15 @@ pub fn options() -> TargetOptions {
 
         pre_link_args,
 
+        // This has no effect in LLVM 8 or prior, but in LLVM 9 and later when
+        // PIC code is implemented this has quite a drastric effect if it stays
+        // at the default, `pic`. In an effort to keep wasm binaries as minimal
+        // as possible we're defaulting to `static` for now, but the hope is
+        // that eventually we can ship a `pic`-compatible standard library which
+        // works with `static` as well (or works with some method of generating
+        // non-relative calls and such later on).
+        relocation_model: "static".to_string(),
+
         .. Default::default()
     }
 }