Skip to content

Targeting linux on OSX yields compilation errors #463

@netgusto

Description

@netgusto

Compiling on OSX for linux yields some error.

error: linking with `cc` failed: exit code: 1
ld: unknown option: --as-needed

To reproduce :

$ rustup target add x86_64-unknown-linux-gnu
$ cd  /tmp
$ mkdir supworld
$ cd supworld
$ cargo init --bin
$ cargo build --target=x86_64-unknown-linux-gnu -v
   Compiling supworld v0.1.0 (file:///private/tmp/supworld)
     Running `rustc src/main.rs --crate-name supworld --crate-type bin -g --out-dir /private/tmp/supworld/target/x86_64-unknown-linux-gnu/debug --emit=dep-info,link --target x86_64-unknown-linux-gnu -L dependency=/private/tmp/supworld/target/x86_64-unknown-linux-gnu/debug -L dependency=/private/tmp/supworld/target/x86_64-unknown-linux-gnu/debug/deps`
error: linking with `cc` failed: exit code: 1
note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/Users/user/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/private/tmp/supworld/target/x86_64-unknown-linux-gnu/debug/supworld.0.o" "-o" "/private/tmp/supworld/target/x86_64-unknown-linux-gnu/debug/supworld" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/private/tmp/supworld/target/x86_64-unknown-linux-gnu/debug" "-L" "/private/tmp/supworld/target/x86_64-unknown-linux-gnu/debug/deps" "-L" "/Users/user/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/Users/user/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-4fda350b.rlib" "/Users/user/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-4fda350b.rlib" "/Users/user/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_unicode-4fda350b.rlib" "/Users/user/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-4fda350b.rlib" "/Users/user/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-4fda350b.rlib" "/Users/user/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-4fda350b.rlib" "/Users/user/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-4fda350b.rlib" "/Users/user/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-4fda350b.rlib" "-l" "dl" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "compiler-rt"
note: clang: warning: argument unused during compilation: '-pie'
ld: unknown option: --as-needed
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
Could not compile `supworld`.

Caused by:
  Process didn't exit successfully: `rustc src/main.rs --crate-name supworld --crate-type bin -g --out-dir /private/tmp/supworld/target/x86_64-unknown-linux-gnu/debug --emit=dep-info,link --target x86_64-unknown-linux-gnu -L dependency=/private/tmp/supworld/target/x86_64-unknown-linux-gnu/debug -L dependency=/private/tmp/supworld/target/x86_64-unknown-linux-gnu/debug/deps` (exit code: 101)

Environment:

# OSX: El Capitan 10.11.3
$ cc -v
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin15.3.0
Thread model: posix

$ rustc --version
rustc 1.8.0 (db2939409 2016-04-11)

$ rustup --version
rustup 0.1.12 (c6e430a 2016-05-12)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions