Hi, I have a question regarding the behavior of weak symbol resolution in LTO: Suppose there are weak definitions in both the source code and some native lib. In non-LTO path, we will use the version from source code. In LTO path, LLVM may discard the definition as it has "linkeonce" linkage type. So the native version will be selected by linker. Now, non-LTO and LTO build may have different behavior. The question is do we need to make non-LTO and LTO have the same behavior? If so, the LTO part needs to create pseudo uses (or some other mechanism) to keep the symbol from deletion. Thanks, Weiming
On 8 December 2015 at 18:04, Zhao, Weiming via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Hi, > > I have a question regarding the behavior of weak symbol resolution in LTO: > > Suppose there are weak definitions in both the source code and some native > lib. > In non-LTO path, we will use the version from source code. > In LTO path, LLVM may discard the definition as it has "linkeonce" linkage > type. So the native version will be selected by linker. > Now, non-LTO and LTO build may have different behavior. > > The question is do we need to make non-LTO and LTO have the same behavior? > If so, the LTO part needs to create pseudo uses (or some other mechanism) to > keep the symbol from deletion.On the gold plugin this was pr19901. It was fixed by having the plugin convert linkonce to weak when the resolution is PREVAILING_DEF (i.e. there is an use from a native file). Cheers, Rafael
Hi Rafael, Nice. That should fix the problem. Thanks, Weiming On 12/11/2015 3:11 PM, Rafael EspĂndola wrote:> On 8 December 2015 at 18:04, Zhao, Weiming via llvm-dev > <llvm-dev at lists.llvm.org> wrote: >> Hi, >> >> I have a question regarding the behavior of weak symbol resolution in LTO: >> >> Suppose there are weak definitions in both the source code and some native >> lib. >> In non-LTO path, we will use the version from source code. >> In LTO path, LLVM may discard the definition as it has "linkeonce" linkage >> type. So the native version will be selected by linker. >> Now, non-LTO and LTO build may have different behavior. >> >> The question is do we need to make non-LTO and LTO have the same behavior? >> If so, the LTO part needs to create pseudo uses (or some other mechanism) to >> keep the symbol from deletion. > > On the gold plugin this was pr19901. > > It was fixed by having the plugin convert linkonce to weak when the > resolution is PREVAILING_DEF (i.e. there is an use from a native > file). > > Cheers, > Rafael
Maybe Matching Threads
- [LLVMdev] Error with Gold Linker during LTO
- [LLVMdev] Proposal: New DAG node type for reciprocal operation
- [LLVMdev] Proposal: New DAG node type for reciprocal operation
- JIT, LTO and @llvm.global_ctors: Looking for advise
- [LLVMdev] [RFC] Linkage of user-supplied library functions in LTO