[PATCH] D114397: [lld-macho] Mark dylib symbols coming from -weak_framework as weak-def.

Vy Nguyen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 23 14:12:22 PST 2021


oontvoo added inline comments.


================
Comment at: lld/MachO/Driver.cpp:391
       if (isWeak)
-        dylibFile->forceWeakImport = true;
+        assert(dylibFile->forceWeakImport);
       if (isReexport) {
----------------
thevinster wrote:
> Hmm.... I'm not sure why this change is needed? I think the original code of forcefully setting `forceWeakImport` on the dylibFile should be fine. I think the only change missing here is the change in `isWeakDef` and `isWeakRef` to make sure it accounts for the `forceWeakImport` flag which you already did in `Symbols.h`. Everything else can stay as is. 
There were two problems:
- (in DriverUtil::loadDylib) if the dylib has previously been loaded without the weak flag, and it is being loaded again now with the flag, then this flag will not mean anything because the loadDylib() would return pointer to the cached Dylib object.
- consequently, symbols from such dylib cannot be effectively marked "weak" (because they were previously seen as regular/strong dylib) 

So the change here is to ensure we propagate the flag to loadDylib


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114397



More information about the llvm-commits mailing list