Skip to content

[android] do not import stdatomic from android's libc++ #74348

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
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions stdlib/public/Platform/SwiftAndroidNDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#ifdef __cplusplus
// The Android r26 NDK contains an old libc++ modulemap that requires C++23
// for 'stdatomic', which can't be imported unless we're using C++23. Thus,
// import stdatomic from the NDK directly, bypassing the stdatomic from the libc++.
#pragma clang module import _stdatomic
#else
#include <stdatomic.h>
#endif
#include <stdint.h>
#include <stdio.h>
#include <stdio_ext.h>
Expand Down
7 changes: 7 additions & 0 deletions stdlib/public/Platform/SwiftBionic.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#ifdef __cplusplus
// The Android r26 NDK contains an old libc++ modulemap that requires C++23
// for 'stdatomic', which can't be imported unless we're using C++23. Thus,
// import stdatomic from the NDK directly, bypassing the stdatomic from the libc++.
#pragma clang module import _stdatomic
#else
#include <stdatomic.h>
#endif
#include <stdint.h>
#include <stdio.h>
#include <stdio_ext.h>
Expand Down
29 changes: 29 additions & 0 deletions test/Interop/Cxx/stdlib/android-and-std-module.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend %s -c -cxx-interoperability-mode=default -Xcc -std=c++14 -Xcc -fmodules-cache-path=%t
// RUN: %target-swift-frontend %s -c -cxx-interoperability-mode=default -Xcc -std=c++17 -Xcc -fmodules-cache-path=%t
// RUN: %target-swift-frontend %s -c -cxx-interoperability-mode=default -Xcc -std=c++20 -Xcc -fmodules-cache-path=%t

// RUN: find %t | %FileCheck %s

// RUN: %empty-directory(%t)

// RUN: %target-swift-frontend %s -c -cxx-interoperability-mode=default -Xcc -std=c++17 -Xcc -fmodules-cache-path=%t -DADD_CXXSTDLIB
// RUN: %target-swift-frontend %s -c -cxx-interoperability-mode=default -Xcc -std=c++20 -Xcc -fmodules-cache-path=%t -DADD_CXXSTDLIB

// REQUIRES: OS=linux-android

import Android
import Bionic

#if ADD_CXXSTDLIB
import CxxStdlib
#endif

func test() {
#if ADD_CXXSTDLIB
let _ = std.string()
#endif
}

// CHECK-DAG: Android{{.*}}.pcm
// CHECK-DAG: std{{.*}}.pcm