[llvm] -fno-plt: Infer nonlazybind at -O0 (PR #97873)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 7 12:50:01 PDT 2024


MaskRay wrote:

> Why do we wait to infer this in the first place, as opposed to just making the backend emit the right thing based on the module metadata? This seems fragile.

My understanding:

The `nonlazybind` function attribute has been available for a long time, possibly originally used by ObjC for Mach-O.
ELF -fno-plt reused `nonlazybind` since the backend behavior is identical. For intrinsics, the module flags metadata `"RtLibUseGOT"` with the `Max` behavior is used.

Keeping function attributes (`nonlazybind`) allows fine-grained `-fno-plt` and `-fplt` merging for LTO (and also ObjC/Mach-O's needs).
If `"RtLibUseGOT"` with the `Max` is used exclusively instead, `-fplt` modules will use the `-fno-plt` behavior as well.

I agree that this appears slightly complicated, but the complexity seems manageable.

https://github.com/llvm/llvm-project/pull/97873


More information about the llvm-commits mailing list