[link] enable packed bundled lib in non stable cases
This commit is contained in:
parent
dffea43fc1
commit
601fc8b36b
19 changed files with 145 additions and 126 deletions
|
@ -49,20 +49,21 @@ fn find_bundled_library(
|
|||
name: Option<Symbol>,
|
||||
verbatim: Option<bool>,
|
||||
kind: NativeLibKind,
|
||||
has_cfg: bool,
|
||||
sess: &Session,
|
||||
) -> Option<Symbol> {
|
||||
if sess.opts.unstable_opts.packed_bundled_libs &&
|
||||
sess.crate_types().iter().any(|ct| ct == &CrateType::Rlib || ct == &CrateType::Staticlib) &&
|
||||
let NativeLibKind::Static { bundle: Some(true) | None, .. } = kind {
|
||||
find_native_static_library(
|
||||
name.unwrap().as_str(),
|
||||
verbatim.unwrap_or(false),
|
||||
&sess.target_filesearch(PathKind::Native).search_path_dirs(),
|
||||
sess,
|
||||
).file_name().and_then(|s| s.to_str()).map(Symbol::intern)
|
||||
} else {
|
||||
None
|
||||
if let NativeLibKind::Static { bundle: Some(true) | None, whole_archive } = kind
|
||||
&& sess.crate_types().iter().any(|t| matches!(t, &CrateType::Rlib | CrateType::Staticlib))
|
||||
&& (sess.opts.unstable_opts.packed_bundled_libs || has_cfg || whole_archive == Some(true))
|
||||
{
|
||||
let verbatim = verbatim.unwrap_or(false);
|
||||
let search_paths = &sess.target_filesearch(PathKind::Native).search_path_dirs();
|
||||
return find_native_static_library(name.unwrap().as_str(), verbatim, search_paths, sess)
|
||||
.file_name()
|
||||
.and_then(|s| s.to_str())
|
||||
.map(Symbol::intern);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub(crate) fn collect(tcx: TyCtxt<'_>) -> Vec<NativeLib> {
|
||||
|
@ -385,7 +386,7 @@ impl<'tcx> Collector<'tcx> {
|
|||
|
||||
let name = name.map(|(name, _)| name);
|
||||
let kind = kind.unwrap_or(NativeLibKind::Unspecified);
|
||||
let filename = find_bundled_library(name, verbatim, kind, sess);
|
||||
let filename = find_bundled_library(name, verbatim, kind, cfg.is_some(), sess);
|
||||
self.libs.push(NativeLib {
|
||||
name,
|
||||
filename,
|
||||
|
@ -475,7 +476,7 @@ impl<'tcx> Collector<'tcx> {
|
|||
let name = Some(Symbol::intern(new_name.unwrap_or(&passed_lib.name)));
|
||||
let sess = self.tcx.sess;
|
||||
let filename =
|
||||
find_bundled_library(name, passed_lib.verbatim, passed_lib.kind, sess);
|
||||
find_bundled_library(name, passed_lib.verbatim, passed_lib.kind, false, sess);
|
||||
self.libs.push(NativeLib {
|
||||
name,
|
||||
filename,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue