[PATCH] D119294: [lld-macho] -flat_namespace for dylibs should make all externs interposable

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 11 16:49:21 PST 2022


MaskRay added a comment.

> I'm wondering: is there's a case where a dso_local function/global that comes into link with -flat_namespace/-interposable set? In ELF land interposability is set at compile time but with these flags on MachO it looks possible to set them at link time. If so that also makes pre-LTO optimizations strange because it might inline a function that later turns interposable. Given the previous statement I suspect I'm missing something here.

https://maskray.me/blog/2021-05-09-fno-semantic-interposition#clang--fno-semantic-interposition has some information about ELF -fno-semantic-interposition.

For ELF, yes. -fno-pic and -fpie have no interposition on defined symbols.
For -fpic, Clang defaults to `-fhalf-no-semantic-interposition` where interprocedural optimizations are available at compile time even if at link time the symbol are preemptible.
This seems strange but is important to retain the longstanding behavior.
I actually hope that we can transit from the current confusing 3 states to: "Can Clang default to -fno-semantic-interposition?" but there may be some risk.

> Hmm, maybe that's why clang doesn't seem to set dso_local when compiling for macos?

D98458 <https://reviews.llvm.org/D98458> (in release/13.x but not in release/12.x) is related. Seems that XNU has reliance on not having dso_local for some cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119294



More information about the llvm-commits mailing list