Skip to content

A recent C++ Interop pull for libswift in the Swift compiler appears to have broken bootstrapping for libc++ platforms like Android #60272

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

Closed
finagolfin opened this issue Jul 28, 2022 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@finagolfin
Copy link
Member

Describe the bug
Since #58699, I get LLVM module import errors, apparently because of the recent inclusion of those LLVM modules, 5768aeb:

cd /data/data/com.termux/files/home/swift/SwiftCompilerSources && /data/data/com.termux/files/home/build/Ninja-Release/swift-android-aarch64/bootstrapping0/bin/swiftc -c -o /data/data/com.termux/files/home/build/Ninja-Release/swift-android-aarch64/bootstrapping1/SwiftCompilerSources/Basic.o -target aarch64-unknown-linux-android -module-name Basic -emit-module -emit-module-path /data/data/com.termux/files/home/build/Ninja-Release/swift-android-aarch64/bootstrapping1/SwiftCompilerSources/Basic.swiftmodule -parse-as-library /data/data/com.termux/files/home/swift/SwiftCompilerSources/Sources/Basic/SourceLoc.swift /data/data/com.termux/files/home/swift/SwiftCompilerSources/Sources/Basic/Utils.swift -wmo -Xfrontend -validate-tbd-against-ir=none -Xfrontend -enable-experimental-cxx-interop -Xcc -UIBOutlet -Xcc -UIBAction -Xcc -UIBInspectable -Xfrontend -disable-implicit-string-processing-module-import -O -cross-module-optimization -Xcc -I -Xcc /data/data/com.termux/files/home/llvm-project/llvm/include -Xcc -I -Xcc /data/data/com.termux/files/home/build/Ninja-Release/llvm-android-aarch64/include -Xcc -I -Xcc /data/data/com.termux/files/home/swift/include -Xcc -I -Xcc /data/data/com.termux/files/home/build/Ninja-Release/swift-android-aarch64/SwiftCompilerSources/../include -I /data/data/com.termux/files/home/build/Ninja-Release/swift-android-aarch64/bootstrapping1/SwiftCompilerSources
<unknown>:0: warning: unable to perform implicit import of "_Concurrency" module: no such module found
/data/data/com.termux/files/home/swift/include/swift/AST/ASTBridging.h:16:10: note: while building module 'BasicBridging' imported from /data/data/com.termux/files/home/swift/include/swift/AST/ASTBridging.h:16:
#include "swift/Basic/BasicBridging.h"
         ^
/data/data/com.termux/files/home/swift/include/swift/Basic/Debug.h:15:10: note: while building module 'LLVM_Utils' imported from /data/data/com.termux/files/home/swift/include/swift/Basic/Debug.h:15:
#include "llvm/Support/Compiler.h"
         ^
<module-includes>:125:10: note: in file included from <module-includes>:125:
#include "Support/Caching.h"
         ^
/data/data/com.termux/files/home/llvm-project/llvm/include/llvm/Support/Caching.h:19:10: note: in file included from /data/data/com.termux/files/home/llvm-project/llvm/include/llvm/Support/Caching.h:19:
#include "llvm/Support/thread.h"
         ^
/data/data/com.termux/files/home/llvm-project/llvm/include/llvm/Support/thread.h:55:30: error: missing '#include <bits/pthread_types.h>'; 'pthread_t' must be declared before it is used
  using native_handle_type = pthread_t;
                             ^
/data/data/com.termux/files/usr/include/bits/pthread_types.h:104:14: note: declaration here is not visible
typedef long pthread_t;
             ^
/data/data/com.termux/files/home/swift/include/swift/AST/ASTBridging.h:16:10: note: while building module 'BasicBridging' imported from /data/data/com.termux/files/home/swift/include/swift/AST/ASTBridging.h:16:
#include "swift/Basic/BasicBridging.h"
         ^
<module-includes>:2:10: note: in file included from <module-includes>:2:
#include "Basic/BasicBridging.h"
         ^
/data/data/com.termux/files/home/swift/include/swift/Basic/BasicBridging.h:17:10: note: in file included from /data/data/com.termux/files/home/swift/include/swift/Basic/BasicBridging.h:17:
#include "swift/Basic/SourceLoc.h"
         ^
/data/data/com.termux/files/home/swift/include/swift/Basic/SourceLoc.h:20:10: note: in file included from /data/data/com.termux/files/home/swift/include/swift/Basic/SourceLoc.h:20:
#include "swift/Basic/Debug.h"
         ^
/data/data/com.termux/files/home/swift/include/swift/Basic/Debug.h:15:10: error: could not build module 'LLVM_Utils'
#include "llvm/Support/Compiler.h"
         ^
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "AST/ASTBridging.h"
         ^
/data/data/com.termux/files/home/swift/include/swift/AST/ASTBridging.h:16:10: error: could not build module 'BasicBridging'
#include "swift/Basic/BasicBridging.h"
         ^
/data/data/com.termux/files/home/swift/include/swift/Localization/LocalizationFormat.h:25:10: note: while building module 'LLVM_Bitstream' imported from /data/data/com.termux/files/home/swift/include/swift/Localization/LocalizationFormat.h:25:
#include "llvm/Bitstream/BitstreamReader.h"
         ^
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "Bitstream/BitCodes.h"
         ^
/data/data/com.termux/files/home/llvm-project/llvm/include/llvm/Bitstream/BitCodes.h:20:10: error: could not build module 'LLVM_Utils'
#include "llvm/ADT/SmallVector.h"
         ^
/data/data/com.termux/files/home/swift/SwiftCompilerSources/Sources/Basic/SourceLoc.swift:13:8: error: could not build C module 'ASTBridging'
import ASTBridging
       ^
ninja: build stopped: subcommand failed.

I tried adding an #include <bits/pthread_types.h> in llvm-project/llvm/include/llvm/Support/thread.h or in SwiftGlibc.h: neither made a difference, with the same note /data/data/com.termux/files/usr/include/bits/pthread_types.h:104:14: note: declaration here is not visible. Why isn't it visible? Who knows.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Bootstrapping the Swift compiler on Linux with libc++ may reproduce this issue I'm seeing natively on Android.

Expected behavior
For libswift to keep building as before.

Environment

  • OS: Android 12 AArch64 in the Termux app, using its Swift 5.6.2 package to build the early swift-driver

Additional context
@3405691582 reported similar issues on OpenBSD, likely because it also uses libc++, llvm/llvm-project#56362. OTOH, this change appears to work on macOS with libc++? Reverting #58699 fixed this issue with the July 6 source snapshot, but after subsequent C++ interop pulls for libswift, only turning bootstrapping the compiler off with --bootstrapping=off works around the problem with the latest July 25 source snapshot.

@egorzhdan, let me know if there's anything I should try.

@finagolfin
Copy link
Member Author

Turning on the new pure C++ bridging mode in trunk, #69039, works around this issue and allows bootstrapping again, but leaving this open since the underlying issue is not fixed in the inline bridging mode.

@finagolfin
Copy link
Member Author

This was fixed by adding a new modularized Android overlay in #72634, which will ship with the upcoming Swift 6.

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.
Projects
None yet
Development

No branches or pull requests

1 participant