o8vm/krabs

unrecognized command line option '--target=i586-unknown-none'

Opened this issue · 6 comments

Description
I'm trying to test krabs by following instruction.
https://github.com/ellbrid/krabs/blob/master/docs/linux-image-setup-64.md

But I've got the following error.

== Building stage_4. ==
~/Documents/krabs/src/stage_4th ~/Documents/krabs
    Updating crates.io index
   Compiling compiler_builtins v0.1.25
   Compiling core v0.0.0 (~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
   Compiling rustc-std-workspace-core v1.99.0 (~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/tools/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/tmp/xargo.CBbDiRhAkFj9)
    Finished release [optimized] target(s) in 9.22s
   Compiling cc v1.0.50
   Compiling plankton v0.1.0 (~/Documents/krabs/src/plankton)
   Compiling stage_4th v0.1.0 (~/Documents/krabs/src/stage_4th)
error: failed to run custom build command for `stage_4th v0.1.0 (~/Documents/krabs/src/stage_4th)`

Caused by:
  process didn't exit successfully: `~/Documents/krabs/target/release/build/stage_4th-78eda19270ba321b/build-script-build` (exit code: 1)
--- stdout
TARGET = Some("i586-stage_4th")
OPT_LEVEL = Some("z")
HOST = Some("x86_64-unknown-linux-gnu")
CC_i586-stage_4th = None
CC_i586_stage_4th = None
TARGET_CC = None
CC = None
CROSS_COMPILE = None
CFLAGS_i586-stage_4th = None
CFLAGS_i586_stage_4th = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = None
running: "cc" "-Os" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m32" "-Wall" "-Wextra" "-m32" "--target=i586-unknown-none" "-fno-common" "-mno-sse" "-fno-builtin" "-ffreestanding" "-o" "~/Documents/krabs/target/i586-stage_4th/release/build/stage_4th-b871f005902daf44/out/c_src/huffman.o" "-c" "c_src/huffman.c"
cargo:warning=cc: error: unrecognized command line option '--target=i586-unknown-none'
exit code: 1

Environment

$ uname -a
Linux zdm 5.3.0-28-generic #30~18.04.1-Ubuntu SMP Fri Jan 17 06:14:09 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

$ gcc --version
gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ rustc --version
rustc 1.43.0-nightly (433aae93e 2020-02-14)

Question
Does anyone have knowledge about the error message?

o8vm commented

Your compiler probably does not supports those clang flags and it cause fatal issues like this.
I think this issue can be solved by using clang as the default compiler instead of gcc.

$ sudo apt install -y clang
$ sudo update-alternatives --config cc
There are 2 choices for the alternative cc (providing /usr/bin/cc).

  Selection    Path            Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc     20        auto mode
  1            /usr/bin/clang   10        manual mode
  2            /usr/bin/gcc     20        manual mode

Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/clang to provide /usr/bin/cc (cc) in manual mode

=> Select 1

Can you check if the above works?

As you said, I can build it successfully by switching cc compiler from gcc to clang!
Thanks!

o8vm commented

It seems that the build script can handle this issue without installing clang.

o8vm commented

If the issue persists, please reopen.

Thank you for your quick fix.

At once, I've tried it with new commit ( 593bb96 ).

I could've built it successfully, but I've got the following error in boot step:

Booting from Hard Disk...
Stage1: I/O error

I don't know whether the fix is related to the boot failure.
Do you have any ideas?

o8vm commented

Maybe this is caused by build.sh.
I've found printf command used in build.sh has a compatibility issue.
I'v opened a new issue: #11