Skip to content

Commit 4e3b77e

Browse files
committed
Remove support for compiling with bitcode.
This removes support for compiling files with bitcode from SWBuild, as this functionality is no longer supported. This removes a lot of functionally dead code. Support for stripping bitcode from copied files remains, as there are extant libraries and XCFrameworks which contain bitcode, which must be stripped. Bitcode was only supported for a subset of platforms, to the assignment of STRIP_BITCODE_FROM_COPIED_FILES in Settings based on platform remains, so time isn't spent stripping nonexistent bitcode from other platforms. Some interfaces which Xcode uses continue to refer to bitcode for compatibility, but effectively do nothing. Note that the references to bitcode in the OpenCL support are a concept internal to that tool, and independent of the support being removed here. rdar://148287993
1 parent fcb32fe commit 4e3b77e

File tree

48 files changed

+84
-1162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+84
-1162
lines changed

Sources/SWBApplePlatform/Specs/Darwin Package Types.xcspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
Description = "OCUnit Test Bundle";
5959
DefaultBuildSettings = {
6060
WRAPPER_SUFFIX = "octest";
61-
ENABLE_BITCODE = NO;
6261
};
6362
ProductReference = {
6463
FileType = wrapper.cfbundle;

Sources/SWBApplePlatform/Specs/Darwin Product Types.xcspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@
155155
Description = "OCUnit Test Bundle";
156156
DefaultBuildProperties = {
157157
WRAPPER_EXTENSION = "octest";
158-
ENABLE_BITCODE = NO;
159158
ENTITLEMENTS_REQUIRED = NO;
160159
};
161160
PackageTypes = (

Sources/SWBApplePlatform/Specs/Embedded-Shared.xcspec

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@
2828
Identifier = com.apple.build-system.native;
2929
BasedOn = "default:com.apple.build-system.native";
3030
Properties = (
31-
{
32-
Name = "ENABLE_BITCODE";
33-
Type = Boolean;
34-
DefaultValue = NO;
35-
},
3631
);
3732
},
3833
)

Sources/SWBApplePlatform/Specs/watchOS Shared.xcspec

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -117,50 +117,6 @@
117117
BasedOn = "com.apple.product-type.app-extension";
118118
},
119119

120-
// --- LLVM Compiler
121-
{
122-
_Domain = watchos-shared;
123-
Type = Compiler;
124-
Identifier = "com.apple.compilers.llvm.clang.1_0.compiler";
125-
BasedOn = "default:com.apple.compilers.llvm.clang.1_0.compiler";
126-
InputFileTypes = (
127-
"sourcecode.c.c",
128-
"sourcecode.c.objc",
129-
"sourcecode.cpp.cpp",
130-
"sourcecode.cpp.objcpp",
131-
{
132-
"FileType" = "sourcecode.asm";
133-
"Condition" = "! $(ENABLE_BITCODE)";
134-
"ErrorMessage" = "$(InputFileName): Assembly files are not supported for the $(PLATFORM_DISPLAY_NAME) platform (arch $(CURRENT_ARCH)).";
135-
},
136-
);
137-
Options = (
138-
// Generate bitcode options - not visible in the build settings.
139-
{
140-
Name = "CLANG_BITCODE_GENERATION_MODE";
141-
Type = Enumeration;
142-
Values = (
143-
none,
144-
marker,
145-
bitcode,
146-
);
147-
DefaultValue = "$(BITCODE_GENERATION_MODE)";
148-
Condition = "$(ENABLE_BITCODE)";
149-
CommandLineArgs = {
150-
none = ();
151-
marker = (
152-
"-fembed-bitcode-marker",
153-
"-fno-gnu-inline-asm",
154-
);
155-
bitcode = (
156-
"-fembed-bitcode",
157-
"-fno-gnu-inline-asm",
158-
);
159-
};
160-
},
161-
);
162-
},
163-
164120
// Actool ATV specific bits
165121
{
166122
_Domain = watchos-shared;

Sources/SWBCore/Settings/BuiltinMacros.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,9 @@ public final class BuiltinMacros {
224224

225225
public static let ACTION = BuiltinMacros.declareStringMacro("ACTION")
226226
public static let ARCHS = BuiltinMacros.declareStringListMacro("ARCHS")
227-
public static let BITCODE_GENERATION_MODE = BuiltinMacros.declareStringMacro("BITCODE_GENERATION_MODE")
228227
public static let BUILD_COMPONENTS = BuiltinMacros.declareStringListMacro("BUILD_COMPONENTS")
229228
public static let DEPLOYMENT_LOCATION = BuiltinMacros.declareBooleanMacro("DEPLOYMENT_LOCATION")
230229
public static let DEPLOYMENT_POSTPROCESSING = BuiltinMacros.declareBooleanMacro("DEPLOYMENT_POSTPROCESSING")
231-
public static let ENABLE_BITCODE = BuiltinMacros.declareBooleanMacro("ENABLE_BITCODE")
232230
public static let ENABLE_TESTABILITY = BuiltinMacros.declareBooleanMacro("ENABLE_TESTABILITY")
233231
public static let ENABLE_TESTING_SEARCH_PATHS = BuiltinMacros.declareBooleanMacro("ENABLE_TESTING_SEARCH_PATHS")
234232
public static let ENABLE_PRIVATE_TESTING_SEARCH_PATHS = BuiltinMacros.declareBooleanMacro("ENABLE_PRIVATE_TESTING_SEARCH_PATHS")
@@ -802,7 +800,6 @@ public final class BuiltinMacros {
802800
public static let __KNOWN_SPI_INSTALL_PATHS = BuiltinMacros.declareStringListMacro("__KNOWN_SPI_INSTALL_PATHS")
803801
public static let LD = BuiltinMacros.declareStringMacro("LD")
804802
public static let LDPLUSPLUS = BuiltinMacros.declareStringMacro("LDPLUSPLUS")
805-
public static let LD_BITCODE_GENERATION_MODE = BuiltinMacros.declareStringMacro("LD_BITCODE_GENERATION_MODE")
806803
public static let LD_CLIENT_NAME = BuiltinMacros.declareStringMacro("LD_CLIENT_NAME")
807804
public static let LD_DEPENDENCY_INFO_FILE = BuiltinMacros.declarePathMacro("LD_DEPENDENCY_INFO_FILE")
808805
public static let LD_DYLIB_INSTALL_NAME = BuiltinMacros.declareStringMacro("LD_DYLIB_INSTALL_NAME")
@@ -1426,7 +1423,6 @@ public final class BuiltinMacros {
14261423
AdditionalCommandLineArguments,
14271424
AppIdentifierPrefix,
14281425
BLOCKLISTS_PATH,
1429-
BITCODE_GENERATION_MODE,
14301426
BUILD_COMPONENTS,
14311427
BUILD_DESCRIPTION_CACHE_DIR,
14321428
BUILD_DIR,
@@ -1667,7 +1663,6 @@ public final class BuiltinMacros {
16671663
ENABLE_DEFAULT_SEARCH_PATHS_IN_LIBRARY_SEARCH_PATHS,
16681664
ENABLE_DEFAULT_SEARCH_PATHS_IN_REZ_SEARCH_PATHS,
16691665
ENABLE_DEFAULT_SEARCH_PATHS_IN_SWIFT_INCLUDE_PATHS,
1670-
ENABLE_BITCODE,
16711666
ENABLE_CLOUD_SIGNING,
16721667
ENABLE_GENERIC_TASK_CACHING,
16731668
GENERIC_TASK_CACHE_ENABLE_DIAGNOSTIC_REMARKS,
@@ -1863,7 +1858,6 @@ public final class BuiltinMacros {
18631858
LAUNCH_CONSTRAINT_SELF,
18641859
LD,
18651860
LDPLUSPLUS,
1866-
LD_BITCODE_GENERATION_MODE,
18671861
LD_CLIENT_NAME,
18681862
LD_DEPENDENCY_INFO_FILE,
18691863
LD_DYLIB_INSTALL_NAME,

Sources/SWBCore/Settings/Settings.swift

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,7 +2617,7 @@ private class SettingsBuilder {
26172617
// FIXME: Why is this logic not part of loading the SDK in SDKRegistry.registerSDK()? I think all of the information currently used by this method should be available there.
26182618
func addPlatformSDKSettings(_ platform: Platform?, _ sdk: SDK, _ sdkVariant: SDKVariant?) {
26192619
pushTable(.exported) { table in
2620-
// bitcode
2620+
// Bitcode is no longer supported, so we want to continue to strip bitcode from non-simulator embedded platforms as we always have.
26212621
if let platform, !platform.isSimulator, platform.correspondingSimulatorPlatformName != nil {
26222622
table.push(BuiltinMacros.STRIP_BITCODE_FROM_COPIED_FILES, literal: true)
26232623
}
@@ -4093,12 +4093,6 @@ private class SettingsBuilder {
40934093
// Determine a preferred architecture for indexing, single-file actions, and the static analyzer.
40944094
self.preferredArch = getPreferredArch(effectiveArchs)
40954095

4096-
// For installation and deployment, we need to generate proper bitcode: -fembed-bitcode/-embed-bitcode.
4097-
// NOTE! Do not simply check DEPLOYMENT_POSTPROCESSING as it may not be in-scope yet.
4098-
if parameters.action.isInstallAction || scope.evaluate(BuiltinMacros.DEPLOYMENT_POSTPROCESSING) {
4099-
table.push(BuiltinMacros.BITCODE_GENERATION_MODE, literal: "bitcode")
4100-
}
4101-
41024096
// Set `ARCHS` to the list of architectures we ended up with, and save the original value.
41034097
table.push(BuiltinMacros.__ARCHS__, literal: originalArchs)
41044098
table.push(BuiltinMacros.ARCHS, literal: effectiveArchs.removingDuplicates())
@@ -4117,10 +4111,6 @@ private class SettingsBuilder {
41174111
table.push(BuiltinMacros.__SWIFT_MODULE_ONLY_ARCHS__, literal: originalModuleOnlyArchs)
41184112
table.push(BuiltinMacros.SWIFT_MODULE_ONLY_ARCHS, literal: moduleOnlyArchs)
41194113

4120-
if (scope.evaluate(BuiltinMacros.ENABLE_TESTING_SEARCH_PATHS) && project?.isPackage != true) || !["iphoneos", "appletvos", "watchos"].contains(specLookupContext.platform?.name) {
4121-
table.push(BuiltinMacros.ENABLE_BITCODE, literal: false)
4122-
}
4123-
41244114
// FIXME: There is a more random, but questionable stuff here. To be added in a test case driven fashion.
41254115

41264116
// Resolve some of the key path settings to be absolute.
@@ -4200,21 +4190,6 @@ private class SettingsBuilder {
42004190
}))
42014191
}
42024192

4203-
// Bitcode support was deprecated in Xcode 14 and is being turned off by default in Xcode 15, but there is a user default which can enable it.
4204-
if scope.evaluate(BuiltinMacros.ENABLE_BITCODE) {
4205-
if UserDefaults.enableBitcodeSupport {
4206-
// If we're going to generate bitcode, then symbol editing must be done by the linker, not by a separate nmedit invocation.
4207-
table.push(BuiltinMacros.SEPARATE_SYMBOL_EDIT, literal: false)
4208-
4209-
self.targetDiagnostics.append(Diagnostic(behavior: .warning, location: .buildSetting(BuiltinMacros.ENABLE_BITCODE), data: DiagnosticData("Building with bitcode is deprecated. Please update your project and/or target settings to disable bitcode.")))
4210-
}
4211-
else {
4212-
table.push(BuiltinMacros.ENABLE_BITCODE, literal: false)
4213-
4214-
self.targetDiagnostics.append(Diagnostic(behavior: .warning, location: .buildSetting(BuiltinMacros.ENABLE_BITCODE), data: DiagnosticData("Ignoring ENABLE_BITCODE because building with bitcode is no longer supported.")))
4215-
}
4216-
}
4217-
42184193
// If testability is enabled, then that overrides certain other settings, and in a way that the user cannot override: They're either using testability, or they're not.
42194194
if scope.evaluate(BuiltinMacros.ENABLE_TESTABILITY) {
42204195
table.push(BuiltinMacros.GCC_SYMBOLS_PRIVATE_EXTERN, literal: false)

Sources/SWBCore/SpecImplementations/Tools/CopyTool.swift

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ public final class CopyToolSpec : CompilerSpec, SpecIdentifierType, @unchecked S
4242
let outputPath = cbc.output
4343

4444
// Lookup function for computing the command line.
45-
let enableBitcode = cbc.scope.evaluate(BuiltinMacros.ENABLE_BITCODE)
46-
let bitcodeGenerationMode = cbc.scope.evaluate(BuiltinMacros.BITCODE_GENERATION_MODE)
4745
func lookup(_ macro: MacroDeclaration) -> MacroExpression? {
4846
switch macro {
4947
case BuiltinMacros.COPY_PHASE_STRIP, BuiltinMacros.PBXCP_STRIP_UNSIGNED_BINARIES:
@@ -63,41 +61,22 @@ public final class CopyToolSpec : CompilerSpec, SpecIdentifierType, @unchecked S
6361
guard stripBitcode else {
6462
return nil
6563
}
66-
// If we have been directed to strip bitcode, and bitcode is either disabled or is turned to a level less than 'bitcode' (i.e., less than full bitcode), then we should strip bitcode from binaries we copy.
67-
if !enableBitcode || bitcodeGenerationMode != "bitcode" {
68-
return Static { cbc.scope.namespace.parseLiteralString("YES") } as MacroStringExpression
69-
}
70-
return nil
64+
// Always strip all bitcode.
65+
return Static { cbc.scope.namespace.parseLiteralString("YES") } as MacroStringExpression
7166
case BuiltinMacros.PBXCP_BITCODE_STRIP_MODE:
7267
guard stripBitcode else {
7368
return nil
7469
}
75-
if !enableBitcode {
76-
// If bitcode is not enabled then strip all bitcode.
77-
return Static { cbc.scope.namespace.parseLiteralString("all") } as MacroStringExpression
78-
}
79-
else if bitcodeGenerationMode != "bitcode" {
80-
// If bitcode level is less than full, then strip bitcode.
81-
if bitcodeGenerationMode == "marker" {
82-
// If bitcode is enabled but to generate the marker, then strip down to a marker.
83-
return Static { cbc.scope.namespace.parseLiteralString("replace-with-marker") } as MacroStringExpression
84-
}
85-
else {
86-
// Otherwise strip all bitcode.
87-
return Static { cbc.scope.namespace.parseLiteralString("all") } as MacroStringExpression
88-
}
89-
}
90-
return nil
70+
// Always strip all bitcode.
71+
return Static { cbc.scope.namespace.parseLiteralString("all") } as MacroStringExpression
9172
case BuiltinMacros.PBXCP_BITCODE_STRIP_TOOL:
9273
guard stripBitcode else {
9374
return nil
9475
}
9576
// FIXME: We should change the .xcspec file to make this setting conditional on $(PBXCP_STRIP_BITCODE). Then we can just always generate this value.
96-
if !enableBitcode || bitcodeGenerationMode != "bitcode" {
97-
// Find bitcode_strip in our effective toolchains.
98-
if let bitcodeStripPath = cbc.producer.toolchains.lazy.compactMap({ $0.executableSearchPaths.lookup(Path("bitcode_strip")) }).first {
99-
return cbc.scope.namespace.parseLiteralString(bitcodeStripPath.str) as MacroStringExpression
100-
}
77+
// Find bitcode_strip in our effective toolchains.
78+
if let bitcodeStripPath = cbc.producer.toolchains.lazy.compactMap({ $0.executableSearchPaths.lookup(Path("bitcode_strip")) }).first {
79+
return cbc.scope.namespace.parseLiteralString(bitcodeStripPath.str) as MacroStringExpression
10180
}
10281
return nil
10382
case BuiltinMacros.PBXCP_EXCLUDE_SUBPATHS:

Sources/SWBCore/SpecImplementations/Tools/LinkerTools.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -970,14 +970,14 @@ public final class LdLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @unchec
970970
let argPrefix = "-Xlinker"
971971

972972
// Args without parameters
973-
for arg in ["-dynamiclib", "-bundle", "-r", "-fembed-bitcode-marker", "-dead_strip", "-nostdlib", "-rdynamic"] {
973+
for arg in ["-dynamiclib", "-bundle", "-r", "-dead_strip", "-nostdlib", "-rdynamic"] {
974974
while let index = commandLine.firstIndex(of: arg) {
975975
commandLine.remove(at: index)
976976
}
977977
}
978978

979979
// Args without parameters (-Xlinker-prefixed, e.g. -Xlinker)
980-
for arg in ["-bitcode_verify", "-export_dynamic", "-sdk_imports_each_object"] {
980+
for arg in ["-export_dynamic", "-sdk_imports_each_object"] {
981981
while let index = commandLine.firstIndex(of: arg) {
982982
guard index > 0, commandLine[index - 1] == argPrefix else { break }
983983
commandLine.removeSubrange(index - 1 ... index)
@@ -996,7 +996,7 @@ public final class LdLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @unchec
996996
}
997997

998998
// Args with a parameter (-Xlinker-prefixed, e.g. -Xlinker arg -Xlinker param)
999-
for arg in ["-object_path_lto", "-add_ast_path", "-dependency_info", "-map", "-order_file", "-bitcode_symbol_map", "-final_output", "-allowable_client", "-sdk_imports"] {
999+
for arg in ["-object_path_lto", "-add_ast_path", "-dependency_info", "-map", "-order_file", "-final_output", "-allowable_client", "-sdk_imports"] {
10001000
while let index = commandLine.firstIndex(of: arg) {
10011001
guard index > 0,
10021002
index + 2 < commandLine.count,

Sources/SWBCore/SpecImplementations/Tools/MasterObjectLink.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,6 @@ final class MasterObjectLinkSpec: CommandLineToolSpec, SpecImplementationType, @
3434
var commandLine = [toolSpecInfo.toolPath.str]
3535
commandLine += ["-r", "-arch", arch]
3636

37-
let supportsBitcode = await !cbc.producer.ldLinkerSpec.commandLineFromMacroDeclaration(cbc, delegate, optionContext: toolSpecInfo, BuiltinMacros.LD_BITCODE_GENERATION_MODE).isEmpty
38-
39-
if cbc.scope.evaluate(BuiltinMacros.ENABLE_BITCODE) && supportsBitcode {
40-
// LD_BITCODE_GENERATION_MODE is the linker setting which controls passing bitcode options to the linker; but since we're invoking the linker directly here, rather than the compiler driver, we pass -bitcode_bundle rather than -fembed-bitcode*.
41-
commandLine += ["-bitcode_bundle"]
42-
43-
// If we're generating full bitcode, then we also want to pass -bitcode_verify to make sure all the objects it links against also contain full bitcode.
44-
if cbc.scope.evaluate(BuiltinMacros.BITCODE_GENERATION_MODE) == "bitcode" {
45-
commandLine += ["-bitcode_verify"]
46-
}
47-
}
48-
4937
// We do not pass the deployment target to the linker here. Instead the linker infers the platform and deployment target from the .o files being collected. We did briefly pass it to the linker to silence a linker warning - if we ever see issues here we should confer with the linker folks to make sure we do the right thing. See <rdar://problem/51800525> for more about the history here.
5038

5139
let sysroot = cbc.scope.evaluate(BuiltinMacros.SDK_DIR)

Sources/SWBCore/SpecImplementations/Tools/SwiftCompiler.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,12 +3061,6 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
30613061
fileMapEntry.indexUnitOutputPath = indexObjectPath.str
30623062
}
30633063
}
3064-
let objectFilePrefix = objectFilePath.basenameWithoutSuffix
3065-
// The bitcode file.
3066-
if compilationMode.compileSources {
3067-
let bitcodeFilePath = objectFileDir.join(objectFilePrefix + ".bc")
3068-
fileMapEntry.llvmBitcode = bitcodeFilePath.str
3069-
}
30703064
return (objectFilePath, fileMapEntry)
30713065
}
30723066

@@ -3309,10 +3303,6 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
33093303
"-O",
33103304
"-Osize",
33113305

3312-
// _Very_ deprecated, but continuing to strip for backwards compatibility
3313-
"-embed-bitcode",
3314-
"-embed-bitcode-marker",
3315-
33163306
// Previews does not use compiler output
33173307
"-parseable-output",
33183308
"-use-frontend-parseable-output",
@@ -3784,7 +3774,6 @@ struct SwiftOutputFileMap: Codable {
37843774
struct Entry: Codable {
37853775
var object: String?
37863776
var indexUnitOutputPath: String?
3787-
var llvmBitcode: String?
37883777
var remap: String?
37893778
var diagnostics: String?
37903779
var emitModuleDiagnostics: String?
@@ -3798,7 +3787,6 @@ struct SwiftOutputFileMap: Codable {
37983787
enum CodingKeys: String, CodingKey {
37993788
case object
38003789
case indexUnitOutputPath = "index-unit-output-path"
3801-
case llvmBitcode = "llvm-bc"
38023790
case remap
38033791
case diagnostics
38043792
case emitModuleDiagnostics = "emit-module-diagnostics"

0 commit comments

Comments
 (0)