Fix linking with PIC

This commit is contained in:
Brendan Hansknecht 2021-08-28 15:24:02 -07:00
parent c7f5793d2a
commit c1cae950e7
2 changed files with 12 additions and 1 deletions

View file

@ -84,6 +84,9 @@ pub fn build_zig_host_native(
// include libc
"--library",
"c",
"-fPIC",
"-O",
"ReleaseSafe",
])
.output()
.unwrap()
@ -157,6 +160,9 @@ pub fn build_zig_host_native(
// include libc
"--library",
"c",
"-fPIC",
"-O",
"ReleaseSafe",
])
.output()
.unwrap()
@ -198,6 +204,9 @@ pub fn build_zig_host_wasm32(
"i386-linux-musl",
// "wasm32-wasi",
// "-femit-llvm-ir=/home/folkertdev/roc/roc/examples/benchmarks/platform/host.ll",
"-fPIC",
"-O",
"ReleaseSafe",
])
.output()
.unwrap()
@ -258,6 +267,8 @@ pub fn rebuild_host(target: &Triple, host_input_path: &Path) {
.env_clear()
.env("PATH", &env_path)
.args(&[
"-O2",
"-fPIC",
"-c",
c_host_src.to_str().unwrap(),
"-o",

View file

@ -273,7 +273,7 @@ pub fn gen_from_mono_module(
use target_lexicon::Architecture;
match target.architecture {
Architecture::X86_64 | Architecture::Aarch64(_) => {
let reloc = RelocMode::Default;
let reloc = RelocMode::PIC;
let model = CodeModel::Default;
let target_machine =
target::target_machine(target, convert_opt_level(opt_level), reloc, model)