@@ -9,7 +9,6 @@ use crate::{lint, HashStableContext};
99use crate :: { EarlyErrorHandler , Session } ;
1010
1111use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
12-
1312use rustc_data_structures:: stable_hasher:: { StableOrd , ToStableHashKey } ;
1413use rustc_target:: abi:: Align ;
1514use rustc_target:: spec:: { LinkerFlavorCli , PanicStrategy , SanitizerSet , SplitDebuginfo } ;
@@ -210,6 +209,50 @@ impl LinkerPluginLto {
210209 }
211210}
212211
212+ /// The different values `-C link-self-contained` can take: a list of individually enabled or
213+ /// disabled components used during linking, coming from the rustc distribution, instead of being
214+ /// found somewhere on the host system.
215+ ///
216+ /// They can be set in bulk via `-C link-self-contained=yes|y|on` or `-C
217+ /// link-self-contained=no|n|off`, and those boolean values are the historical defaults.
218+ ///
219+ /// But each component is fine-grained, and can be unstably targeted, to use:
220+ /// - some CRT objects
221+ /// - the libc static library
222+ /// - libgcc/libunwind libraries
223+ /// - a linker we distribute
224+ /// - some sanitizer runtime libraries
225+ /// - all other MinGW libraries and Windows import libs
226+ ///
227+ #[ derive( Default , Clone , PartialEq , Debug ) ]
228+ pub struct LinkSelfContained {
229+ /// Whether the user explicitly set `-C link-self-contained` on or off, the historical values.
230+ /// Used for compatibility with the existing opt-in and target inference.
231+ pub explicitly_set : Option < bool > ,
232+
233+ /// The components that are enabled.
234+ components : LinkSelfContainedComponents ,
235+ }
236+
237+ bitflags:: bitflags! {
238+ #[ derive( Default ) ]
239+ /// The `-C link-self-contained` components that can individually be enabled or disabled.
240+ pub struct LinkSelfContainedComponents : u8 {
241+ /// CRT objects (e.g. on `windows-gnu`, `musl`, `wasi` targets)
242+ const CRT_OBJECTS = 1 << 0 ;
243+ /// libc static library (e.g. on `musl`, `wasi` targets)
244+ const LIBC = 1 << 1 ;
245+ /// libgcc/libunwind (e.g. on `windows-gnu`, `fuchsia`, `fortanix`, `gnullvm` targets)
246+ const UNWIND = 1 << 2 ;
247+ /// Linker, dlltool, and their necessary libraries (e.g. on `windows-gnu` and for `rust-lld`)
248+ const LINKER = 1 << 3 ;
249+ /// Sanitizer runtime libraries
250+ const SANITIZERS = 1 << 4 ;
251+ /// Other MinGW libs and Windows import libs
252+ const MINGW = 1 << 5 ;
253+ }
254+ }
255+
213256/// Used with `-Z assert-incr-state`.
214257#[ derive( Clone , Copy , PartialEq , Hash , Debug ) ]
215258pub enum IncrementalStateAssertion {
0 commit comments