Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 0e38a65

Browse files
committed
linker: Refactor APIs for linking static libraries
Rename `link(_whole)(staticlib,rlib)` to something more suitable.
1 parent 50501c6 commit 0e38a65

File tree

2 files changed

+114
-69
lines changed

2 files changed

+114
-69
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ fn link_sanitizer_runtime(
12731273
} else {
12741274
let filename = format!("librustc{channel}_rt.{name}.a");
12751275
let path = find_sanitizer_runtime(sess, &filename).join(&filename);
1276-
linker.link_whole_rlib(&path);
1276+
linker.link_whole_staticlib_by_path(&path);
12771277
}
12781278
}
12791279

@@ -2506,20 +2506,20 @@ fn add_native_libs_from_crate(
25062506
// If rlib contains native libs as archives, they are unpacked to tmpdir.
25072507
let path = tmpdir.join(filename.as_str());
25082508
if whole_archive {
2509-
cmd.link_whole_rlib(&path);
2509+
cmd.link_whole_staticlib_by_path(&path);
25102510
} else {
2511-
cmd.link_rlib(&path);
2511+
cmd.link_staticlib_by_path(&path);
25122512
}
25132513
}
25142514
} else {
25152515
if whole_archive {
2516-
cmd.link_whole_staticlib(
2516+
cmd.link_whole_staticlib_by_name(
25172517
name,
25182518
verbatim,
25192519
search_paths.get_or_init(|| archive_search_paths(sess)),
25202520
);
25212521
} else {
2522-
cmd.link_staticlib(name, verbatim)
2522+
cmd.link_staticlib_by_name(name, verbatim)
25232523
}
25242524
}
25252525
}
@@ -2534,7 +2534,7 @@ fn add_native_libs_from_crate(
25342534
// link kind is unspecified.
25352535
if !link_output_kind.can_link_dylib() && !sess.target.crt_static_allows_dylibs {
25362536
if link_static {
2537-
cmd.link_staticlib(name, verbatim)
2537+
cmd.link_staticlib_by_name(name, verbatim)
25382538
}
25392539
} else {
25402540
if link_dynamic {
@@ -2791,7 +2791,7 @@ fn add_static_crate<'a>(
27912791
} else {
27922792
fix_windows_verbatim_for_gcc(path)
27932793
};
2794-
cmd.link_rlib(&rlib_path);
2794+
cmd.link_staticlib_by_path(&rlib_path);
27952795
};
27962796

27972797
if !are_upstream_rust_objects_already_included(sess)

0 commit comments

Comments
 (0)