michaeleisel / zld

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

Add instruction to use with Bazel #70

Closed thii closed 4 years ago

michaeleisel commented 4 years ago

when you find out how to use it with bazel, let me know :P

there are two issues that i know of right now: getting the zld executable to be at the right place during linking, and getting clang to invoke it instead of ld, via -fuse-ld=.... if we add that arg to linkopts, we get -Wl,-fuse-ld=..., and we don't want that -Wl. one can also mess with the toolchain, but my understanding is that that's quite a pain. PR here: https://github.com/bazelbuild/rules_apple/pull/945

thii commented 4 years ago

Adding the linktopts via the build command or the .bazelrc file worked for us. Bazel doesn’t add the extra -Wl here like it does for the rule’s linktopts attribute.

For getting the zld executable tobe at the right place, right now we’re having to build w/o sandbox, but yeah modifying the toolchain to declare it as an input would definitely a proper way.

michaeleisel commented 4 years ago

ha, i thought this was a github issue, not a pr. yes, this makes sense. could you add a bit about it needing to be not in the sandbox?

michaeleisel commented 4 years ago

also, how do you download and determine the path to zld? can you do it with a repository rule?

thii commented 4 years ago

We download it via a bazel wrapper at tools/bazel (which is invoked by Homebrew installed bazel), and give it an absolute path (e.g. /tmp/zld-09ea158, so at least zld version is part of the cache key).

michaeleisel commented 4 years ago

thanks!