Skip to content

Commit c03fa7b

Browse files
authored
Rollup merge of #59712 - alexcrichton:wasm-static-not-pic, r=eddyb
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.
2 parents 3600e4d + 471db2b commit c03fa7b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/librustc_target/spec/wasm32_base.rs

+9
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ pub fn options() -> TargetOptions {
118118

119119
pre_link_args,
120120

121+
// This has no effect in LLVM 8 or prior, but in LLVM 9 and later when
122+
// PIC code is implemented this has quite a drastric effect if it stays
123+
// at the default, `pic`. In an effort to keep wasm binaries as minimal
124+
// as possible we're defaulting to `static` for now, but the hope is
125+
// that eventually we can ship a `pic`-compatible standard library which
126+
// works with `static` as well (or works with some method of generating
127+
// non-relative calls and such later on).
128+
relocation_model: "static".to_string(),
129+
121130
.. Default::default()
122131
}
123132
}

0 commit comments

Comments
 (0)