Repository navigation
with migrate translates the GCC atomic builtins to std.sync's Atomic operations (#955) - #3567
Merged
Merged
Conversation
This was referenced Nov 23, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of #955 (the emit-C lanes). Does not close it.
with migraterefused every GCC atomic builtin ("has no translation"). The C backend emits them forAtomic[T], so the roundtrip lane (the compiler emitted as C and migrated back) stopped on 14 functions.What is translated.
__atomic_load_n,store_n,exchange_n,fetch_add/sub/and/or/xor,add_fetch,sub_fetch,compare_exchange_nand__atomic_thread_fencebecome the operation of that name onstd.sync.Atomic[T]over the same memory, the way std's own locks spell it:X_fetchreturns the new value, so its operand is evaluated twice and must be a constant or a name; otherwise refused.expected. The weak flag is ignored (a strong exchange is a valid weak one).use std.syncand the helper from flags set where the translation happens, not from the output's text.What is not. Only the
__atomic_*spellings.<stdatomic.h>(atomic_load(&g)) is still refused, loudly. And one older defect is untouched and separate:_Atomicon a type is dropped silently (_Atomic int g; g++migrates to a plain add). Both are recorded on #955.Tests.
bs_check_migrate_atomic_builtins(basic migrator lane): a C program whosemainreturns the number of the first operation whose result or effect is wrong, over int, long and pointer atomics; the migrated program returns 0 as C does.behav_migrate_unexposed_operatorsused an atomic load as its example of a refused operator; it now uses one with a run-time ordering, which is still refused by name.Roundtrip after this: the 14 stops are gone; one function remains (a closure the C backend emits as a statement expression used as a value).
:c-migrator-testsgreen. Battery green; self-audit and:release-checksgreen (587 s). A first battery was red on the test above before its expectation was updated.