Repository navigation
cgen: preserve standalone poll and native-cache helpers #32297
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /* Shared by the SDK-backed header and standalone compiler snapshots. */ | ||
| #ifndef V_NATIVE_OBJECT_CACHE_IMPL | ||
| #define V_NATIVE_OBJECT_CACHE_IMPL | ||
|
|
||
| #if defined(ENOSYS) | ||
| #define V_NATIVE_OBJECT_CACHE_ENOSYS ENOSYS | ||
| #elif defined(__linux__) | ||
| #define V_NATIVE_OBJECT_CACHE_ENOSYS 38 | ||
| #elif defined(_WIN32) | ||
| #define V_NATIVE_OBJECT_CACHE_ENOSYS 40 | ||
| #else | ||
| #define V_NATIVE_OBJECT_CACHE_ENOSYS 78 | ||
| #endif | ||
|
|
||
| #if defined(__linux__) | ||
| #if defined(EOPNOTSUPP) | ||
| #define V_NATIVE_OBJECT_CACHE_EOPNOTSUPP EOPNOTSUPP | ||
| #else | ||
| #define V_NATIVE_OBJECT_CACHE_EOPNOTSUPP 95 | ||
| #endif | ||
| /* Linux UAPI syscall tables: x86, arm, asm-generic, powerpc and s390. | ||
| * Native headers remain authoritative when the SDK provides the number. */ | ||
| #if defined(SYS_renameat2) | ||
| #define V_NATIVE_OBJECT_CACHE_RENAMEAT2 SYS_renameat2 | ||
| #elif defined(__x86_64__) && defined(__ILP32__) | ||
| #define V_NATIVE_OBJECT_CACHE_RENAMEAT2 (0x40000000 + 316) | ||
| #elif defined(__x86_64__) | ||
| #define V_NATIVE_OBJECT_CACHE_RENAMEAT2 316 | ||
| #elif defined(__i386__) | ||
| #define V_NATIVE_OBJECT_CACHE_RENAMEAT2 353 | ||
| #elif defined(__arm__) | ||
| #define V_NATIVE_OBJECT_CACHE_RENAMEAT2 382 | ||
| #elif defined(__aarch64__) || defined(__riscv) || defined(__loongarch__) | ||
| #define V_NATIVE_OBJECT_CACHE_RENAMEAT2 276 | ||
| #elif defined(__powerpc__) | ||
| #define V_NATIVE_OBJECT_CACHE_RENAMEAT2 357 | ||
| #elif defined(__s390__) | ||
| #define V_NATIVE_OBJECT_CACHE_RENAMEAT2 347 | ||
| #endif | ||
| #endif | ||
|
|
||
| /* Use the syscall: Bionic's renameat2 wrapper is unavailable before API 30. | ||
| * Keep these guards in C so a portable vc snapshot can build on other hosts. */ | ||
| static inline int v_native_object_cache_rename_noreplace(const char *source, const char *destination) { | ||
| #if defined(__linux__) && defined(V_NATIVE_OBJECT_CACHE_RENAMEAT2) | ||
| /* Linux AT_FDCWD is -100 and RENAME_NOREPLACE is 1. Avoid importing fcntl | ||
| * types into headerless snapshots or requiring the flag in old headers. */ | ||
| if (syscall(V_NATIVE_OBJECT_CACHE_RENAMEAT2, -100, source, -100, destination, 1U) == 0) { | ||
| return 0; | ||
| } | ||
| return errno; | ||
| #else | ||
| (void)source; | ||
| (void)destination; | ||
| return V_NATIVE_OBJECT_CACHE_ENOSYS; | ||
| #endif | ||
| } | ||
|
|
||
| static inline int v_native_object_cache_publish(const char *source, const char *destination) { | ||
| #ifndef _WIN32 | ||
| #ifdef V_NATIVE_OBJECT_CACHE_HEADERLESS | ||
| if (link((char *)source, (char *)destination) == 0) { | ||
| #else | ||
| if (link(source, destination) == 0) { | ||
| #endif | ||
| return 0; | ||
| } | ||
| const int code = errno; | ||
| #if defined(__linux__) | ||
| /* Android SELinux can forbid links in app-private storage; some filesystems | ||
| * do not implement hard links. Neither prevents an atomic no-replace rename. */ | ||
| if (code == EACCES || code == EPERM || code == V_NATIVE_OBJECT_CACHE_EOPNOTSUPP) { | ||
| return v_native_object_cache_rename_noreplace(source, destination); | ||
| } | ||
| #endif | ||
| return code; | ||
| #else | ||
| (void)source; | ||
| (void)destination; | ||
| return V_NATIVE_OBJECT_CACHE_ENOSYS; | ||
| #endif | ||
| } | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Fingerprint the newly embedded native-cache implementation
This new
$embed_filetarget is absent fromv3_cache_compiler_runtime_inputsindriver.v. That list contributes the running backend's external inputs to the cache salt for development/older-bootstrap consumers that read embedded files at runtime; changing this implementation would leave that part of the cache identity unchanged. Please addvlib/v/driver/native_object_cache_impl.cto the list alongside the other embedded runtime inputs. The existing focused testtest_module_cache_compiler_runtime_inputs_cover_compiler_embedded_filesreproducibly fails atcache_prune_test.v:206on this exact head and names this new embed. Modern compiler self-builds that embed the bytes are separately covered by executable identity, but that does not cover the runtime-reading cases.