Skip to content

rustbuild with verbose fails with custom cargo path #41779

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
semarie opened this issue May 6, 2017 · 7 comments
Closed

rustbuild with verbose fails with custom cargo path #41779

semarie opened this issue May 6, 2017 · 7 comments
Assignees
Labels
E-help-wanted Call for participation: Help is requested to fix this issue. P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@semarie
Copy link
Contributor

semarie commented May 6, 2017

When rustbuild is invoked with -v, extra_help variable is populate using metadata::build() (for any command). It will call cargo metadata for several crates.

The build configuration used is at this place is Config::default().

As I use config.toml to set cargo binary path, the setting is ignored, and rustbuild fails when -v is on command-line: by default it uses stage0_root path, and cargo binary isn't available at this place.

@semarie
Copy link
Contributor Author

semarie commented Jun 10, 2017

@alexcrichton ping ? it is a regress for stable

@alexcrichton
Copy link
Member

Sounds bad!

@alexcrichton alexcrichton added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) regression-from-stable-to-stable Performance or correctness regression from one stable version to another. labels Jun 13, 2017
@brson brson added E-help-wanted Call for participation: Help is requested to fix this issue. P-medium Medium priority labels Jun 15, 2017
@Mark-Simulacrum Mark-Simulacrum self-assigned this Jun 15, 2017
@Mark-Simulacrum
Copy link
Member

Will investigate.

@Mark-Simulacrum
Copy link
Member

Hm, I'm unable to reproduce. @semarie Could you post a log with the failure?

@semarie
Copy link
Contributor Author

semarie commented Jun 16, 2017

The problem is in src/bootstrap/flags.rs:

impl Flags {
    pub fn parse(args: &[String]) -> Flags {
// [...]
        // All subcommands can have an optional "Available paths" section
        if matches.opt_present("verbose") {
            let flags = Flags::parse(&["build".to_string()]);
            let mut config = Config::default();
            config.build = flags.build.clone();
            let mut build = Build::new(flags, config);
            metadata::build(&mut build);
            let maybe_rules_help = step::build_rules(&build).get_help(subcommand);
            if maybe_rules_help.is_some() {
                extra_help.push_str(maybe_rules_help.unwrap().as_str());
            }
        } else {
            extra_help.push_str(format!("Run `./x.py {} -h -v` to see a list of available paths.",
                     subcommand).as_str());
        }
// [...]
    }
}

For calling metadata::build() (it will run cargo binary behind the scene), a config is required, but the code take Config::default() for that, and the default path is stage0_root.join(exe("cargo", &config.build)).

In my configuration, the cargo binary is in a different directory than rustc binary, and it isn't in the stage0 directory.

Here a log a build of rust-1.18.0 (using OpenBSD ports framework):

cd /home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/build-amd64 && exec /usr/bin/env -i RUSTFLAGS="-L /home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/modgcc-libs" CC=cc PYTHONUSERBASE=/home/semarie/repos/openbsd/ports/pobj/rust-1.18.0 LIBTOOL="/usr/local/bin/libtool"  PATH='/home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin' PREFIX='/usr/local'  LOCALBASE='/usr/local' X11BASE='/usr/X11R6'  CFLAGS='-O2 -pipe'  TRUEPREFIX='/usr/local' DESTDIR=''  HOME='/rust-1.18.0_writes_to_HOME' COMPILER_VERSION=gcc4  PICFLAG="-fpic" ASPICFLAG=  BINGRP=bin BINOWN=root BINMODE=755 NONBINMODE=644  DIRMODE=755  INSTALL_COPY=-c INSTALL_STRIP=-s  MANGRP=bin MANOWN=root
MANMODE=644 BSD_INSTALL_PROGRAM="/home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/bin/install -c -s  -m 755"  BSD_INSTALL_SCRIPT="/home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/bin/install -c  -m 755"  BSD_INSTALL_DATA="/home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/bin/install -c  -m 644"  BSD_INSTALL_MAN="/home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/bin/install -c  -m 644"  BSD_INSTALL_PROGRAM_DIR="/home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/bin/install -d  -m 755"  BSD_INSTALL_SCRIPT_DIR="/home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/bin/install -d  -m 755"  BSD_INSTALL_DATA_DIR="/home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/bin/install -d  -m 755"  BSD_INSTALL_MAN_DIR="/home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/bin/install -d  -m 755"  /usr/local/bin/python2.7 /home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/rustc-1.18.0-src/src/bootstrap/bootstrap.py dist --verbose --jobs=1
   Compiling libc v0.2.21
   Compiling rustc-serialize v0.3.23
   Compiling getopts v0.2.14
   Compiling gcc v0.3.45
   Compiling num_cpus v0.2.13
   Compiling filetime v0.1.10
   Compiling build_helper v0.1.0 (file:///home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/rustc-1.18.0-src/src/build_helper)
   Compiling cmake v0.1.22
   Compiling toml v0.1.30
   Compiling bootstrap v0.0.0 (file:///home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/rustc-1.18.0-src/src/bootstrap)
    Finished dev [unoptimized] target(s) in 39.19 secs


failed to execute command: "/data/semarie/repos/openbsd/ports/pobj/rust-1.18.0/build-amd64/build/x86_64-unknown-openbsd/stage0/bin/cargo" "metadata" "--manifest-path" "/home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/rustc-1.18.0-src/src/libst/Cargo.toml"
error: No such file or directory (os error 2)


Build completed unsuccessfully in 0:00:40

The config.ml is:

[build]
rustc = "/home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/rustc-bootstrap-amd64-1.18.0-20170611/bin/rustc"
cargo = "/home/semarie/repos/openbsd/ports/pobj/rust-1.18.0/cargo-bootstrap-amd64-0.19.0-20170611/cargo"
prefix = "/usr/local"
vendor = true
[rust]
channel = "stable"
codegen-tests = false
[dist]
src-tarball = false
[target.x86_64-unknown-openbsd]
llvm-config = "/usr/local/bin/llvm-config"

@devurandom
Copy link
Contributor

I confirm this with Rust 1.18.0 (building using 1.17.0, as described in #42543).

@devurandom
Copy link
Contributor

#42695 fixes this issue.

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jun 18, 2017
…crichton

Use custom cargo/rustc paths when parsing flags.

Fixes rust-lang#41779, probably also rust-lang#42543 (I think they're duplicates).

I'm not entirely happy with the implementation, since it means we parse the configuration twice, but it's the minimal solution. I think the other choice is to move both calls to Config::parse inside Flags::parse and merge them, but I don't know if that's a good idea.

r? @alexcrichton
frewsxcv added a commit to frewsxcv/rust that referenced this issue Jun 18, 2017
…crichton

Use custom cargo/rustc paths when parsing flags.

Fixes rust-lang#41779, probably also rust-lang#42543 (I think they're duplicates).

I'm not entirely happy with the implementation, since it means we parse the configuration twice, but it's the minimal solution. I think the other choice is to move both calls to Config::parse inside Flags::parse and merge them, but I don't know if that's a good idea.

r? @alexcrichton
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
E-help-wanted Call for participation: Help is requested to fix this issue. P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

5 participants