[libcxx-commits] [PATCH] D137131: [libc++] Android temp dir is /data/local/tmp, enable Windows test

Ryan Prichard via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 5 22:19:24 PDT 2023


rprichard added a subscriber: enh.
rprichard added a comment.

Android apps aren't generally allowed to access `/data/local/tmp`, but they are able to access the app-specific cache dir <https://developer.android.com/reference/android/content/Context#getCacheDir()>. (`/data/data/${APP_ID}/cache` or `/data/user/0/$APP_ID}/cache`). New-enough versions of Android set `TMPDIR` to this cache dir for apps. I wonder if it'd make sense for libc++ to use the app cache as fallback for `std::filesystem::temp_directory_path()`, when running in an app context (app UID?). I suspect the answer is "no", because it's not feasible to determine the path to the app cache. Not sure though.

It's probably useful for `std::filesystem::temp_directory_path()` to work for the shell user even if it doesn't work for app users. That makes it useful for many test suites. I think this patch is an improvement as-is.

For libc++ filesystem testing, adb_run.py could set TMPDIR to /data/local/tmp. On new-enough versions of Android, that happens automatically in the initial `adb shell` environment, but `su` and `run-as` clear TMPDIR.

Bionic has similar behavior with respect to the temp dir. e.g. https://android-review.git.corp.google.com/c/platform/bionic/+/2545855


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137131/new/

https://reviews.llvm.org/D137131



More information about the libcxx-commits mailing list