-
Notifications
You must be signed in to change notification settings - Fork 258
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
std::filesystem support #609
Comments
libc++ compiles its experimental parts into libc++experimental, a library that you need to link in separately. Unfortunately, we don't seem to build it as part of the NDK. Retitling the bug to look into shipping it. In the mean time, you might be able to just add the required files directly into your project (from |
Ah okay, that makes perfect sense. I didn't realize libc++ also had a separate library like gcc's libstdc++fs. |
The tests for |
Unlikely to fit into r18. I want to get this done for the platform before the NDK since it should be a smaller problem to solve, and haven't done that yet. |
So, for now, can we suppose that full support for std::filesystem will appear in r19? |
Given how strongly people feel about #463 I will be doing that before this, and I'm skeptical that I'll be able to accomplish that before r19 is complete (there's always a fair amount of overhead in coordinating with external products, and CMake is an unfamiliar code base to all of us here). Going to move this to the r20 bucket to match the other bug, but odds are there will be some down time while waiting on reviews for #463 so I'll try to make some progress on this then. |
Also, a disclaimer that when this does land, the NDK's support for |
Of note: [edit] It seems like the symbols are still in a separate library, |
No. Like I've said, the difficulty here is getting the tests running. |
I'd like to see the filesystem support happening aswell 👍 |
Looking forward to the experimental file system libraries being available. |
In the current NDK the experimental filesystem is still not part of the libc++ library, and now the sources can no longer be installed through the SDK tools so our old work around suggested by @jmgao no longer works. Any suggestions for what to do now? |
@KayEss you can probably follow https://android.googlesource.com/platform/external/libcxx/+/master/CMakeLists.txt |
https://issuetracker.google.com/121291977 was another request for std::filesystem... |
@DanAlbert Is it still planned for r20? |
Conveniently, upstream has actually fixed some of the issues that we were going to need to fix about a month ago, so there's a bit less work on our end. After disabling a bunch of tests (everything relating to hard links, sockets, and fifos, since selinux prevents their use in /data/local/tmp), I do have a passing test run for Q devices. There's at least one thing preventing me from running the tests on JB devices more or less at all though. I have an idea of how to fix it, but haven't had a chance to try yet. That could easily be where most of the trouble is so it's hard to say for sure whether this is close to done or not, but the few that do run have me optimistic. |
Alright, managed to get a full test run on Jelly Bean. Everything looks good within a reasonable margin of error. Tests did uncover two bugs, but they're relatively minor:
There are a fair number of other things that don't work, most of which depend on API level, but they are all related to Android security policy and
It's going to take me some time to get the test fixes pushed upstream, but if that takes too long I don't think we need to wait for that before shipping it in r22 beta 1. As for the two bugs, I don't think those are severe enough that we necessarily need to fix them before shipping. It'd be better to get them fixed if we can, but I don't think we need to hold back the feature for them. |
(see https://android-review.googlesource.com/c/platform/external/libcxx/+/1110835/7/src/filesystem/operations.cpp for my libc++ workaround for those.) |
Unix domain sockets are supported. So, maybe the test should run in app private sandbox, and not in |
Converting our tests to run in an app is something I've been working on. It's going to take some time, it seems, especially for the libc++ tests. Nothing untenable, just going to take longer than I want to hold this back. Good to know that it's not wasted effort though :) |
The implementation for this is now checked in to master and will be in r22. I've forked the remaining testing cleanup into #1265 so I can close this to make it obvious that the part you folks care about is complete without having to read the whole thing :) |
When attemping to build with ndk 19+ I get the following error: error: undefined reference to 'std::__ndk1::__fs::filesystem::path::__extension() const' Looking at this issue here android/ndk#609 and https://android.googlesource.com/platform/ndk/+/master/docs/Roadmap.md#package-management it's stated that the ndk does not support std::filesystem.
These comments have been a few weeks ago, but I just found this discussion and want to add a small detail to the suggested workaround implementation in case someone might think about it: It is comparable to Still, to be clear, I'm currently not developing on Android myself, and I have no CI integration for it, so the current level of support is just based on feedback and fixed issues of users. And I am thankful for that! Any feedback or help to get a CI setup on Github going to enhance support would sure be appreciated. |
Hi @DanAlbert , can we use I still have the compile errors: In function `std::__ndk1::__fs::filesystem::exists(std::__ndk1::__fs::filesystem::path const&)':
/root/workspace/3rd_party/android-ndk-r21d-linux-x86_64/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/filesystem:1615: undefined reference to `std::__ndk1::__fs::filesystem::__status(std::__ndk1::__fs::filesystem::path const&, std::__ndk1::error_code*)'
In function `std::__ndk1::__fs::filesystem::create_directory(std::__ndk1::__fs::filesystem::path const&)':
/root/workspace/3rd_party/android-ndk-r21d-linux-x86_64/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/filesystem:1555: undefined reference to `std::__ndk1::__fs::filesystem::__create_directory(std::__ndk1::__fs::filesystem::path const&, std::__ndk1::error_code*)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
This is my cmake commad: cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=arm64-v8a \
-DANDROID_PLATFORM=android-29 \
-DANDROID_NATIVE_API_LEVEL=29 \
-DANDROID_STL=c++_shared \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=$DEST \
.. Accroding to this link target_link_libraries( vmc_io_lite
c++fs
) But this will cause below error message: /root/workspace/3rd_party/android-ndk-r21d-linux-x86_64/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lc++fs
clang++: error: linker command failed with exit code 1 (use -v to see invocation) Can we use these function in r22? |
This path is for r21d not r22: /root/workspace/3rd_party/android-ndk-r21d-linux-x86_64/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/filesystem |
Workaround for bug android/ndk#609
Split statfs and statvfs. The former has been available forever, and the latter is implemented in terms of the former. The implementation has been moved into headers so that it can be used at low API levels. There's no reason for any Android or Linux code to use statvfs rather than statfs, but code that needs to build on Darwin too will want to use statvfs because Darwin's statfs is very spartan. Bug: android/ndk#609 Test: treehugger Change-Id: Icf3d5723a260099fddb2d9f902e3047b0f041647
Split statfs and statvfs. The former has been available forever, and the latter is implemented in terms of the former. The implementation has been moved into headers so that it can be used at low API levels. There's no reason for any Android or Linux code to use statvfs rather than statfs, but code that needs to build on Darwin too will want to use statvfs because Darwin's statfs is very spartan. Bug: android/ndk#609 Test: treehugger Change-Id: Icf3d5723a260099fddb2d9f902e3047b0f041647
Description
The libc++ libraries (both shared and static) seem to be missing symbols needed to use
<experimental/filesystem>
. For example, trying to compile a simple program that callsstd::experimental::filesystem::remove_all(path)
will fail at link time with:Sample project: https://github.com/chenxiaolong/ndk_filesystem_test (run
./test.sh
to reproduce issue)Is this expected to happen? I couldn't find any details as to whether the filesystem library should work with the NDK.
Environment Details
16.1.4479499
)The text was updated successfully, but these errors were encountered: