rustc_target: Update some old naming around self contained linking · rust-lang/rust@e74299b (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

``

`@@ -1586,9 +1586,11 @@ fn add_pre_link_objects(

`

1586

1586

`link_output_kind: LinkOutputKind,

`

1587

1587

`self_contained: bool,

`

1588

1588

`) {

`

1589

``

`-

let opts = &sess.target;

`

1590

``

`-

let objects =

`

1591

``

`-

if self_contained { &opts.pre_link_objects_fallback } else { &opts.pre_link_objects };

`

``

1589

`+

let objects = if self_contained {

`

``

1590

`+

&sess.target.pre_link_objects_self_contained

`

``

1591

`+

} else {

`

``

1592

`+

&sess.target.pre_link_objects

`

``

1593

`+

};

`

1592

1594

`for obj in objects.get(&link_output_kind).iter().copied().flatten() {

`

1593

1595

` cmd.add_object(&get_object_file_path(sess, obj, self_contained));

`

1594

1596

`}

`

`@@ -1601,9 +1603,11 @@ fn add_post_link_objects(

`

1601

1603

`link_output_kind: LinkOutputKind,

`

1602

1604

`self_contained: bool,

`

1603

1605

`) {

`

1604

``

`-

let opts = &sess.target;

`

1605

``

`-

let objects =

`

1606

``

`-

if self_contained { &opts.post_link_objects_fallback } else { &opts.post_link_objects };

`

``

1606

`+

let objects = if self_contained {

`

``

1607

`+

&sess.target.post_link_objects_self_contained

`

``

1608

`+

} else {

`

``

1609

`+

&sess.target.post_link_objects

`

``

1610

`+

};

`

1607

1611

`for obj in objects.get(&link_output_kind).iter().copied().flatten() {

`

1608

1612

` cmd.add_object(&get_object_file_path(sess, obj, self_contained));

`

1609

1613

`}

`

`@@ -1882,12 +1886,12 @@ fn linker_with_args<'a>(

`

1882

1886

`out_filename: &Path,

`

1883

1887

`codegen_results: &CodegenResults,

`

1884

1888

`) -> Result<Command, ErrorGuaranteed> {

`

1885

``

`-

let crt_objects_fallback = crt_objects_fallback(sess, crate_type);

`

``

1889

`+

let self_contained = self_contained(sess, crate_type);

`

1886

1890

`let cmd = &mut *super::linker::get_linker(

`

1887

1891

` sess,

`

1888

1892

` path,

`

1889

1893

` flavor,

`

1890

``

`-

crt_objects_fallback,

`

``

1894

`+

self_contained,

`

1891

1895

`&codegen_results.crate_info.target_cpu,

`

1892

1896

`);

`

1893

1897

`let link_output_kind = link_output_kind(sess, crate_type);

`

`@@ -1914,7 +1918,7 @@ fn linker_with_args<'a>(

`

1914

1918

`// ------------ Object code and libraries, order-dependent ------------

`

1915

1919

``

1916

1920

`// Pre-link CRT objects.

`

1917

``

`-

add_pre_link_objects(cmd, sess, link_output_kind, crt_objects_fallback);

`

``

1921

`+

add_pre_link_objects(cmd, sess, link_output_kind, self_contained);

`

1918

1922

``

1919

1923

`add_linked_symbol_object(

`

1920

1924

` cmd,

`

`@@ -2024,7 +2028,7 @@ fn linker_with_args<'a>(

`

2024

2028

` cmd,

`

2025

2029

` sess,

`

2026

2030

` link_output_kind,

`

2027

``

`-

crt_objects_fallback,

`

``

2031

`+

self_contained,

`

2028

2032

` flavor,

`

2029

2033

` crate_type,

`

2030

2034

` codegen_results,

`

`@@ -2040,7 +2044,7 @@ fn linker_with_args<'a>(

`

2040

2044

`// ------------ Object code and libraries, order-dependent ------------

`

2041

2045

``

2042

2046

`// Post-link CRT objects.

`

2043

``

`-

add_post_link_objects(cmd, sess, link_output_kind, crt_objects_fallback);

`

``

2047

`+

add_post_link_objects(cmd, sess, link_output_kind, self_contained);

`

2044

2048

``

2045

2049

`// ------------ Late order-dependent options ------------

`

2046

2050

``

`@@ -2057,7 +2061,7 @@ fn add_order_independent_options(

`

2057

2061

`cmd: &mut dyn Linker,

`

2058

2062

`sess: &Session,

`

2059

2063

`link_output_kind: LinkOutputKind,

`

2060

``

`-

crt_objects_fallback: bool,

`

``

2064

`+

self_contained: bool,

`

2061

2065

`flavor: LinkerFlavor,

`

2062

2066

`crate_type: CrateType,

`

2063

2067

`codegen_results: &CodegenResults,

`

`@@ -2086,7 +2090,7 @@ fn add_order_independent_options(

`

2086

2090

`// Make the binary compatible with data execution prevention schemes.

`

2087

2091

` cmd.add_no_exec();

`

2088

2092

``

2089

``

`-

if crt_objects_fallback {

`

``

2093

`+

if self_contained {

`

2090

2094

` cmd.no_crt_objects();

`

2091

2095

`}

`

2092

2096

``

`@@ -2115,7 +2119,7 @@ fn add_order_independent_options(

`

2115

2119

``

2116

2120

` cmd.linker_plugin_lto();

`

2117

2121

``

2118

``

`-

add_library_search_dirs(cmd, sess, crt_objects_fallback);

`

``

2122

`+

add_library_search_dirs(cmd, sess, self_contained);

`

2119

2123

``

2120

2124

` cmd.output_filename(out_filename);

`

2121

2125

``