11use std:: { borrow:: Cow , env} ;
22
3+ use crate :: spec:: link_args:: LazyLinkArgsState ;
34use crate :: spec:: { add_link_args, add_link_args_iter, MaybeLazy } ;
45use crate :: spec:: { cvs, Cc , DebuginfoKind , FramePointer , LinkArgs , LinkerFlavor , Lld } ;
56use crate :: spec:: { SplitDebuginfo , StackProbeType , StaticCow , Target , TargetOptions } ;
@@ -94,7 +95,10 @@ impl TargetAbi {
9495 }
9596}
9697
97- pub fn pre_link_args ( os : & ' static str , arch : Arch , abi : TargetAbi ) -> LinkArgs {
98+ pub ( crate ) type ApplePreLinkArgs =
99+ ( /*os:*/ & ' static str , /*arch:*/ Arch , /*abi:*/ TargetAbi ) ;
100+
101+ pub ( crate ) fn pre_link_args ( ( os, arch, abi) : ApplePreLinkArgs ) -> LinkArgs {
98102 let platform_name: StaticCow < str > = match abi {
99103 TargetAbi :: Normal => os. into ( ) ,
100104 TargetAbi :: Simulator => format ! ( "{os}-simulator" ) . into ( ) ,
@@ -114,7 +118,9 @@ pub fn pre_link_args(os: &'static str, arch: Arch, abi: TargetAbi) -> LinkArgs {
114118 } ;
115119 let sdk_version = min_version. clone ( ) ;
116120
117- let mut args = TargetOptions :: link_args_base (
121+ let mut args = LinkArgs :: new ( ) ;
122+ add_link_args (
123+ & mut args,
118124 LinkerFlavor :: Darwin ( Cc :: No , Lld :: No ) ,
119125 & [ "-arch" , arch. target_name ( ) , "-platform_version" ] ,
120126 ) ;
@@ -140,12 +146,7 @@ pub fn pre_link_args(os: &'static str, arch: Arch, abi: TargetAbi) -> LinkArgs {
140146 args
141147}
142148
143- pub fn opts (
144- os : & ' static str ,
145- arch : Arch ,
146- abi : TargetAbi ,
147- pre_link_args : MaybeLazy < LinkArgs , ( LinkerFlavor , & ' static [ & ' static str ] ) > ,
148- ) -> TargetOptions {
149+ pub fn opts ( os : & ' static str , arch : Arch , abi : TargetAbi ) -> TargetOptions {
149150 TargetOptions {
150151 abi : abi. target_abi ( ) . into ( ) ,
151152 os : os. into ( ) ,
@@ -156,7 +157,7 @@ pub fn opts(
156157 // macOS has -dead_strip, which doesn't rely on function_sections
157158 function_sections : false ,
158159 dynamic_linking : true ,
159- pre_link_args,
160+ pre_link_args : MaybeLazy :: lazied ( LazyLinkArgsState :: Apple ( ( os , arch , abi ) ) ) ,
160161 families : cvs ! [ "unix" ] ,
161162 is_like_osx : true ,
162163 // LLVM notes that macOS 10.11+ and iOS 9+ default
0 commit comments