File tree Expand file tree Collapse file tree 2 files changed +22
-9
lines changed
Expand file tree Collapse file tree 2 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -938,17 +938,19 @@ template <class LP> void Writer::createLoadCommands() {
938938 }
939939
940940 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 ()) + " is re-exported so cannot be weak-linked" );
945+
946+ lcType = LC_REEXPORT_DYLIB;
947+ } else if (dylibFile->forceWeakImport || dylibFile->refState == RefState::Weak) {
948+ lcType = LC_LOAD_WEAK_DYLIB;
949+ }
945950 in.header ->addLoadCommand (make<LCDylib>(lcType, dylibFile->installName ,
946- dylibFile->compatibilityVersion ,
947- dylibFile->currentVersion ));
951+ dylibFile->compatibilityVersion ,
952+ dylibFile->currentVersion ));
948953
949- if (dylibFile->reexport )
950- in.header ->addLoadCommand (
951- make<LCDylib>(LC_REEXPORT_DYLIB, dylibFile->installName ));
952954 }
953955
954956 for (const auto &dyldEnv : config->dyldEnvs )
Original file line number Diff line number Diff line change 4242# REEXPORT-HEADERS-NOT: Load command
4343# REEXPORT-HEADERS: name [[PATH]]
4444
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+
4556# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/sub-library.o
4657# RUN: %lld -o %t/sub-library -L%t -lsuper %t/sub-library.o
4758
You can’t perform that action at this time.
0 commit comments