@@ -191,7 +191,25 @@ public void SetupExtraLinkerSettings(IFileGenerator fileGenerator, Project.Confi
191
191
fileGenerator . Write ( _linkerOptionsTemplate ) ;
192
192
}
193
193
194
+ public IEnumerable < Project . Configuration . BuildStepExecutable > GetExtraStampEvents ( Project . Configuration configuration , string fastBuildOutputFile )
195
+ {
196
+ if ( FastBuildSettings . FastBuildSupportLinkerStampList )
197
+ {
198
+ foreach ( var step in GetStripDebugSymbolsSteps ( configuration , fastBuildOutputFile , asStampSteps : true ) )
199
+ yield return step ;
200
+ }
201
+ }
202
+
194
203
public IEnumerable < Project . Configuration . BuildStepBase > GetExtraPostBuildEvents ( Project . Configuration configuration , string fastBuildOutputFile )
204
+ {
205
+ if ( ! FastBuildSettings . FastBuildSupportLinkerStampList )
206
+ {
207
+ foreach ( var step in GetStripDebugSymbolsSteps ( configuration , fastBuildOutputFile , asStampSteps : false ) )
208
+ yield return step ;
209
+ }
210
+ }
211
+
212
+ private IEnumerable < Project . Configuration . BuildStepExecutable > GetStripDebugSymbolsSteps ( Project . Configuration configuration , string fastBuildOutputFile , bool asStampSteps )
195
213
{
196
214
if ( Util . GetExecutingPlatform ( ) == Platform . mac )
197
215
{
@@ -207,22 +225,38 @@ public void SetupExtraLinkerSettings(IFileGenerator fileGenerator, Project.Confi
207
225
if ( debugFormat == Options . XCode . Compiler . DebugInformationFormat . DwarfWithDSym )
208
226
{
209
227
string outputPath = Path . Combine ( configuration . TargetPath , configuration . TargetFileFullNameWithExtension + ".dSYM" ) ;
228
+ string dsymutilSentinelFile = Path . Combine ( configuration . IntermediatePath , configuration . TargetFileName + ".dsymdone" ) ;
210
229
yield return new Project . Configuration . BuildStepExecutable (
211
230
"/usr/bin/dsymutil" ,
212
- fastBuildOutputFile ,
213
- Path . Combine ( configuration . IntermediatePath , configuration . TargetFileName + ".dsymdone" ) ,
231
+ asStampSteps ? string . Empty : fastBuildOutputFile ,
232
+ asStampSteps ? string . Empty : dsymutilSentinelFile ,
214
233
$ "{ fastBuildOutputFile } -o { outputPath } ",
215
234
useStdOutAsOutput : true ) ;
235
+
236
+ var stripDebugSymbols = Options . GetObject < Options . XCode . Linker . StripLinkedProduct > ( configuration ) ;
237
+ if ( stripDebugSymbols == Options . XCode . Linker . StripLinkedProduct . Enable )
238
+ {
239
+ string strippedSentinelFile = Path . Combine ( configuration . IntermediatePath , configuration . TargetFileName + ".stripped" ) ;
240
+ yield return new Project . Configuration . BuildStepExecutable (
241
+ "/usr/bin/strip" ,
242
+ asStampSteps ? string . Empty : dsymutilSentinelFile ,
243
+ 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 } ",
252
+ useStdOutAsOutput : true
253
+ ) ;
254
+ }
216
255
}
217
256
}
218
257
}
219
258
}
220
259
221
- public IEnumerable < Project . Configuration . BuildStepExecutable > GetExtraStampEvents ( Project . Configuration configuration , string fastBuildOutputFile )
222
- {
223
- return Enumerable . Empty < Project . Configuration . BuildStepExecutable > ( ) ;
224
- }
225
-
226
260
public string GetOutputFilename ( Project . Configuration . OutputType outputType , string fastBuildOutputFile ) => fastBuildOutputFile ;
227
261
228
262
public enum CompilerFlavor
0 commit comments