Bug 240388 - lang/rust: fails to build: error: Could not compile `rustdoc`.
Summary: lang/rust: fails to build: error: Could not compile `rustdoc`.
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: FreeBSD Rust Team
Depends on:
Reported: 2019-09-07 12:08 UTC by Roman Bogorodskiy
Modified: 2019-11-02 11:21 UTC (History)
1 user (show)

See Also:
tobik: maintainer-feedback+


Note You need to log in before you can comment on or make changes to this bug.
Description Roman Bogorodskiy freebsd_committer 2019-09-07 12:08:52 UTC
build started at Sat Sep  7 05:57:15 +04 2019
port directory: /usr/ports/lang/rust
package name: rust-1.37.0
building for: FreeBSD current-local-job-04 13.0-CURRENT FreeBSD 13.0-CURRENT 1300045 amd64
maintained by: rust@FreeBSD.org
Makefile ident:      $FreeBSD: head/lang/rust/Makefile 510684 2019-09-01 07:26:54Z tobik $
Poudriere version: 3.3.2
Host OSVERSION: 1300045
Jail OSVERSION: 1300045


   Compiling parking_lot_core v0.4.0
   Compiling num_cpus v1.8.0
   Compiling tempfile v3.0.5
   Compiling parking_lot v0.7.1
   Compiling rustdoc v0.0.0 (/wrkdirs/usr/ports/lang/rust/work/rustc-1.37.0-src/src/librustdoc)
thread 'rustc' panicked at 'failed to get current_exe: No such file or directory (os error 2)', src/librustc/session/filesearch.rs:139:23
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.37.0 running on x86_64-unknown-freebsd

note: compiler flags: -Z external-macro-backtrace -Z unstable-options -C opt-level=2 -C debuginfo=0 -C linker=cc -C debug-assertions=n -C link-args=-Wl,-rpath,$ORIGIN/../lib --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `rustdoc`.

To learn more, run the command again with --verbose.

command did not execute successfully: "/wrkdirs/usr/ports/lang/rust/work/rustc-1.37.0-src/build/x86_64-unknown-freebsd/stage0/bin/cargo" "build" "--target" "x86_64-unknown-freebsd" "-j" "4" "--release" "--frozen" "--manifest-path" "/wrkdirs/usr/ports/lang/rust/work/rustc-1.37.0-src/src/tools/rustdoc/Cargo.toml"
expected success, got: exit code: 101

Traceback (most recent call last):
  File "/wrkdirs/usr/ports/lang/rust/work/rustc-1.37.0-src/x.py", line 11, in <module>
  File "/wrkdirs/usr/ports/lang/rust/work/rustc-1.37.0-src/src/bootstrap/bootstrap.py", line 847, in main
  File "/wrkdirs/usr/ports/lang/rust/work/rustc-1.37.0-src/src/bootstrap/bootstrap.py", line 833, in bootstrap
    run(args, env=env, verbose=build.verbose)
  File "/wrkdirs/usr/ports/lang/rust/work/rustc-1.37.0-src/src/bootstrap/bootstrap.py", line 141, in run
    raise RuntimeError(err)
RuntimeError: failed to run: /wrkdirs/usr/ports/lang/rust/work/rustc-1.37.0-src/build/bootstrap/debug/bootstrap build --verbose --config ./config.toml --jobs 4
*** Error code 1

make: stopped in /usr/ports/lang/rust
Comment 2 Roman Bogorodskiy freebsd_committer 2019-09-08 12:54:26 UTC
(In reply to Tobias Kortkamp from comment #1)

Running GENERIC kernel.



devel_llvm60_UNSET=     DEBUG
devel_llvm70_UNSET=     DEBUG
textproc_php72-xml_UNSET_FORCE= DEBUG
java_openjdk8_UNSET=    DEBUG
www_chromium_UNSET=     DEBUG
Comment 3 Tobias Kortkamp freebsd_committer 2019-09-08 13:12:06 UTC
Hmm, so nothing too out of the ordinary.

> 'rustc' panicked at 'failed to get current_exe: No such file or directory (os error 2)', src/librustc/session/filesearch.rs:139:23

AFAICT the only reason the above error would happen is if for some
reason env::current_exe() fails.  It tries to read the kern.proc.pathname
sysctl and I cannot imagine a likely reason why that would fail.
Comment 4 Jan Beich freebsd_committer 2019-09-10 12:11:04 UTC
(In reply to Tobias Kortkamp from comment #3)
What if vn_fullpath(9) fails?

$ cat a.c
#include <sys/param.h>
#include <sys/sysctl.h>
#include <err.h>
#include <unistd.h>

int main(int argc, char **argv, char **envp)
  if (unlink(argv[0]))
      err(1, "unlink failed");

  int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
  size_t sz = 0;
  if (sysctl(mib, nitems(mib), NULL, &sz, NULL, 0))
    err(1, "kern.proc.pathname failed");

$ cc a.c
$ ./a.out
a.out: kern.proc.pathname failed: No such file or directory

$ cat b.c
#include <sys/param.h>
#include <sys/sysctl.h>
#include <err.h>
#include <unistd.h>

int main()

  int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
  size_t sz = 0;
  if (sysctl(mib, nitems(mib), NULL, &sz, NULL, 0))
    err(1, "kern.proc.pathname failed");

$ mkdir foo
$ mount -t tmpfs none foo
$ cc b.c -o foo/b
$ foo/b &
$ umount -f foo
b: kern.proc.pathname failed: Bad file descriptor
Comment 5 Roman Bogorodskiy freebsd_committer 2019-09-10 14:23:49 UTC
I just noticed rustc failure with the similar error, but while compiling www/firefox:

   Compiling utf8-ranges v1.0.0
     Running `CARGO_MANIFEST_DIR=/wrkdirs/usr/ports/www/firefox/work/firefox-69.0/third_party/rust/utf8-ranges CARGO_PKG_VERSION=1.0.0 CARGO=/usr/local/bin/cargo CARGO_PKG_AUTHORS='Andrew Gallant <jamslam@gmail.com>' LD_LIBRARY_PATH='/wrkdirs/usr/ports/www/firefox/work/.build/release/deps:/usr/local/lib' CARGO_PKG_NAME=utf8-ranges CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_MAJOR=1 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_HOMEPAGE='https://github.com/BurntSushi/utf8-ranges' CARGO_PKG_DESCRIPTION='Convert ranges of Unicode codepoints to UTF-8 byte ranges.' CARGO_PKG_REPOSITORY='https://github.com/BurntSushi/utf8-ranges' CARGO_PKG_VERSION_PRE= /usr/local/bin/rustc --crate-name utf8_ranges /wrkdirs/usr/ports/www/firefox/work/firefox-69.0/third_party/rust/utf8-ranges/src/lib.rs --color never --crate-type lib --emit=dep-info,metadata,link -C opt-level=2 -C codegen-units=1 -C metadata=b993191aa2b6f4e8 -C extra-filename=-b993191aa2b6f4e8 --out-dir /wrkdirs/usr/ports/www/firefox/work/.build/release/deps -C linker=/wrkdirs/usr/ports/www/firefox/work/firefox-69.0/build/cargo-linker -L dependency=/wrkdirs/usr/ports/www/firefox/work/.build/release/deps --cap-lints warn`                                                                                                    
thread 'rustc' panicked at 'failed to get current_exe: No such file or directory (os error 2)', src/librustc/session/filesearch.rs:139:23                                                                          
stack backtrace:
   Compiling opaque-debug v0.2.1
   0:        0x80123dff6 - <std::sync::mpsc::RecvTimeoutError as std::error::Error>::description::h03460f723066f58f                                                                                                
   1:        0x801251589 - std::panicking::take_hook::h834ab7337b1abf20
   2:        0x801251311 - std::panicking::take_hook::h834ab7337b1abf20
   3:        0x802c4cf83 - <rustc::ty::SymbolName as core::fmt::Display>::fmt::hf4c24edb7540ca8c
   4:        0x801251dca - std::panicking::rust_panic_with_hook::ha2f60615971a541f
     Running `CARGO_MANIFEST_DIR=/wrkdirs/usr/ports/www/firefox/work/firefox-69.0/third_party/rust/opaque-debug CARGO_PKG_VERSION=0.2.1 CARGO=/usr/local/bin/cargo CARGO_PKG_AUTHORS='RustCrypto Developers' LD_LIBRARY_PATH='/wrkdirs/usr/ports/www/firefox/work/.build/release/deps:/usr/local/lib' CARGO_PKG_NAME=opaque-debug CARGO_PKG_VERSION_MINOR=2 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_PATCH=1 CARGO_PKG_HOMEPAGE= CARGO_PKG_DESCRIPTION='Macro for opaque Debug trait implementation' CARGO_PKG_REPOSITORY='https://github.com/RustCrypto/utils' CARGO_PKG_VERSION_PRE= /usr/local/bin/rustc --crate-name opaque_debug /wrkdirs/usr/ports/www/firefox/work/firefox-69.0/third_party/rust/opaque-debug/src/lib.rs --color never --crate-type lib --emit=dep-info,metadata,link -C opt-level=2 -C codegen-units=1 -C metadata=fe5c8da568bebae0 -C extra-filename=-fe5c8da568bebae0 --out-dir /wrkdirs/usr/ports/www/firefox/work/.build/release/deps -C linker=/wrkdirs/usr/ports/www/firefox/work/firefox-69.0/build/cargo-linker -L dependency=/wrkdirs/usr/ports/www/firefox/work/.build/release/deps --cap-lints warn`
   5:        0x802cc002e - rustc::hir::intravisit::NestedVisitorMap::inter::hc4aece9e6997b0b6
   6:        0x8027685d5 - rustc::session::filesearch::get_or_default_sysroot::h40812957e429a478
   7:        0x802e85eed - rustc::session::build_session_with_source_map::h826a1f5e1708ebd8
   8:        0x80184bb82 - rustc_interface::util::create_session::hb76ac1e8778ab63f
   9:        0x8010ea5bb - rust_metadata_rustc_driver_538c90749b0bcda79110a2a1ba11cc73
  10:        0x80110d057 - rust_metadata_rustc_driver_538c90749b0bcda79110a2a1ba11cc73
  11:        0x80112167d - rust_metadata_rustc_driver_538c90749b0bcda79110a2a1ba11cc73
  12:        0x801139c17 - rust_metadata_rustc_driver_538c90749b0bcda79110a2a1ba11cc73
  13:        0x8011652e6 - <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt::h0624af4a1e91eaf7                                                                                                  
  14:        0x801255c3f - __rust_maybe_catch_panic
  15:        0x8010ed465 - rust_metadata_rustc_driver_538c90749b0bcda79110a2a1ba11cc73
  16:        0x8012495ff - std::sys::unix::stdio::is_ebadf::had7252a7e9f395ba
  17:        0x801250411 - std::sys_common::alloc::realloc_fallback::hfda0bf5d3edfabb4
  18:        0x80124cbb9 - std::sys::unix::thread::Thread::new::h936b474ab97ea5ca
  19:        0x803430716 - pthread_create
query stack during panic:
end of query stack
Comment 6 Tobias Kortkamp freebsd_committer 2019-09-10 14:41:50 UTC
(In reply to Roman Bogorodskiy from comment #5)
So you managed to build lang/rust after all?  Or is this with the
pre-built package from pkg.FreeBSD.org?
Comment 7 Roman Bogorodskiy freebsd_committer 2019-09-10 15:12:07 UTC
(In reply to Tobias Kortkamp from comment #6)

Yeah, it built after several attempts (no changes to the system between retries). 
I guess it could be something wrong with the system, but it's not doing anything load intensive except building packages, and I don't see any intermittent failures with other packages, that is, rust and firefox are the only ones so far.
Comment 8 mikael.urankar 2019-09-11 07:04:01 UTC
fwiw I've also had the problem on armv7 and ppc64, rebooting the board makes the problem disappear.
Comment 9 Tobias Kortkamp freebsd_committer 2019-09-27 20:51:04 UTC
Can either of you reproduce the problem with Rust 1.38.0?
Comment 10 Roman Bogorodskiy freebsd_committer 2019-09-28 15:08:26 UTC
(In reply to Tobias Kortkamp from comment #9)

I plan to do next package build next weekend (Oct 5-6), I'll let you know how it goes.
Comment 11 Roman Bogorodskiy freebsd_committer 2019-10-08 15:16:20 UTC
I had no such problems with 1.38.0.
Comment 12 mikael.urankar 2019-10-08 15:32:24 UTC
no problem for me (so far)
Comment 13 Tobias Kortkamp freebsd_committer 2019-11-02 11:21:30 UTC
Thanks for retesting.  I'll close this for now.  Please reopen this bug if
it happens again.