Skip to content

[Glibc] Add missing C stdlib header #58710

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
Jul 5, 2022
Merged

[Glibc] Add missing C stdlib header #58710

merged 1 commit into from
Jul 5, 2022

Conversation

egorzhdan
Copy link
Contributor

assert.h is missing from the modulemap, which causes clang to consider assert.h to be a part of the first module to include it. This causes issues in SwiftCompilerSources when we try to use classes coming from LLVM headers on Linux:

<module-includes>:2:10: note: in file included from <module-includes>:2:
#include "Basic/BasicBridging.h"
         ^
/home/build-user/swift/include/swift/Basic/BasicBridging.h:17:10: note: in file included from /home/build-user/swift/include/swift/Basic/BasicBridging.h:17:
#include "swift/Basic/SourceLoc.h"
         ^
/home/build-user/swift/include/swift/Basic/SourceLoc.h:60:5: error: declaration of '__assert_fail' must be imported from module 'LLVM_Utils.Support.MathExtras' before it is required
    assert(isValid() && "Can't advance an invalid location");
    ^
/usr/include/assert.h:95:9: note: expanded from macro 'assert'
      : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION))
        ^
/usr/include/assert.h:69:13: note: declaration here is not visible
extern void __assert_fail (const char *__assertion, const char *__file,
            ^
/home/build-user/swift/SwiftCompilerSources/Sources/Basic/Utils.swift:13:19: error: could not build C module 'BasicBridging'
@_exported import BasicBridging
                  ^

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/glibc-assert branch from eb57610 to 19b097d Compare July 4, 2022 10:44
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

`assert.h` is missing from the modulemap, which causes clang to consider `assert.h` to be a part of the first module to include it. This causes issues in SwiftCompilerSources when we try to use classes coming from LLVM headers on Linux.
@egorzhdan egorzhdan force-pushed the egorzhdan/glibc-assert branch from 19b097d to c314ae0 Compare July 5, 2022 15:46
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan marked this pull request as ready for review July 5, 2022 17:51
@egorzhdan egorzhdan requested a review from zoecarver July 5, 2022 17:56
@egorzhdan egorzhdan merged commit 43032e8 into main Jul 5, 2022
@egorzhdan egorzhdan deleted the egorzhdan/glibc-assert branch July 5, 2022 18:53
@3405691582
Copy link
Member

3405691582 commented Jul 16, 2022

Why might this not be working on other platforms (even with the VFS changes applied)? Perhaps due to libc++? I find I have to work around this by manually adding #include <assert.h> in SourceLoc.h.

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