diff --git a/compiler/build/src/link.rs b/compiler/build/src/link.rs index 5f47b533da..a32c0378c5 100644 --- a/compiler/build/src/link.rs +++ b/compiler/build/src/link.rs @@ -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", diff --git a/compiler/build/src/program.rs b/compiler/build/src/program.rs index 511a13e276..d6b2e0cc77 100644 --- a/compiler/build/src/program.rs +++ b/compiler/build/src/program.rs @@ -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)