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

rustc: reason(s) for linker options should be introspectable/reported via command line switch #1307

Open
steveklabnik opened this issue Feb 14, 2015 · 0 comments
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. A-linkage Area: linker issues, dylib, cdylib, shared libraries, so S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@steveklabnik
Copy link
Member

Issue by pnkfelix
Sunday Aug 03, 2014 at 05:45 GMT

For earlier discussion, see rust-lang/rust#16210

This issue was labelled with: A-tools, I-enhancement in the Rust repository


I tried to build gfx-rs on my mac yesterday.

I thought I had it working, but then when I tried to build the cube example that it includes, I hit a linker error:

% RUST_LOG=cargo cargo build --verbose
...
     Running `rustc main.rs --crate-name cube --crate-type bin --out-dir /Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target -L /Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target -L /Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/deps -L /Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/native/gl-e5df2498e985d18a -L /Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/native/glfw-cd120128a43da8e1 --extern gfx=/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/deps/libgfx-b022e83c25570dad.rlib --extern cgmath=/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/deps/libcgmath-5360c9e091e9a1d6.rlib`
       Fresh cgmath v0.0.1 (https://github.com/bjz/cgmath-rs.git#0189aead)
       Fresh glfw v0.0.1 (https://github.com/bjz/glfw-rs.git#91c77bd2)
       Fresh comm v0.1.0 (file:/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube)
       Fresh gl-init-rs v0.0.1 (https://github.com/tomaka/gl-init-rs.git#ed3ed47a)
       Fresh sax-rs v0.0.1 (https://github.com/bjz/sax-rs#fa887b57)
       Fresh gfx_macros v0.1.0 (file:/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube)
       Fresh gl_generator v0.0.1 (https://github.com/bjz/gl-rs.git#ca705653)
       Fresh gl v0.0.1 (https://github.com/bjz/gl-rs.git#ca705653)
       Fresh device v0.1.0 (file:/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube)
       Fresh glfw_platform v0.1.0 (file:/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube)
       Fresh gl_init_platform v0.1.0 (file:/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube)
       Fresh render v0.1.0 (file:/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube)
       Fresh gfx v0.1.0 (file:/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube)
   Compiling example-cube v0.1.0 (file:/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube)
5:cargo::ops::cargo_rustc: executing primary
error: linking with `cc` failed: exit code: 1
note: cc '-m64' '-L' '/Users/pnkfelix/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib' '-o' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/cube' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/cube.o' '-Wl,-force_load,/Users/pnkfelix/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib/libmorestack.a' '-nodefaultlibs' '-Wl,-dead_strip' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/deps/libcgmath-5360c9e091e9a1d6.rlib' '/Users/pnkfelix/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib/libnative-4e7c5e5c.rlib' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/deps/libgfx-b022e83c25570dad.rlib' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/deps/libgl_init_platform-07f8e5a4e7852f90.rlib' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/deps/libglfw_platform-e57d12d968abd11c.rlib' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/deps/libglfw-cd120128a43da8e1.rlib' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/deps/librender-5a028bc6cc784f4e.rlib' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/deps/libdevice-d4da5ff6384e848b.rlib' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/deps/libgl-e5df2498e985d18a.rlib' '/Users/pnkfelix/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib/liblog-4e7c5e5c.rlib' '/Users/pnkfelix/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib/libsemver-4e7c5e5c.rlib' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/deps/libgl-init-rs-39edd4b8f5666e81.rlib' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/deps/libcomm-2045099daf6674bb.rlib' '/Users/pnkfelix/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib/libstd-4e7c5e5c.rlib' '/Users/pnkfelix/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib/libsync-4e7c5e5c.rlib' '/Users/pnkfelix/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib/librustrt-4e7c5e5c.rlib' '/Users/pnkfelix/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib/libcollections-4e7c5e5c.rlib' '/Users/pnkfelix/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib/liballoc-4e7c5e5c.rlib' '/Users/pnkfelix/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib/liblibc-4e7c5e5c.rlib' '/Users/pnkfelix/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib/libunicode-4e7c5e5c.rlib' '/Users/pnkfelix/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib/librand-4e7c5e5c.rlib' '/Users/pnkfelix/opt/rust-dbg/lib/rustlib/x86_64-apple-darwin/lib/libcore-4e7c5e5c.rlib' '-L' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/native/gl-e5df2498e985d18a' '-L' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/deps' '-L' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target/native/glfw-cd120128a43da8e1' '-L' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/target' '-L' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/.rust' '-L' '/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube' '-lglfw3' '-framework' 'Cocoa' '-framework' 'OpenGL' '-framework' 'IOKit' '-framework' 'CoreFoundation' '-framework' 'CoreVideo' '-lGL' '-lX11' '-lSystem' '-lpthread' '-lc' '-lm' '-lcompiler-rt'
note: ld: warning: directory not found for option '-L/Users/pnkfelix/Dev/Rust/gfx-rs/src/examples/cube/.rust'
ld: library not found for -lGL
clang: error: linker command failed with exit code 1 (use -v to see invocation)

So, here is the issue: I see we have -framework OpenGL in the invocation. But there is also -lGL and -lX11 in the above command. And I have no idea which crate (gfx-rs has many subcrates it pulls in via cargo) is injecting which of those linker directives.

This bug is for fixing the implicit tooling issue here (not about fixing gfx-rs itself to work on OS X). From what I can see from skimming cargo's source code, the linker directives are not being inserted by cargo, but rather by rustc; but there is no way for me to modify the rustc command line that cargo gives me to find out more information about which crate(s) is the source for each linker flag.

@carols10cents carols10cents added the A-diagnostics Area: Error and warning messages generated by Cargo itself. label May 10, 2017
@weihanglo weihanglo added A-linkage Area: linker issues, dylib, cdylib, shared libraries, so S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. labels May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. A-linkage Area: linker issues, dylib, cdylib, shared libraries, so S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
Development

No branches or pull requests

3 participants