Skip to content
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

Fix possible build errors from ENABLE_THREAD_SANITIZER=YES #2085

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions Source/XCDBLD/BuildArguments.swift
Expand Up @@ -90,6 +90,13 @@ public struct BuildArguments {
if sdk != .macOSX {
args += [ "-sdk", sdk.rawValue ]
}

// Thread Sanitizer isn't supported on other than macOS devices
// If ENABLE_THREAD_SANITIZER=YES passed through env, it will lead
// to error.
if [ .iPhoneOS, .watchOS, .tvOS ].contains(sdk) {
args += [ "ENABLE_THREAD_SANITIZER=NO" ]
}
}

if let toolchain = toolchain {
Expand Down
36 changes: 23 additions & 13 deletions Tests/XCDBLDTests/BuildArgumentsSpec.swift
Expand Up @@ -66,21 +66,31 @@ class BuildArgumentsSpec: QuickSpec {
}

describe("specifying the sdk") {
for sdk in SDK.allSDKs.subtracting([.macOSX]) {
itCreatesBuildArguments("includes \(sdk) in the argument if specified", arguments: ["-sdk", sdk.rawValue]) { subject in
subject.sdk = sdk
for sdk in SDK.allSDKs {
switch sdk {
case .macOSX:
// Passing in -sdk macosx appears to break implicit dependency
// resolution (see Carthage/Carthage#347).
//
// Since we wouldn't be trying to build this target unless it were
// for macOS already, just let xcodebuild figure out the SDK on its
// own.
itCreatesBuildArguments("does not include the sdk flag if .macOSX is specified", arguments: []) { subject in
subject.sdk = .macOSX
}
case .iPhoneOS, .watchOS, .tvOS:
// Thread Sanitizer isn't supported on other than macOS devices
// If ENABLE_THREAD_SANITIZER=YES passed through env, it will lead
// to error.
itCreatesBuildArguments("includes \(sdk) in the argument if specified", arguments: ["-sdk", sdk.rawValue, "ENABLE_THREAD_SANITIZER=NO"]) { subject in
subject.sdk = sdk
}
default:
itCreatesBuildArguments("includes \(sdk) in the argument if specified", arguments: ["-sdk", sdk.rawValue]) { subject in
subject.sdk = sdk
}
}
}

// Passing in -sdk macosx appears to break implicit dependency
// resolution (see Carthage/Carthage#347).
//
// Since we wouldn't be trying to build this target unless it were
// for macOS already, just let xcodebuild figure out the SDK on its
// own.
itCreatesBuildArguments("does not include the sdk flag if .macOSX is specified", arguments: []) { subject in
subject.sdk = .macOSX
}
}

itCreatesBuildArguments("includes the destination if given", arguments: ["-destination", "exampleDestination"]) { subject in
Expand Down