Skip to content

Revert "Inclusive language: rename master object file to prelinked object file" #457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/SWBCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ add_library(SWBCore
SpecImplementations/Tools/LaunchServicesRegisterTool.swift
SpecImplementations/Tools/LinkerTools.swift
SpecImplementations/Tools/Lipo.swift
SpecImplementations/Tools/MasterObjectLink.swift
SpecImplementations/Tools/MergeInfoPlist.swift
SpecImplementations/Tools/MkdirTool.swift
SpecImplementations/Tools/ModulesVerifierTool.swift
SpecImplementations/Tools/PLUtilTool.swift
SpecImplementations/Tools/PrelinkedObjectLink.swift
SpecImplementations/Tools/ProcessSDKImports.swift
SpecImplementations/Tools/ProcessXCFrameworkLibrary.swift
SpecImplementations/Tools/ProductPackaging.swift
Expand Down
4 changes: 2 additions & 2 deletions Sources/SWBCore/Settings/BuiltinMacros.swift
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ public final class BuiltinMacros {
public static let GENERATE_EMBED_IN_CODE_ACCESSORS = BuiltinMacros.declareBooleanMacro("GENERATE_EMBED_IN_CODE_ACCESSORS")
public static let GENERATE_INFOPLIST_FILE = BuiltinMacros.declareBooleanMacro("GENERATE_INFOPLIST_FILE")
public static let GENERATE_KERNEL_MODULE_INFO_FILE = BuiltinMacros.declareBooleanMacro("GENERATE_KERNEL_MODULE_INFO_FILE")
public static let GENERATE_PRELINK_OBJECT_FILE = BuiltinMacros.declareBooleanMacro("GENERATE_PRELINK_OBJECT_FILE")
public static let GENERATE_MASTER_OBJECT_FILE = BuiltinMacros.declareBooleanMacro("GENERATE_MASTER_OBJECT_FILE")
public static let GENERATE_PKGINFO_FILE = BuiltinMacros.declareBooleanMacro("GENERATE_PKGINFO_FILE")
public static let GENERATE_RESOURCE_ACCESSORS = BuiltinMacros.declareBooleanMacro("GENERATE_RESOURCE_ACCESSORS")
public static let GENERATE_TEST_ENTRY_POINT = BuiltinMacros.declareBooleanMacro("GENERATE_TEST_ENTRY_POINT")
Expand Down Expand Up @@ -1753,7 +1753,7 @@ public final class BuiltinMacros {
GENERATE_EMBED_IN_CODE_ACCESSORS,
GENERATE_INFOPLIST_FILE,
GENERATE_KERNEL_MODULE_INFO_FILE,
GENERATE_PRELINK_OBJECT_FILE,
GENERATE_MASTER_OBJECT_FILE,
GENERATE_PKGINFO_FILE,
GENERATE_RESOURCE_ACCESSORS,
GENERATE_TEST_ENTRY_POINT,
Expand Down
2 changes: 1 addition & 1 deletion Sources/SWBCore/SpecImplementations/RegisterSpecs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public struct BuiltinSpecsExtension: SpecificationsExtension {
ValidateDevelopmentAssets.self,
ConstructStubExecutorFileListToolSpec.self,
GateSpec.self,
PrelinkedObjectLinkSpec.self,
MasterObjectLinkSpec.self,
SetAttributesSpec.self,
WriteFileSpec.self,
SignatureCollectionSpec.self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
import SWBUtil
import SWBMacro

/// Spec to use the linker to run `ld -r` to create a prelinked object file.
public final class PrelinkedObjectLinkSpec: CommandLineToolSpec, SpecImplementationType, @unchecked Sendable {
public static let identifier = "com.apple.build-tools.prelinked-object-link"
/// Spec to use the linker to run `ld -r` to create a prelinked object file (a.k.a. "master object file").
final class MasterObjectLinkSpec: CommandLineToolSpec, SpecImplementationType, @unchecked Sendable {
static let identifier = "com.apple.build-tools.master-object-link"

public class func construct(registry: SpecRegistry, proxy: SpecProxy) -> Spec {
return PrelinkedObjectLinkSpec(registry, proxy, ruleInfoTemplate: [], commandLineTemplate: [])
class func construct(registry: SpecRegistry, proxy: SpecProxy) -> Spec {
return MasterObjectLinkSpec(registry, proxy, ruleInfoTemplate: [], commandLineTemplate: [])
}

public override func constructTasks(_ cbc: CommandBuildContext, _ delegate: any TaskGenerationDelegate) async {
override func constructTasks(_ cbc: CommandBuildContext, _ delegate: any TaskGenerationDelegate) async {
guard let toolSpecInfo = await cbc.producer.ldLinkerSpec.discoveredCommandLineToolSpecInfo(cbc.producer, cbc.scope, delegate) as? DiscoveredLdLinkerToolSpecInfo else {
delegate.error("Could not find path to ld binary")
return
Expand Down Expand Up @@ -62,14 +62,14 @@ public final class PrelinkedObjectLinkSpec: CommandLineToolSpec, SpecImplementat
commandLine += cbc.scope.evaluate(BuiltinMacros.PRELINK_FLAGS)
let warningLdFlags = cbc.scope.evaluate(BuiltinMacros.WARNING_LDFLAGS)
if !warningLdFlags.isEmpty {
// WARNING_LDFLAGS for some reason is only used for creating the prelinked object file.
// WARNING_LDFLAGS for some reason is only used for creating the master object file.
delegate.warning("WARNING_LDFLAGS is deprecated; use OTHER_LDFLAGS instead.", location: .buildSetting(BuiltinMacros.WARNING_LDFLAGS))
commandLine += warningLdFlags
}
commandLine += cbc.inputs.map({ $0.absolutePath.str })
commandLine += cbc.scope.evaluate(BuiltinMacros.PRELINK_LIBS)
commandLine += ["-o", outputPath.str]

delegate.createTask(type: self, ruleInfo: ["PrelinkedObjectLink", outputPath.str], commandLine: commandLine, environment: EnvironmentBindings(), workingDirectory: cbc.producer.defaultWorkingDirectory, inputs: cbc.inputs.map({ $0.absolutePath }), outputs: [outputPath], action: nil, execDescription: "Link \(outputPath.basename)", enableSandboxing: enableSandboxing)
delegate.createTask(type: self, ruleInfo: ["MasterObjectLink", outputPath.str], commandLine: commandLine, environment: EnvironmentBindings(), workingDirectory: cbc.producer.defaultWorkingDirectory, inputs: cbc.inputs.map({ $0.absolutePath }), outputs: [outputPath], action: nil, execDescription: "Link \(outputPath.basename)", enableSandboxing: enableSandboxing)
}
}
8 changes: 4 additions & 4 deletions Sources/SWBCore/Specs/CoreBuildSystem.xcspec
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,9 @@
};
},
{
Name = "GENERATE_PRELINK_OBJECT_FILE";
Name = "GENERATE_MASTER_OBJECT_FILE";
Type = bool;
DefaultValue = "$(GENERATE_MASTER_OBJECT_FILE:default=NO)"; // ignore-unacceptable-language; kept for compatibility
DefaultValue = NO;
},
{
Name = "PRELINK_LIBS";
Expand Down Expand Up @@ -1598,10 +1598,10 @@ When `GENERATE_INFOPLIST_FILE` is enabled, sets the value of the [CFBundleIdenti
);
},
{
Name = "GENERATE_PRELINK_OBJECT_FILE";
Name = "GENERATE_MASTER_OBJECT_FILE";
Type = Boolean;
Category = "Linking - General";
DefaultValue = "$(GENERATE_MASTER_OBJECT_FILE:default=NO)"; // ignore-unacceptable-language; kept for compatibility
DefaultValue = NO;
ConditionFlavors = (
arch,
sdk,
Expand Down
4 changes: 2 additions & 2 deletions Sources/SWBCore/Specs/en.lproj/CoreBuildSystem.strings
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ Generally you should not specify an order file in Debug or Development configura
"[LINKER_DISPLAYS_MANGLED_NAMES]-name" = "Display Mangled Names";
"[LINKER_DISPLAYS_MANGLED_NAMES]-description" = "Activating this setting causes the linker to display mangled names for C++ symbols. Normally, this is not recommended, but turning it on can help to diagnose and solve C++ link errors.";

"[GENERATE_PRELINK_OBJECT_FILE]-name" = "Perform Single-Object Prelink";
"[GENERATE_PRELINK_OBJECT_FILE]-description" = "Activating this setting will cause the object files built by a target to be prelinked using `ld -r` into a single object file, and that object file will then be linked into the final product. This is useful to force the linker to resolve symbols and link the object files into a single module before building a static library. Also, a separate set of link flags can be applied to the prelink allowing additional control over, for instance, exported symbols.";
"[GENERATE_MASTER_OBJECT_FILE]-name" = "Perform Single-Object Prelink";
"[GENERATE_MASTER_OBJECT_FILE]-description" = "Activating this setting will cause the object files built by a target to be prelinked using `ld -r` into a single object file, and that object file will then be linked into the final product. This is useful to force the linker to resolve symbols and link the object files into a single module before building a static library. Also, a separate set of link flags can be applied to the prelink allowing additional control over, for instance, exported symbols.";

"[PRELINK_LIBS]-name" = "Prelink libraries";
"[PRELINK_LIBS]-description" = "Additional libraries to pass when performing a single-object prelink.";
Expand Down
5 changes: 1 addition & 4 deletions Sources/SWBProjectModel/PIFGenerationModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ public enum PIF {
public var GCC_OPTIMIZATION_LEVEL: String?
public var GCC_PREPROCESSOR_DEFINITIONS: [String]?
public var GENERATE_EMBED_IN_CODE_ACCESSORS: String?
public var GENERATE_PRELINK_OBJECT_FILE: String?
public var GENERATE_MASTER_OBJECT_FILE: String?
public var GENERATE_RESOURCE_ACCESSORS: String?
public var HEADER_SEARCH_PATHS: [String]?
public var INFOPLIST_FILE: String?
Expand Down Expand Up @@ -1045,9 +1045,6 @@ public enum PIF {
public var USE_HEADERMAP: String?
public var USES_SWIFTPM_UNSAFE_FLAGS: String?
public var WATCHOS_DEPLOYMENT_TARGET: String?

@available(*, deprecated, renamed: "GENERATE_PRELINK_OBJECT_FILE")
public var GENERATE_MASTER_OBJECT_FILE: String? // ignore-unacceptable-language
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,14 +865,14 @@ final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, FilesBase
}
}

// Handle linking prelinked objects. Presently we always do this if GENERATE_PRELINK_OBJECT_FILE even if there are no other tasks, since PRELINK_LIBS or PRELINK_FLAGS might be set to values which will cause a prelinked object file to be generated.
// FIXME: The implicitly means that if GENERATE_PRELINK_OBJECT_FILE is enabled then we will always try to link. That's arguably not correct.
if !isForAPI && scope.evaluate(BuiltinMacros.GENERATE_PRELINK_OBJECT_FILE) {
let executableName = scope.evaluate(BuiltinMacros.EXECUTABLE_NAME) + "-" + arch + "-prelink.o"
// Handle linking master objects. Presently we always do this if GENERATE_MASTER_OBJECT_FILE even if there are no other tasks, since PRELINK_LIBS or PRELINK_FLAGS might be set to values which will cause a master object file to be generated.
// FIXME: The implicitly means that if GENERATE_MASTER_OBJECT_FILE is enabled then we will always try to link. That's arguably not correct.
if !isForAPI && scope.evaluate(BuiltinMacros.GENERATE_MASTER_OBJECT_FILE) {
let executableName = scope.evaluate(BuiltinMacros.EXECUTABLE_NAME) + "-" + arch + "-master.o"
// FIXME: It would be more consistent to put this in the per-arch directory.
let output = Path(scope.evaluate(BuiltinMacros.PER_VARIANT_OBJECT_FILE_DIR)).join(executableName)
await appendGeneratedTasks(&perArchTasks, options: [.linking, .linkingRequirement, .unsignedProductRequirement]) { delegate in
await context.prelinkedObjectLinkSpec.constructTasks(CommandBuildContext(producer: context, scope: scope, inputs: linkerInputNodes.map { FileToBuild(context: context, absolutePath: $0.path) }, output: output), delegate)
await context.masterObjectLinkSpec.constructTasks(CommandBuildContext(producer: context, scope: scope, inputs: linkerInputNodes.map { FileToBuild(context: context, absolutePath: $0.path) }, output: output), delegate)
}
linkerInputNodes = [context.createNode(output)]
}
Expand Down Expand Up @@ -912,7 +912,7 @@ final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, FilesBase
continue
}

// Create the linker task. If we have no input files but decide to create the task anyway, then this task will rely on gate tasks to be properly ordered (which is what happens for the prelinked object file task above if there are no input files).
// Create the linker task. If we have no input files but decide to create the task anyway, then this task will rely on gate tasks to be properly ordered (which is what happens for the master object file task above if there are no input files).
if !linkerInputNodes.isEmpty || (components.contains("build") && scope.evaluate(BuiltinMacros.MERGE_LINKED_LIBRARIES)) {
// Compute the output path.
let output: Path
Expand Down
10 changes: 5 additions & 5 deletions Sources/SWBTaskConstruction/TaskProducers/TaskProducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public class TaskProducerContext: StaleFileRemovalContext, BuildFileResolution
public let ldLinkerSpec: LdLinkerSpec
public let libtoolLinkerSpec: LibtoolLinkerSpec
public let lipoSpec: LipoToolSpec
let prelinkedObjectLinkSpec: CommandLineToolSpec
let masterObjectLinkSpec: CommandLineToolSpec
public let mkdirSpec: MkdirToolSpec
let modulesVerifierSpec: ModulesVerifierToolSpec
let clangModuleVerifierInputGeneratorSpec: ClangModuleVerifierInputGeneratorSpec
Expand Down Expand Up @@ -354,7 +354,7 @@ public class TaskProducerContext: StaleFileRemovalContext, BuildFileResolution
self.ldLinkerSpec = try! workspaceContext.core.specRegistry.getSpec(domain: domain) as LdLinkerSpec
self.libtoolLinkerSpec = try! workspaceContext.core.specRegistry.getSpec(domain: domain) as LibtoolLinkerSpec
self.lipoSpec = workspaceContext.core.specRegistry.getSpec("com.apple.xcode.linkers.lipo", domain: domain) as! LipoToolSpec
self.prelinkedObjectLinkSpec = workspaceContext.core.specRegistry.getSpec(PrelinkedObjectLinkSpec.identifier, domain: domain) as! CommandLineToolSpec
self.masterObjectLinkSpec = workspaceContext.core.specRegistry.getSpec("com.apple.build-tools.master-object-link", domain: domain) as! CommandLineToolSpec
self.mkdirSpec = workspaceContext.core.specRegistry.getSpec("com.apple.tools.mkdir", domain: domain) as! MkdirToolSpec
self.modulesVerifierSpec = workspaceContext.core.specRegistry.getSpec("com.apple.build-tools.modules-verifier", domain: domain) as! ModulesVerifierToolSpec
self.clangModuleVerifierInputGeneratorSpec = workspaceContext.core.specRegistry.getSpec("com.apple.build-tools.module-verifier-input-generator", domain: domain) as! ClangModuleVerifierInputGeneratorSpec
Expand Down Expand Up @@ -724,9 +724,9 @@ public class TaskProducerContext: StaleFileRemovalContext, BuildFileResolution
return false
}

// If this target is generating a prelinked object file, then we assume it will produce a binary.
// FIXME: This is nasty. See SourcesTaskProducer.generateTasks() for handling of GENERATE_PRELINK_OBJECT_FILE.
guard !scope.evaluate(BuiltinMacros.GENERATE_PRELINK_OBJECT_FILE) else {
// If this target is generating a master object file, then we assume it will produce a binary.
// FIXME: This is nasty. See SourcesTaskProducer.generateTasks() for handling of GENERATE_MASTER_OBJECT_FILE.
guard !scope.evaluate(BuiltinMacros.GENERATE_MASTER_OBJECT_FILE) else {
return true
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftBuild/ProjectModel/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extension ProjectModel {
case GENERATE_INFOPLIST_FILE
case GCC_C_LANGUAGE_STANDARD
case GCC_OPTIMIZATION_LEVEL
case GENERATE_PRELINK_OBJECT_FILE
case GENERATE_MASTER_OBJECT_FILE
case INFOPLIST_FILE
case IPHONEOS_DEPLOYMENT_TARGET
case KEEP_PRIVATE_EXTERNS
Expand Down
Loading