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

rust build of 1.47.0: rustdoc fails when cross-building for NetBSD/sparc64 #78406

Closed
he32 opened this issue Oct 26, 2020 · 10 comments
Closed

rust build of 1.47.0: rustdoc fails when cross-building for NetBSD/sparc64 #78406

he32 opened this issue Oct 26, 2020 · 10 comments
Labels
A-cross Area: Cross compilation C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. O-netbsd Operating system: NetBSD T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@he32
Copy link
Contributor

he32 commented Oct 26, 2020

While building for NetBSD/sparc64 with NetBSD/amd64 as host, I reproducibly encounter this error:

 Documenting std v0.0.0 (/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/library/std)
error: `crate::os::linux::raw::stat` is both a struct and a function
  --> library/std/src/os/linux/fs.rs:21:19
   |
21 |     /// [`stat`]: crate::os::linux::raw::stat
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous link
   |
   = note: `-D broken-intra-doc-links` implied by `-D warnings`
help: to link to the struct, prefix with the item type
   |
21 |     /// [`stat`]: struct@crate::os::linux::raw::stat
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: to link to the function, add parentheses
   |
21 |     /// [`stat`]: crate::os::linux::raw::stat()
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

error: Could not document `std`.

...and since this is an error, the whole build fails. Trying to append () to the
string as suggested just produces another error, so is obviously not the right thing to do.

Oddly, when building natively on NetBSD/amd64, this error is not flagged.
Also, when cross-building for NetBSD/macppc or NetBSD/armv7 on NetBSD/amd64,
this error is also not flagged.

I expected to see the build complete without errors; 1.46.0 certainly did.

Yes, we carry a number of patches to rust in pkgsrc, not all of them up-streamable...

Still, hints for what might be the root cause of this failure are most welcome,
or how I might work around this issue.

It seems odd that it's complaining about what on the face of it appears to be a
Linux-specific function when this isn't run on or being built for Linux...

Meta

rustc --version --verbose:

rustc 1.46.0 (04488afe3 2020-08-24)
binary: rustc
commit-hash: 04488afe34512aa4c33566eb16d8c912a3ae04f9
commit-date: 2020-08-24
host: x86_64-unknown-netbsd
release: 1.46.0
LLVM version: 10.0

(That's the bootstrap version used.)

Backtrace

Caused by:
  process didn't exit successfully: `/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/bootstrap/debug/rustdoc --edition=2018 --crate-type dylib --crate-type rlib --crate-name std library/std/src/lib.rs --target sparc64-unknown-netbsd -o /usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/sparc64-unknown-netbsd/doc --cfg 'feature="addr2line"' --cfg 'feature="backtrace"' --cfg 'feature="compiler-builtins-c"' --cfg 'feature="gimli-symbolize"' --cfg 'feature="miniz_oxide"' --cfg 'feature="object"' --cfg 'feature="panic_unwind"' --cfg 'feature="std_detect_dlsym_getauxval"' --cfg 'feature="std_detect_file_io"' --error-format=json --json=diagnostic-rendered-ansi --markdown-css rust.css --markdown-no-toc -Z unstable-options --resource-suffix 1.47.0 --index-page /usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/src/doc/index.md -L dependency=/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/sparc64-unknown-netbsd/release/deps -L dependency=/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/release/deps --extern addr2line=/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/sparc64-unknown-netbsd/release/deps/libaddr2line-03cb55b7425d7dbb.rmeta --extern alloc=/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/sparc64-unknown-netbsd/release/deps/liballoc-455bc16b9b6b4424.rmeta --extern cfg_if=/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/sparc64-unknown-netbsd/release/deps/libcfg_if-7fc54f1c23911eb1.rmeta --extern compiler_builtins=/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/sparc64-unknown-netbsd/release/deps/libcompiler_builtins-317780efb78c97c5.rmeta --extern core=/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/sparc64-unknown-netbsd/release/deps/libcore-0f5f9e2fc8fc9f24.rmeta --extern hashbrown=/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/sparc64-unknown-netbsd/release/deps/libhashbrown-943e711081285abb.rmeta --extern libc=/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/sparc64-unknown-netbsd/release/deps/liblibc-3b8680b5a3769d54.rmeta --extern miniz_oxide=/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/sparc64-unknown-netbsd/release/deps/libminiz_oxide-3fbd2f81c64e7314.rmeta --extern object=/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/sparc64-unknown-netbsd/release/deps/libobject-b55e8f81947c9d81.rmeta --extern panic_abort=/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/sparc64-unknown-netbsd/release/deps/libpanic_abort-83aafb0d29c77dec.rmeta --extern panic_unwind=/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/sparc64-unknown-netbsd/release/deps/libpanic_unwind-5427c3db55291636.rmeta --extern rustc_demangle=/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/sparc64-unknown-netbsd/release/deps/librustc_demangle-de5e000b109f02c7.rmeta --extern unwind=/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/x86_64-unknown-netbsd/stage2-std/sparc64-unknown-netbsd/release/deps/libunwind-478e4996ad0d78a7.rmeta -Dwarnings -Winvalid_codeblock_attributes --crate-version 1.47.0 --cfg backtrace_in_libstd` (exit code: 1)


command did not execute successfully: "/usr/pkgsrc/lang/rust/work/rust-bootstrap/bin/cargo" "rustdoc" "--target" "sparc64-unknown-netbsd" "-Zbinary-dep-depinfo" "-j" "4" "--release" "--frozen" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/library/test/Cargo.toml" "-p" "std" "--" "--markdown-css" "rust.css" "--markdown-no-toc" "-Z" "unstable-options" "--resource-suffix" "1.47.0" "--index-page" "/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/src/doc/index.md"
expected success, got: exit code: 101


Traceback (most recent call last):
  File "./x.py", line 11, in <module>
    bootstrap.main()
  File "/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/src/bootstrap/bootstrap.py", line 1016, in main
    bootstrap(help_triggered)
  File "/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/src/bootstrap/bootstrap.py", line 1002, in bootstrap
    run(args, env=env, verbose=build.verbose)
  File "/usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/src/bootstrap/bootstrap.py", line 143, in run
    raise RuntimeError(err)
RuntimeError: failed to run: /usr/pkgsrc/lang/rust/work/rustc-1.47.0-src/build/bootstrap/debug/bootstrap -v dist -j 4

@he32 he32 added the C-bug Category: This is a bug. label Oct 26, 2020
@Mark-Simulacrum
Copy link
Member

Are you self-bootstrapping the cross build (setting rustc/cargo 1.47 as well)? I guess that's the only difference I can think of that would obviously cause things like this.

It's also possible this is just always broken, rust-lang/rust doesn't cross-compile documentation I think for most platforms so we don't really test it.

@Mark-Simulacrum
Copy link
Member

cc @jyn514

@jyn514 jyn514 added A-cross Area: Cross compilation T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Oct 26, 2020
@jyn514
Copy link
Member

jyn514 commented Oct 26, 2020

The easiest way to fix this is just to disambiguate the intra-doc link: struct@crate::os::linux::raw::stat.

...and since this is an error, the whole build fails.

I highly recommend setting disable-warnings = true, I don't think rustc guarantees at all that it will build without warnings when cross-compiled.

@jyn514
Copy link
Member

jyn514 commented Oct 26, 2020

See also #76526.

@jyn514 jyn514 added O-netbsd Operating system: NetBSD E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Oct 26, 2020
@he32
Copy link
Contributor Author

he32 commented Oct 26, 2020

Are you self-bootstrapping the cross build (setting rustc/cargo 1.47 as well)? I guess that's the only difference I can think of that would obviously cause things like this.

Nor sure I fully understand the question. The bootstrap compiler is 1.46.0, but it looks like in this instance it's the built-as-part-of-bootstrap rustdoc from 1.47 that's being run. My build is started with

${PYTHONBIN} ./x.py -v dist -j 4

and just prior to the error the build log contains

    c Rustdoc { compiler: Compiler { stage: 2, host: TargetSelection { triple: "x86_64-unknown-netbsd", file: None } } }

so this is done as part of the stage 2 of the bootstrap.

It's also possible this is just always broken, rust-lang/rust doesn't cross-compile documentation I think for most platforms so we don't really test it.

Hm. "Room for improvement!" :)

@he32
Copy link
Contributor Author

he32 commented Oct 27, 2020

The easiest way to fix this is just to disambiguate the intra-doc link: struct@crate::os::linux::raw::stat.

Thanks, that worked. Silly of me not trying that variant first...

...and since this is an error, the whole build fails.

I highly recommend setting disable-warnings = true, I don't think rustc guarantees at all that it will build without warnings when cross-compiled.

Is this really supposed to be deny-warnings = false in config.toml? (Default appears to be true)

@jyn514
Copy link
Member

jyn514 commented Oct 27, 2020

Yes, thanks, I meant = false.

Are you interested in making a PR with the struct@ fix so this is fixed for others too? :)

@cuviper
Copy link
Member

cuviper commented Oct 28, 2020

I already fixed this one in #77777.

@jyn514
Copy link
Member

jyn514 commented Oct 28, 2020

Great, so this is fixed in nightly then.

@jyn514 jyn514 closed this as completed Oct 28, 2020
@cuviper
Copy link
Member

cuviper commented Oct 28, 2020

It seems odd that it's complaining about what on the face of it appears to be a
Linux-specific function when this isn't run on or being built for Linux...

This does confuse me too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cross Area: Cross compilation C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. O-netbsd Operating system: NetBSD T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants