Skip to content

Commit 34859df

Browse files
borsNoratrieb
authored andcommitted
Auto merge of rust-lang#122646 - saethlin:library-frame-pointers, r=onur-ozkan
Enable frame pointers for the standard library There's been a few past experiments for enabling frame pointers for all our artifacts. I don't think that frame pointers in the distributed compiler are nearly as useful as frame pointers in the standard library. Our users are much more likely to be profiling apps written in Rust than they are profiling the Rust compiler. So yeah it would be cool to have frame pointers in the compiler, but much more of the value is having them on the precompiled standard library. That's what this PR does.
2 parents 13abc0a + aeb3447 commit 34859df

26 files changed

+1145
-22
lines changed

Cargo.lock

+36
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,12 @@ version = "0.3.1"
15851585
source = "registry+https://github.com/rust-lang/crates.io-index"
15861586
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
15871587

1588+
[[package]]
1589+
name = "glob-match"
1590+
version = "0.2.1"
1591+
source = "registry+https://github.com/rust-lang/crates.io-index"
1592+
checksum = "9985c9503b412198aa4197559e9a318524ebc4519c229bfa05a535828c950b9d"
1593+
15881594
[[package]]
15891595
name = "globset"
15901596
version = "0.4.13"
@@ -5030,6 +5036,19 @@ dependencies = [
50305036
"serde",
50315037
]
50325038

5039+
[[package]]
5040+
name = "serde_yaml"
5041+
version = "0.9.31"
5042+
source = "registry+https://github.com/rust-lang/crates.io-index"
5043+
checksum = "adf8a49373e98a4c5f0ceb5d05aa7c648d75f63774981ed95b7c7443bbd50c6e"
5044+
dependencies = [
5045+
"indexmap",
5046+
"itoa",
5047+
"ryu",
5048+
"serde",
5049+
"unsafe-libyaml",
5050+
]
5051+
50335052
[[package]]
50345053
name = "sha1"
50355054
version = "0.10.6"
@@ -5392,6 +5411,17 @@ dependencies = [
53925411
"xattr",
53935412
]
53945413

5414+
[[package]]
5415+
name = "target-docs"
5416+
version = "0.1.0"
5417+
dependencies = [
5418+
"eyre",
5419+
"glob-match",
5420+
"serde",
5421+
"serde_json",
5422+
"serde_yaml",
5423+
]
5424+
53955425
[[package]]
53965426
name = "tempfile"
53975427
version = "3.10.1"
@@ -6038,6 +6068,12 @@ dependencies = [
60386068
"diff",
60396069
]
60406070

6071+
[[package]]
6072+
name = "unsafe-libyaml"
6073+
version = "0.2.10"
6074+
source = "registry+https://github.com/rust-lang/crates.io-index"
6075+
checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b"
6076+
60416077
[[package]]
60426078
name = "unstable-book-gen"
60436079
version = "0.1.0"

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ members = [
4646
"src/tools/rustdoc-gui-test",
4747
"src/tools/opt-dist",
4848
"src/tools/coverage-dump",
49+
"src/tools/target-docs",
4950
]
5051

5152
exclude = [

compiler/rustc_target/src/spec/targets/aarch64_apple_tvos.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ pub fn target() -> Target {
66
Target {
77
llvm_target: tvos_llvm_target(arch).into(),
88
metadata: crate::spec::TargetMetadata {
9-
description: None,
10-
tier: None,
11-
host_tools: None,
9+
description: Some("ARM64 tvOS".into()),
10+
tier: Some(2),
11+
host_tools: Some(false),
1212
std: None,
1313
},
1414
pointer_width: 64,

compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ pub fn target() -> Target {
1818
Target {
1919
llvm_target: "i686-pc-windows-gnu".into(),
2020
metadata: crate::spec::TargetMetadata {
21-
description: None,
22-
tier: None,
23-
host_tools: None,
24-
std: None,
21+
description: Some("32-bit MinGW (Windows 7+)".into()),
22+
tier: Some(1),
23+
host_tools: Some(true),
24+
std: Some(true),
2525
},
2626
pointer_width: 32,
2727
data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\

compiler/rustc_target/src/spec/targets/loongarch64_unknown_linux_gnu.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ pub fn target() -> Target {
44
Target {
55
llvm_target: "loongarch64-unknown-linux-gnu".into(),
66
metadata: crate::spec::TargetMetadata {
7-
description: None,
8-
tier: None,
9-
host_tools: None,
10-
std: None,
7+
description: Some("LoongArch64 Linux, LP64D ABI (kernel 5.19, glibc 2.36)".into()),
8+
tier: Some(2),
9+
host_tools: Some(true),
10+
std: Some(true),
1111
},
1212
pointer_width: 64,
1313
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n64-S128".into(),

compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ pub fn target() -> Target {
1111
Target {
1212
llvm_target: "powerpc64-ibm-aix".into(),
1313
metadata: crate::spec::TargetMetadata {
14-
description: None,
15-
tier: None,
16-
host_tools: None,
17-
std: None,
14+
description: Some("64-bit AIX (7.2 and newer)".into()),
15+
tier: Some(3),
16+
host_tools: Some(true),
17+
std: Some(true),
1818
},
1919
pointer_width: 64,
2020
data_layout: "E-m:a-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),

src/bootstrap/src/core/build_steps/compile.rs

+4
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,10 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
550550
cargo.rustflag("-Cforce-unwind-tables=yes");
551551
}
552552

553+
// Enable frame pointers by default for the library. Note that they are still controlled by a
554+
// separate setting for the compiler.
555+
cargo.rustflag("-Cforce-frame-pointers=yes");
556+
553557
let html_root =
554558
format!("-Zcrate-attr=doc(html_root_url=\"{}/\")", builder.doc_rust_lang_org_channel(),);
555559
cargo.rustflag(&html_root);

src/bootstrap/src/core/build_steps/doc.rs

+26-4
Original file line numberDiff line numberDiff line change
@@ -1147,14 +1147,16 @@ impl Step for RustcBook {
11471147

11481148
/// Builds the rustc book.
11491149
///
1150-
/// The lints are auto-generated by a tool, and then merged into the book
1150+
/// The lints and target docs are auto-generated by a tool, and then merged into the book
11511151
/// in the "md-doc" directory in the build output directory. Then
11521152
/// "rustbook" is used to convert it to HTML.
11531153
fn run(self, builder: &Builder<'_>) {
11541154
let out_base = builder.md_doc_out(self.target).join("rustc");
11551155
t!(fs::create_dir_all(&out_base));
1156-
let out_listing = out_base.join("src/lints");
1157-
builder.cp_link_r(&builder.src.join("src/doc/rustc"), &out_base);
1156+
let out_lints_listing = out_base.join("src/lints");
1157+
let out_src_listing = out_base.join("src");
1158+
1159+
builder.cp_r_but_like_really_copy(&builder.src.join("src/doc/rustc"), &out_base);
11581160
builder.info(&format!("Generating lint docs ({})", self.target));
11591161

11601162
let rustc = builder.rustc(self.compiler);
@@ -1165,7 +1167,7 @@ impl Step for RustcBook {
11651167
cmd.arg("--src");
11661168
cmd.arg(builder.src.join("compiler"));
11671169
cmd.arg("--out");
1168-
cmd.arg(&out_listing);
1170+
cmd.arg(&out_lints_listing);
11691171
cmd.arg("--rustc");
11701172
cmd.arg(&rustc);
11711173
cmd.arg("--rustc-target").arg(self.target.rustc_target_arg());
@@ -1194,6 +1196,26 @@ impl Step for RustcBook {
11941196
builder.run(&mut cmd);
11951197
drop(doc_generator_guard);
11961198

1199+
// Run target-docs generator
1200+
let mut cmd = builder.tool_cmd(Tool::TargetDocs);
1201+
cmd.arg(builder.src.join("src/doc/rustc/target_infos"));
1202+
cmd.arg(&out_src_listing);
1203+
cmd.env("RUSTC", &rustc);
1204+
// For now, we just check that the files are correct but do not generate output.
1205+
// Let the user override it to TARGET_CHECK_ONLY=0 for testing, but use 1 by default.
1206+
// See #120745 for more info.
1207+
cmd.env("TARGET_CHECK_ONLY", std::env::var("TARGET_CHECK_ONLY").unwrap_or("1".to_owned()));
1208+
1209+
let doc_generator_guard = builder.msg(
1210+
Kind::Run,
1211+
self.compiler.stage,
1212+
"target-docs",
1213+
self.compiler.host,
1214+
self.target,
1215+
);
1216+
builder.run(&mut cmd);
1217+
drop(doc_generator_guard);
1218+
11971219
// Run rustbook/mdbook to generate the HTML pages.
11981220
builder.ensure(RustbookSrc {
11991221
target: self.target,

src/bootstrap/src/core/build_steps/tool.rs

+1
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ bootstrap_tool!(
301301
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes";
302302
ExpandYamlAnchors, "src/tools/expand-yaml-anchors", "expand-yaml-anchors";
303303
LintDocs, "src/tools/lint-docs", "lint-docs";
304+
TargetDocs, "src/tools/target-docs", "target-docs";
304305
JsonDocCk, "src/tools/jsondocck", "jsondocck";
305306
JsonDocLint, "src/tools/jsondoclint", "jsondoclint";
306307
HtmlChecker, "src/tools/html-checker", "html-checker";

src/bootstrap/src/lib.rs

+41-2
Original file line numberDiff line numberDiff line change
@@ -1656,7 +1656,21 @@ impl Build {
16561656
self.copy_link_internal(src, dst, false);
16571657
}
16581658

1659-
fn copy_link_internal(&self, src: &Path, dst: &Path, dereference_symlinks: bool) {
1659+
pub fn copy_but_like_really_copy(&self, src: &Path, dst: &Path) {
1660+
self.copy_internal(src, dst, false, false);
1661+
}
1662+
1663+
pub fn copy_link(&self, src: &Path, dst: &Path) {
1664+
self.copy_internal(src, dst, false, true);
1665+
}
1666+
1667+
fn copy_internal(
1668+
&self,
1669+
src: &Path,
1670+
dst: &Path,
1671+
dereference_symlinks: bool,
1672+
link_if_possible: bool,
1673+
) {
16601674
if self.config.dry_run() {
16611675
return;
16621676
}
@@ -1676,7 +1690,7 @@ impl Build {
16761690
return;
16771691
}
16781692
}
1679-
if let Ok(()) = fs::hard_link(&src, dst) {
1693+
if link_if_possible && fs::hard_link(&src, dst).is_ok() {
16801694
// Attempt to "easy copy" by creating a hard link
16811695
// (symlinks don't work on windows), but if that fails
16821696
// just fall back to a slow `copy` operation.
@@ -1711,6 +1725,25 @@ impl Build {
17111725
}
17121726
}
17131727

1728+
// TODO: Rename to cp_r or something like that after #122590 has been merged.
1729+
pub fn cp_r_but_like_really_copy(&self, src: &Path, dst: &Path) {
1730+
if self.config.dry_run() {
1731+
return;
1732+
}
1733+
for f in self.read_dir(src) {
1734+
let path = f.path();
1735+
let name = path.file_name().unwrap();
1736+
let dst = dst.join(name);
1737+
if t!(f.file_type()).is_dir() {
1738+
t!(fs::create_dir_all(&dst));
1739+
self.cp_r_but_like_really_copy(&path, &dst);
1740+
} else {
1741+
let _ = fs::remove_file(&dst);
1742+
self.copy_but_like_really_copy(&path, &dst);
1743+
}
1744+
}
1745+
}
1746+
17141747
/// Copies the `src` directory recursively to `dst`. Both are assumed to exist
17151748
/// when this function is called.
17161749
/// Will attempt to use hard links if possible and fall back to copying.
@@ -1764,7 +1797,13 @@ impl Build {
17641797
if !src.exists() {
17651798
panic!("ERROR: File \"{}\" not found!", src.display());
17661799
}
1800+
<<<<<<< HEAD
17671801
self.copy_link_internal(src, &dst, true);
1802+
||||||| parent of b9770bcfe34 (Introduce infrastructure for generating target docs)
1803+
self.copy_internal(src, &dst, true);
1804+
=======
1805+
self.copy_internal(src, &dst, true, true);
1806+
>>>>>>> b9770bcfe34 (Introduce infrastructure for generating target docs)
17681807
chmod(&dst, perms);
17691808
}
17701809

src/doc/rustc/src/SUMMARY.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
- [x86_64-fortanix-unknown-sgx](platform-support/x86_64-fortanix-unknown-sgx.md)
7070
- [x86_64-unknown-none](platform-support/x86_64-unknown-none.md)
7171
- [x86_64h-apple-darwin](platform-support/x86_64h-apple-darwin.md)
72+
<!-- - [List of Targets](platform-support/targets.md) (see #120745) -->
73+
<!-- TARGET_LIST SECTION START -->
74+
<!-- TARGET_LIST SECTION END -->
7275
- [Targets](targets/index.md)
7376
- [Built-in Targets](targets/built-in.md)
7477
- [Custom Targets](targets/custom.md)
@@ -79,4 +82,4 @@
7982
- [Exploit Mitigations](exploit-mitigations.md)
8083
- [Symbol Mangling](symbol-mangling/index.md)
8184
- [v0 Symbol Format](symbol-mangling/v0.md)
82-
- [Contributing to `rustc`](contributing.md)
85+
- [Contributing to `rustc`](contributing.md)

src/doc/rustc/src/platform-support.md

+9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ All tier 1 targets with host tools support the full standard library.
3232

3333
target | notes
3434
-------|-------
35+
<!-- TIER1HOST SECTION START -->
36+
<!-- See `src/tools/target-docs` -->
37+
<!-- TIER1HOST SECTION END -->
3538
`aarch64-unknown-linux-gnu` | ARM64 Linux (kernel 4.1, glibc 2.17+)
3639
`i686-pc-windows-gnu` | 32-bit MinGW (Windows 10+) [^x86_32-floats-return-ABI]
3740
`i686-pc-windows-msvc` | 32-bit MSVC (Windows 10+) [^x86_32-floats-return-ABI]
@@ -86,6 +89,8 @@ so Rustup may install the documentation for a similar tier 1 target instead.
8689

8790
target | notes
8891
-------|-------
92+
<!-- TIER2HOST SECTION START -->
93+
<!-- TIER2HOST SECTION END -->
8994
`aarch64-apple-darwin` | ARM64 macOS (11.0+, Big Sur+)
9095
`aarch64-pc-windows-msvc` | ARM64 Windows MSVC
9196
`aarch64-unknown-linux-musl` | ARM64 Linux with musl 1.2.3
@@ -133,6 +138,8 @@ so Rustup may install the documentation for a similar tier 1 target instead.
133138

134139
target | std | notes
135140
-------|:---:|-------
141+
<!-- TIER2 SECTION START -->
142+
<!-- TIER2 SECTION END -->
136143
`aarch64-apple-ios` | ✓ | ARM64 iOS
137144
[`aarch64-apple-ios-sim`](platform-support/aarch64-apple-ios-sim.md) | ✓ | Apple iOS Simulator on ARM64
138145
`aarch64-fuchsia` | ✓ | Alias for `aarch64-unknown-fuchsia`
@@ -234,6 +241,8 @@ host tools.
234241

235242
target | std | host | notes
236243
-------|:---:|:----:|-------
244+
<!-- TIER3 SECTION START -->
245+
<!-- TIER3 SECTION END -->
237246
[`arm64e-apple-ios`](platform-support/arm64e-apple-ios.md) | ✓ | | ARM64e Apple iOS
238247
[`arm64e-apple-darwin`](platform-support/arm64e-apple-darwin.md) | ✓ | ✓ | ARM64e Apple Darwin
239248
[`arm64ec-pc-windows-msvc`](platform-support/arm64ec-pc-windows-msvc.md) | ? | | Arm64EC Windows MSVC

src/doc/rustc/src/platform-support/aix.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# `powerpc64-ibm-aix`
22

3+
<!--
4+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5+
6+
***WARNING***
7+
This target has already been migrated to the new target docs system: #120745
8+
When editing this file, make sure that you keep the equivalent docs in ../../target_infos in sync!!!
9+
10+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11+
-->
12+
313
**Tier: 3**
414

515
Rust for AIX operating system, currently only 64-bit PowerPC is supported.

src/doc/rustc/src/platform-support/apple-tvos.md

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
- aarch64-apple-tvos
33
- x86_64-apple-tvos
44

5+
<!--
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
8+
***WARNING***
9+
This target has already been migrated to the new target docs system: #120745
10+
When editing this file, make sure that you keep the equivalent docs in ../../target_infos in sync!!!
11+
12+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
13+
-->
14+
515
**Tier: 3**
616

717
Apple tvOS targets:

src/doc/rustc/src/platform-support/loongarch-linux.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# loongarch\*-unknown-linux-\*
22

3+
<!--
4+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5+
6+
***WARNING***
7+
This target has already been migrated to the new target docs system: #120745
8+
When editing this file, make sure that you keep the equivalent docs in ../../target_infos in sync!!!
9+
10+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11+
-->
12+
13+
314
**Tier: 2**
415

516
[LoongArch] is a new RISC ISA developed by Loongson Technology Corporation Limited.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# List of all targets
2+
3+
An alphabetical list of all targets.
4+
5+
<!-- TARGET SECTION START -->
6+
<!-- See `src/tools/target-docs` -->
7+
<!-- TARGET SECTION END -->

0 commit comments

Comments
 (0)