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

Cannot build on MacOS: failed to run rustc #26

Open
anta40 opened this issue Nov 10, 2022 · 2 comments
Open

Cannot build on MacOS: failed to run rustc #26

anta40 opened this issue Nov 10, 2022 · 2 comments

Comments

@anta40
Copy link

anta40 commented Nov 10, 2022

I'm on MacOS Monterey, and this is the output of rustup show

Default host: x86_64-apple-darwin
rustup home:  /Users/andre/.rustup

installed toolchains
--------------------

stable-x86_64-apple-darwin
nightly-x86_64-apple-darwin (default)

active toolchain
----------------

nightly-x86_64-apple-darwin (overridden by '/Users/andre/Desktop/xv6-rust/rust-toolchain')
rustc 1.67.0-nightly (e75aab045 2022-11-09)

I also already had i386-elf-gcc installed:

$ i386-elf-gcc -v
Using built-in specs.
COLLECT_GCC=i386-elf-gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/i386-elf-gcc/11.2.0_1/libexec/gcc/i386-elf/11.2.0/lto-wrapper
Target: i386-elf
Configured with: ../configure --prefix=/usr/local/Cellar/i386-elf-gcc/11.2.0_1 --target=i386-elf --disable-multilib --disable-nls --disable-werror --without-headers --without-isl --enable-languages=c,c++
Thread model: single
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (GCC) 

Did a few modifications on Makefile

CC := i386-elf-gcc
LD := i386-elf-ld
OBJDUMP := i386-elf-objdump
OBJCOPY := i386-elf-objcopy
NM := i386-elf-nm
AR := i386-elf-ar

And also changed the content of rust-toolchain file:
nightly-x86_64-apple-darwin

OK, let's try make all. Got this:

i386-elf-nm -n obj/user/wc > obj/user/wc.sym
RUSTFLAGS="-Z print-link-args -C link-arg=-b -C link-arg=binary -C link-arg=obj/user/nop -C link-arg=obj/user/hello -C link-arg=obj/user/yield -C link-arg=obj/user/forktest -C link-arg=obj/user/spin -C link-arg=obj/user/init -C link-arg=obj/user/filetest -C link-arg=obj/user/sh -C link-arg=obj/user/argstest -C link-arg=obj/user/malloctest -C link-arg=obj/user/ls -C link-arg=obj/user/pwd -C link-arg=obj/user/mkdir -C link-arg=obj/user/echo -C link-arg=obj/user/whello -C link-arg=obj/user/cat -C link-arg=obj/user/pipetest -C link-arg=obj/user/wc -C link-arg=-b -C link-arg=default" CFLAGS="-Wa,--compress-debug-sections=none -Wl,--compress-debug-sections=none" cargo xbuild --target i686-xv6rust.json --verbose 
error: cargo metadata invocation failed: Error during execution of `cargo metadata`: error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `rustc - --crate-name ___ --print=file-names -Z print-link-args -C link-arg=-b -C link-arg=binary -C link-arg=obj/user/nop -C link-arg=obj/user/hello -C link-arg=obj/user/yield -C link-arg=obj/user/forktest -C link-arg=obj/user/spin -C link-arg=obj/user/init -C link-arg=obj/user/filetest -C link-arg=obj/user/sh -C link-arg=obj/user/argstest -C link-arg=obj/user/malloctest -C link-arg=obj/user/ls -C link-arg=obj/user/pwd -C link-arg=obj/user/mkdir -C link-arg=obj/user/echo -C link-arg=obj/user/whello -C link-arg=obj/user/cat -C link-arg=obj/user/pipetest -C link-arg=obj/user/wc -C link-arg=-b -C link-arg=default --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (exit status: 1)
  --- stderr
  error: unknown unstable option: `print-link-args`


make: *** [kernel] Error 1
rm obj/user/filetest.o obj/user/nop.o obj/user/sh.o obj/user/init.o obj/user/forktest.o obj/user/whello.o obj/user/pipetest.o obj/user/spin.o obj/user/argstest.o obj/user/hello.o obj/user/wc.o obj/user/malloctest.o obj/user/ls.o obj/user/echo.o obj/user/pwd.o obj/user/yield.o obj/user/cat.o obj/user/mkdir.o

Any idea how to fix this?

@tiqwab
Copy link
Owner

tiqwab commented Nov 13, 2022

The problem will be fixed by changing -Z print-link-args to --print link-args.
ref. rust-lang/rust#91606

But I think there are still many compile errors because I didn't maintain the code for last two years.

@danikhan632
Copy link

I'm on MacOS Monterey, and this is the output of rustup show

Default host: x86_64-apple-darwin
rustup home:  /Users/andre/.rustup

installed toolchains
--------------------

stable-x86_64-apple-darwin
nightly-x86_64-apple-darwin (default)

active toolchain
----------------

nightly-x86_64-apple-darwin (overridden by '/Users/andre/Desktop/xv6-rust/rust-toolchain')
rustc 1.67.0-nightly (e75aab045 2022-11-09)

I also already had i386-elf-gcc installed:

$ i386-elf-gcc -v
Using built-in specs.
COLLECT_GCC=i386-elf-gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/i386-elf-gcc/11.2.0_1/libexec/gcc/i386-elf/11.2.0/lto-wrapper
Target: i386-elf
Configured with: ../configure --prefix=/usr/local/Cellar/i386-elf-gcc/11.2.0_1 --target=i386-elf --disable-multilib --disable-nls --disable-werror --without-headers --without-isl --enable-languages=c,c++
Thread model: single
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (GCC) 

Did a few modifications on Makefile

CC := i386-elf-gcc
LD := i386-elf-ld
OBJDUMP := i386-elf-objdump
OBJCOPY := i386-elf-objcopy
NM := i386-elf-nm
AR := i386-elf-ar

And also changed the content of rust-toolchain file: nightly-x86_64-apple-darwin

OK, let's try make all. Got this:

i386-elf-nm -n obj/user/wc > obj/user/wc.sym
RUSTFLAGS="-Z print-link-args -C link-arg=-b -C link-arg=binary -C link-arg=obj/user/nop -C link-arg=obj/user/hello -C link-arg=obj/user/yield -C link-arg=obj/user/forktest -C link-arg=obj/user/spin -C link-arg=obj/user/init -C link-arg=obj/user/filetest -C link-arg=obj/user/sh -C link-arg=obj/user/argstest -C link-arg=obj/user/malloctest -C link-arg=obj/user/ls -C link-arg=obj/user/pwd -C link-arg=obj/user/mkdir -C link-arg=obj/user/echo -C link-arg=obj/user/whello -C link-arg=obj/user/cat -C link-arg=obj/user/pipetest -C link-arg=obj/user/wc -C link-arg=-b -C link-arg=default" CFLAGS="-Wa,--compress-debug-sections=none -Wl,--compress-debug-sections=none" cargo xbuild --target i686-xv6rust.json --verbose 
error: cargo metadata invocation failed: Error during execution of `cargo metadata`: error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `rustc - --crate-name ___ --print=file-names -Z print-link-args -C link-arg=-b -C link-arg=binary -C link-arg=obj/user/nop -C link-arg=obj/user/hello -C link-arg=obj/user/yield -C link-arg=obj/user/forktest -C link-arg=obj/user/spin -C link-arg=obj/user/init -C link-arg=obj/user/filetest -C link-arg=obj/user/sh -C link-arg=obj/user/argstest -C link-arg=obj/user/malloctest -C link-arg=obj/user/ls -C link-arg=obj/user/pwd -C link-arg=obj/user/mkdir -C link-arg=obj/user/echo -C link-arg=obj/user/whello -C link-arg=obj/user/cat -C link-arg=obj/user/pipetest -C link-arg=obj/user/wc -C link-arg=-b -C link-arg=default --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (exit status: 1)
  --- stderr
  error: unknown unstable option: `print-link-args`


make: *** [kernel] Error 1
rm obj/user/filetest.o obj/user/nop.o obj/user/sh.o obj/user/init.o obj/user/forktest.o obj/user/whello.o obj/user/pipetest.o obj/user/spin.o obj/user/argstest.o obj/user/hello.o obj/user/wc.o obj/user/malloctest.o obj/user/ls.o obj/user/echo.o obj/user/pwd.o obj/user/yield.o obj/user/cat.o obj/user/mkdir.o

Any idea how to fix this?

Did u ever get this to work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants