Skip to content

Commit ea232bb

Browse files
committed
move LinkSelfContainedComponents to rustc_target
1 parent a1fe258 commit ea232bb

File tree

4 files changed

+36
-37
lines changed

4 files changed

+36
-37
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4391,7 +4391,6 @@ dependencies = [
43914391
name = "rustc_session"
43924392
version = "0.0.0"
43934393
dependencies = [
4394-
"bitflags 1.3.2",
43954394
"getopts",
43964395
"libc",
43974396
"rustc_ast",

compiler/rustc_session/Cargo.toml

Lines changed: 0 additions & 1 deletion
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

Lines changed: 1 addition & 35 deletions
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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,41 @@ impl ToJson for LinkerFlavorCli {
531531
}
532532
}
533533

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

0 commit comments

Comments
 (0)