Skip to content

[DO NOT MERGE] Valgrind testing #479

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
25 changes: 25 additions & 0 deletions .github/workflows/dispatch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
apt-get update -y
apt-get install -y cmake ninja-build
cd /tmp && mkdir build
git clone https://github.com/apple/swift-corelibs-libdispatch
cd /tmp/swift-corelibs-libdispatch
#git checkout swift-6.0-RELEASE
cd /tmp
cmake -G Ninja \
/tmp/swift-corelibs-libdispatch \
-B /tmp/build \
-DCMAKE_C_FLAGS=-fno-omit-frame-pointer \
-DCMAKE_CXX_FLAGS=-fno-omit-frame-pointer \
-DCMAKE_REQUIRED_DEFINITIONS=-D_GNU_SOURCE \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DENABLE_SWIFT=YES \
-DCMAKE_C_COMPILER=/usr/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib
cd /tmp/build && ninja install
rm -rf /tmp/build /tmp/swift-corelibs-libdispatch
apt-get remove -y cmake ninja-build
apt-get autoremove -y
rm -r /var/lib/apt/lists/*
16 changes: 12 additions & 4 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Test
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
with:
linux_os_versions: '["noble", "jammy", "focal", "rhel-ubi9"]'
linux_os_versions: '["noble"]'
linux_pre_build_command: |
if command -v apt-get >/dev/null 2>&1 ; then # bookworm, noble, jammy, focal
apt-get update -y
Expand All @@ -23,6 +23,10 @@ jobs:

# Debug symbols
apt-get install -y libc6-dbg

apt-get install -y valgrind

./.github/workflows/dispatch.sh
elif command -v dnf >/dev/null 2>&1 ; then # rhel-ubi9
dnf update -y

Expand All @@ -31,6 +35,8 @@ jobs:

# Debug symbols
dnf debuginfo-install -y glibc

dnf install -y valgrind
elif command -v yum >/dev/null 2>&1 ; then # amazonlinux2
yum update -y

Expand All @@ -40,10 +46,12 @@ jobs:
# Debug symbols
yum install -y yum-utils
debuginfo-install -y glibc

yum install -y valgrind
fi
linux_build_command: 'swift test --no-parallel'
linux_swift_versions: '["nightly-main", "nightly-6.2"]'
windows_swift_versions: '["nightly-main"]'
linux_build_command: 'swift build --build-tests -Xswiftc -sanitize=thread -Xcc -fsanitize=thread && ASAN_OPTIONS=detect_leaks=0 ./.build/debug/SwiftBuildPackageTests.xctest --testing-library swift-testing'
linux_swift_versions: '["nightly-main"]'
windows_swift_versions: '[]'
windows_build_command: 'swift test --no-parallel'
cmake-smoke-test:
name: cmake-smoke-test
Expand Down
6 changes: 3 additions & 3 deletions Sources/SWBBuildSystem/BuildOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ private class InProcessCommand: SWBLLBuild.ExternalCommand, SWBLLBuild.ExternalD
// Get the current output delegate from the adaptor.
//
// FIXME: This should never fail (since we are executing), but we have seen a crash here with that assumption. For now we are defensive until the source can be tracked down: <rdar://problem/31670274> Diagnose unexpected missing output delegate from: <rdar://problem/31669245> Crash in InProcessCommand.execute()
guard let outputDelegate = adaptor.getActiveOutputDelegate(command) else {
guard let outputDelegate = await adaptor.getActiveOutputDelegate(command) else {
return .failed
}

Expand Down Expand Up @@ -1604,9 +1604,9 @@ internal final class OperationSystemAdaptor: SWBLLBuild.BuildSystemDelegate, Act
/// Get the active output delegate for an executing command.
///
/// - returns: The active delegate, or nil if not found.
func getActiveOutputDelegate(_ command: Command) -> (any TaskOutputDelegate)? {
func getActiveOutputDelegate(_ command: Command) async -> (any TaskOutputDelegate)? {
// FIXME: This is a very bad idea, doing a sync against the response queue is introducing artificial latency when an in-process command needs to wait for the response queue to flush. However, we also can't simply move to a decoupled lock, because we don't want the command to start reporting output before it has been fully reported as having started. We need to move in-process task to another model.
return queue.blocking_sync {
return await queue.sync {
self.commandOutputDelegates[command]
}
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/SWBCore/LibSwiftDriver/LibSwiftDriver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ public final class SwiftModuleDependencyGraph: SwiftGlobalExplicitDependencyGrap
return fileDependencies
}

public func queryTransitiveDependencyModuleNames(for key: String) throws -> [String] {
let graph = try registryQueue.blocking_sync {
guard let driver = registry[key] else {
public func queryTransitiveDependencyModuleNames(for key: String) async throws -> [String] {
let graph = try await registryQueue.sync {
guard let driver = self.registry[key] else {
throw StubError.error("Unable to find jobs for key \(key). Be sure to plan the build ahead of fetching results.")
}
return driver.intermoduleDependencyGraph
Expand Down
2 changes: 1 addition & 1 deletion Sources/SWBCore/OnDemandResources.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public import SWBMacro

public typealias ODRTagSet = Set<String>

public struct ODRAssetPackInfo {
public struct ODRAssetPackInfo: Sendable {
public var identifier: String
public var tags: ODRTagSet
public var path: Path
Expand Down
1 change: 1 addition & 0 deletions Sources/SWBCore/Settings/BuiltinMacros.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2670,6 +2670,7 @@ public enum LinkerDriverChoice: String, Equatable, Hashable, EnumerationMacroTyp

case clang
case swiftc
case qcc
}

/// Enumeration macro type for the value of the `INFOPLIST_KEY_LSApplicationCategoryType` build setting.
Expand Down
4 changes: 4 additions & 0 deletions Sources/SWBCore/SpecImplementations/ProductTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ public class ProductTypeSpec : Spec, SpecType, @unchecked Sendable {
args += ["-compatibility_version", compatibilityVersion]
case .swiftc:
args += ["-Xlinker", "-compatibility_version", "-Xlinker", compatibilityVersion]
case .qcc:
break
}
}

Expand All @@ -285,6 +287,8 @@ public class ProductTypeSpec : Spec, SpecType, @unchecked Sendable {
args += ["-current_version", currentVersion]
case .swiftc:
args += ["-Xlinker", "-current_version", "-Xlinker", currentVersion]
case .qcc:
break
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/SWBCore/SpecImplementations/Tools/LinkerTools.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ public final class LdLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @unchec
return cbc.producer.hostOperatingSystem.imageFormat.executableName(basename: "clang")
case .swiftc:
return cbc.producer.hostOperatingSystem.imageFormat.executableName(basename: "swiftc")
case .qcc:
return cbc.producer.hostOperatingSystem.imageFormat.executableName(basename: "qcc")
}
}

Expand Down
2 changes: 2 additions & 0 deletions Sources/SWBQNXPlatform/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ struct QNXSDKRegistryExtension: SDKRegistryExtension {

"ARCH_NAME_x86_64": .plString("x86_64"),
"ARCH_NAME_aarch64": .plString("aarch64le"),

"LINKER_DRIVER": "qcc",
]

return [(qnxSdk.sysroot, qnxPlatform, [
Expand Down
Loading
Loading