Cannot compile "hello world" on OSX


#1

Hi Rust Community!

Yesterday my rust project compiled and today it does not. I’m racking my brain as to what change may have been the catalyst. Since then, I made a new project (“cargo new --bin yar”) and could not compile it.

Potentially related:

  • I recently upgraded from OSX Mountain Lion to El Capitan
  • I also upgraded to the latest xcode as part of that (7.1.1)

The error:

$ cargo run -v
Compiling yar v0.1.0 (file:///Users/aaronmoore/Desktop/markov/yar)
Running rustc src/main.rs --crate-name yar --crate-type bin -g --out-dir /Users/aaronmoore/Desktop/markov/yar/target/debug --emit=dep-info,link -L dependency=/Users/aaronmoore/Desktop/markov/yar/target/debug -L dependency=/Users/aaronmoore/Desktop/markov/yar/target/debug/deps
error: linking with cc failed: exit code: 1
note: “cc” “-m64” “-L” “/usr/local/lib/rustlib/x86_64-apple-darwin/lib” “/Users/aaronmoore/Desktop/markov/yar/target/debug/yar.0.o” “-o” “/Users/aaronmoore/Desktop/markov/yar/target/debug/yar” “-Wl,-dead_strip” “-nodefaultlibs” “/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-1bf6e69c.rlib” “/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcollections-1bf6e69c.rlib” “/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librustc_unicode-1bf6e69c.rlib” “/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librand-1bf6e69c.rlib” “/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc-1bf6e69c.rlib” “/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-1bf6e69c.rlib” “/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblibc-1bf6e69c.rlib” “/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcore-1bf6e69c.rlib” “-L” “/Users/aaronmoore/Desktop/markov/yar/target/debug” “-L” “/Users/aaronmoore/Desktop/markov/yar/target/debug/deps” “-L” “/usr/local/lib/rustlib/x86_64-apple-darwin/lib” “-L” “/Users/aaronmoore/Desktop/markov/yar/.rust/lib/x86_64-apple-darwin” “-L” “/Users/aaronmoore/Desktop/markov/yar/lib/x86_64-apple-darwin” “-l” “System” “-l” “pthread” “-l” “c” “-l” “m” “-l” "compiler-rt"
note: ld: warning: directory not found for option '-L/Users/aaronmoore/Desktop/markov/yar/.rust/lib/x86_64-apple-darwin’
ld: warning: directory not found for option '-L/Users/aaronmoore/Desktop/markov/yar/lib/x86_64-apple-darwin’
ld: targeted OS version does not support use of thread local variables in __ZN10sys_common11thread_info14current_thread20hbbf3cb762de1f7c0ZTrE for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
Could not compile yar.

Caused by:
Process didn’t exit successfully: rustc src/main.rs --crate-name yar --crate-type bin -g --out-dir /Users/aaronmoore/Desktop/markov/yar/target/debug --emit=dep-info,link -L dependency=/Users/aaronmoore/Desktop/markov/yar/target/debug -L dependency=/Users/aaronmoore/Desktop/markov/yar/target/debug/deps (exit code: 101)

Also, here is what I get when I run the individual clang command on its own with the -v flag:

Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -ios_simulator_version_min 7.0.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.1.sdk -o /Users/aaronmoore/Desktop/markov/yar/target/debug/yar -L/usr/local/lib/rustlib/x86_64-apple-darwin/lib -L/Users/aaronmoore/Desktop/markov/yar/target/debug -L/Users/aaronmoore/Desktop/markov/yar/target/debug/deps -L/usr/local/lib/rustlib/x86_64-apple-darwin/lib -L/Users/aaronmoore/Desktop/markov/yar/.rust/lib/x86_64-apple-darwin -L/Users/aaronmoore/Desktop/markov/yar/lib/x86_64-apple-darwin /Users/aaronmoore/Desktop/markov/yar/target/debug/yar.0.o -dead_strip /usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-1bf6e69c.rlib /usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcollections-1bf6e69c.rlib /usr/local/lib/rustlib/x86_64-apple-darwin/lib/librustc_unicode-1bf6e69c.rlib /usr/local/lib/rustlib/x86_64-apple-darwin/lib/librand-1bf6e69c.rlib /usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc-1bf6e69c.rlib /usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-1bf6e69c.rlib /usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblibc-1bf6e69c.rlib /usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcore-1bf6e69c.rlib -lSystem -lpthread -lc -lm -lcompiler-rt
ld: warning: directory not found for option '-L/Users/aaronmoore/Desktop/markov/yar/.rust/lib/x86_64-apple-darwin’
ld: warning: directory not found for option '-L/Users/aaronmoore/Desktop/markov/yar/lib/x86_64-apple-darwin’
ld: targeted OS version does not support use of thread local variables in __ZN10sys_common11thread_info14current_thread20hbbf3cb762de1f7c0ZTrE for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Before I upgraded rust from 1.3 to 1.4 (in attempt to solve the issue) the error message was complaining about not being able to line dylibs compiled for osx when the build target was the ios simulator. My project is not intended for the ios simulator and I’m confused as to why that is cropping up.

I will continue to hammer away at debugging this, but if anyone has insights they could share, I’d be most appreciative.

Thanks!

Aaron


#2

Something was configured wrong in my environment. I ultimately was able to fix this by logging out and then logging back in.

O.o

So… I guess ignore this. If anyone has any tips on what this might have been, I’d still be interested, though.


#3

I’m thinking the upgrade removed some of your files.

ld: warning: directory not found for option '-L/Users/aaronmoore/Desktop/markov/yar/.rust/lib/x86_64-apple-darwin'
ld: warning: directory not found for option '-L/Users/aaronmoore/Desktop/markov/yar/lib/x86_64-apple-darwin'

When I upgraded, all of the files in my download directory were deleted (I was not good at cleaning it up).