Skip to content

[ASTGen] Avoid including C standard libary headers in brigdging headers #65120

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 1 commit into from
Apr 13, 2023

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Apr 12, 2023

Instead, use builtin types. e.g. size_t -> unsigned long

C stdlib headers are part of Darwin/Glibc clang module. If a Swift file imports a bridging headers and that has #include C stdlib headers, Swift compiler implicitly imports Darwin/Glibc overlay modules. That violates dependency layering. I.e. Compiler depends on Darwin overlay, Darwin overlay is created by the compiler.

rdar://107957117

@rintaro rintaro requested review from bnbarham and removed request for xedin, slavapestov, CodaFi and hborla April 12, 2023 22:17
@rintaro
Copy link
Member Author

rintaro commented Apr 12, 2023

@swift-ci Please smoke test

@rintaro rintaro force-pushed the briding-without-overlay branch from af2e962 to 03542e8 Compare April 12, 2023 22:21
@rintaro
Copy link
Member Author

rintaro commented Apr 12, 2023

@swift-ci Please smoke test

@bnbarham
Copy link
Contributor

This is ... unfortunate but I have no better workarounds. Any thoughts @etcwilde @compnerd?

@compnerd
Copy link
Member

No, sadly, there is no good solution here that I can think of. We do have SwiftShims that can provide some of these, particularly the sized types, which is exactly for this reason.

@compnerd
Copy link
Member

C:\Users\swift-ci\jenkins\workspace\swift-PR-windows\swift\lib\AST\CASTBridging.cpp(693): error C2397: conversion from 'unsigned __int64' to 'unsigned long' requires a narrowing conversion

Seems that there are some width issues here

@rintaro rintaro force-pushed the briding-without-overlay branch from 03542e8 to 4ac9d0f Compare April 12, 2023 23:06
@rintaro
Copy link
Member Author

rintaro commented Apr 12, 2023

@swift-ci Please smoke test

Copy link
Member

@etcwilde etcwilde left a comment

Choose a reason for hiding this comment

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

huh, not having C headers is most unfortunate. Once we require a Swift compiler in the builder toolchain, we should be able to go back since we can use that Swift to generate the modules needed to build the compiler, no?

Alternatively, could we use the appropriate C++ headers instead? e.g #include <cstdint> or does that trigger the same issue?

C stdlib headers are part of "Darwin"/"Glibc" clang module.
If a Swift file imports a bridging headers and that has '#include'
C stdlib headers, Swift compiler implicitly imports "Darwin"/"Glibc"
overlay modules. That violates dependency layering. I.e. Compiler
depends on Darwin overlay, Darwin overlay is created by the compiler.

rdar://107957117
@rintaro rintaro force-pushed the briding-without-overlay branch from 4ac9d0f to fe1eb46 Compare April 13, 2023 00:22
@rintaro
Copy link
Member Author

rintaro commented Apr 13, 2023

@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented Apr 13, 2023

Alternatively, could we use the appropriate C++ headers instead? e.g #include or does that trigger the same issue?

Maybe 🤔? But since this is imported from Swift code built with host Swift compilers, I don't think we can use any C++ headers in these at this point

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.

4 participants