auto merge of #6198 : luqmana/rust/linker-arg, r=graydon
This commit is contained in:
commit
5bf7e8bb50
|
@ -752,18 +752,26 @@ pub fn link_binary(sess: Session,
|
||||||
// instead of hard-coded gcc.
|
// instead of hard-coded gcc.
|
||||||
// For win32, there is no cc command,
|
// For win32, there is no cc command,
|
||||||
// so we add a condition to make it use gcc.
|
// so we add a condition to make it use gcc.
|
||||||
let cc_prog: ~str = if sess.targ_cfg.os == session::os_android {
|
let cc_prog: ~str = match sess.opts.linker {
|
||||||
match &sess.opts.android_cross_path {
|
Some(copy linker) => linker,
|
||||||
&Some(copy path) => {
|
None => {
|
||||||
fmt!("%s/bin/arm-linux-androideabi-gcc", path)
|
if sess.targ_cfg.os == session::os_android {
|
||||||
}
|
match &sess.opts.android_cross_path {
|
||||||
&None => {
|
&Some(copy path) => {
|
||||||
sess.fatal(~"need Android NDK path for linking \
|
fmt!("%s/bin/arm-linux-androideabi-gcc", path)
|
||||||
(--android-cross-path)")
|
}
|
||||||
|
&None => {
|
||||||
|
sess.fatal(~"need Android NDK path for linking \
|
||||||
|
(--android-cross-path)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if sess.targ_cfg.os == session::os_win32 {
|
||||||
|
~"gcc"
|
||||||
|
} else {
|
||||||
|
~"cc"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if sess.targ_cfg.os == session::os_win32 { ~"gcc" }
|
};
|
||||||
else { ~"cc" };
|
|
||||||
// The invocations of cc share some flags across platforms
|
// The invocations of cc share some flags across platforms
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -650,7 +650,7 @@ pub fn build_session_options(binary: @~str,
|
||||||
};
|
};
|
||||||
|
|
||||||
let addl_lib_search_paths = getopts::opt_strs(matches, ~"L").map(|s| Path(*s));
|
let addl_lib_search_paths = getopts::opt_strs(matches, ~"L").map(|s| Path(*s));
|
||||||
|
let linker = getopts::opt_maybe_str(matches, ~"linker");
|
||||||
let linker_args = getopts::opt_strs(matches, ~"link-args").flat_map( |a| {
|
let linker_args = getopts::opt_strs(matches, ~"link-args").flat_map( |a| {
|
||||||
let mut args = ~[];
|
let mut args = ~[];
|
||||||
for str::each_split_char(*a, ' ') |arg| {
|
for str::each_split_char(*a, ' ') |arg| {
|
||||||
|
@ -676,6 +676,7 @@ pub fn build_session_options(binary: @~str,
|
||||||
jit: jit,
|
jit: jit,
|
||||||
output_type: output_type,
|
output_type: output_type,
|
||||||
addl_lib_search_paths: addl_lib_search_paths,
|
addl_lib_search_paths: addl_lib_search_paths,
|
||||||
|
linker: linker,
|
||||||
linker_args: linker_args,
|
linker_args: linker_args,
|
||||||
maybe_sysroot: sysroot_opt,
|
maybe_sysroot: sysroot_opt,
|
||||||
target_triple: target,
|
target_triple: target,
|
||||||
|
@ -760,6 +761,7 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] {
|
||||||
optmulti("L", "", "Add a directory to the library search path",
|
optmulti("L", "", "Add a directory to the library search path",
|
||||||
"PATH"),
|
"PATH"),
|
||||||
optflag("", "lib", "Compile a library crate"),
|
optflag("", "lib", "Compile a library crate"),
|
||||||
|
optopt("", "linker", "Program to use for linking instead of the default.", "LINKER"),
|
||||||
optmulti("", "link-args", "FLAGS is a space-separated list of flags
|
optmulti("", "link-args", "FLAGS is a space-separated list of flags
|
||||||
passed to the linker", "FLAGS"),
|
passed to the linker", "FLAGS"),
|
||||||
optflag("", "ls", "List the symbols defined by a library crate"),
|
optflag("", "ls", "List the symbols defined by a library crate"),
|
||||||
|
|
|
@ -124,6 +124,7 @@ pub struct options {
|
||||||
jit: bool,
|
jit: bool,
|
||||||
output_type: back::link::output_type,
|
output_type: back::link::output_type,
|
||||||
addl_lib_search_paths: ~[Path],
|
addl_lib_search_paths: ~[Path],
|
||||||
|
linker: Option<~str>,
|
||||||
linker_args: ~[~str],
|
linker_args: ~[~str],
|
||||||
maybe_sysroot: Option<@Path>,
|
maybe_sysroot: Option<@Path>,
|
||||||
target_triple: ~str,
|
target_triple: ~str,
|
||||||
|
@ -302,7 +303,8 @@ pub fn basic_options() -> @options {
|
||||||
jit: false,
|
jit: false,
|
||||||
output_type: link::output_type_exe,
|
output_type: link::output_type_exe,
|
||||||
addl_lib_search_paths: ~[],
|
addl_lib_search_paths: ~[],
|
||||||
linker_args:~[],
|
linker: None,
|
||||||
|
linker_args: ~[],
|
||||||
maybe_sysroot: None,
|
maybe_sysroot: None,
|
||||||
target_triple: host_triple(),
|
target_triple: host_triple(),
|
||||||
target_feature: ~"",
|
target_feature: ~"",
|
||||||
|
|
Loading…
Reference in New Issue