Skip to content

Cannot compile rustc on FreeBSD #23287

Closed
@aidancully

Description

@aidancully

Problem was introduced in 95d9046.

Command line:

CFG_LLVM_LINKAGE_FILE=/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/rt/llvmdeps.rs \
LD_LIBRARY_PATH=/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib:$LD_LIBRARY_PATH   \
x86_64-unknown-freebsd/stage1/bin/rustc --cfg stage1  -O --cfg rtopt --cfg debug \
-C prefer-dynamic --target=x86_64-unknown-freebsd  -D warnings \
-L "x86_64-unknown-freebsd/rt" \
-L "/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/llvm/Release+Asserts/lib" \
-L ""  \
--out-dir x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib \
-C extra-filename=-4e7c5e5c /usr/home/aidan/rust/rust/src/libstd/lib.rs

Produces error:

error: linking with `cc` failed: exit code: 1
note: "cc" "-L/usr/local/lib" "-L/usr/local/lib/gcc46" "-L/usr/local/lib/gcc44" "-m64" \
"-L" "/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib" \
"-o" "x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/libstd-4e7c5e5c.so" \
"x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/std-4e7c5e5c.o" \
"-Wl,--whole-archive" "-lmorestack" "-Wl,--no-whole-archive" \
"x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/std-4e7c5e5c.metadata.o" \
"-nodefaultlibs" \
"/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/libcollections-4e7c5e5c.rlib" \
"/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/librand-4e7c5e5c.rlib" \
"/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/liballoc-4e7c5e5c.rlib" \
"/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/libunicode-4e7c5e5c.rlib" \
"/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/liblibc-4e7c5e5c.rlib" \
"/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/libcore-4e7c5e5c.rlib" \
"-L" "x86_64-unknown-freebsd/rt" \
"-L" "/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/llvm/Release+Asserts/lib" \
"-L" "" \
"-L" "/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib" \
"-L" "/usr/home/aidan/rust/rust/.rust/lib/x86_64-unknown-freebsd" \
"-L" "/usr/home/aidan/rust/rust/lib/x86_64-unknown-freebsd" \
"-Wl,--whole-archive" "-Wl,-Bstatic" "-lrust_builtin" "-lbacktrace" "-lrustrt_native" \
"-Wl,--no-whole-archive" "-Wl,-Bdynamic" "-lexecinfo" "-lpthread" "-lrt" "-lgcc_s" \
"-lpthread" "-lc" "-lm" "-shared" "-lcompiler-rt"
note: /usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib: file not recognized: File format not recognized

error: aborting due to previous error
/usr/home/aidan/rust/rust/mk/target.mk:166: recipe for target 'x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/stamp.std' failed
gmake: *** [x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/stamp.std] Error 101

The problem seems to be that the FreeBSD linker expects "-L" to be a single argument, while rustc is splitting it into two arguments, "-L" and "". Running the following command line by hand:

"cc" "-L/usr/local/lib" "-L/usr/local/lib/gcc46" "-L/usr/local/lib/gcc44" "-m64" \
"-L/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib" \
"-o" "x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/libstd-4e7c5e5c.so" \
"x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/std-4e7c5e5c.o" \
"-Wl,--whole-archive" "-lmorestack" "-Wl,--no-whole-archive" \
"x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/std-4e7c5e5c.metadata.o" \
"-nodefaultlibs" \
"/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/libcollections-4e7c5e5c.rlib" \
"/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/librand-4e7c5e5c.rlib" \
"/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/liballoc-4e7c5e5c.rlib" \
"/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/libunicode-4e7c5e5c.rlib" \
"/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/liblibc-4e7c5e5c.rlib" \
"/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib/libcore-4e7c5e5c.rlib" \
"-Lx86_64-unknown-freebsd/rt" \
"-L/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/llvm/Release+Asserts/lib" \
"-L" \
"-L/usr/home/aidan/rust/rust/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/lib" \
"-L/usr/home/aidan/rust/rust/.rust/lib/x86_64-unknown-freebsd" \
"-L/usr/home/aidan/rust/rust/lib/x86_64-unknown-freebsd" "-Wl,--whole-archive" \
"-Wl,-Bstatic" "-lrust_builtin" "-lbacktrace" "-lrustrt_native" "-Wl,--no-whole-archive" \
"-Wl,-Bdynamic" "-lexecinfo" "-lpthread" "-lrt" "-lgcc_s" "-lpthread" "-lc" "-lm" \
"-shared" "-lcompiler-rt"

(same as before, but with -L and <path> arguments merged into a single argument)

This allowed the link to succeed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions