rustc_target: Update some old naming around self contained linking · rust-lang/rust@8fa707a (original) (raw)
`@@ -20,7 +20,7 @@ use rustc_session::utils::NativeLibKind;
`
20
20
`use rustc_session::{filesearch, Session};
`
21
21
`use rustc_span::symbol::Symbol;
`
22
22
`use rustc_span::DebuggerVisualizerFile;
`
23
``
`-
use rustc_target::spec::crt_objects::{CrtObjects, CrtObjectsFallback};
`
``
23
`+
use rustc_target::spec::crt_objects::{CrtObjects, LinkSelfContainedDefault};
`
24
24
`use rustc_target::spec::{LinkOutputKind, LinkerFlavor, LldFlavor, SplitDebuginfo};
`
25
25
`use rustc_target::spec::{PanicStrategy, RelocModel, RelroLevel, SanitizerSet, Target};
`
26
26
``
`@@ -764,15 +764,15 @@ fn link_natively<'a>(
`
764
764
`"Linker does not support -static-pie command line option. Retrying with -static instead."
`
765
765
`);
`
766
766
`` // Mirror add_(pre,post)_link_objects
to replace CRT objects.
``
767
``
`-
let self_contained = crt_objects_fallback(sess, crate_type);
`
``
767
`+
let self_contained = self_contained(sess, crate_type);
`
768
768
`let opts = &sess.target;
`
769
769
`let pre_objects = if self_contained {
`
770
``
`-
&opts.pre_link_objects_fallback
`
``
770
`+
&opts.pre_link_objects_self_contained
`
771
771
`} else {
`
772
772
`&opts.pre_link_objects
`
773
773
`};
`
774
774
`let post_objects = if self_contained {
`
775
``
`-
&opts.post_link_objects_fallback
`
``
775
`+
&opts.post_link_objects_self_contained
`
776
776
`} else {
`
777
777
`&opts.post_link_objects
`
778
778
`};
`
`@@ -1556,26 +1556,26 @@ fn detect_self_contained_mingw(sess: &Session) -> bool {
`
1556
1556
`true
`
1557
1557
`}
`
1558
1558
``
1559
``
`-
/// Whether we link to our own CRT objects instead of relying on gcc to pull them.
`
``
1559
`+
/// Various toolchain components used during linking are used from rustc distribution
`
``
1560
`+
/// instead of being found somewhere on the host system.
`
1560
1561
`/// We only provide such support for a very limited number of targets.
`
1561
``
`-
fn crt_objects_fallback(sess: &Session, crate_type: CrateType) -> bool {
`
``
1562
`+
fn self_contained(sess: &Session, crate_type: CrateType) -> bool {
`
1562
1563
`if let Some(self_contained) = sess.opts.cg.link_self_contained {
`
1563
1564
`return self_contained;
`
1564
1565
`}
`
1565
1566
``
1566
``
`-
match sess.target.crt_objects_fallback {
`
``
1567
`+
match sess.target.link_self_contained {
`
``
1568
`+
LinkSelfContainedDefault::False => false,
`
``
1569
`+
LinkSelfContainedDefault::True => true,
`
1567
1570
`// FIXME: Find a better heuristic for "native musl toolchain is available",
`
1568
1571
`// based on host and linker path, for example.
`
1569
1572
`// (https://github.com/rust-lang/rust/pull/71769#issuecomment-626330237).
`
1570
``
`-
Some(CrtObjectsFallback::Musl) => sess.crt_static(Some(crate_type)),
`
1571
``
`-
Some(CrtObjectsFallback::Mingw) => {
`
``
1573
`+
LinkSelfContainedDefault::Musl => sess.crt_static(Some(crate_type)),
`
``
1574
`+
LinkSelfContainedDefault::Mingw => {
`
1572
1575
` sess.host == sess.target
`
1573
1576
` && sess.target.vendor != "uwp"
`
1574
1577
` && detect_self_contained_mingw(&sess)
`
1575
1578
`}
`
1576
``
`-
// FIXME: Figure out cases in which WASM needs to link with a native toolchain.
`
1577
``
`-
Some(CrtObjectsFallback::Wasm) => true,
`
1578
``
`-
None => false,
`
1579
1579
`}
`
1580
1580
`}
`
1581
1581
``
`@@ -1592,7 +1592,7 @@ fn add_pre_link_objects(
`
1592
1592
`let opts = &sess.target;
`
1593
1593
`let empty = Default::default();
`
1594
1594
`let objects = if self_contained {
`
1595
``
`-
&opts.pre_link_objects_fallback
`
``
1595
`+
&opts.pre_link_objects_self_contained
`
1596
1596
`} else if !(sess.target.os == "fuchsia" && flavor == LinkerFlavor::Gcc) {
`
1597
1597
`&opts.pre_link_objects
`
1598
1598
`} else {
`
`@@ -1610,9 +1610,11 @@ fn add_post_link_objects(
`
1610
1610
`link_output_kind: LinkOutputKind,
`
1611
1611
`self_contained: bool,
`
1612
1612
`) {
`
1613
``
`-
let opts = &sess.target;
`
1614
``
`-
let objects =
`
1615
``
`-
if self_contained { &opts.post_link_objects_fallback } else { &opts.post_link_objects };
`
``
1613
`+
let objects = if self_contained {
`
``
1614
`+
&sess.target.post_link_objects_self_contained
`
``
1615
`+
} else {
`
``
1616
`+
&sess.target.post_link_objects
`
``
1617
`+
};
`
1616
1618
`for obj in objects.get(&link_output_kind).iter().copied().flatten() {
`
1617
1619
` cmd.add_object(&get_object_file_path(sess, obj, self_contained));
`
1618
1620
`}
`
`@@ -1891,12 +1893,12 @@ fn linker_with_args<'a>(
`
1891
1893
`out_filename: &Path,
`
1892
1894
`codegen_results: &CodegenResults,
`
1893
1895
`) -> Result<Command, ErrorGuaranteed> {
`
1894
``
`-
let crt_objects_fallback = crt_objects_fallback(sess, crate_type);
`
``
1896
`+
let self_contained = self_contained(sess, crate_type);
`
1895
1897
`let cmd = &mut *super::linker::get_linker(
`
1896
1898
` sess,
`
1897
1899
` path,
`
1898
1900
` flavor,
`
1899
``
`-
crt_objects_fallback,
`
``
1901
`+
self_contained,
`
1900
1902
`&codegen_results.crate_info.target_cpu,
`
1901
1903
`);
`
1902
1904
`let link_output_kind = link_output_kind(sess, crate_type);
`
`@@ -1923,7 +1925,7 @@ fn linker_with_args<'a>(
`
1923
1925
`// ------------ Object code and libraries, order-dependent ------------
`
1924
1926
``
1925
1927
`// Pre-link CRT objects.
`
1926
``
`-
add_pre_link_objects(cmd, sess, flavor, link_output_kind, crt_objects_fallback);
`
``
1928
`+
add_pre_link_objects(cmd, sess, flavor, link_output_kind, self_contained);
`
1927
1929
``
1928
1930
`add_linked_symbol_object(
`
1929
1931
` cmd,
`
`@@ -2033,7 +2035,7 @@ fn linker_with_args<'a>(
`
2033
2035
` cmd,
`
2034
2036
` sess,
`
2035
2037
` link_output_kind,
`
2036
``
`-
crt_objects_fallback,
`
``
2038
`+
self_contained,
`
2037
2039
` flavor,
`
2038
2040
` crate_type,
`
2039
2041
` codegen_results,
`
`@@ -2049,7 +2051,7 @@ fn linker_with_args<'a>(
`
2049
2051
`// ------------ Object code and libraries, order-dependent ------------
`
2050
2052
``
2051
2053
`// Post-link CRT objects.
`
2052
``
`-
add_post_link_objects(cmd, sess, link_output_kind, crt_objects_fallback);
`
``
2054
`+
add_post_link_objects(cmd, sess, link_output_kind, self_contained);
`
2053
2055
``
2054
2056
`// ------------ Late order-dependent options ------------
`
2055
2057
``
`@@ -2066,7 +2068,7 @@ fn add_order_independent_options(
`
2066
2068
`cmd: &mut dyn Linker,
`
2067
2069
`sess: &Session,
`
2068
2070
`link_output_kind: LinkOutputKind,
`
2069
``
`-
crt_objects_fallback: bool,
`
``
2071
`+
self_contained: bool,
`
2070
2072
`flavor: LinkerFlavor,
`
2071
2073
`crate_type: CrateType,
`
2072
2074
`codegen_results: &CodegenResults,
`
`@@ -2098,7 +2100,7 @@ fn add_order_independent_options(
`
2098
2100
`// Make the binary compatible with data execution prevention schemes.
`
2099
2101
` cmd.add_no_exec();
`
2100
2102
``
2101
``
`-
if crt_objects_fallback {
`
``
2103
`+
if self_contained {
`
2102
2104
` cmd.no_crt_objects();
`
2103
2105
`}
`
2104
2106
``
`@@ -2127,7 +2129,7 @@ fn add_order_independent_options(
`
2127
2129
``
2128
2130
` cmd.linker_plugin_lto();
`
2129
2131
``
2130
``
`-
add_library_search_dirs(cmd, sess, crt_objects_fallback);
`
``
2132
`+
add_library_search_dirs(cmd, sess, self_contained);
`
2131
2133
``
2132
2134
` cmd.output_filename(out_filename);
`
2133
2135
``