@@ -632,15 +632,25 @@ extension LLBuildManifestBuilder {
632
632
private func addMainSymbolRemovalCmd( toolchain: Toolchain ,
633
633
inputFile: AbsolutePath , outputFile: AbsolutePath ,
634
634
mainSymbolListFile: AbsolutePath ) {
635
- let args = [
636
- // FIXME: Using `nmedit` only works on Darwin. For Linux (and Windows?) we need to use `strip` from the
637
- // `binutils`, and for other platforms, who knows. This needs to be made generic.
638
- // FIXME: Even on Darwin, we need the toolchain to provide the path of the `nmedit` tool.
639
- toolchain. swiftCompiler. parentDirectory. appending ( component: " nmedit " ) . pathString,
640
- " -R " , mainSymbolListFile. pathString,
641
- inputFile. pathString,
642
- " -o " , outputFile. pathString
643
- ]
635
+ let args : [ String ]
636
+ #if canImport(Darwin)
637
+ // On Darwin systems, use `nmedit` to remove the `main` symbol.
638
+ args = [
639
+ // FIXME: The toolchain should provide the path of the `nmedit` tool.
640
+ toolchain. swiftCompiler. parentDirectory. appending ( component: " nmedit " ) . pathString,
641
+ " -R " , mainSymbolListFile. pathString,
642
+ inputFile. pathString,
643
+ " -o " , outputFile. pathString
644
+ ]
645
+ #else
646
+ // On non-Darwin systems, use `objcopy` from `binutils` to mark the `main` symbol as local.
647
+ args = [
648
+ " objcopy " ,
649
+ " -L " , " main " ,
650
+ inputFile. pathString,
651
+ outputFile. pathString
652
+ ]
653
+ #endif
644
654
manifest. addShellCmd (
645
655
name: outputFile. pathString,
646
656
description: " Eliding symbols from \( outputFile. basename) " ,
0 commit comments