Skip to content

Conversation

vsapsai
Copy link
Contributor

@vsapsai vsapsai commented Sep 26, 2025

The idea is the same as Clang flag -gen-reproducer=error but for explicit module builds. The name of the setting is a subject to change depending on how it ends up being used.

Not all module-related issues are crashes, so it is useful to allow creating and sharing reproducers for errors.

rdar://158780565

… for errors.

The idea is the same as Clang flag `-gen-reproducer=error` but for
explicit module builds. The name of the setting is a subject to change
depending on how it ends up being used.

Not all module-related issues are crashes, so it is useful to allow
creating and sharing reproducers for errors.

rdar://158780565
Comment on lines +322 to +324
let shouldGenerateReproducer = (lastResult == .failed) &&
(explicitModulesPayload.shouldGenerateReproducerForErrors ||
(outputDelegate.result?.isCrashed ?? false))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've spent some time trying to improve this code, so let me share a few options I've discarded. If you prefer one of the mentioned options, let me know

let shouldGenerateReproducer: Bool
if lastResult == .failed {
    if explicitModulesPayload.shouldGenerateReproducerForErrors {
        shouldGenerateReproducer = true
    } else if case .exit(exitStatus: .uncaughtSignal, metrics: _) = outputDelegate.result {
        // In case of crash.
        shouldGenerateReproducer = true
    } else {
        shouldGenerateReproducer = false
    }
} else {
    shouldGenerateReproducer = false
}

Slight variation with if-expression

let shouldGenerateReproducer = if lastResult == .failed {
    if explicitModulesPayload.shouldGenerateReproducerForErrors {
        true
    } else if case .exit(exitStatus: .uncaughtSignal, metrics: _) = outputDelegate.result {
        // In case of crash.
        true
    } else {
        false
    }
} else {
    false
}

Try to add case

let shouldGenerateReproducer = if lastResult == .failed {
    switch (explicitModulesPayload.shouldGenerateReproducerForErrors, outputDelegate.result) {
    case (true, _): true
    case (_, .some(.exit(exitStatus: .uncaughtSignal, metrics: _))): true
    default: false
    }
} else {
    false
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinion from me, seems fine as it is.

@jakepetroules
Copy link
Collaborator

@swift-ci test

1 similar comment
@vsapsai
Copy link
Contributor Author

vsapsai commented Oct 1, 2025

@swift-ci test

@vsapsai
Copy link
Contributor Author

vsapsai commented Oct 1, 2025

As far as I can tell all the failed tests are in ClangCompilationCachingTests.swift that is unrelated to my change.

@vsapsai vsapsai merged commit 823f4f8 into swiftlang:main Oct 1, 2025
48 of 49 checks passed
@vsapsai vsapsai deleted the reproducer-on-error branch October 8, 2025 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants