Generated stand-in crate uses global_asm!, which the workspaces forbid(unsafe_code) rejects

Open
#24 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
50/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
compilers

Research direction

Reproduce with the issue's commands to see the global_asm! lint error. Locate where rustd invokes cargo for stand-in crates and ensure --cap-lints allow is passed or workspace unsafe_code lints are stripped. Done when cargo rustd build -p nanocode-cli --bin nanocode succeeds.

Written by the indexing model from the issue text.

Description

Environment: bare-metal x86-64, 48 cores, 377 GB RAM, Ubuntu 24.04, Rust 1.99.0 with rust-src, rustd nightly release 4530fb8 from install.sh (RUSTD_VERSION=nightly).

git clone https://github.com/gakonst/nanocode && cd nanocode && git checkout 74ef4e9
echo 1.99.0 > rust-toolchain
sed -i '/^rustc-wrapper/d;/^rustc-workspace-wrapper/d' .cargo/config.toml   # drop the repo's own wrappers
cargo rustd build -p nanocode-cli --bin nanocode

Expected: rustd builds the bin. Plain cargo builds it in 24 s.

Actual: it fails in 0.8 s:

error: rustd does not build `nanocode`: what stands in for it does not build:
error: usage of `core::arch::global_asm`
  --> target/debug/.rustd-units/nanocode-09d0f3fa57332cc6/…/nanocode-09d0f3fa57332cc6.rustd.rs:20:1
20 | core::arch::global_asm!(".weak main", "main:");
   = note: requested on the command line with `-F unsafe-code`

nanocode sets unsafe_code = "forbid" in [workspace.lints], and cargo passes that to every crate, including rustd's stand-in. forbid can't be overridden from inside the crate, so code rustd generates should be built without the workspace's lint flags (or with --cap-lints allow).

Dominant language
Rust
Stars
248
Forks
13
Avg merge
7h 52m
Merged PRs (30d)
5

Getting set up

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.

More from DioxusLabs/rustd

All issues in DioxusLabs/rustd

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.