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

rustbuild with verbose fails with custom `cargo` path #41779

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

Comments

Projects
None yet
5 participants
@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

This comment has been minimized.

Copy link
Contributor Author

semarie commented Jun 10, 2017

@alexcrichton ping ? it is a regress for stable

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jun 13, 2017

Sounds bad!

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Jun 15, 2017

Will investigate.

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Jun 15, 2017

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

@semarie

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor

devurandom commented Jun 17, 2017

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

@devurandom

This comment has been minimized.

Copy link
Contributor

devurandom commented Jun 17, 2017

#42695 fixes this issue.

bors added a commit that referenced this issue Jun 17, 2017

Auto merge of #42695 - Mark-Simulacrum:fix-verbose, r=alexcrichton
Use custom cargo/rustc paths when parsing flags.

Fixes #41779, probably also #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

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

Rollup merge of rust-lang#42695 - Mark-Simulacrum:fix-verbose, r=alex…
…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

Rollup merge of rust-lang#42695 - Mark-Simulacrum:fix-verbose, r=alex…
…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

@bors bors closed this in #42695 Jun 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.