Skip to content

Bug 1496426 - Use GCC atomic builtins for Linux x86/x86_64 - #65

Merged
sylvestre merged 1 commit into
mozilla:mainfrom
larseggert:linux-x86-atomics
Oct 14, 2026
Merged

sylvestre merged 1 commit into
mozilla:mainfrom
larseggert:linux-x86-atomics

Conversation

@larseggert

@larseggert larseggert commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Match ppc64/mips/riscv/loongarch: use __sync_* builtins instead of hand-written asm, requiring __GNUC__ (and __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 for i386, matching pratom.h). Stop building the now-unused .s files. Matches Arch and RHEL packaging patches.

https://bugzilla.mozilla.org/show_bug.cgi?id=1496426

Needs a perf/try comparison before merging.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The compiler guards permit toolchains and i386 targets that may not support the selected atomic builtins.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Replaces Linux x86/x86_64 assembly atomics with GCC-compatible builtins.

Changes:

  • Adds __sync_* atomic implementations.
  • Removes obsolete assembly sources.
  • Updates generated and source configure scripts.
File Description
pr/​include/​md/​_linux.h Defines builtin atomic operations.
configure.in Stops selecting x86 assembly sources.
configure Mirrors the configuration change.
pr/​src/​md/​unix/​os_Linux_x86.s Deletes 32-bit assembly atomics.
pr/​src/​md/​unix/​os_Linux_x86_64.s Deletes 64-bit assembly atomics.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pr/include/md/_linux.h Outdated
@codecov-commenter

codecov-commenter commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.91%. Comparing base (6bac64c) to head (b1e546e).
⚠️ Report is 23 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #65      +/-   ##
==========================================
+ Coverage   42.20%   48.91%   +6.70%     
==========================================
  Files          70       93      +23     
  Lines       12071    17828    +5757     
  Branches     2261     2261              
==========================================
+ Hits         5095     8721    +3626     
- Misses       6126     8687    +2561     
+ Partials      850      420     -430     
Flag Coverage Δ
freebsd 42.60% <ø> (+0.03%) ⬆️
macos-15-intel 42.70% <ø> (+0.01%) ⬆️
macos-latest 42.72% <ø> (+0.03%) ⬆️
netbsd 39.23% <ø> (-0.06%) ⬇️
openbsd 1.00% <ø> (ø)
solaris 39.76% <ø> (-0.01%) ⬇️
ubuntu-24.04-arm-clang 41.83% <ø> (+0.05%) ⬆️
ubuntu-latest-gcc 39.47% <ø> (-0.05%) ⬇️
ubuntu-latest-gcc-x86 39.49% <ø> (-0.01%) ⬇️
windows-arm64-cl 51.14% <ø> (?)
windows-x64-cl 51.46% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@larseggert
larseggert force-pushed the linux-x86-atomics branch 2 times, most recently from 58e5448 to 52d0206 Compare September 25, 2026 10:08
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

nspr4 backport check

Commit Alone In order Files ABI Subject
b1e546e4 yes yes public headers unchanged, review macros Bug 1496426 - Use GCC atomic builtins for Linux x86/x86_64

Alone: cherry-picks onto nspr4 by itself. In order: cherry-picks onto nspr4 after the earlier commits, skipping any that conflict.

Verdict: needs review

abidiff reports
==> ./1/abidiff-libnspr4.so.txt <==
Functions changes summary: 0 Removed (4 filtered out), 0 Changed, 0 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

Comment thread configure.in Outdated
Comment thread pr/include/md/_linux.h
#endif

#if defined(__i386__)
#if defined(__GNUC__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does Firefox's config/external/nspr/pr/moz.build still list os_Linux_x86.s / os_Linux_x86_64.s?
if so, it needs updating in the same landing, otherwise the next NSPR import breaks the build

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, moz.build:31 and :34 still list them. They need to be removed when NSPR with this change is vendored.

Match ppc64/mips/riscv/loongarch: use `__sync_*` builtins instead of
hand-written asm, requiring `__GNUC__` (and
`__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4` for i386, matching `pratom.h`).
Stop building the now-unused `.s` files. Matches Arch and RHEL
packaging patches.

https://bugzilla.mozilla.org/show_bug.cgi?id=1496426

Needs a perf/try comparison before merging.
@sylvestre
sylvestre merged commit 902baf1 into mozilla:main Oct 14, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants