Skip to content

Fix bignum.cc build failure on GCC 8 (x86_64)#569

Closed
akhanzode wants to merge 1 commit intogoogle:masterfrom
akhanzode:fix-bignum-adx-guard
Closed

Fix bignum.cc build failure on GCC 8 (x86_64)#569
akhanzode wants to merge 1 commit intogoogle:masterfrom
akhanzode:fix-bignum-adx-guard

Conversation

@akhanzode
Copy link
Copy Markdown

Description

The _addcarry_u64 and _subborrow_u64 intrinsics in bignum.cc require the ADX instruction set extension, which GCC < 9 does not enable by default on x86_64. The existing #ifdef __x86_64__ guard is too broad, causing build failures on GCC 8.5.0 (the default compiler on Rocky Linux 8 / RHEL 8).

bignum.cc:299:7: error: '_addcarry_u64' was not declared in this scope
bignum.cc:316:13: error: '_subborrow_u64' was not declared in this scope

Fix

Replace #ifdef __x86_64__ with a stricter check:

#if defined(__x86_64__) && (defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 9) || defined(__ADX__))

This allows the intrinsics on Clang (all versions), GCC >= 9, or any compiler with -madx. On older GCC, falls through to the existing portable absl::uint128 arithmetic path with no functional change.

Fixes #568

@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 18, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

The _addcarry_u64 and _subborrow_u64 intrinsics require the ADX
instruction set extension, which GCC < 9 does not enable by default
on x86_64. The existing #ifdef __x86_64__ guard is too broad.

Replace with a stricter check that also verifies ADX support:
- Clang (all versions support the intrinsics on x86_64)
- GCC >= 9 (enables ADX by default)
- Any compiler with -madx flag (__ADX__ is defined)

On older GCC without ADX, falls through to the existing portable
absl::uint128 arithmetic path with no functional change.

Fixes google#568
@akhanzode akhanzode force-pushed the fix-bignum-adx-guard branch from c4ad8f7 to af2e6d5 Compare April 18, 2026 20:43
@jmr
Copy link
Copy Markdown
Member

jmr commented Apr 19, 2026

#568 (comment)

@jmr jmr closed this Apr 19, 2026
@jmr jmr reopened this Apr 19, 2026
@jmr
Copy link
Copy Markdown
Member

jmr commented Apr 19, 2026

You can replace __x86_64__ with __ADX__ if that's really all we need. If it happens to fix RHEL 8, great, but no guarantees with that.

#568 (comment)

@jmr
Copy link
Copy Markdown
Member

jmr commented Apr 19, 2026

I think __ADX__ is the wrong macro here. It indicates support for the ADCX/ADOX instructions (Intel ADX extension), but _addcarry_u64 and _subborrow_u64 map to plain ADC and SBB, which are base x86 instructions — no ADX required.

@jmr jmr closed this Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bignum.cc: _addcarry_u64/_subborrow_u64 build failure on GCC 8 (x86_64)

2 participants