@@ -221,7 +221,7 @@ public void SetupExtraLinkerSettings(IFileGenerator fileGenerator, Project.Confi
221
221
configuration . Output == Project . Configuration . OutputType . Dll
222
222
) )
223
223
{
224
- var debugFormat = Options . GetObject < Sharpmake . Options . XCode . Compiler . DebugInformationFormat > ( configuration ) ;
224
+ var debugFormat = Options . GetObject < Options . XCode . Compiler . DebugInformationFormat > ( configuration ) ;
225
225
if ( debugFormat == Options . XCode . Compiler . DebugInformationFormat . DwarfWithDSym )
226
226
{
227
227
string outputPath = Path . Combine ( configuration . TargetPath , configuration . TargetFileFullNameWithExtension + ".dSYM" ) ;
@@ -233,22 +233,37 @@ public void SetupExtraLinkerSettings(IFileGenerator fileGenerator, Project.Confi
233
233
$ "{ fastBuildOutputFile } -o { outputPath } ",
234
234
useStdOutAsOutput : true ) ;
235
235
236
- var stripDebugSymbols = Options . GetObject < Options . XCode . Linker . StripLinkedProduct > ( configuration ) ;
237
- if ( stripDebugSymbols == Options . XCode . Linker . StripLinkedProduct . Enable )
236
+ // Stripping
237
+ if ( Options . GetObject < Options . XCode . Linker . StripLinkedProduct > ( configuration ) == Options . XCode . Linker . StripLinkedProduct . Enable )
238
238
{
239
+ List < string > stripOptionList = new List < string > ( ) ;
240
+ switch ( Options . GetObject < Options . XCode . Linker . StripStyle > ( configuration ) )
241
+ {
242
+ case Options . XCode . Linker . StripStyle . AllSymbols :
243
+ stripOptionList . Add ( "-s" ) ;
244
+ break ;
245
+ case Options . XCode . Linker . StripStyle . NonGlobalSymbols :
246
+ stripOptionList . Add ( "-x" ) ;
247
+ break ;
248
+ case Options . XCode . Linker . StripStyle . DebuggingSymbolsOnly :
249
+ stripOptionList . Add ( "-S" ) ;
250
+ break ;
251
+ }
252
+ if ( Options . GetObject < Options . XCode . Linker . StripSwiftSymbols > ( configuration ) == Options . XCode . Linker . StripSwiftSymbols . Enable )
253
+ stripOptionList . Add ( "-T" ) ;
254
+
255
+ var additionalStripFlags = Options . GetObject < Options . XCode . Linker . AdditionalStripFlags > ( configuration ) ;
256
+ if ( additionalStripFlags != null )
257
+ stripOptionList . Add ( XCodeUtil . ResolveProjectVariable ( configuration . Project , additionalStripFlags . Value ) ) ;
258
+
259
+ string stripOptions = string . Join ( " " , stripOptionList ) ;
260
+
239
261
string strippedSentinelFile = Path . Combine ( configuration . IntermediatePath , configuration . TargetFileName + ".stripped" ) ;
240
262
yield return new Project . Configuration . BuildStepExecutable (
241
263
"/usr/bin/strip" ,
242
264
asStampSteps ? string . Empty : dsymutilSentinelFile ,
243
265
asStampSteps ? string . Empty : strippedSentinelFile ,
244
- // From MacOS strip manual page:
245
- // -r : Save all symbols referenced dynamically.
246
- // -S : Remove the debuging symbol table entries (those created by the -g optin to cc and other compilers).
247
- // -T : The intent of this flag is to remove Swift symbols from the Mach-O symbol table,
248
- // It removes the symbols whose names begin with '_$S' or '_$s' only when it finds an __objc_imageinfo section with and it has non-zero swift version.
249
- // In the future the implementation of this flag may change to match the intent.
250
- // -x : Remove all local symbols (saving only global symbols)
251
- $ "-rSTx { fastBuildOutputFile } ",
266
+ $ "{ stripOptions } { fastBuildOutputFile } ",
252
267
useStdOutAsOutput : true
253
268
) ;
254
269
}
@@ -1372,6 +1387,19 @@ public virtual void SelectLinkerOptions(IGenerationContext context)
1372
1387
Options . Option ( Options . XCode . Linker . StripLinkedProduct . Enable , ( ) => options [ "StripLinkedProduct" ] = "YES" )
1373
1388
) ;
1374
1389
1390
+ context . SelectOption (
1391
+ Options . Option ( Options . XCode . Linker . StripStyle . AllSymbols , ( ) => options [ "StripStyle" ] = "all" ) ,
1392
+ Options . Option ( Options . XCode . Linker . StripStyle . NonGlobalSymbols , ( ) => options [ "StripStyle" ] = "non-global" ) ,
1393
+ Options . Option ( Options . XCode . Linker . StripStyle . DebuggingSymbolsOnly , ( ) => options [ "StripStyle" ] = "debugging" )
1394
+ ) ;
1395
+
1396
+ context . SelectOption (
1397
+ Options . Option ( Options . XCode . Linker . StripSwiftSymbols . Disable , ( ) => options [ "StripSwiftSymbols" ] = "NO" ) ,
1398
+ Options . Option ( Options . XCode . Linker . StripSwiftSymbols . Enable , ( ) => options [ "StripSwiftSymbols" ] = "YES" )
1399
+ ) ;
1400
+
1401
+ options [ "AdditionalStripFlags" ] = XCodeUtil . ResolveProjectVariable ( context . Project , Options . StringOption . Get < Options . XCode . Linker . AdditionalStripFlags > ( conf ) ) ;
1402
+
1375
1403
context . SelectOption (
1376
1404
Options . Option ( Options . XCode . Linker . PerformSingleObjectPrelink . Disable , ( ) => options [ "GenerateMasterObjectFile" ] = "NO" ) ,
1377
1405
Options . Option ( Options . XCode . Linker . PerformSingleObjectPrelink . Enable , ( ) => options [ "GenerateMasterObjectFile" ] = "YES" )
0 commit comments