Skip to content

Fix Swift Compiler Modules support in Debug mode #73506

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 2 commits into from
May 8, 2024

Conversation

drodriguez
Copy link
Contributor

The new swift-driver seems to enqueue a wrapmodule job which uses
the given module-name to form the output file name when not doing
optmizations (seems to happen only for -Onone in my testing). Since the
CMake functions macros are using the module name also as the explicit output
name, this clashes and ends up in an unhelpful error message from the driver.

SwiftDriverExecution/MultiJobExecutor.swift:207: Fatal error: multiple
producers for output ... SwiftCompilerSources/Basic.o: Wrapping Swift
module Basic & Compiling Basic SourceLoc.swift

This was reported in https://forums.swift.org/t/debug-swift-build-fails/71380

The changes use a different output object name (by using .object.o
suffix) which does not clash with what the swift-driver does
automatically. The code around the output objects and the static
libraries have to change slightly to handle this case.

Additionally, the resulting library when in Debug is now declaring its
dependency on swiftSwiftOnoneSupport, to avoid linking errors when the
libraries are used in the final binaries.

Debug mode seems to enable PURE_BRIDGING_MODE, which seems to skip
transitively including some C headers that files like
Utilities/Test.swift depend on. To avoid errors building, add the
missing include in a new #else branch.

I think CI will not test the Debug mode, so the only thing that it can prove is
that these changes do not break the Release mode.

drodriguez added 2 commits May 7, 2024 19:51
The new `swift-driver` seems to enqueue a `wrapmodule` job which uses
the given `module-name` to form the output file name when not doing
optmizations (seems to happen only for `-Onone` in my testing). Since the
CMake functions macros are using the module name also as the explicit output
name, this clashes and ends up in an unhelpful error message from the driver.

```
SwiftDriverExecution/MultiJobExecutor.swift:207: Fatal error: multiple
producers for output ... SwiftCompilerSources/Basic.o: Wrapping Swift
module Basic & Compiling Basic SourceLoc.swift
```

The changes use a different output object name (by using `.object.o`
suffix) which does not clash with what the `swift-driver` does
automatically. The code around the output objects and the static
libraries have to change slightly to handle this case.

Additionally, the resulting library when in `Debug` is now declaring its
dependency on `swiftSwiftOnoneSupport`, to avoid linking errors when the
libraries are used in the final binaries.
Debug mode seems to enable PURE_BRIDGING_MODE, which seems to skip
transitively including some C headers that files like
`Utilities/Test.swift` depend on. To avoid errors building, add the
missing include in a new `#else` branch.
@drodriguez drodriguez requested a review from eeckstein as a code owner May 8, 2024 03:06
@drodriguez
Copy link
Contributor Author

@swift-ci please test

@drodriguez
Copy link
Contributor Author

Failed because of swiftlang/llvm-project#8714

@drodriguez
Copy link
Contributor Author

@swift-ci please test

@drodriguez drodriguez merged commit c6745e6 into swiftlang:main May 8, 2024
@drodriguez drodriguez deleted the fix-debug-mode branch May 8, 2024 22:35
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