Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

profiler = true in config.toml no longer works #79124

Closed
richkadel opened this issue Nov 17, 2020 · 4 comments · Fixed by #79155
Closed

profiler = true in config.toml no longer works #79124

richkadel opened this issue Nov 17, 2020 · 4 comments · Fixed by #79155
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@richkadel
Copy link
Contributor

richkadel commented Nov 17, 2020

PR #78354 broke the build for users of profiler_builtins.

The PR copies the (commented out) #profiler = false line (among other things) from the [build] section to the sample target-specific (linux in config.toml.example) section, and made related changes to bootstrap.

Intuitively (especially because the [build] profiler = false/true option is still present, I believe that if profiler = true in build, then profiler should also be true in the target-specific setting, if not explicitly set for the target.

Since I always build with profiler = true, I did not expect the build to stop working after rebasing with the change, but with this PR, the profiler_builtins library is no longer built.

I think the new target-specific settings, if not set, need to default to the non-specific setting.

Workaround:

I had to add a target-specific setting on each platform I test with (Linux, Windows, and MacOS). On Mac, for example, I added these two lines in my config.toml:

[target.x86_64-apple-darwin]
profiler = true

It's still building, but it looks like it finally started building the profiler_builtins library.

cc @Mark-Simulacrum

@richkadel richkadel added the C-bug Category: This is a bug. label Nov 17, 2020
@jyn514 jyn514 added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Nov 17, 2020
@richkadel
Copy link
Contributor Author

FYI, I confirmed the workaround (setting the target-specific profiler setting) does work and my tests work again.

@12101111
Copy link
Contributor

I can't reproduce this issue.

sed -r -e 's/^#.*$//' -e '/^$/d' config.toml:

changelog-seen = 2
[llvm]
link-shared = true
[build]
sanitizers = true
profiler = true
[install]
[rust]
[target.x86_64-unknown-linux-gnu]
cc = "clang"
cxx = "clang++"
ar = "/usr/bin/llvm-ar"
ranlib = "/usr/bin/llvm-ranlib"
linker = "clang"
llvm-config = "/usr/bin/llvm-config"
[dist]
> LANG=C git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/bootstrap/config.rs

no changes added to commit (use "git add" and/or "git commit -a")

The master branch is at b5c37e8

git diff

diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index 94319a6d1e9..eb0e78bc941 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -341,7 +341,7 @@ fn do_merge<T: Merge>(x: &mut Option<T>, y: Option<T>) {
 }

 /// TOML representation of various global build decisions.
-#[derive(Deserialize, Default, Clone, Merge)]
+#[derive(Deserialize, Default, Clone, Merge, Debug)]
 #[serde(deny_unknown_fields, rename_all = "kebab-case")]
 struct Build {
     build: Option<String>,
@@ -621,8 +621,8 @@ pub fn parse(args: &[String]) -> Config {
             config.config = cfg;
         }

+        println!("Build: {:?}", toml.build);
         let build = toml.build.unwrap_or_default();
-
         config.hosts = if let Some(arg_host) = flags.host {
             arg_host
         } else if let Some(file_host) = build.host {
@@ -899,7 +899,14 @@ pub fn parse(args: &[String]) -> Config {
                 target.sanitizers = cfg.sanitizers.unwrap_or(build.sanitizers.unwrap_or_default());
                 target.profiler = cfg.profiler.unwrap_or(build.profiler.unwrap_or_default());

+                println!("`sanitizers` in [build]: {:?}", build.sanitizers);
+                println!("`profiler` in [build]: {:?}", build.profiler);
+                println!("`sanitizers` in [target.{:?}]: {:?}", triple, cfg.sanitizers);
+                println!("`profiler` in [target.{:?}]: {:?}", triple, cfg.profiler);
+                println!("final sanitizers config for {:?} : {:?}", triple, target.sanitizers);
+                println!("final profiler config for {:?} profiler: {:?}", triple, target.profiler);
                 config.target_config.insert(TargetSelection::from_user(&triple), target);
+
             }
         }

build log:

> ./x.py build --stage 2
   Compiling bootstrap v0.0.0 (/home/han/rust/src/bootstrap)
    Finished dev [unoptimized + debuginfo] target(s) in 5.59s
Build: Some(Build { build: None, host: None, target: None, build_dir: None, cargo: None, rustc: None, rustfmt: None, docs: None, compiler_docs: None, submodules: None, fast_submodules: None, gdb: None, nodejs: None, python: None, locked_deps: None, vendor: None, full_bootstrap: None, extended: None, tools: None, verbose: None, sanitizers: Some(true), profiler: Some(true), cargo_native_static: None, low_priority: None, configure_args: None, local_rebuild: None, print_step_timings: None, doc_stage: None, build_stage: None, test_stage: None, install_stage: None, dist_stage: None, bench_stage: None })
`sanitizers` in [build]: Some(true)
`profiler` in [build]: Some(true)
`sanitizers` in [target."x86_64-unknown-linux-gnu"]: None
`profiler` in [target."x86_64-unknown-linux-gnu"]: None
final sanitizers config for "x86_64-unknown-linux-gnu" : true
final profiler config for "x86_64-unknown-linux-gnu" profiler: true
Building stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
....

binary:

> cd build
> fd profiler_builtins
x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libprofiler_builtins-980d9c24cb189583.rlib
x86_64-unknown-linux-gnu/stage0-std/release/build/profiler_builtins-bf12831b7cdd460d
x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/build/profiler_builtins-b68ef23e630bcb17
x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps/libprofiler_builtins-9dbeff80a926e7f3.rlib
x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps/libprofiler_builtins-9dbeff80a926e7f3.rmeta
x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps/profiler_builtins-9dbeff80a926e7f3.d
x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/libprofiler_builtins-9dbeff80a926e7f3.rlib
x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libprofiler_builtins-bf052076084443f1.rlib
x86_64-unknown-linux-gnu/stage1-std/release/build/profiler_builtins-3e0a6190a91a94e7
x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/build/profiler_builtins-781d280c78c97112
x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libprofiler_builtins-bf052076084443f1.rlib
x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libprofiler_builtins-bf052076084443f1.rmeta
x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/profiler_builtins-bf052076084443f1.d
x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libprofiler_builtins-bf052076084443f1.rlib

> ls x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib
libaddr2line-332cb94bf345094b.rlib          librustc-dev_rt.asan.a
libadler-79ca49f3556701a4.rlib              librustc-dev_rt.lsan.a
liballoc-fe9f96fdcdfe4199.rlib              librustc-dev_rt.msan.a
libcfg_if-822e432ce2db6e62.rlib             librustc-dev_rt.tsan.a
libcompiler_builtins-906b6a065e57e3b0.rlib  librustc_demangle-fe649840dc443879.rlib
libcore-7f60aaeb82b6bf4d.rlib               librustc_std_workspace_alloc-358f99852a855d0c.rlib
libgetopts-5251889848c01689.rlib            librustc_std_workspace_core-19ff454e2880fb3f.rlib
libgimli-574b2ef29d4f20c5.rlib              librustc_std_workspace_std-1186ab5d6f452152.rlib
libhashbrown-96ceb36319f90397.rlib          libstd-781fdb343374624a.rlib
liblibc-fc24b68582e61891.rlib               libstd-781fdb343374624a.so
libminiz_oxide-fe73ed392107a322.rlib        libterm-c9b1a355d5d5251b.rlib
libobject-d3897e5b78a79908.rlib             libtest-5c093475bfb34ae2.rlib
libpanic_abort-a4cf26a03fcee531.rlib        libtest-5c093475bfb34ae2.so
libpanic_unwind-2a21e5ef94ceb829.rlib       libunicode_width-46b877fd84bbfd50.rlib
libproc_macro-787384d30f7ecbdd.rlib         libunwind-5f3a6e512e002a67.rlib
libprofiler_builtins-bf052076084443f1.rlib  self-contained

@12101111
Copy link
Contributor

Also test on Windows 10
commit 54508a2
config.toml:

changelog-seen = 2
[llvm]
[build]
build = "x86_64-pc-windows-msvc"
sanitizers = true
profiler = true
[install]
[rust]
[target.x86_64-pc-windows-msvc]
[dist]

Output:

> python ./x.py build --stage 2
Updating only changed submodules
Submodules updated in 0.17 seconds
    Finished dev [unoptimized + debuginfo] target(s) in 0.30s
Build: Some(Build { build: Some("x86_64-pc-windows-msvc"), host: None, target: None, build_dir: None, cargo: None, rustc: None, rustfmt: None, docs: None, compiler_docs: None, submodules: None, fast_submodules: None, gdb: None, nodejs: None, python: None, locked_deps: None, vendor: None, full_bootstrap: None, extended: None, tools: None, verbose: None, sanitizers: Some(true), profiler: Some(true), cargo_native_static: None, low_priority: None, configure_args: None, local_rebuild: None, print_step_timings: None, doc_stage: None, build_stage: None, test_stage: None, install_stage: None, dist_stage: None, bench_stage: None })
`sanitizers` in [build]: Some(true)
`profiler` in [build]: Some(true)
`sanitizers` in [target."x86_64-pc-windows-msvc"]: None
`profiler` in [target."x86_64-pc-windows-msvc"]: None
final sanitizers config for "x86_64-pc-windows-msvc" : true
final profiler config for "x86_64-pc-windows-msvc" profiler: true
Building stage0 std artifacts (x86_64-pc-windows-msvc -> x86_64-pc-windows-msvc)

binary:

> fd profiler_builtins
x86_64-pc-windows-msvc\stage0-std\release\build\profiler_builtins-0fe06f81c31b9f86
x86_64-pc-windows-msvc\stage1-std\release\build\profiler_builtins-c8156efb6ad06c4e
x86_64-pc-windows-msvc\stage0-std\x86_64-pc-windows-msvc\release\build\profiler_builtins-eab3dfd17a0d5ee9
x86_64-pc-windows-msvc\stage0-std\x86_64-pc-windows-msvc\release\deps\libprofiler_builtins-23c82d4c3ff5dfcc.rmeta
x86_64-pc-windows-msvc\stage0-std\x86_64-pc-windows-msvc\release\deps\libprofiler_builtins-23c82d4c3ff5dfcc.rlib
x86_64-pc-windows-msvc\stage0-std\x86_64-pc-windows-msvc\release\deps\profiler_builtins-23c82d4c3ff5dfcc.d
x86_64-pc-windows-msvc\stage1-std\x86_64-pc-windows-msvc\release\build\profiler_builtins-baafc8bd8e1c2147
x86_64-pc-windows-msvc\stage1-std\x86_64-pc-windows-msvc\release\deps\libprofiler_builtins-94dca554e4a2a924.rlib
x86_64-pc-windows-msvc\stage1-std\x86_64-pc-windows-msvc\release\deps\libprofiler_builtins-94dca554e4a2a924.rmeta
x86_64-pc-windows-msvc\stage1-std\x86_64-pc-windows-msvc\release\deps\profiler_builtins-94dca554e4a2a924.d
x86_64-pc-windows-msvc\stage0\lib\rustlib\x86_64-pc-windows-msvc\lib\libprofiler_builtins-d5702ec6a6329fe3.rlib
x86_64-pc-windows-msvc\stage1\lib\rustlib\x86_64-pc-windows-msvc\lib\libprofiler_builtins-94dca554e4a2a924.rlib
x86_64-pc-windows-msvc\stage0-sysroot\lib\rustlib\x86_64-pc-windows-msvc\lib\libprofiler_builtins-23c82d4c3ff5dfcc.rlib
x86_64-pc-windows-msvc\stage2\lib\rustlib\x86_64-pc-windows-msvc\lib\libprofiler_builtins-94dca554e4a2a924.rlib

image

@richkadel
Copy link
Contributor Author

Try it on Windows with a clean copy of config.toml.example and set:

[build]
profiler = true

(I also set ninja = true. I doubt that matters.)

Don't change the target section. It should still say [target.x86_64-unknown-linux-gnu]. I have no reason to set target-specific settings for windows-msvc so I don't create a target-specific section for it. Defaults should be fine.

It could be that just having the msvc section like you do is another workaround, but that shouldn't be required.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Nov 19, 2020
…k-Simulacrum

fix handling the default config for profiler and sanitizers

rust-lang#78354 don't handle the case that user don't add any target-specific config in `[target.*]` of `config.toml`:
```toml
changelog-seen = 2
[llvm]
link-shared = true
[build]
sanitizers = true
profiler = true
[install]
[rust]
[dist]
```

The previes code handle the default config in `Config::prase()`:

```rust
target.sanitizers = cfg.sanitizers.unwrap_or(build.sanitizers.unwrap_or_default());
target.profiler = cfg.profiler.unwrap_or(build.profiler.unwrap_or_default());
config.target_config.insert(TargetSelection::from_user(&triple), target);
```

In this case, `toml.target` don't contain any target, so the above code won't execute. Instead, a default `Target` is insert in https://github.com/rust-lang/rust/blob/c919f490bbcd2b29b74016101f7ec71aaa24bdbb/src/bootstrap/sanity.rs#L162-L166

The default value for `bool` is false, hence the issue in rust-lang#79124

This fix change the type of `sanitizers` and `profiler` to `Option<bool>`, so the default value is `None`, and fallback config is handled in  `Config::sanitizers_enabled` and `Config::profiler_enabled`

fix rust-lang#79124

cc `@Mark-Simulacrum` `@richkadel`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants