2013-06-15 15:40:56 -05:00
|
|
|
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
2012-12-03 18:48:01 -06:00
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2013-05-17 17:28:44 -05:00
|
|
|
|
2014-03-05 08:36:01 -06:00
|
|
|
use driver::session::Session;
|
2012-12-23 16:41:37 -06:00
|
|
|
use metadata::cstore;
|
2012-09-04 13:54:36 -05:00
|
|
|
use metadata::filesearch;
|
2014-04-08 12:15:46 -05:00
|
|
|
use util::fs;
|
2011-10-04 17:23:32 -05:00
|
|
|
|
2014-02-19 21:29:58 -06:00
|
|
|
use collections::HashSet;
|
2014-04-08 12:15:46 -05:00
|
|
|
use std::os;
|
2013-11-08 13:06:57 -06:00
|
|
|
use syntax::abi;
|
2012-12-23 16:41:37 -06:00
|
|
|
|
2013-11-08 13:06:57 -06:00
|
|
|
fn not_win32(os: abi::Os) -> bool {
|
|
|
|
os != abi::OsWin32
|
2012-01-30 23:00:57 -06:00
|
|
|
}
|
|
|
|
|
2014-05-09 20:45:36 -05:00
|
|
|
pub fn get_rpath_flags(sess: &Session, out_filename: &Path) -> Vec<StrBuf> {
|
2012-01-12 10:59:49 -06:00
|
|
|
let os = sess.targ_cfg.os;
|
2011-10-06 16:28:52 -05:00
|
|
|
|
2011-10-06 15:11:56 -05:00
|
|
|
// No rpath on windows
|
2013-11-08 13:06:57 -06:00
|
|
|
if os == abi::OsWin32 {
|
2014-03-04 12:02:49 -06:00
|
|
|
return Vec::new();
|
2011-10-06 15:11:56 -05:00
|
|
|
}
|
|
|
|
|
2014-03-04 12:02:49 -06:00
|
|
|
let mut flags = Vec::new();
|
Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.
When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.
Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.
Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:
* If both a .dylib and .rlib are found for a rust library, the compiler will
prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
overridable by explicitly saying what flavor you'd like (rlib, staticlib,
dylib).
* If no options are passed to the command line, and no crate_type is found in
the destination crate, then an executable is generated
With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.
This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.
Closes #552
2013-11-15 16:03:29 -06:00
|
|
|
|
|
|
|
if sess.targ_cfg.os == abi::OsFreebsd {
|
2014-05-09 20:45:36 -05:00
|
|
|
flags.push_all(["-Wl,-rpath,/usr/local/lib/gcc46".to_strbuf(),
|
|
|
|
"-Wl,-rpath,/usr/local/lib/gcc44".to_strbuf(),
|
|
|
|
"-Wl,-z,origin".to_strbuf()]);
|
Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.
When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.
Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.
Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:
* If both a .dylib and .rlib are found for a rust library, the compiler will
prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
overridable by explicitly saying what flavor you'd like (rlib, staticlib,
dylib).
* If no options are passed to the command line, and no crate_type is found in
the destination crate, then an executable is generated
With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.
This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.
Closes #552
2013-11-15 16:03:29 -06:00
|
|
|
}
|
|
|
|
|
2013-10-21 15:08:31 -05:00
|
|
|
debug!("preparing the RPATH!");
|
2011-10-04 17:23:32 -05:00
|
|
|
|
2014-04-17 10:52:25 -05:00
|
|
|
let sysroot = sess.sysroot();
|
2011-10-04 17:23:32 -05:00
|
|
|
let output = out_filename;
|
2013-12-25 14:08:04 -06:00
|
|
|
let libs = sess.cstore.get_used_crates(cstore::RequireDynamic);
|
2014-04-08 12:05:18 -05:00
|
|
|
let libs = libs.move_iter().filter_map(|(_, l)| {
|
|
|
|
l.map(|p| p.clone())
|
2014-05-04 01:43:38 -05:00
|
|
|
}).collect::<Vec<_>>();
|
2011-10-05 01:12:46 -05:00
|
|
|
|
2014-05-09 20:45:36 -05:00
|
|
|
let rpaths = get_rpaths(os,
|
|
|
|
sysroot,
|
|
|
|
output,
|
|
|
|
libs.as_slice(),
|
|
|
|
sess.opts.target_triple.as_slice());
|
2014-03-08 14:36:22 -06:00
|
|
|
flags.push_all(rpaths_to_flags(rpaths.as_slice()).as_slice());
|
Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.
When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.
Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.
Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:
* If both a .dylib and .rlib are found for a rust library, the compiler will
prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
overridable by explicitly saying what flavor you'd like (rlib, staticlib,
dylib).
* If no options are passed to the command line, and no crate_type is found in
the destination crate, then an executable is generated
With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.
This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.
Closes #552
2013-11-15 16:03:29 -06:00
|
|
|
flags
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2014-05-09 20:45:36 -05:00
|
|
|
pub fn rpaths_to_flags(rpaths: &[StrBuf]) -> Vec<StrBuf> {
|
2014-03-04 12:02:49 -06:00
|
|
|
let mut ret = Vec::new();
|
Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.
When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.
Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.
Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:
* If both a .dylib and .rlib are found for a rust library, the compiler will
prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
overridable by explicitly saying what flavor you'd like (rlib, staticlib,
dylib).
* If no options are passed to the command line, and no crate_type is found in
the destination crate, then an executable is generated
With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.
This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.
Closes #552
2013-11-15 16:03:29 -06:00
|
|
|
for rpath in rpaths.iter() {
|
2014-05-09 20:45:36 -05:00
|
|
|
ret.push(("-Wl,-rpath," + (*rpath).as_slice()).to_strbuf());
|
Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.
When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.
Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.
Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:
* If both a .dylib and .rlib are found for a rust library, the compiler will
prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
overridable by explicitly saying what flavor you'd like (rlib, staticlib,
dylib).
* If no options are passed to the command line, and no crate_type is found in
the destination crate, then an executable is generated
With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.
This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.
Closes #552
2013-11-15 16:03:29 -06:00
|
|
|
}
|
|
|
|
return ret;
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2013-11-08 13:06:57 -06:00
|
|
|
fn get_rpaths(os: abi::Os,
|
2012-08-24 17:28:43 -05:00
|
|
|
sysroot: &Path,
|
|
|
|
output: &Path,
|
|
|
|
libs: &[Path],
|
2014-05-09 20:45:36 -05:00
|
|
|
target_triple: &str) -> Vec<StrBuf> {
|
2013-10-21 15:08:31 -05:00
|
|
|
debug!("sysroot: {}", sysroot.display());
|
|
|
|
debug!("output: {}", output.display());
|
|
|
|
debug!("libs:");
|
2013-08-03 11:45:23 -05:00
|
|
|
for libpath in libs.iter() {
|
2013-10-21 15:08:31 -05:00
|
|
|
debug!(" {}", libpath.display());
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
2013-10-21 15:08:31 -05:00
|
|
|
debug!("target_triple: {}", target_triple);
|
2011-10-04 17:23:32 -05:00
|
|
|
|
|
|
|
// Use relative paths to the libraries. Binaries can be moved
|
|
|
|
// as long as they maintain the relative relationship to the
|
|
|
|
// crates they depend on.
|
2012-08-24 17:28:43 -05:00
|
|
|
let rel_rpaths = get_rpaths_relative_to_output(os, output, libs);
|
2011-10-04 17:23:32 -05:00
|
|
|
|
|
|
|
// And a final backup rpath to the global library location.
|
2014-03-25 23:25:43 -05:00
|
|
|
let fallback_rpaths = vec!(get_install_prefix_rpath(sysroot, target_triple));
|
2011-10-05 00:40:38 -05:00
|
|
|
|
2014-05-09 20:45:36 -05:00
|
|
|
fn log_rpaths(desc: &str, rpaths: &[StrBuf]) {
|
2013-10-21 15:08:31 -05:00
|
|
|
debug!("{} rpaths:", desc);
|
2013-08-03 11:45:23 -05:00
|
|
|
for rpath in rpaths.iter() {
|
2013-10-21 15:08:31 -05:00
|
|
|
debug!(" {}", *rpath);
|
2011-10-05 00:40:38 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-08 14:36:22 -06:00
|
|
|
log_rpaths("relative", rel_rpaths.as_slice());
|
|
|
|
log_rpaths("fallback", fallback_rpaths.as_slice());
|
2011-10-05 00:40:38 -05:00
|
|
|
|
2012-06-28 17:00:03 -05:00
|
|
|
let mut rpaths = rel_rpaths;
|
2014-03-08 14:36:22 -06:00
|
|
|
rpaths.push_all(fallback_rpaths.as_slice());
|
2011-10-04 17:23:32 -05:00
|
|
|
|
|
|
|
// Remove duplicates
|
2014-03-08 14:36:22 -06:00
|
|
|
let rpaths = minimize_rpaths(rpaths.as_slice());
|
2012-08-01 19:30:05 -05:00
|
|
|
return rpaths;
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2013-11-08 13:06:57 -06:00
|
|
|
fn get_rpaths_relative_to_output(os: abi::Os,
|
2012-08-24 17:28:43 -05:00
|
|
|
output: &Path,
|
2014-05-09 20:45:36 -05:00
|
|
|
libs: &[Path]) -> Vec<StrBuf> {
|
2013-08-09 22:09:47 -05:00
|
|
|
libs.iter().map(|a| get_rpath_relative_to_output(os, output, a)).collect()
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2013-11-08 13:06:57 -06:00
|
|
|
pub fn get_rpath_relative_to_output(os: abi::Os,
|
2013-01-29 17:48:50 -06:00
|
|
|
output: &Path,
|
|
|
|
lib: &Path)
|
2014-05-09 20:45:36 -05:00
|
|
|
-> StrBuf {
|
2013-06-28 17:32:26 -05:00
|
|
|
use std::os;
|
2012-12-27 17:49:26 -06:00
|
|
|
|
2013-03-28 20:39:09 -05:00
|
|
|
assert!(not_win32(os));
|
2012-07-13 20:43:52 -05:00
|
|
|
|
2011-10-06 16:28:52 -05:00
|
|
|
// Mac doesn't appear to support $ORIGIN
|
2012-08-06 14:34:08 -05:00
|
|
|
let prefix = match os {
|
2013-11-08 13:06:57 -06:00
|
|
|
abi::OsAndroid | abi::OsLinux | abi::OsFreebsd
|
2012-11-29 18:21:49 -06:00
|
|
|
=> "$ORIGIN",
|
2013-11-08 13:06:57 -06:00
|
|
|
abi::OsMacos => "@loader_path",
|
|
|
|
abi::OsWin32 => unreachable!()
|
2011-10-06 16:28:52 -05:00
|
|
|
};
|
|
|
|
|
2014-04-08 12:15:46 -05:00
|
|
|
let mut lib = fs::realpath(&os::make_absolute(lib)).unwrap();
|
2013-09-26 19:21:59 -05:00
|
|
|
lib.pop();
|
2014-04-08 12:15:46 -05:00
|
|
|
let mut output = fs::realpath(&os::make_absolute(output)).unwrap();
|
2013-09-26 19:21:59 -05:00
|
|
|
output.pop();
|
|
|
|
let relative = lib.path_relative_from(&output);
|
|
|
|
let relative = relative.expect("could not create rpath relative to output");
|
|
|
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
2014-05-09 20:45:36 -05:00
|
|
|
(prefix + "/" + relative.as_str()
|
|
|
|
.expect("non-utf8 component in path")).to_strbuf()
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2014-05-09 20:45:36 -05:00
|
|
|
pub fn get_install_prefix_rpath(sysroot: &Path, target_triple: &str) -> StrBuf {
|
2014-04-23 14:56:58 -05:00
|
|
|
let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX");
|
2013-08-06 23:50:23 -05:00
|
|
|
|
2014-03-25 23:25:43 -05:00
|
|
|
let tlib = filesearch::relative_target_lib_path(sysroot, target_triple);
|
2013-12-03 21:15:12 -06:00
|
|
|
let mut path = Path::new(install_prefix);
|
2013-10-07 21:16:58 -05:00
|
|
|
path.push(&tlib);
|
2013-09-26 19:21:59 -05:00
|
|
|
let path = os::make_absolute(&path);
|
|
|
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
2014-05-09 20:45:36 -05:00
|
|
|
path.as_str().expect("non-utf8 component in rpath").to_strbuf()
|
2013-08-06 23:50:23 -05:00
|
|
|
}
|
|
|
|
|
2014-05-09 20:45:36 -05:00
|
|
|
pub fn minimize_rpaths(rpaths: &[StrBuf]) -> Vec<StrBuf> {
|
2013-04-03 08:28:36 -05:00
|
|
|
let mut set = HashSet::new();
|
2014-03-04 12:02:49 -06:00
|
|
|
let mut minimized = Vec::new();
|
2013-08-03 11:45:23 -05:00
|
|
|
for rpath in rpaths.iter() {
|
2013-09-26 19:21:59 -05:00
|
|
|
if set.insert(rpath.as_slice()) {
|
2013-07-02 14:47:32 -05:00
|
|
|
minimized.push(rpath.clone());
|
2011-10-05 00:40:38 -05:00
|
|
|
}
|
|
|
|
}
|
2013-02-08 20:04:28 -06:00
|
|
|
minimized
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2013-05-27 18:04:00 -05:00
|
|
|
#[cfg(unix, test)]
|
2011-10-04 17:23:32 -05:00
|
|
|
mod test {
|
2014-04-07 17:40:58 -05:00
|
|
|
use back::rpath::get_install_prefix_rpath;
|
2013-07-31 15:47:32 -05:00
|
|
|
use back::rpath::{minimize_rpaths, rpaths_to_flags, get_rpath_relative_to_output};
|
2013-11-08 13:06:57 -06:00
|
|
|
use syntax::abi;
|
2014-01-04 19:55:20 -06:00
|
|
|
use metadata::filesearch;
|
2012-12-27 17:49:26 -06:00
|
|
|
|
2011-10-04 17:23:32 -05:00
|
|
|
#[test]
|
2013-04-15 10:08:52 -05:00
|
|
|
fn test_rpaths_to_flags() {
|
2014-05-09 20:45:36 -05:00
|
|
|
let flags = rpaths_to_flags([
|
|
|
|
"path1".to_strbuf(),
|
|
|
|
"path2".to_strbuf()
|
|
|
|
]);
|
|
|
|
assert_eq!(flags,
|
|
|
|
vec!("-Wl,-rpath,path1".to_strbuf(),
|
|
|
|
"-Wl,-rpath,path2".to_strbuf()));
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2013-04-15 10:08:52 -05:00
|
|
|
fn test_prefix_rpath() {
|
2014-03-25 23:25:43 -05:00
|
|
|
let sysroot = filesearch::get_or_default_sysroot();
|
2014-03-26 22:53:01 -05:00
|
|
|
let res = get_install_prefix_rpath(&sysroot, "triple");
|
2014-04-23 14:56:58 -05:00
|
|
|
let mut d = Path::new((option_env!("CFG_PREFIX")).expect("CFG_PREFIX"));
|
2014-01-04 19:55:20 -06:00
|
|
|
d.push("lib");
|
|
|
|
d.push(filesearch::rustlibdir());
|
|
|
|
d.push("triple/lib");
|
2013-10-21 15:08:31 -05:00
|
|
|
debug!("test_prefix_path: {} vs. {}",
|
2013-10-17 00:01:20 -05:00
|
|
|
res,
|
2013-09-26 19:21:59 -05:00
|
|
|
d.display());
|
2013-10-17 00:01:20 -05:00
|
|
|
assert!(res.as_bytes().ends_with(d.as_vec()));
|
2011-10-06 18:12:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2013-04-15 10:08:52 -05:00
|
|
|
fn test_prefix_rpath_abs() {
|
2014-03-25 23:25:43 -05:00
|
|
|
let sysroot = filesearch::get_or_default_sysroot();
|
2014-03-26 22:53:01 -05:00
|
|
|
let res = get_install_prefix_rpath(&sysroot, "triple");
|
2013-12-03 21:15:12 -06:00
|
|
|
assert!(Path::new(res).is_absolute());
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2013-04-15 10:08:52 -05:00
|
|
|
fn test_minimize1() {
|
2014-05-09 20:45:36 -05:00
|
|
|
let res = minimize_rpaths([
|
|
|
|
"rpath1".to_strbuf(),
|
|
|
|
"rpath2".to_strbuf(),
|
|
|
|
"rpath1".to_strbuf()
|
|
|
|
]);
|
|
|
|
assert!(res.as_slice() == [
|
|
|
|
"rpath1".to_strbuf(),
|
|
|
|
"rpath2".to_strbuf()
|
|
|
|
]);
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
|
|
|
|
2011-10-05 00:40:38 -05:00
|
|
|
#[test]
|
2013-04-15 10:08:52 -05:00
|
|
|
fn test_minimize2() {
|
2014-05-09 20:45:36 -05:00
|
|
|
let res = minimize_rpaths([
|
|
|
|
"1a".to_strbuf(),
|
|
|
|
"2".to_strbuf(),
|
|
|
|
"2".to_strbuf(),
|
|
|
|
"1a".to_strbuf(),
|
|
|
|
"4a".to_strbuf(),
|
|
|
|
"1a".to_strbuf(),
|
|
|
|
"2".to_strbuf(),
|
|
|
|
"3".to_strbuf(),
|
|
|
|
"4a".to_strbuf(),
|
|
|
|
"3".to_strbuf()
|
|
|
|
]);
|
|
|
|
assert!(res.as_slice() == [
|
|
|
|
"1a".to_strbuf(),
|
|
|
|
"2".to_strbuf(),
|
|
|
|
"4a".to_strbuf(),
|
|
|
|
"3".to_strbuf()
|
|
|
|
]);
|
2011-10-05 00:40:38 -05:00
|
|
|
}
|
|
|
|
|
2011-10-04 22:07:18 -05:00
|
|
|
#[test]
|
2011-10-06 16:28:52 -05:00
|
|
|
#[cfg(target_os = "linux")]
|
2013-07-31 15:47:32 -05:00
|
|
|
#[cfg(target_os = "android")]
|
2013-04-15 10:08:52 -05:00
|
|
|
fn test_rpath_relative() {
|
2013-11-08 13:06:57 -06:00
|
|
|
let o = abi::OsLinux;
|
2012-07-13 20:43:52 -05:00
|
|
|
let res = get_rpath_relative_to_output(o,
|
2013-12-03 21:15:12 -06:00
|
|
|
&Path::new("bin/rustc"), &Path::new("lib/libstd.so"));
|
2013-09-26 19:21:59 -05:00
|
|
|
assert_eq!(res.as_slice(), "$ORIGIN/../lib");
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|
2011-10-05 00:40:38 -05:00
|
|
|
|
2011-12-30 02:18:55 -06:00
|
|
|
#[test]
|
|
|
|
#[cfg(target_os = "freebsd")]
|
2013-04-15 10:08:52 -05:00
|
|
|
fn test_rpath_relative() {
|
2013-11-08 13:06:57 -06:00
|
|
|
let o = abi::OsFreebsd;
|
2012-07-14 12:27:09 -05:00
|
|
|
let res = get_rpath_relative_to_output(o,
|
2013-12-03 21:15:12 -06:00
|
|
|
&Path::new("bin/rustc"), &Path::new("lib/libstd.so"));
|
2013-09-26 19:21:59 -05:00
|
|
|
assert_eq!(res.as_slice(), "$ORIGIN/../lib");
|
2011-12-30 02:18:55 -06:00
|
|
|
}
|
|
|
|
|
2011-10-06 16:28:52 -05:00
|
|
|
#[test]
|
|
|
|
#[cfg(target_os = "macos")]
|
2013-04-15 10:08:52 -05:00
|
|
|
fn test_rpath_relative() {
|
2013-11-08 13:06:57 -06:00
|
|
|
let o = abi::OsMacos;
|
2012-08-24 17:28:43 -05:00
|
|
|
let res = get_rpath_relative_to_output(o,
|
2013-12-03 21:15:12 -06:00
|
|
|
&Path::new("bin/rustc"),
|
|
|
|
&Path::new("lib/libstd.so"));
|
2013-11-05 16:17:30 -06:00
|
|
|
assert_eq!(res.as_slice(), "@loader_path/../lib");
|
2011-10-06 16:28:52 -05:00
|
|
|
}
|
2011-10-04 17:23:32 -05:00
|
|
|
}
|