Skip to content

Merge main into rebranch to pick up missing content #1693

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

Merged
merged 14 commits into from
Sep 12, 2024
Merged
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 Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
// The 'swift-argument-parser' version declared here must match that
// used by 'swift-package-manager' and 'sourcekit-lsp'. Please coordinate
// dependency version changes here with those projects.
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "1.4.0")),
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.4.0"),
]
} else {
package.dependencies += [
Expand Down
17 changes: 13 additions & 4 deletions Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2929,10 +2929,19 @@ extension Diagnostic.Message {
extension Driver {
static func validateWarningControlArgs(_ parsedOptions: inout ParsedOptions,
diagnosticEngine: DiagnosticsEngine) {
if parsedOptions.hasArgument(.suppressWarnings) &&
parsedOptions.hasFlag(positive: .warningsAsErrors, negative: .noWarningsAsErrors, default: false) {
diagnosticEngine.emit(.error(Error.conflictingOptions(.warningsAsErrors, .suppressWarnings)),
location: nil)
if parsedOptions.hasArgument(.suppressWarnings) {
if parsedOptions.hasFlag(positive: .warningsAsErrors, negative: .noWarningsAsErrors, default: false) {
diagnosticEngine.emit(.error(Error.conflictingOptions(.warningsAsErrors, .suppressWarnings)),
location: nil)
}
if parsedOptions.hasArgument(.Wwarning) {
diagnosticEngine.emit(.error(Error.conflictingOptions(.Wwarning, .suppressWarnings)),
location: nil)
}
if parsedOptions.hasArgument(.Werror) {
diagnosticEngine.emit(.error(Error.conflictingOptions(.Werror, .suppressWarnings)),
location: nil)
}
}
}

Expand Down
9 changes: 5 additions & 4 deletions Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ extension Driver {
// Add flags for C++ interop
try commandLine.appendLast(.enableExperimentalCxxInterop, from: &parsedOptions)
try commandLine.appendLast(.cxxInteroperabilityMode, from: &parsedOptions)
if let stdlibVariant = parsedOptions.getLastArgument(.experimentalCxxStdlib)?.asSingle {
appendXccFlag("-stdlib=\(stdlibVariant)")
}

if isEmbeddedEnabled && parsedOptions.hasArgument(.enableLibraryEvolution) {
diagnosticEngine.emit(.error_no_library_evolution_embedded)
Expand Down Expand Up @@ -228,7 +225,11 @@ extension Driver {
try commandLine.appendLast(.profileGenerate, from: &parsedOptions)
try commandLine.appendLast(.profileUse, from: &parsedOptions)
try commandLine.appendLast(.profileCoverageMapping, from: &parsedOptions)
try commandLine.appendLast(.warningsAsErrors, .noWarningsAsErrors, from: &parsedOptions)
try commandLine.appendAllExcept(
includeList: [.warningTreating],
excludeList: [],
from: &parsedOptions
)
try commandLine.appendLast(.sanitizeEQ, from: &parsedOptions)
try commandLine.appendLast(.sanitizeRecoverEQ, from: &parsedOptions)
try commandLine.appendLast(.sanitizeAddressUseOdrIndicator, from: &parsedOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ extension GenericUnixToolchain {

if targetTriple.environment == .android {
if let sysroot = parsedOptions.getLastArgument(.sysroot)?.asSingle {
commandLine.appendFlag("-sysroot")
commandLine.appendFlag("--sysroot")
try commandLine.appendPath(VirtualPath(path: sysroot))
} else if let sysroot = AndroidNDK.getDefaultSysrootPath(in: self.env) {
commandLine.appendFlag("-sysroot")
commandLine.appendFlag("--sysroot")
try commandLine.appendPath(VirtualPath(path: sysroot.pathString))
}
} else if let path = targetInfo.sdkPath?.path {
Expand Down Expand Up @@ -285,9 +285,10 @@ extension GenericUnixToolchain {
}

if parsedOptions.hasArgument(.profileGenerate) {
let environment = (targetTriple.environment == .android) ? "-android" : ""
let libProfile = VirtualPath.lookup(targetInfo.runtimeResourcePath.path)
.appending(components: "clang", "lib", targetTriple.osName,
"libclang_rt.profile-\(targetTriple.archName).a")
"libclang_rt.profile-\(targetTriple.archName)\(environment).a")
commandLine.appendPath(libProfile)

// HACK: Hard-coded from llvm::getInstrProfRuntimeHookVarName()
Expand Down
4 changes: 0 additions & 4 deletions Sources/SwiftDriver/Jobs/WindowsToolchain+LinkerSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,6 @@ extension WindowsToolchain {
commandLine.appendPath(VirtualPath.lookup(sdkPath))
}

if let stdlib = parsedOptions.getLastArgument(.experimentalCxxStdlib) {
commandLine.appendFlag("-stdlib=\(stdlib.asSingle)")
}

// Pass down an optimization level
if let optArg = mapOptimizationLevelToClangArg(from: &parsedOptions) {
commandLine.appendFlag(optArg)
Expand Down
9 changes: 0 additions & 9 deletions Sources/SwiftDriver/Toolchains/DarwinToolchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ public final class DarwinToolchain: Toolchain {
case argumentNotSupported(String)
case invalidDeploymentTargetForIR(platform: DarwinPlatform, version: Triple.Version, archName: String)
case unsupportedTargetVariant(variant: Triple)
case darwinOnlySupportsLibCxx

public var description: String {
switch self {
Expand All @@ -177,8 +176,6 @@ public final class DarwinToolchain: Toolchain {
return "unsupported '\(variant.isiOS ? "-target-variant" : "-target")' value '\(variant.triple)'; use 'ios-macabi' instead"
case .argumentNotSupported(let argument):
return "\(argument) is no longer supported for Apple platforms"
case .darwinOnlySupportsLibCxx:
return "The only C++ standard library supported on Apple platforms is libc++"
}
}
}
Expand Down Expand Up @@ -211,12 +208,6 @@ public final class DarwinToolchain: Toolchain {
if parsedOptions.hasArgument(.staticExecutable) {
throw ToolchainValidationError.argumentNotSupported("-static-executable")
}
// If a C++ standard library is specified, it has to be libc++.
if let cxxLib = parsedOptions.getLastArgument(.experimentalCxxStdlib) {
if cxxLib.asSingle != "libc++" {
throw ToolchainValidationError.darwinOnlySupportsLibCxx
}
}
}

public func getDefaultDwarfVersion(targetTriple: Triple) -> UInt8 {
Expand Down
17 changes: 13 additions & 4 deletions Sources/SwiftOptions/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ extension Option {
public static let experimentalAllowedReexportedModules: Option = Option("-experimental-allowed-reexported-modules=", .commaJoined, attributes: [.noDriver], helpText: "Allow reexporting symbols from the provided modules if they are themselves exported from the main module. This is a comma separated list of module names.")
public static let experimentalCForeignReferenceTypes: Option = Option("-experimental-c-foreign-reference-types", .flag, attributes: [.helpHidden, .frontend, .moduleInterface], helpText: "Enable experimental C foreign references types (with reference counting).")
public static let experimentalClangImporterDirectCc1Scan: Option = Option("-experimental-clang-importer-direct-cc1-scan", .flag, attributes: [.helpHidden, .frontend], helpText: "Enables swift driver to construct swift-frontend invocations using -direct-clang-cc1-module-build")
public static let experimentalCxxStdlib: Option = Option("-experimental-cxx-stdlib", .separate, attributes: [.helpHidden], helpText: "C++ standard library to use; forwarded to Clang's -stdlib flag")
public static let emitModuleSeparately: Option = Option("-experimental-emit-module-separately", .flag, attributes: [.helpHidden], helpText: "Emit module files as a distinct job")
public static let driverExperimentalExplicitModuleBuild: Option = Option("-experimental-explicit-module-build", .flag, alias: Option.driverExplicitModuleBuild, attributes: [.helpHidden], helpText: "Prebuild module dependencies to make them explicit")
public static let forceWorkaroundBrokenModules: Option = Option("-experimental-force-workaround-broken-modules", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Attempt unsafe recovery for imported modules with broken modularization")
Expand Down Expand Up @@ -584,6 +583,7 @@ extension Option {
public static let json_: Option = Option("--json", .flag, alias: Option.json, attributes: [.noDriver], helpText: "Print output in JSON format.")
public static let j: Option = Option("-j", .joinedOrSeparate, attributes: [.doesNotAffectIncrementalBuild], metaVar: "<n>", helpText: "Number of commands to execute in parallel")
public static let LEQ: Option = Option("-L=", .joined, alias: Option.L, attributes: [.frontend, .doesNotAffectIncrementalBuild, .argumentIsPath], group: .linkerOption)
public static let languageMode: Option = Option("-language-mode", .separate, alias: Option.swiftVersion, attributes: [.frontend, .moduleInterface], metaVar: "<mode>", helpText: "Interpret input according to a specific Swift language mode")
public static let ldPath: Option = Option("-ld-path=", .joined, attributes: [.helpHidden, .doesNotAffectIncrementalBuild, .argumentIsPath], helpText: "Specifies the path to the linker to be used")
public static let libc: Option = Option("-libc", .separate, attributes: [], helpText: "libc runtime library to use")
public static let libraryLevelEQ: Option = Option("-library-level=", .joined, alias: Option.libraryLevel, attributes: [.helpHidden, .frontend, .moduleInterface], metaVar: "<level>")
Expand Down Expand Up @@ -640,7 +640,7 @@ extension Option {
public static let noStrictImplicitModuleContext: Option = Option("-no-strict-implicit-module-context", .flag, attributes: [.helpHidden, .frontend], helpText: "Disable the strict forwarding of compilation context to downstream implicit module dependencies")
public static let noToolchainStdlibRpath: Option = Option("-no-toolchain-stdlib-rpath", .flag, attributes: [.helpHidden, .doesNotAffectIncrementalBuild], helpText: "Do not add an rpath entry for the toolchain's standard library (default)")
public static let noVerifyEmittedModuleInterface: Option = Option("-no-verify-emitted-module-interface", .flag, attributes: [.frontend, .noInteractive, .doesNotAffectIncrementalBuild], helpText: "Don't check that module interfaces emitted during compilation typecheck")
public static let noWarningsAsErrors: Option = Option("-no-warnings-as-errors", .flag, attributes: [.frontend], helpText: "Don't treat warnings as errors")
public static let noWarningsAsErrors: Option = Option("-no-warnings-as-errors", .flag, attributes: [.frontend], helpText: "Treat warnings as warnings", group: .warningTreating)
public static let noWholeModuleOptimization: Option = Option("-no-whole-module-optimization", .flag, attributes: [.frontend, .noInteractive], helpText: "Disable optimizing input files together instead of individually")
public static let driverScanDependenciesNonLib: Option = Option("-nonlib-dependency-scanner", .flag, attributes: [.helpHidden], helpText: "Use calls to `swift-frontend -scan-dependencies` instead of dedicated dependency scanning library")
public static let nostartfiles: Option = Option("-nostartfiles", .flag, attributes: [.helpHidden, .frontend, .noInteractive, .doesNotAffectIncrementalBuild], helpText: "Do not link in the Swift language startup routines")
Expand Down Expand Up @@ -872,14 +872,16 @@ extension Option {
public static let warnSwift3ObjcInferenceComplete: Option = Option("-warn-swift3-objc-inference-complete", .flag, attributes: [.helpHidden, .frontend, .doesNotAffectIncrementalBuild], helpText: "Deprecated, has no effect")
public static let warnSwift3ObjcInferenceMinimal: Option = Option("-warn-swift3-objc-inference-minimal", .flag, attributes: [.helpHidden, .frontend, .doesNotAffectIncrementalBuild], helpText: "Deprecated, has no effect")
public static let warnSwift3ObjcInference: Option = Option("-warn-swift3-objc-inference", .flag, alias: Option.warnSwift3ObjcInferenceComplete, attributes: [.helpHidden, .frontend, .doesNotAffectIncrementalBuild])
public static let warningsAsErrors: Option = Option("-warnings-as-errors", .flag, attributes: [.frontend], helpText: "Treat warnings as errors")
public static let warningsAsErrors: Option = Option("-warnings-as-errors", .flag, attributes: [.frontend], helpText: "Treat warnings as errors", group: .warningTreating)
public static let weakLinkAtTarget: Option = Option("-weak-link-at-target", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Weakly link symbols for declarations that were introduced at the deployment target. Symbols introduced before the deployment target are still strongly linked.")
public static let Werror: Option = Option("-Werror", .separate, attributes: [.helpHidden, .frontend], metaVar: "<diagnostic_group>", helpText: "Treat this warning group as error", group: .warningTreating)
public static let wholeModuleOptimization: Option = Option("-whole-module-optimization", .flag, attributes: [.frontend, .noInteractive], helpText: "Optimize input files together instead of individually")
public static let windowsSdkRoot: Option = Option("-windows-sdk-root", .separate, attributes: [.frontend, .argumentIsPath], metaVar: "<root>", helpText: "Windows SDK Root")
public static let windowsSdkVersion: Option = Option("-windows-sdk-version", .separate, attributes: [.frontend], metaVar: "<version>", helpText: "Windows SDK Version")
public static let wmo: Option = Option("-wmo", .flag, alias: Option.wholeModuleOptimization, attributes: [.helpHidden, .frontend, .noInteractive])
public static let workingDirectoryEQ: Option = Option("-working-directory=", .joined, alias: Option.workingDirectory)
public static let workingDirectory: Option = Option("-working-directory", .separate, metaVar: "<path>", helpText: "Resolve file paths relative to the specified directory")
public static let Wwarning: Option = Option("-Wwarning", .separate, attributes: [.helpHidden, .frontend], metaVar: "<diagnostic_group>", helpText: "Treat this warning group as warning", group: .warningTreating)
public static let Xcc: Option = Option("-Xcc", .separate, attributes: [.frontend], metaVar: "<arg>", helpText: "Pass <arg> to the C/C++/Objective-C compiler")
public static let XclangLinker: Option = Option("-Xclang-linker", .separate, attributes: [.helpHidden], metaVar: "<arg>", helpText: "Pass <arg> to Clang when it is use for linking.")
public static let Xfrontend: Option = Option("-Xfrontend", .separate, attributes: [.helpHidden], metaVar: "<arg>", helpText: "Pass <arg> to the Swift frontend")
Expand Down Expand Up @@ -1351,7 +1353,6 @@ extension Option {
Option.experimentalAllowedReexportedModules,
Option.experimentalCForeignReferenceTypes,
Option.experimentalClangImporterDirectCc1Scan,
Option.experimentalCxxStdlib,
Option.emitModuleSeparately,
Option.driverExperimentalExplicitModuleBuild,
Option.forceWorkaroundBrokenModules,
Expand Down Expand Up @@ -1457,6 +1458,7 @@ extension Option {
Option.json_,
Option.j,
Option.LEQ,
Option.languageMode,
Option.ldPath,
Option.libc,
Option.libraryLevelEQ,
Expand Down Expand Up @@ -1747,12 +1749,14 @@ extension Option {
Option.warnSwift3ObjcInference,
Option.warningsAsErrors,
Option.weakLinkAtTarget,
Option.Werror,
Option.wholeModuleOptimization,
Option.windowsSdkRoot,
Option.windowsSdkVersion,
Option.wmo,
Option.workingDirectoryEQ,
Option.workingDirectory,
Option.Wwarning,
Option.Xcc,
Option.XclangLinker,
Option.Xfrontend,
Expand All @@ -1774,6 +1778,7 @@ extension Option {
case linkerOption
case modes
case pluginSearch
case warningTreating
}
}

Expand All @@ -1798,6 +1803,8 @@ extension Option.Group {
return "<mode options>"
case .pluginSearch:
return "<plugin search options>"
case .warningTreating:
return "<options to control warning treating>"
}
}
}
Expand All @@ -1823,6 +1830,8 @@ extension Option.Group {
return "MODES"
case .pluginSearch:
return nil
case .warningTreating:
return nil
}
}
}
2 changes: 1 addition & 1 deletion TestInputs/ExplicitModuleBuilds/CHeaders/G.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000
#include "X.h"
#endif

Expand Down
Loading