Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mac/lld] Add support for the LC_LINKER_OPTION load command in o files
clang puts `-framework CoreFoundation` in this load command for files that use @available / __builtin_available. Without support for this, binaries that don't explicitly link to CoreFoundation fail to link. Differential Revision: https://reviews.llvm.org/D92624
- Loading branch information
Showing
4 changed files
with
121 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# REQUIRES: x86 | ||
# RUN: rm -rf %t | ||
# RUN: split-file %s %t | ||
|
||
# RUN: llvm-as %t/framework.ll -o %t/framework.o | ||
# RUN: %lld %t/framework.o -o %t/frame | ||
# RUN: llvm-objdump --macho --all-headers %t/frame | FileCheck --check-prefix=FRAME %s | ||
# FRAME: cmd LC_LOAD_DYLIB | ||
# FRAME-NEXT: cmdsize | ||
# FRAME-NEXT: name /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation | ||
|
||
# RUN: llvm-as %t/l.ll -o %t/l.o | ||
# RUN: %lld %t/l.o -o %t/l | ||
# RUN: llvm-objdump --macho --all-headers %t/l | FileCheck --check-prefix=LIB %s | ||
# LIB: cmd LC_LOAD_DYLIB | ||
# LIB-NEXT: cmdsize | ||
# LIB-NEXT: name /usr/lib/libSystem.B.dylib | ||
|
||
# RUN: llvm-as %t/invalid.ll -o %t/invalid.o | ||
# RUN: not %lld %t/invalid.o -o /dev/null 2>&1 | FileCheck --check-prefix=INVALID %s | ||
# INVALID: error: -why_load is not allowed in LC_LINKER_OPTION | ||
|
||
#--- framework.ll | ||
target triple = "x86_64-apple-macosx10.15.0" | ||
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
|
||
!0 = !{!"-framework", !"CoreFoundation"} | ||
!llvm.linker.options = !{!0} | ||
|
||
define void @main() { | ||
ret void | ||
} | ||
|
||
#--- l.ll | ||
target triple = "x86_64-apple-macosx10.15.0" | ||
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
|
||
!0 = !{!"-lSystem"} | ||
!llvm.linker.options = !{!0} | ||
|
||
define void @main() { | ||
ret void | ||
} | ||
|
||
#--- invalid.ll | ||
|
||
target triple = "x86_64-apple-macosx10.15.0" | ||
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
|
||
!0 = !{!"-why_load"} | ||
!llvm.linker.options = !{!0} | ||
|
||
define void @main() { | ||
ret void | ||
} |