Skip to content

Commit 3897749

Browse files
committed
Auto merge of #10088 - joshtriplett:stabilize-strip, r=ehuss
Stabilize the `strip` profile option, now that rustc has stable `-C strip` rust-lang/rust#90058 stabilized `-Z strip` as `-C strip`. Stabilize the corresponding Cargo option. Update the documentation to move it from the unstable reference to the profiles documentation. Update the tests to account for stabilization.
2 parents 35e82eb + bd55063 commit 3897749

File tree

6 files changed

+39
-92
lines changed

6 files changed

+39
-92
lines changed

src/cargo/core/compiler/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ fn build_base_args(
10231023
}
10241024

10251025
if strip != Strip::None {
1026-
cmd.arg("-Z").arg(format!("strip={}", strip));
1026+
cmd.arg("-C").arg(format!("strip={}", strip));
10271027
}
10281028

10291029
if unit.is_std {

src/cargo/core/features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ features! {
393393
(stable, resolver, "1.51", "reference/resolver.html#resolver-versions"),
394394

395395
// Allow to specify whether binaries should be stripped.
396-
(unstable, strip, "", "reference/unstable.html#profile-strip-option"),
396+
(stable, strip, "1.58", "reference/profiles.html#strip-option"),
397397

398398
// Specifying a minimal 'rust-version' attribute for crates
399399
(stable, rust_version, "1.56", "reference/manifest.html#the-rust-version-field"),

src/cargo/util/toml/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,6 @@ impl TomlProfile {
530530
}
531531
}
532532

533-
if self.strip.is_some() {
534-
features.require(Feature::strip())?;
535-
}
536-
537533
if let Some(codegen_backend) = &self.codegen_backend {
538534
features.require(Feature::codegen_backend())?;
539535
if codegen_backend.contains(|c: char| !c.is_ascii_alphanumeric() && c != '_') {

src/doc/src/reference/profiles.md

+22
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,28 @@ once more testing has been performed, and support for DWARF is stabilized.
9393
[nightly channel]: ../../book/appendix-07-nightly-rust.html
9494
[`-C split-debuginfo` flag]: ../../rustc/codegen-options/index.html#split-debuginfo
9595

96+
#### strip
97+
98+
The `strip` option controls the [`-C strip` flag], which directs rustc to
99+
strip either symbols or debuginfo from a binary. This can be enabled like so:
100+
101+
```toml
102+
[package]
103+
# ...
104+
105+
[profile.release]
106+
strip = "debuginfo"
107+
```
108+
109+
Other possible string values of `strip` are `none`, `symbols`, and `off`. The
110+
default is `none`.
111+
112+
You can also configure this option with the two absolute boolean values
113+
`true` and `false`. The former enables `strip` at its higher level, `symbols`,
114+
while the latter disables `strip` completely.
115+
116+
[`-C strip` flag]: ../../rustc/codegen-options/index.html#strip
117+
96118
#### debug-assertions
97119

98120
The `debug-assertions` setting controls the [`-C debug-assertions` flag] which

src/doc/src/reference/unstable.md

+5-22
Original file line numberDiff line numberDiff line change
@@ -820,28 +820,6 @@ The following is a description of the JSON structure:
820820
}
821821
```
822822

823-
### Profile `strip` option
824-
* Tracking Issue: [rust-lang/rust#72110](https://github.com/rust-lang/rust/issues/72110)
825-
826-
This feature provides a new option in the `[profile]` section to strip either
827-
symbols or debuginfo from a binary. This can be enabled like so:
828-
829-
```toml
830-
cargo-features = ["strip"]
831-
832-
[package]
833-
# ...
834-
835-
[profile.release]
836-
strip = "debuginfo"
837-
```
838-
839-
Other possible string values of `strip` are `none`, `symbols`, and `off`. The default is `none`.
840-
841-
You can also configure this option with the two absolute boolean values
842-
`true` and `false`. The former enables `strip` at its higher level, `symbols`,
843-
while the latter disables `strip` completely.
844-
845823
### rustdoc-map
846824
* Tracking Issue: [#8296](https://github.com/rust-lang/cargo/issues/8296)
847825

@@ -1387,6 +1365,11 @@ See [`cargo fix --edition`](../commands/cargo-fix.md) and [The Edition Guide](..
13871365
Custom named profiles have been stabilized in the 1.57 release. See the
13881366
[profiles chapter](profiles.md#custom-profiles) for more information.
13891367

1368+
### Profile `strip` option
1369+
1370+
The profile `strip` option has been stabilized in the 1.59 release. See the
1371+
[profiles chapter](profiles.md#strip) for more information.
1372+
13901373
### Future incompat report
13911374

13921375
Support for generating a future-incompat report has been stabilized

tests/testsuite/profiles.rs

+10-64
Original file line numberDiff line numberDiff line change
@@ -472,16 +472,14 @@ fn thin_lto_works() {
472472
#[cargo_test]
473473
fn strip_works() {
474474
if !is_nightly() {
475-
// -Zstrip is unstable
475+
// rustc 1.58 stabilized -C strip; disable the test until that ships.
476476
return;
477477
}
478478

479479
let p = project()
480480
.file(
481481
"Cargo.toml",
482482
r#"
483-
cargo-features = ["strip"]
484-
485483
[package]
486484
name = "foo"
487485
version = "0.1.0"
@@ -494,73 +492,27 @@ fn strip_works() {
494492
.build();
495493

496494
p.cargo("build --release -v")
497-
.masquerade_as_nightly_cargo()
498495
.with_stderr(
499496
"\
500497
[COMPILING] foo [..]
501-
[RUNNING] `rustc [..] -Z strip=symbols [..]`
498+
[RUNNING] `rustc [..] -C strip=symbols [..]`
502499
[FINISHED] [..]
503500
",
504501
)
505502
.run();
506503
}
507504

508-
#[cargo_test]
509-
fn strip_requires_cargo_feature() {
510-
if !is_nightly() {
511-
// -Zstrip is unstable
512-
return;
513-
}
514-
515-
let p = project()
516-
.file(
517-
"Cargo.toml",
518-
r#"
519-
[package]
520-
name = "foo"
521-
version = "0.1.0"
522-
523-
[profile.release]
524-
strip = 'symbols'
525-
"#,
526-
)
527-
.file("src/main.rs", "fn main() {}")
528-
.build();
529-
530-
p.cargo("build --release -v")
531-
.masquerade_as_nightly_cargo()
532-
.with_status(101)
533-
.with_stderr(
534-
"\
535-
[ERROR] failed to parse manifest at `[CWD]/Cargo.toml`
536-
537-
Caused by:
538-
feature `strip` is required
539-
540-
The package requires the Cargo feature called `strip`, but that feature is \
541-
not stabilized in this version of Cargo (1.[..]).
542-
Consider adding `cargo-features = [\"strip\"]` to the top of Cargo.toml \
543-
(above the [package] table) to tell Cargo you are opting in to use this unstable feature.
544-
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#profile-strip-option \
545-
for more information about the status of this feature.
546-
",
547-
)
548-
.run();
549-
}
550-
551505
#[cargo_test]
552506
fn strip_passes_unknown_option_to_rustc() {
553507
if !is_nightly() {
554-
// -Zstrip is unstable
508+
// rustc 1.58 stabilized -C strip; disable the test until that ships.
555509
return;
556510
}
557511

558512
let p = project()
559513
.file(
560514
"Cargo.toml",
561515
r#"
562-
cargo-features = ["strip"]
563-
564516
[package]
565517
name = "foo"
566518
version = "0.1.0"
@@ -573,13 +525,12 @@ fn strip_passes_unknown_option_to_rustc() {
573525
.build();
574526

575527
p.cargo("build --release -v")
576-
.masquerade_as_nightly_cargo()
577528
.with_status(101)
578529
.with_stderr_contains(
579530
"\
580531
[COMPILING] foo [..]
581-
[RUNNING] `rustc [..] -Z strip=unknown [..]`
582-
error: incorrect value `unknown` for debugging option `strip` - either `none`, `debuginfo`, or `symbols` was expected
532+
[RUNNING] `rustc [..] -C strip=unknown [..]`
533+
error: incorrect value `unknown` for [..] `strip` [..] was expected
583534
",
584535
)
585536
.run();
@@ -588,16 +539,14 @@ error: incorrect value `unknown` for debugging option `strip` - either `none`, `
588539
#[cargo_test]
589540
fn strip_accepts_true_to_strip_symbols() {
590541
if !is_nightly() {
591-
// -Zstrip is unstable
542+
// rustc 1.58 stabilized -C strip; disable the test until that ships.
592543
return;
593544
}
594545

595546
let p = project()
596547
.file(
597548
"Cargo.toml",
598549
r#"
599-
cargo-features = ["strip"]
600-
601550
[package]
602551
name = "foo"
603552
version = "0.1.0"
@@ -610,11 +559,10 @@ fn strip_accepts_true_to_strip_symbols() {
610559
.build();
611560

612561
p.cargo("build --release -v")
613-
.masquerade_as_nightly_cargo()
614562
.with_stderr(
615563
"\
616564
[COMPILING] foo [..]
617-
[RUNNING] `rustc [..] -Z strip=symbols [..]`
565+
[RUNNING] `rustc [..] -C strip=symbols [..]`
618566
[FINISHED] [..]
619567
",
620568
)
@@ -624,15 +572,14 @@ fn strip_accepts_true_to_strip_symbols() {
624572
#[cargo_test]
625573
fn strip_accepts_false_to_disable_strip() {
626574
if !is_nightly() {
627-
// -Zstrip is unstable
575+
// rustc 1.58 stabilized -C strip; disable the test until that ships.
628576
return;
629577
}
578+
630579
let p = project()
631580
.file(
632581
"Cargo.toml",
633582
r#"
634-
cargo-features = ["strip"]
635-
636583
[package]
637584
name = "foo"
638585
version = "0.1.0"
@@ -645,7 +592,6 @@ fn strip_accepts_false_to_disable_strip() {
645592
.build();
646593

647594
p.cargo("build --release -v")
648-
.masquerade_as_nightly_cargo()
649-
.with_stderr_does_not_contain("-Z strip")
595+
.with_stderr_does_not_contain("-C strip")
650596
.run();
651597
}

0 commit comments

Comments
 (0)