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

[SR-11272] swift package generate-xcodeproj: Including inttypes.h, raises error 'Include of non-modular header inside framework module 'CFoo.a'' #53673

Open
weissi opened this issue Aug 8, 2019 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@weissi
Copy link
Member

weissi commented Aug 8, 2019

Previous ID SR-11272
Radar rdar://problem/54079647
Original Reporter @weissi
Type Bug

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, ClangImporter
Assignee None
Priority Medium

md5: 250539387e1e5e1ea2f9365306e6d2cf

Issue Description:

The attached project is super simple. It has a Swift and a C module (CFoo). The C module includes inttypes.h and nothing else.

When I compile the project with swift build, everything works fine. The generated Xcode project however doesn't compile with this error:

Include of non-modular header inside framework module 'CFoo.a'

The issue seems to be that the clang importer prefers Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/inttypes.h instead of the inttypes.h from the Darwin module.

@weissi
Copy link
Member Author

weissi commented Aug 8, 2019

CC @belkadan & @aciidb0mb3r

@weissi
Copy link
Member Author

weissi commented Aug 8, 2019

@swift-ci create

@typesanitizer
Copy link

The issue doesn't seem to be specific to inttypes.h. The toolchain path is listed earlier in the search paths, so it is preferred. For example, if I add a file myheader.h to the toolchain path and on the SDK path (along with adding module myheader ... in the SDK path's module.modulemap), the one in the toolchain path is preferred and produces the same error. Ben Langmuir pointed out that some of the toolchain headers use #include_next to include the SDK header (see clang docs to understand how that interacts with modules). The toolchain's inttypes.h does have a #include_next <inttypes.h> so that's not the issue, I think.

So the question is: what is special about float.h, stdint.h etc. that they do not produce this error? I think this has to do with the fact that they're builtins. To be more specific, if one looks at module.modulemap in the SDK, you'll see a bunch of modules such as float/stdint are builtins. None of the headers corresponding to non-builtin modules are also present in the toolchain path with the exception of inttypes.h.

As far as I can tell, this is a Clang issue, not a Swift issue. However, it would be good to understand why this is happening and provide a patch upstream or apply some workaround here.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants