Skip to content
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
10 changes: 4 additions & 6 deletions Sources/SwiftDriver/Utilities/System.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,15 @@ func quoteArgument(_ argument: String) -> String {
#if canImport(Darwin) || os(Linux) || os(Android) || os(OpenBSD) || os(FreeBSD)
// Adapted from llvm::sys::commandLineFitsWithinSystemLimits.
func commandLineFitsWithinSystemLimits(path: String, args: [String]) -> Bool {
let upperBound = sysconf(Int32(_SC_ARG_MAX))
guard upperBound != -1 else {
let systemLimit = sysconf(Int32(_SC_ARG_MAX))
guard systemLimit != -1 else {
// The system reports no limit.
return true
}
// The lower bound for ARG_MAX on a POSIX system
let lowerBound = Int(_POSIX_ARG_MAX)
// This the same baseline used by xargs.
let baseline = 128 * 1024
let posixLimit = Int(_POSIX_ARG_MAX)

var effectiveArgMax = max(min(baseline, upperBound), lowerBound)
var effectiveArgMax = max(systemLimit, posixLimit)
// Conservatively assume environment variables consume half the space.
effectiveArgMax /= 2

Expand Down
4 changes: 2 additions & 2 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ final class SwiftDriverTests: XCTestCase {
}

func testUsingResponseFiles() throws {
let manyArgs = (1...20000).map { "-DTEST_\($0)" }
let manyArgs = (1...200000).map { "-DTEST_\($0)" }
// Needs response file
do {
let source = try AbsolutePath(validating: "/foo.swift")
Expand Down Expand Up @@ -1879,7 +1879,7 @@ final class SwiftDriverTests: XCTestCase {
// The jobs below often take large command lines (e.g., when passing a large number of Clang
// modules to Swift). Ensure that they don't regress in their ability to pass response files
// from the driver to the frontend.
let manyArgs = (1...20000).map { "-DTEST_\($0)" }
let manyArgs = (1...200000).map { "-DTEST_\($0)" }

// Compile + separate emit module job
do {
Expand Down