Commit 356f033d authored by qinsoon's avatar qinsoon

link order matters on linux

parent d8d598e6
Pipeline #426 failed with stages
in 57 minutes and 10 seconds
......@@ -64,15 +64,6 @@ fn link_dylib_internal (files: Vec<PathBuf>, lib: &Vec<String>, libpath: &Vec<St
let mut cc = Command::new(get_test_clang_path());
// include mu static lib
let libmu_path = if cfg!(debug_assertions) {
"target/debug/libmu.a"
} else {
"target/release/libmu.a"
};
let libmu = get_path_under_mu(libmu_path);
cc.arg(format!("{}", libmu.to_str().unwrap()));
// external libs
for path in libpath.iter() {
cc.arg(format!("-L{}", path));
......@@ -81,15 +72,28 @@ fn link_dylib_internal (files: Vec<PathBuf>, lib: &Vec<String>, libpath: &Vec<St
cc.arg(format!("-l{}", l));
}
// options
cc.arg("-shared");
cc.arg("-fPIC");
cc.arg("-Wl");
cc.arg("-undefined");
cc.arg("dynamic_lookup");
// all object files
for obj in object_files {
cc.arg(obj.as_os_str());
}
// include mu static lib
let libmu_path = if cfg!(debug_assertions) {
"target/debug/libmu.a"
} else {
"target/release/libmu.a"
};
let libmu = get_path_under_mu(libmu_path);
cc.arg(format!("{}", libmu.to_str().unwrap()));
// output
cc.arg("-o");
cc.arg(out.as_os_str());
......
  • Not really. It is the --as-needed and the --no-as-needed command line option of ld, the GNU Linker, that affects the sensitivity of the order of object files. This flag is intended as an optimisation for linking speed.

    The default linker flags vary among GNU/Linux distributions. Ubuntu and ArchLinux, for example, differ from each other in this flag.

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment