rust-osdev / cargo-xbuild

Automatically cross-compiles the sysroot crates core, compiler_builtins, and alloc.
Apache License 2.0
260 stars 25 forks source link

cargo xbuild not building core? #13

Closed steveklabnik closed 6 years ago

steveklabnik commented 6 years ago

Hey there! This is kind of a weird bug report; Everything works on CI:

but not locally.

I just got a new computer. I'm trying to build intermezzos. It appears that cargo-xbuild isn't trying to build libcore, and I'm not sure why.

Log:

```text > cargo xbuild --target .\intermezzos.json --verbose + "rustc" "--print" "sysroot" + "rustc" "--print" "target-list" + RUSTFLAGS="--sysroot C:\\Users\\Steve%20Klabnik\\src\\intermezzos\\kernel\\target/sysroot" + "cargo" "build" "--target" ".\\intermezzos.json" "--verbose" Fresh unicode-width v0.1.5 Compiling zero v0.1.2 Compiling ux v0.1.2 Compiling usize_conversions v0.2.0 Compiling os_bootinfo v0.2.1 Compiling bitflags v1.0.4 Compiling bit_field v0.9.0 Running `rustc --crate-name zero "C:\Users\Steve Klabnik\.cargo\registry\src\github.com-1ecc6299db9ec823\zero-0.1.2\src\lib.rs" --color always --crate-type lib --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=ba0b6236150e3006 -C extra-filename=-ba0b6236150e3006 --out-dir "C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" --target "\\?\C:\Users\Steve Klabnik\src\intermezzos\kernel\intermezzos.json" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\debug\deps" --cap-lints allow --sysroot C:\Users\Steve%20Klabnik\src\intermezzos\kernel\target/sysroot` Running `rustc --crate-name ux "C:\Users\Steve Klabnik\.cargo\registry\src\github.com-1ecc6299db9ec823\ux-0.1.2\src\lib.rs" --color always --crate-type lib --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=09d8d1073892a348 -C extra-filename=-09d8d1073892a348 --out-dir "C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" --target "\\?\C:\Users\Steve Klabnik\src\intermezzos\kernel\intermezzos.json" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\debug\deps" --cap-lints allow --sysroot C:\Users\Steve%20Klabnik\src\intermezzos\kernel\target/sysroot` Running `rustc --crate-name usize_conversions "C:\Users\Steve Klabnik\.cargo\registry\src\github.com-1ecc6299db9ec823\usize_conversions-0.2.0\src\lib.rs" --color always --crate-type lib --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=784cfbd532dc9233 -C extra-filename=-784cfbd532dc9233 --out-dir "C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" --target "\\?\C:\Users\Steve Klabnik\src\intermezzos\kernel\intermezzos.json" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\debug\deps" --cap-lints allow --sysroot C:\Users\Steve%20Klabnik\src\intermezzos\kernel\target/sysroot` Running `rustc --crate-name os_bootinfo "C:\Users\Steve Klabnik\.cargo\registry\src\github.com-1ecc6299db9ec823\os_bootinfo-0.2.1\src\lib.rs" --color always --crate-type lib --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=bcccaaae8157f32d -C extra-filename=-bcccaaae8157f32d --out-dir "C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" --target "\\?\C:\Users\Steve Klabnik\src\intermezzos\kernel\intermezzos.json" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\debug\deps" --cap-lints allow --sysroot C:\Users\Steve%20Klabnik\src\intermezzos\kernel\target/sysroot` Running `rustc --crate-name bitflags "C:\Users\Steve Klabnik\.cargo\registry\src\github.com-1ecc6299db9ec823\bitflags-1.0.4\src\lib.rs" --color always --crate-type lib --emit=dep-info,link -C panic=abort -C debuginfo=2 --cfg "feature=\"default\"" -C metadata=416d1ccdb23746f4 -C extra-filename=-416d1ccdb23746f4 --out-dir "C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" --target "\\?\C:\Users\Steve Klabnik\src\intermezzos\kernel\intermezzos.json" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\debug\deps" --cap-lints allow --sysroot C:\Users\Steve%20Klabnik\src\intermezzos\kernel\target/sysroot` error[E0463]: can't find crate for `core` | = note: the `intermezzos-11677179942914453679` target may not be installed error: aborting due to previous error For more information about this error, try `rustc --explain E0463`. error[E0463]: can't find crate for `core` | = note: the `intermezzos-11677179942914453679` target may not be installed error: Could not compile `zero`. Caused by: process didn't exit successfully: `rustc --crate-name zero "C:\Users\Steve Klabnik\.cargo\registry\src\github.com-1ecc6299db9ec823\zero-0.1.2\src\lib.rs" --color always --crate-type lib --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=ba0b6236150e3006 -C extra-filename=-ba0b6236150e3006 --out-dir "C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" --target "\\?\C:\Users\Steve Klabnik\src\intermezzos\kernel\intermezzos.json" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\debug\deps" --cap-lints allow --sysroot C:\Users\Steve%20Klabnik\src\intermezzos\kernel\target/sysroot` (exit code: 1) warning: build failed, waiting for other jobs to finish... error: aborting due to previous error For more information about this error, try `rustc --explain E0463`. error[E0463]: can't find crate for `core` | = note: the `intermezzos-11677179942914453679` target may not be installed error: aborting due to previous error For more information about this error, try `rustc --explain E0463`. error: Could not compile `usize_conversions`. Caused by: process didn't exit successfully: `rustc --crate-name usize_conversions "C:\Users\Steve Klabnik\.cargo\registry\src\github.com-1ecc6299db9ec823\usize_conversions-0.2.0\src\lib.rs" --color always --crate-type lib --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=784cfbd532dc9233 -C extra-filename=-784cfbd532dc9233 --out-dir "C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" --target "\\?\C:\Users\Steve Klabnik\src\intermezzos\kernel\intermezzos.json" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\debug\deps" --cap-lints allow --sysroot C:\Users\Steve%20Klabnik\src\intermezzos\kernel\target/sysroot` (exit code: 1) warning: build failed, waiting for other jobs to finish... error[E0463]: can't find crate for `core` | = note: the `intermezzos-11677179942914453679` target may not be installed error: aborting due to previous error For more information about this error, try `rustc --explain E0463`. Running `rustc --crate-name bit_field "C:\Users\Steve Klabnik\.cargo\registry\src\github.com-1ecc6299db9ec823\bit_field-0.9.0\src\lib.rs" --color always --crate-type lib --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=b0a184e3c9e20697 -C extra-filename=-b0a184e3c9e20697 --out-dir "C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" --target "\\?\C:\Users\Steve Klabnik\src\intermezzos\kernel\intermezzos.json" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\debug\deps" --cap-lints allow --sysroot C:\Users\Steve%20Klabnik\src\intermezzos\kernel\target/sysroot` error: Could not compile `ux`. Caused by: process didn't exit successfully: `rustc --crate-name ux "C:\Users\Steve Klabnik\.cargo\registry\src\github.com-1ecc6299db9ec823\ux-0.1.2\src\lib.rs" --color always --crate-type lib --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=09d8d1073892a348 -C extra-filename=-09d8d1073892a348 --out-dir "C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" --target "\\?\C:\Users\Steve Klabnik\src\intermezzos\kernel\intermezzos.json" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\debug\deps" --cap-lints allow --sysroot C:\Users\Steve%20Klabnik\src\intermezzos\kernel\target/sysroot` (exit code: 1) warning: build failed, waiting for other jobs to finish... error: Could not compile `os_bootinfo`. Caused by: process didn't exit successfully: `rustc --crate-name os_bootinfo "C:\Users\Steve Klabnik\.cargo\registry\src\github.com-1ecc6299db9ec823\os_bootinfo-0.2.1\src\lib.rs" --color always --crate-type lib --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=bcccaaae8157f32d -C extra-filename=-bcccaaae8157f32d --out-dir "C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" --target "\\?\C:\Users\Steve Klabnik\src\intermezzos\kernel\intermezzos.json" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\debug\deps" --cap-lints allow --sysroot C:\Users\Steve%20Klabnik\src\intermezzos\kernel\target/sysroot` (exit code: 1) warning: build failed, waiting for other jobs to finish... error[E0463]: can't find crate for `core` | = note: the `intermezzos-11677179942914453679` target may not be installed error: aborting due to previous error For more information about this error, try `rustc --explain E0463`. error: Could not compile `bitflags`. Caused by: process didn't exit successfully: `rustc --crate-name bitflags "C:\Users\Steve Klabnik\.cargo\registry\src\github.com-1ecc6299db9ec823\bitflags-1.0.4\src\lib.rs" --color always --crate-type lib --emit=dep-info,link -C panic=abort -C debuginfo=2 --cfg "feature=\"default\"" -C metadata=416d1ccdb23746f4 -C extra-filename=-416d1ccdb23746f4 --out-dir "C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" --target "\\?\C:\Users\Steve Klabnik\src\intermezzos\kernel\intermezzos.json" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\debug\deps" --cap-lints allow --sysroot C:\Users\Steve%20Klabnik\src\intermezzos\kernel\target/sysroot` (exit code: 1) warning: build failed, waiting for other jobs to finish... error[E0463]: can't find crate for `core` | = note: the `intermezzos-11677179942914453679` target may not be installed error: aborting due to previous error For more information about this error, try `rustc --explain E0463`. error: Could not compile `bit_field`. Caused by: process didn't exit successfully: `rustc --crate-name bit_field "C:\Users\Steve Klabnik\.cargo\registry\src\github.com-1ecc6299db9ec823\bit_field-0.9.0\src\lib.rs" --color always --crate-type lib --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=b0a184e3c9e20697 -C extra-filename=-b0a184e3c9e20697 --out-dir "C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" --target "\\?\C:\Users\Steve Klabnik\src\intermezzos\kernel\intermezzos.json" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\debug\deps" --cap-lints allow --sysroot C:\Users\Steve%20Klabnik\src\intermezzos\kernel\target/sysroot` (exit code: 1) ```

It fails to find libcore, but it doesn't even try to build it...

Any ideas?

phil-opp commented 6 years ago

Hmm, that's strange. Did you try cargo clean? If that doesn't help, maybe the problem is that there is a space in the project path (in your username). We added support for such paths in #6 and #8, but maybe there are still some bugs with it.

I was on vacation until yesterday, so I have a bit of backlog, but I try to investigate this as soon as possible.

steveklabnik commented 6 years ago

This is a new machine, so the target dir is empty; I had just cloned down the project.

Spaces is an interesting thought... maybe!

Don’t stress it, this is a hobby project, I can wait until you have time :)

On Sep 28, 2018, at 1:59 AM, Philipp Oppermann notifications@github.com wrote:

Hmm, that's strange. Did you try cargo clean? If that doesn't help, maybe the problem is that there is a space in the project path (in your username). We added support for such paths in #6 and #8, but maybe there are still some bugs with it.

I was on vacation until yesterday, so I have a bit of backlog, but I try to investigate this as soon as possible.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

steveklabnik commented 6 years ago

I tried it in a directory with no spaces, and still got the same output.

phil-opp commented 6 years ago

I tried it in a directory with no spaces, and still got the same output.

Thanks for trying!

So I tried to investigate this issue by looking at the code, but I don't have any idea how this could happen. It's diffult to debug without being able to reproduce it.

If you have the time, you could try to clone this project and insert some printlns here (notably to check if cmode is None): https://github.com/rust-osdev/cargo-xbuild/blob/2dc14120ad68683e29b0dd0f93ba6a62328765a8/src/lib.rs#L189-L207

Then you can install it through cargo install --debug --force and use it on intermezzOS. Maybe the output helps us to understand what's going on.

steveklabnik commented 6 years ago

It's diffult to debug without being able to reproduce it.

I can only imagine!

That said, the plot thickens:

> bootimage build
Building kernel
CMODE: Some(Cross(Custom { json: "C:\\Users\\Steve Klabnik\\src\\intermezzos\\kernel\\intermezzos.json", triple: "intermezzos", orig_triple: "C:\\Users\\Steve Klabnik\\src\\intermezzos\\kernel\\intermezzos.json" }))
   Compiling core v0.0.0 (C:\Users\Steve Klabnik\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libcore)
    Finished release [optimized] target(s) in 23.48s
   Compiling compiler_builtins v0.1.0 (C:\Users\Steve Klabnik\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libcompiler_builtins)
    Finished release [optimized] target(s) in 2.48s
   Compiling alloc v0.0.0 (C:\Users\STEVEK~1\AppData\Local\Temp\xargo.UxAe55P4WbwD)
    Finished release [optimized] target(s) in 4.01s
about to call xargo::run
cmode: Cross(Custom { json: "C:\\Users\\Steve Klabnik\\src\\intermezzos\\kernel\\intermezzos.json", triple: "intermezzos", orig_triple: "C:\\Users\\Steve Klabnik\\src\\intermezzos\\kernel\\intermezzos.json" })
command_name: "build"
verbose: false
   Compiling winapi v0.3.6
   Compiling unicode-width v0.1.5
   Compiling bit_field v0.9.0
   Compiling ux v0.1.2
   Compiling usize_conversions v0.2.0
   Compiling bitflags v1.0.4
   Compiling os_bootinfo v0.2.1
   Compiling zero v0.1.2
error[E0463]: can't find crate for `core`
  |
  = note: the `intermezzos-11677179942914453679` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: Could not compile `bit_field`.
warning: build failed, waiting for other jobs to finish...
error[E0463]: can't find crate for `core`
  |
  = note: the `intermezzos-11677179942914453679` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error[E0463]: can't find crate for `core`
error[E0463]: can't find crate for `core`
  |
  |
  = note: the `intermezzos-11677179942914453679` target may not be installed

  = note: the `intermezzos-11677179942914453679` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error[E0463]: can't find crate for `core`
  |
  = note: the `intermezzos-11677179942914453679` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: Could not compile `ux`.
warning: build failed, waiting for other jobs to finish...
error: Could not compile `os_bootinfo`.
warning: build failed, waiting for other jobs to finish...
error[E0463]: can't find crate for `core`
  |
  = note: the `intermezzos-11677179942914453679` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: Could not compile `usize_conversions`.
warning: build failed, waiting for other jobs to finish...
error: Could not compile `bitflags`.
warning: build failed, waiting for other jobs to finish...
error: Could not compile `zero`.
warning: build failed, waiting for other jobs to finish...
error: build failed

It does claim to build it, but it seems like there's a hash on the version where it tries to use it?

phil-opp commented 6 years ago

Really strange. Does the target/sysroot stay empty?

The hash should be normal, it is a hash of the full file name that is just added when printing (to differentiate different targets in different folders).

steveklabnik commented 6 years ago

It's not empty:

> ls .\target\sysroot\lib\rustlib\

    Directory: C:\Users\Steve Klabnik\src\intermezzos\kernel\target\sysroot\lib\rustlib

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        10/5/2018  12:25 PM                intermezzos
d-----        10/5/2018  12:25 PM                x86_64-pc-windows-msvc

and

> ls .\target\sysroot\lib\rustlib\intermezzos\lib

    Directory: C:\Users\Steve Klabnik\src\intermezzos\kernel\target\sysroot\lib\rustlib\intermezzos\lib

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        10/5/2018  12:25 PM           9104 alloc-eecae0817cf58db2.d
-a----        10/5/2018  12:25 PM           8446 compiler_builtins-5d977f04261135e8.d
-a----        10/5/2018  12:25 PM          59120 core-7e7e4f9ce1a7895f.d
-a----        10/5/2018  12:25 PM        2782064 liballoc-eecae0817cf58db2.rlib
-a----        10/5/2018  12:25 PM         388264 libcompiler_builtins-5d977f04261135e8.rlib
-a----        10/5/2018  12:25 PM       23740438 libcore-7e7e4f9ce1a7895f.rlib
steveklabnik commented 6 years ago

Oh! Look at that hash on libcore.

from my build output:

 = note: the `intermezzos-11677179942914453679` target may not be installed

those are different hashes...

phil-opp commented 6 years ago

Ok, so the sysroot is built and put in the correct directory. Maybe there's something wrong with the sysroot path in RUSTFLAGS:

RUSTFLAGS="--sysroot C:\\Users\\Steve%20Klabnik\\src\\intermezzos\\kernel\\target/sysroot"

Maybe the forward slash separator at the end or the %20 escape (but then it shouldn't happen with a path without spaces)? You could try to set the environment variable yourself and execute the cargo command directly (cargo build --target .\\intermezzos.json).

those are different hashes...

You mean the hash in libcore-7e7e4f9ce1a7895f? I think those are used for cargo's dependency resolution (to differentiate multiple versions of the same crate) and have nothing to do with the target triple.

steveklabnik commented 6 years ago

I think those are used for cargo's dependency resolution (to differentiate multiple versions of the same crate) and have nothing to do with the target triple.

Ah, okay.

You could try to set the environment variable yourself and execute the cargo command directly (cargo build --target .\intermezzos.json).

This also fails:

> $env:RUSTFLAGS="--sysroot C:\\Users\\Steve%20Klabnik\\src\\intermezzos\\kernel\\target/sysroot"
~\src\intermezzos\kernel [master ↑1]> cargo build --target .\\intermezzos.json
   Compiling bitflags v1.0.4
   Compiling os_bootinfo v0.2.1
   Compiling bit_field v0.9.0
   Compiling usize_conversions v0.2.0
   Compiling zero v0.1.2
   Compiling ux v0.1.2
   Compiling vga v0.1.0 (C:\Users\Steve Klabnik\src\intermezzos\kernel\vga)
   Compiling rlibc v1.0.0
error[E0463]: can't find crate for `core`
  |
  = note: the `intermezzos-11677179942914453679` target may not be installed

etc etc

It is properly passing it through.. if I run with --verbose:

     Running `rustc --crate-name usize_conversions "C:\Users\Steve Klabnik\.cargo\registry\src\github.com-1ecc6299db9ec823\usize_conversions-0.2.0\src\lib.rs" --color always --crate-type lib --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=66599485949f8e22 -C extra-filename=-66599485949f8e22 --out-dir "C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" --target "\\?\C:\Users\Steve Klabnik\src\intermezzos\kernel\intermezzos.json" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermezzos\debug\deps" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\debug\deps" --cap-lints allow --sysroot C:\\Users\\Steve%20Klabnik\\src\\intermezzos\\kernel\\target/sysroot`
phil-opp commented 6 years ago

And if you replace the forward slash with a (double) backslash (i.e. …\\kernel\\target\\sysroot)?

(I'm only guessing here, I don't know much about Windows)

phil-opp commented 6 years ago

Ok, I just tried to deliberately use a wrong sysroot path with blog_os and I get a similar error:

> RUSTFLAGS="--sysroot /does/not/exist" "cargo" "build" "--target" "x86_64-blog_os.json"
   Compiling bitflags v1.0.3                                                                                                     
error[E0463]: can't find crate for `core`                                       
  |                                                                             
  = note: the `x86_64-blog_os-13011881373029310060` target may not be installed 

error: aborting due to previous error                                           

For more information about this error, try `rustc --explain E0463`.             
error: Could not compile `bitflags`.                                            
warning: build failed, waiting for other jobs to finish...

So the issue might really be a wrong sysroot path.

steveklabnik commented 6 years ago

No change; Windows is pretty tolerant of accepting both / and \.

That said, I tried messing around with some things. I took one of the outputs from the verbose build log and played around with the sysroot. This works:

 rustc --crate-name ux "C:\Users\Steve Klabnik\.cargo\registry\src\github.com-1ecc6299db9ec823\ux-0.1.2\src\lib.rs" --color always --crate-type
lib --emit=dep-info,link -C panic=abort -C debuginfo=2 -C metadata=b446262c41a4777f -C extra-filename=-b446262c41a4777f --out-dir "C:\Users\Steve Klabnik\src\intermezzos\kernel\targ
et\intermezzos\debug\deps" --target "\\?\C:\Users\Steve Klabnik\src\intermezzos\kernel\intermezzos.json" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\intermez
zos\debug\deps" -L "dependency=C:\Users\Steve Klabnik\src\intermezzos\kernel\target\debug\deps" --cap-lints allow --sysroot "C:\Users\Steve Klabnik\src\intermezzos\kernel\target\sys
root"

one interesting thing here, PowerShell gives syntax highlighting. Check out the difference between the sysroot with %20 and the one without:

without

with quotes and the %20, it fails with the same "wrong sysroot" errors we've been seeing, but with quotes and a space, it works just fine!

Whew! So maybe that helps track this down?

phil-opp commented 6 years ago

Ok, so it seems like the %20 escape is at fault here. It was introduced in https://github.com/rust-osdev/cargo-xbuild/pull/6 after multiple failed escaping attempts. I couldn't test it myself, so I'm not sure if it really works.

The problem is that the --sysroot argument must be passed in RUSTFLAGS (to reach all dependencies) and without escaping rustc interprets a path with spaces as multiple arguments. I don't know any alternative way to escape the space in the environment variable, so I can't suggest you any other way of testing other than trying it under a different user name that doesn't contain spaces.

phil-opp commented 6 years ago

It's a pity that the only way to pass --sysroot is a through an unseparated string in an environment variable. It makes things pretty ugly.

steveklabnik commented 6 years ago

Hm, I will try to play around with it.

The way you normally escape "s in Powershell is "", but yeah:

~\src\intermezzos\kernel [master ↑1]> $env:RUSTFLAGS="--sysroot ""C:\Users\Steve Klabnik\src\intermezzos\kernel\target\sysroot"""
~\src\intermezzos\kernel [master ↑1]> bootimage build
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --sysroot "\"C:\Users\Steve" "Klabnik\src\intermezzos\kernel\target\sysroot\"" --target x86_64-pc-windows-msvc --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro` (exit code: 1)
--- stderr
error: multiple input filenames provided

as you mentioned. hmmmmmmmmmmmmmm

phil-opp commented 6 years ago

Oh, maybe it works in cmd but not in powershell?

steveklabnik commented 6 years ago

I don't know why it didn't work in the path without spaces as well, maybe i messed it up...

steveklabnik commented 6 years ago

I've filed an upstream bug: https://github.com/rust-lang/rust/issues/54856

steveklabnik commented 6 years ago

(cmd fails in the same way)

steveklabnik commented 6 years ago

Turns out this is a cargo bug, so closing. Thanks again for helping me <3

phil-opp commented 6 years ago

Good to know, thanks for investigating!

galamdring commented 4 years ago

I had a similar issue, and a cargo clean fixed it for me.