[PATCH] D119668: [lld-macho] Add -static

Jared Irwin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 15 16:40:46 PST 2022


Link1J added a comment.

In D119668#3322860 <https://reviews.llvm.org/D119668#3322860>, @int3 wrote:

>> -static drives will probably drive me (or anyone) insane if it is to be completely and correctly implemented. It seems to touch everything, and I don't even know if everything below is all that it does.
>
> I guess my question is... why are we implementing this, if it's too much work to implement correctly? Do you foresee a real use case?

It isn't making the changes that are hard, as most of the stuff is already in `lld`. The part that was driving me insane is tracking down what it changes. I was doing very basic code searches in `ld64` code, and it was hard to track what it was doing (There are about three different variables to control most flags it has). So it really seems like `-static` is just making `ld64` output older style mach-o binaries, with most of the dynamic linker stuff missing.

In the end, I think that I at least got everything noted down, with most that I implemented being found from linking using `ld64`. So everything should be listed, so that others could make the changes. 
I do plan to make the changes for `-image_base`, as I already have a patch in the works to add it.

I am going to use it, and it does have uses it OS development. So I thought it would be a good idea to add it upstream, as `lld` is a lot easier to get working on other platforms then `ld64` is.
Also some of the items added (like `LC_UNIXTHREAD`) do have uses for linking binaries for older macOS versions. So I don't expect this flag to get a lot of use directly, there is a lot that can be used for improvement for linking older macOS binaries, or for building projects like `darling`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119668/new/

https://reviews.llvm.org/D119668



More information about the llvm-commits mailing list