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

[BUG] Compilation Error with std::execution in C++17 #2038

Closed
bitforth opened this issue Jun 27, 2024 · 3 comments
Closed

[BUG] Compilation Error with std::execution in C++17 #2038

bitforth opened this issue Jun 27, 2024 · 3 comments
Labels

Comments

@bitforth
Copy link

Description

I'm trying to compile a C++ program using the Android NDK that relies on the C++17 feature std::execution.

During the build process, I encounter the following errors:

error: no member named 'par' in namespace 'std::execution'
error: no member named 'par_unseq' in namespace 'std::execution'

Sample Program:

#include <execution>
#include <algorithm>
#include <vector>

int main() {
    std::vector<int> vec = {1, 2, 3, 4, 5};
    std::for_each(std::execution::par, vec.begin(), vec.end(), [](int &n) { n *= 2; });
    return 0;
}

Compilation Command:

/Users/A.Chavez/Library/Android/sdk/ndk/27.0.11902837/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ \
  --target=aarch64-none-linux-android24 \
  --sysroot=/Users/A.Chavez/Library/Android/sdk/ndk/27.0.11902837/toolchains/llvm/prebuilt/darwin-x86_64/sysroot \
  -std=c++20 \
  -stdlib=libc++ \
  -I/Users/A.Chavez/Library/Android/sdk/ndk/27.0.11902837/sources/cxx-stl/llvm-libc++/include \
  -I/Users/A.Chavez/Library/Android/sdk/ndk/27.0.11902837/sources/cxx-stl/llvm-libc++abi/include \
  -I/Users/A.Chavez/Library/Android/sdk/ndk/27.0.11902837/sources/android/support/include \
  -c test.cpp

Context:
I've set the APP_CPPFLAGS to -std=c++20 and APP_STL to c++_shared in my CMakeList.txt file. I am using NDK version 27.0.11902837 but this happens with any NDK that should support C++17 (NDK 26 too)

The documentation indicates that libc++ should support modern C++ features, but it seems std::execution might not be supported.

How can I resolve this error and successfully compile my program using the Android NDK?

Is there any specific configuration or additional steps required to enable support for std::execution?

I'm using CMake for building the project

Affected versions

r26, r27

Canary version

No response

Host OS

Mac

Host OS version

macOS 14.5

Affected ABIs

arm64-v8a

Build system

CMake

Other build system

No response

minSdkVersion

24

Device API level

24

@bitforth bitforth added the bug label Jun 27, 2024
@appujee
Copy link
Collaborator

appujee commented Jun 27, 2024

Even llvm trunk doesn't have support for it: https://godbolt.org/z/8j9EPbdzY

@bitforth
Copy link
Author

Even llvm trunk doesn't have support for it: https://godbolt.org/z/8j9EPbdzY

So does that mean that I'm going to have to rewrite the parts of my code that uses std::execution right?

@DanAlbert
Copy link
Member

Yes, unfortunately. We can't do any better than LLVM does. If you're like a lot of Android developers and would be porting to iOS as well, they won't have it either.

Closing as there isn't work for us to do aside from the regular updates from upstream.

@DanAlbert DanAlbert closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 participants