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

View file

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