File tree Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -938,17 +938,20 @@ template <class LP> void Writer::createLoadCommands() {
938
938
}
939
939
940
940
ordinal = dylibFile->ordinal = dylibOrdinal++;
941
- LoadCommandType lcType =
942
- dylibFile->forceWeakImport || dylibFile->refState == RefState::Weak
943
- ? LC_LOAD_WEAK_DYLIB
944
- : LC_LOAD_DYLIB;
941
+ LoadCommandType lcType = LC_LOAD_DYLIB;
942
+ if (dylibFile->reexport ) {
943
+ if (dylibFile->forceWeakImport )
944
+ warn (path::filename (dylibFile->getName ()) +
945
+ " is re-exported so cannot be weak-linked" );
946
+
947
+ lcType = LC_REEXPORT_DYLIB;
948
+ } else if (dylibFile->forceWeakImport ||
949
+ dylibFile->refState == RefState::Weak) {
950
+ lcType = LC_LOAD_WEAK_DYLIB;
951
+ }
945
952
in.header ->addLoadCommand (make<LCDylib>(lcType, dylibFile->installName ,
946
953
dylibFile->compatibilityVersion ,
947
954
dylibFile->currentVersion ));
948
-
949
- if (dylibFile->reexport )
950
- in.header ->addLoadCommand (
951
- make<LCDylib>(LC_REEXPORT_DYLIB, dylibFile->installName ));
952
955
}
953
956
954
957
for (const auto &dyldEnv : config->dyldEnvs )
Original file line number Diff line number Diff line change 42
42
# REEXPORT-HEADERS-NOT: Load command
43
43
# REEXPORT-HEADERS: name [[PATH]]
44
44
45
+ ## Check that specifying a library both with `l` and `reexport_library`
46
+ ## doesn't emit two load commands.
47
+ # RUN: %lld -dylib -reexport_library %t/libgoodbye.dylib \
48
+ # RUN: -L%t -lgoodbye %t/libsuper.o -o %t/libsuper.dylib
49
+ # RUN: llvm-otool -L %t/libsuper.dylib | FileCheck %s \
50
+ # RUN: --check-prefix=REEXPORT-DOUBLE -DPATH=%t/libgoodbye.dylib
51
+
52
+ # REEXPORT-DOUBLE: [[PATH]]
53
+ # REEXPORT-DOUBLE-SAME: reexport
54
+ # REEXPORT-DOUBLE-NOT: [[PATH]]
55
+
45
56
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/sub-library.o
46
57
# RUN: %lld -o %t/sub-library -L%t -lsuper %t/sub-library.o
47
58
You can’t perform that action at this time.
0 commit comments