michaeleisel / zld

A faster version of Apple's linker
MIT License
1.19k stars 50 forks source link

Error Library not loaded. #62

Closed shirshak55 closed 4 years ago

shirshak55 commented 4 years ago

I am trying to use it for Rust.

rustc 1.49.0-nightly (25c8c53dd 2020-10-03)

I added it in ~/.cargo/config

[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/zld"]

And as soon as i do cargo run it gives error

➜  r5ai git:(main) ✗ cargo run
   Compiling libc v0.2.78
   Compiling proc-macro2 v1.0.24
   Compiling syn v1.0.42
   Compiling log v0.4.11
error: linking with `cc` failed: exit code: 254
  |
  = note: "cc" "-m64" "-arch" "x86_64" "-L" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.0.rcgu.o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.1.rcgu.o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.10.rcgu.o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.11.rcgu.o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.12.rcgu.o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.13.rcgu.o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.14.rcgu.o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.15.rcgu.o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.2.rcgu.o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.3.rcgu.o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.4.rcgu.o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.5.rcgu.o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.6.rcgu.o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.7.rcgu.o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.8.rcgu.o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.build_script_build.tdatf7av-cgu.9.rcgu.o" "-o" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2" "/Users/shirshak/Desktop/code/r5ai/target/debug/build/log-24c71d92410457b2/build_script_build-24c71d92410457b2.1afe22bl998ag2f7.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/shirshak/Desktop/code/r5ai/target/debug/deps" "-L" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-f5a6dfa2dca04db0.rlib" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-a602b1ebad91d2d3.rlib" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libobject-f7936dd792262a74.rlib" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-bb56016a39783030.rlib" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgimli-1873d4fc46d20288.rlib" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-55bacf2d542c4144.rlib" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-ff8a738b6f2b559a.rlib" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-3864ce8d4cb7a483.rlib" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-de47433f56869db6.rlib" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-1571a545da17c3ef.rlib" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-48dc7fd9359a0304.rlib" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-0a2b336e241cf742.rlib" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-465082706ea1ede1.rlib" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-e3cd79f6ad1173fd.rlib" "/Users/shirshak/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-4071d15d8824a4bb.rlib" "-lSystem" "-lresolv" "-lc" "-lm" "-fuse-ld=/usr/local/bin/zld"
  = note: dyld: Library not loaded: @rpath/libLTO.dylib
            Referenced from: /usr/local/bin/zld
            Reason: image not found
          clang: error: unable to execute command: Abort trap: 6
          clang: error: linker command failed due to signal (use -v to see invocation)

error: aborting due to previous error

error: could not compile `log`

To learn more, run the command again with --verbose.

I am using it after formatting osx is there any other requirement etc it needs?

michaeleisel commented 4 years ago

installing the xcode toolchain should fix this. it includes libLTO.dylib

shirshak55 commented 4 years ago

Thanks :) Didn't realized xcode was needed here :)

FredrikNoren commented 4 years ago

@michaeleisel I'm also getting this error. I tried running xcode-select --install but still getting the same error. Do I need all of xcode? Or is there something else I need? I also tried brew install llvm but that didn't help.

shirshak55 commented 4 years ago

@FredrikNoren I installed whole Xcode and yes xcode select might not cut it. Apple ecosystem man :(

FredrikNoren commented 4 years ago

Ah bummer. Yeah 10gig just to download it is pretty hefty :/

shirshak55 commented 4 years ago

@FredrikNoren yea but you can download it directly there is link in stackoverflow for xip . Apple store downloads like a potato.

michaeleisel commented 4 years ago

perhaps in the future, it'd be beneficial to bundle the dylibs in a .zip? at the moment, you could identify which libraries are loaded, e.g. with otool -l or DYLD_PRINT_LIBRARIES, and delete the rest after installing xcode if you really want

shirshak55 commented 4 years ago

it would be better if there was easy way without installing xcode. Xcode takes like 12 hour to download :( Its mostly internet bandwidth issue rather than disk usage. And apple store frequently fails to download we need to go and hunt xip files for installing xcode

michaeleisel commented 4 years ago

the dylibs will always be necessary, but perhaps they can be packaged. in the meantime, you may find the downloads at https://developer.apple.com/download/more/?=xcode more reliable than from the app store app