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

Enable profiler=true in config.toml and target = [wasm32-unknown-unknown] will cause bootstrap fail #78329

Closed
12101111 opened this issue Oct 24, 2020 · 3 comments · Fixed by #78354
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. O-wasm Target: WASM (WebAssembly), http://webassembly.org/ T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@12101111
Copy link
Contributor

I'm trying to build rust with profiler support in Gentoo Linux.

The config.toml:

[llvm]
optimize = true
release-debuginfo = false
assertions = false
ninja = true
targets = "X86;ARM;AArch64;RISCV;WebAssembly;AMDGPU;BPF"
experimental-targets = ""
link-shared = true
use-libcxx = true
[build]
build = "x86_64-unknown-linux-gnu"
host = ["x86_64-unknown-linux-gnu"]
target = ["x86_64-unknown-linux-gnu","wasm32-unknown-unknown"]
cargo = "/usr/lib/rust/1.47.0/bin/cargo"
rustc = "/usr/lib/rust/1.47.0/bin/rustc"
docs = false
compiler-docs = false
submodules = false
python = "python3.9"
locked-deps = true
vendor = true
extended = true
tools = ["rustfmt","rls","analysis","src","miri","clippy","cargo",]
verbose = 1
sanitizers = true
profiler = true
cargo-native-static = false
[install]
prefix = "/usr/lib/rust/1.47.0"
sysconfdir = "etc"
docdir = "share/doc/rust"
bindir = "bin"
libdir = "lib"
mandir = "share/man"
[rust]
# https://github.com/rust-lang/rust/issues/54872
codegen-units-std = 1
optimize = true
debug = false
debug-assertions = false
debuginfo-level-rustc = 0
backtrace = true
incremental = false
default-linker = "clang"
parallel-compiler = true
channel = "nightly"
rpath = false
verbose-tests = true
optimize-tests = true
codegen-tests = true
dist-src = false
remap-debuginfo = true
lld = false
backtrace-on-ice = true
jemalloc = false
[dist]
src-tarball = false
[target.x86_64-unknown-linux-gnu]
cc = "clang"
cxx = "clang++"
linker = "clang"
ar = "llvm-ar"
llvm-config = "/usr/lib/llvm/11/bin/llvm-config"
[target.wasm32-unknown-unknown]
linker = "lld"

And log:

libdir: "/usr/lib/rust/1.47.0/lib"
     Running `/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/build/x86_64-unknown-linux-gnu/stage2-std/release/build/compiler_builtins-b5a017e01bbe25e7/build-script-build`
     Running `/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/build/x86_64-unknown-linux-gnu/stage2-std/release/build/unwind-e198a4d246959a50/build-script-build`
     Running `/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/build/x86_64-unknown-linux-gnu/stage2-std/release/build/dlmalloc-467a08e53f9bc8a2/build-script-build`
     Running `/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/build/x86_64-unknown-linux-gnu/stage2-std/release/build/profiler_builtins-9cfe97611d835f7d/build-script-build`
     Running `/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/build/x86_64-unknown-linux-gnu/stage2-std/release/build/hashbrown-302bc88665f9ec43/build-script-build`
     Running `/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/build/x86_64-unknown-linux-gnu/stage2-std/release/build/std-ab9e34662867ca47/build-script-build`
The following warnings were emitted during compilation:

warning: ../../src/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c:24:10: fatal error: 'errno.h' file not found
warning: #include <errno.h>
warning:          ^~~~~~~~~
warning: 1 error generated.

error: failed to run custom build command for `profiler_builtins v0.0.0 (/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/library/profiler_builtins)`

Caused by:
  process didn't exit successfully: `/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/build/x86_64-unknown-linux-gnu/stage2-std/release/build/profiler_builtins-9cfe97611d835f7d/build-script-build` (exit code: 1)
  --- stdout
  TARGET = Some("wasm32-unknown-unknown")
  OPT_LEVEL = Some("3")
  HOST = Some("x86_64-unknown-linux-gnu")
  CC_wasm32-unknown-unknown = Some("clang")
  CFLAGS_wasm32-unknown-unknown = Some("-ffunction-sections -fdata-sections -fPIC --target=wasm32-unknown-unknown -march=skylake -mtune=skylake -pipe -falign-functions=32 -fomit-frame-pointer -ffunction-sections -fdata-sections -flto=thin -fdebug-prefix-map=/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src=/rustc/1.47.0")
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-march=skylake" "-mtune=skylake" "-pipe" "-falign-functions=32" "-fomit-frame-pointer" "-ffunction-sections" "-fdata-sections" "-flto=thin" "-fdebug-prefix-map=/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src=/rustc/1.47.0" "-I" "../../src/llvm-project/compiler-rt/include" "-fno-builtin" "-fvisibility=hidden" "-fomit-frame-pointer" "-DVISIBILITY_HIDDEN" "-DCOMPILER_RT_HAS_UNAME=1" "-DCOMPILER_RT_HAS_ATOMICS=1" "-o" "/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/build/x86_64-unknown-linux-gnu/stage2-std/wasm32-unknown-unknown/release/build/profiler_builtins-dba639b24db09605/out/../../src/llvm-project/compiler-rt/lib/profile/GCDAProfiling.o" "-c" "../../src/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c"
  cargo:warning=../../src/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c:24:10: fatal error: 'errno.h' file not found
  cargo:warning=#include <errno.h>
  cargo:warning=         ^~~~~~~~~
  cargo:warning=1 error generated.
  exit code: 1

  --- stderr


  error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-march=skylake" "-mtune=skylake" "-pipe" "-falign-functions=32" "-fomit-frame-pointer" "-ffunction-sections" "-fdata-sections" "-flto=thin" "-fdebug-prefix-map=/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src=/rustc/1.47.0" "-I" "../../src/llvm-project/compiler-rt/include" "-fno-builtin" "-fvisibility=hidden" "-fomit-frame-pointer" "-DVISIBILITY_HIDDEN" "-DCOMPILER_RT_HAS_UNAME=1" "-DCOMPILER_RT_HAS_ATOMICS=1" "-o" "/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/build/x86_64-unknown-linux-gnu/stage2-std/wasm32-unknown-unknown/release/build/profiler_builtins-dba639b24db09605/out/../../src/llvm-project/compiler-rt/lib/profile/GCDAProfiling.o" "-c" "../../src/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c" with args "clang" did not execute successfully (status code exit code: 1).


warning: build failed, waiting for other jobs to finish...
'skylake' is not a recognized processor for this target (ignoring processor)
'skylake' is not a recognized processor for this target (ignoring processor)
'skylake' is not a recognized processor for this target (ignoring processor)
'skylake' is not a recognized processor for this target (ignoring processor)
'skylake' is not a recognized processor for this target (ignoring processor)
'skylake' is not a recognized processor for this target (ignoring processor)
'skylake' is not a recognized processor for this target (ignoring processor)
'skylake' is not a recognized processor for this target (ignoring processor)
error: build failed
command did not execute successfully: "/usr/lib/rust/1.47.0/bin/cargo" "build" "--target" "wasm32-unknown-unknown" "-Zbinary-dep-depinfo" "-j" "12" "-v" "--release" "--locked" "--frozen" "--features" "panic-unwind backtrace profiler compiler-builtins-c" "--manifest-path" "/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/library/test/Cargo.toml" "--message-format" "json-render-diagnostics"
expected success, got: exit code: 101
Traceback (most recent call last):
  File "/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/./x.py", line 11, in <module>
    bootstrap.main()
  File "/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/src/bootstrap/bootstrap.py", line 1009, in main
    bootstrap(help_triggered)
  File "/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/src/bootstrap/bootstrap.py", line 995, in bootstrap
    run(args, env=env, verbose=build.verbose)
  File "/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/src/bootstrap/bootstrap.py", line 143, in run
    raise RuntimeError(err)
RuntimeError: failed to run: /tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/build/bootstrap/debug/bootstrap dist -vv --config=/tmp/portage/dev-lang/rust-1.47.0-r1/work/rustc-1.47.0-src/config.toml -j12

I think profiler (and maybe sanitizers) should be an option pre target, not a global option under build section. For example we can enable profiler for x86_64-unknown-linux-gnu and disable it for wasm32-unknown-unknown.

@12101111 12101111 added the C-bug Category: This is a bug. label Oct 24, 2020
@jonas-schievink jonas-schievink added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Oct 24, 2020
@jyn514 jyn514 added C-enhancement Category: An issue proposing an enhancement or a PR with one. O-wasm Target: WASM (WebAssembly), http://webassembly.org/ and removed C-bug Category: This is a bug. labels Oct 24, 2020
@Mark-Simulacrum
Copy link
Member

That would make sense to me; that said, for CI and other environments that want all targets to have this it'll be much easier to have the global option around too. I would likely accept a PR for this if the implementation can be localized to configuration parsing (and maybe slight alterations of how we query for sanitizer/profiler enablement).

@tmiasko
Copy link
Contributor

tmiasko commented Oct 25, 2020

Is profiler functionality unsupported on this target or it is supported but you just don't want to enable it? If the former, it would be in my opinion preferable to just disable it on unsupported targets, so there is no need to configure it further. The sanitizers should already work like that.

@12101111
Copy link
Contributor Author

I'm not sure which target don't support the profiler ( It seems all target with std and libc have profiler support, at least darwin, fuchsia, linux, windows, bsd and other unix like), but wasm32-unknown-unknown is an not supported because it don't have a libc.

As to your question, I want a option to disable it for some selected targets even it's supported and enable it for host target and maybe some other targets.

@bors bors closed this as completed in 194b968 Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. O-wasm Target: WASM (WebAssembly), http://webassembly.org/ 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.

5 participants