Skip to content

Commit acc3b61

Browse files
committed
move LinkSelfContainedComponents to rustc_target
1 parent 71285c1 commit acc3b61

File tree

4 files changed

+36
-37
lines changed

4 files changed

+36
-37
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -4479,7 +4479,6 @@ dependencies = [
44794479
name = "rustc_session"
44804480
version = "0.0.0"
44814481
dependencies = [
4482-
"bitflags 1.3.2",
44834482
"getopts",
44844483
"libc",
44854484
"rustc_ast",

compiler/rustc_session/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ version = "0.0.0"
44
edition = "2021"
55

66
[dependencies]
7-
bitflags = "1.2.1"
87
getopts = "0.2"
98
rustc_macros = { path = "../rustc_macros" }
109
tracing = "0.1"

compiler/rustc_session/src/config.rs

+1-35
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::{EarlyErrorHandler, Session};
1212
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1313
use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey};
1414
use rustc_target::abi::Align;
15+
use rustc_target::spec::LinkSelfContainedComponents;
1516
use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, SplitDebuginfo};
1617
use rustc_target::spec::{Target, TargetTriple, TargetWarnings, TARGETS};
1718

@@ -236,41 +237,6 @@ pub struct LinkSelfContained {
236237
components: LinkSelfContainedComponents,
237238
}
238239

239-
bitflags::bitflags! {
240-
#[derive(Default)]
241-
/// The `-C link-self-contained` components that can individually be enabled or disabled.
242-
pub struct LinkSelfContainedComponents: u8 {
243-
/// CRT objects (e.g. on `windows-gnu`, `musl`, `wasi` targets)
244-
const CRT_OBJECTS = 1 << 0;
245-
/// libc static library (e.g. on `musl`, `wasi` targets)
246-
const LIBC = 1 << 1;
247-
/// libgcc/libunwind (e.g. on `windows-gnu`, `fuchsia`, `fortanix`, `gnullvm` targets)
248-
const UNWIND = 1 << 2;
249-
/// Linker, dlltool, and their necessary libraries (e.g. on `windows-gnu` and for `rust-lld`)
250-
const LINKER = 1 << 3;
251-
/// Sanitizer runtime libraries
252-
const SANITIZERS = 1 << 4;
253-
/// Other MinGW libs and Windows import libs
254-
const MINGW = 1 << 5;
255-
}
256-
}
257-
258-
impl FromStr for LinkSelfContainedComponents {
259-
type Err = ();
260-
261-
fn from_str(s: &str) -> Result<Self, Self::Err> {
262-
Ok(match s {
263-
"crto" => LinkSelfContainedComponents::CRT_OBJECTS,
264-
"libc" => LinkSelfContainedComponents::LIBC,
265-
"unwind" => LinkSelfContainedComponents::UNWIND,
266-
"linker" => LinkSelfContainedComponents::LINKER,
267-
"sanitizers" => LinkSelfContainedComponents::SANITIZERS,
268-
"mingw" => LinkSelfContainedComponents::MINGW,
269-
_ => return Err(()),
270-
})
271-
}
272-
}
273-
274240
impl LinkSelfContained {
275241
/// Incorporates an enabled or disabled component as specified on the CLI, if possible.
276242
/// For example: `+linker`, and `-crto`.

compiler/rustc_target/src/spec/mod.rs

+35
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,41 @@ impl ToJson for LinkerFlavorCli {
520520
}
521521
}
522522

523+
bitflags::bitflags! {
524+
#[derive(Default)]
525+
/// The `-C link-self-contained` components that can individually be enabled or disabled.
526+
pub struct LinkSelfContainedComponents: u8 {
527+
/// CRT objects (e.g. on `windows-gnu`, `musl`, `wasi` targets)
528+
const CRT_OBJECTS = 1 << 0;
529+
/// libc static library (e.g. on `musl`, `wasi` targets)
530+
const LIBC = 1 << 1;
531+
/// libgcc/libunwind (e.g. on `windows-gnu`, `fuchsia`, `fortanix`, `gnullvm` targets)
532+
const UNWIND = 1 << 2;
533+
/// Linker, dlltool, and their necessary libraries (e.g. on `windows-gnu` and for `rust-lld`)
534+
const LINKER = 1 << 3;
535+
/// Sanitizer runtime libraries
536+
const SANITIZERS = 1 << 4;
537+
/// Other MinGW libs and Windows import libs
538+
const MINGW = 1 << 5;
539+
}
540+
}
541+
542+
impl FromStr for LinkSelfContainedComponents {
543+
type Err = ();
544+
545+
fn from_str(s: &str) -> Result<Self, Self::Err> {
546+
Ok(match s {
547+
"crto" => LinkSelfContainedComponents::CRT_OBJECTS,
548+
"libc" => LinkSelfContainedComponents::LIBC,
549+
"unwind" => LinkSelfContainedComponents::UNWIND,
550+
"linker" => LinkSelfContainedComponents::LINKER,
551+
"sanitizers" => LinkSelfContainedComponents::SANITIZERS,
552+
"mingw" => LinkSelfContainedComponents::MINGW,
553+
_ => return Err(()),
554+
})
555+
}
556+
}
557+
523558
#[derive(Clone, Copy, Debug, PartialEq, Hash, Encodable, Decodable, HashStable_Generic)]
524559
pub enum PanicStrategy {
525560
Unwind,

0 commit comments

Comments
 (0)