rust-lang / rust-lang/rust

Cannot build `*-unknown-uefi` target with `profiler = true`

Open
#118,184 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug O-UEFI T-bootstrap T-compiler
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

When building this:

./x build library/std --target x86_64-unknown-uefi

with this config.toml:

[llvm]
download-ci-llvm = true

[target.x86_64-unknown-uefi]
profiler = true

It turns out that build.rs in library/profile_builtins failed to build the profileing code in LLVM compiler-rt.

I am not sure whether it makes sense for setting profiler in UEFI target. Feel free to close this if it is intended to not support.

Meta

rust-lang/rust commit

6d2b84b3ed7848fd91b8d6151d4451b3103ed816
Backtrace

 ./x build library/std --target x86_64-unknown-uefi
Building bootstrap
    Finished dev [unoptimized] target(s) in 0.03s
Building stage0 library artifacts (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.09s
Building compiler artifacts (stage0 -> stage1, x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.16s
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)
Building stage1 library artifacts {std} (x86_64-unknown-linux-gnu -> x86_64-unknown-uefi)
   Compiling profiler_builtins v0.0.0 (/home/dev/rust/library/profiler_builtins)
   Compiling std v0.0.0 (/home/dev/rust/library/std)
The following warnings were emitted during compilation:

warning: profiler_builtins@0.0.0: clang-16: warning: argument unused during compilation: '--gcc-toolchain=/nix/store/hf2gy3km07d5m0p1lwmja0rg9wlnmyr7-gcc-12.3.0' [-Wunused-command-line-argument]
warning: profiler_builtins@0.0.0: ../../src/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c:33:10: fatal error: 'windows.h' file not found
warning: profiler_builtins@0.0.0: #include <windows.h>
warning: profiler_builtins@0.0.0:          ^~~~~~~~~~~
warning: profiler_builtins@0.0.0: 1 error generated.

error: failed to run custom build command for `profiler_builtins v0.0.0 (/home/dev/rust/library/profiler_builtins)`

Caused by:
  process didn't exit successfully: `/home/dev/rust/build/x86_64-unknown-linux-gnu/stage1-std/release/build/profiler_builtins-53581af9689cca4b/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=LLVM_PROFILER_RT_LIB
  TARGET = Some("x86_64-unknown-uefi")
  OPT_LEVEL = Some("3")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_x86_64-unknown-uefi
  CC_x86_64-unknown-uefi = None
  cargo:rerun-if-env-changed=CC_x86_64_unknown_uefi
  CC_x86_64_unknown_uefi = Some("clang")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-uefi
  CFLAGS_x86_64-unknown-uefi = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_uefi
  CFLAGS_x86_64_unknown_uefi = Some("-ffunction-sections -fdata-sections --target=x86_64-unknown-windows-gnu")
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "--target=x86_64-unknown-windows-gnu" "-ffunction-sections" "-fdata-sections" "--target=x86_64-unknown-windows-gnu" "-I" "../../src/llvm-project/compiler-rt/include" "-fno-builtin" "-fomit-frame-pointer" "-fvisibility=hidden" "-DVISIBILITY_HIDDEN" "-DCOMPILER_RT_HAS_UNAME=1" "-DCOMPILER_RT_HAS_ATOMICS=1" "-o" "/home/dev/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-uefi/release/build/profiler_builtins-65f9c5b87ee47c1a/out/../../src/llvm-project/compiler-rt/lib/profile/GCDAProfiling.o" "-c" "../../src/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c"
  cargo:warning=clang-16: warning: argument unused during compilation: '--gcc-toolchain=/nix/store/hf2gy3km07d5m0p1lwmja0rg9wlnmyr7-gcc-12.3.0' [-Wunused-command-line-argument]
  cargo:warning=../../src/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c:33:10: fatal error: 'windows.h' file not found
  cargo:warning=#include <windows.h>
  cargo:warning=         ^~~~~~~~~~~
  cargo:warning=1 error generated.
  exit status: 1

  --- stderr


  error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "--target=x86_64-unknown-windows-gnu" "-ffunction-sections" "-fdata-sections" "--target=x86_64-unknown-windows-gnu" "-I" "../../src/llvm-project/compiler-rt/include" "-fno-builtin" "-fomit-frame-pointer" "-fvisibility=hidden" "-DVISIBILITY_HIDDEN" "-DCOMPILER_RT_HAS_UNAME=1" "-DCOMPILER_RT_HAS_ATOMICS=1" "-o" "/home/dev/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-uefi/release/build/profiler_builtins-65f9c5b87ee47c1a/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 status: 1).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with library/profile_builtins/build.rs and the failing compiler-rt file src/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c. Reproduce the x build library/std --target x86_64-unknown-uefi command with profiler = true, then determine whether UEFI profiling is supported. Done means the intended support decision is reflected by a successful build or a clear rejection path.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.