[PATCH] D158666: [Clang] Fix linker error for function multiversioning

Tom Honermann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 24 07:25:53 PDT 2023


tahonermann added a comment.

A couple of observations with regard to compatibility:

gcc,, at least by default, emits the TC implementations as local functions, the resolver as a weak global function, and the undecorated name as an ifunc. When only a TC declaration (not a definition) is present, gcc still emits the resolver and ifunc, but a failure then occurs at line time since the implementation symbols referenced by the resolver function cannot be resolved to the local symbols emitted for a TU with the TC definitions. I can only guess that this is intentional; that inter-TU calls are intended to be dispatched via the ifunc+resolver and that TC use is therefore restricted to TUs that have definitions. Clang, at least by default, emits the TC implementations as global functions that can be resolved for direct reference by other TUs. This could be seen as potentially exposing implementation details (e.g., the author of the TC functions might reserve the right to change the list of targets without worrying about breaking usage by other TUs.

For TUs that only have a declaration of the function without TC, it will be necessary to recompile the TUs that define TC functions no matter what. This is because the calling TU (that has neither a declaration nor a definition of the function with TC applied) cannot know to dispatch to the ifunc+resolver and cannot provide a definition for the undecorated function name (not even an alias since it doesn't know to do so).


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

https://reviews.llvm.org/D158666



More information about the cfe-commits mailing list