Skip to content

fixes linux build(gcc16) with linux build make command - #50

Open
flipchan wants to merge 1 commit into
iden3:mainfrom
flipchan:linux_build_fedora_tested
Open

fixes linux build(gcc16) with linux build make command#50
flipchan wants to merge 1 commit into
iden3:mainfrom
flipchan:linux_build_fedora_tested

Conversation

@flipchan

Copy link
Copy Markdown

This fixes building on linux and the latest fedora kernels with gcc16

Problem

Rapidsnark failed to compile on systems with GCC 16 due to two issues:

  1. GMP 6.3.0 configure fails — The "long long reliability test 1" in GMP's configure uses -pedantic, which GCC 16 rejects because of stricter enforcement of forward declaration argument matching.

  2. Missing #include <cstdint> — GCC 16 no longer transitively includes <cstdint> from standard library headers like <string>, <memory>, etc. Files using uint32_t, uint64_t, etc. without a direct or transitive path to <cstdint> fail to compile.

Changes

1. Conditional #include <cstdint> behind BUILD_LINUX CMake flag

The cstdint includes are only added when building with -DBUILD_LINUX=ON, which defines RAPIDSNARK_LINUX. This keeps the fix scoped to Linux builds and avoids touching other platforms.

CMakeLists.txt (src/CMakeLists.txt):

option(BUILD_LINUX "Build for Linux (adds cstdint includes needed by GCC 16+)" OFF)
if(BUILD_LINUX)
    add_definitions(-DRAPIDSNARK_LINUX)
endif()

Source files — each guarded with #ifdef RAPIDSNARK_LINUX:

  • src/binfile_utils.hpp#include <cstdint> after <memory> include
  • src/binfile_utils.cpp#include <cstdint> before project includes
  • src/zkey_utils.cpp#include <cstdint> before <stdexcept> include
  • src/random_generator.hpp#include <cstdint> after <random> include

Usage:

make host_linux

2. Workaround for GMP build (not a code change)

The build_gmp.sh host target fails because GMP's configure adds -pedantic which triggers an error in GCC 16's long long reliability test. Workaround:

cd depends/gmp
rm -rf build && mkdir build && cd build
../configure --prefix="$PWD/../../package" \
  --with-pic --disable-fft --enable-fat \
  CFLAGS="-O2 -fomit-frame-pointer -m64 -Wno-error" \
  CC="gcc -std=gnu11"
make -j$(nproc) && make install

The -std=gnu11 flag allows the test code (which uses implicit function declarations) to compile without error.

Notes

  • Only 4 files needed cstdint fixes. All other source files either already included it directly (7 files) or received it transitively through fr_element.hpp / fq_element.hpp / misc.hpp (8 files).
  • The non-standard u_int32_t / u_int64_t types (BSD extensions from <sys/types.h>) used in binfile_utils, zkey_utils, groth16, etc. remain unchanged — they compile on Linux via system header transitive includes but are a separate portability concern.

@flipchan

flipchan commented Jul 24, 2026

Copy link
Copy Markdown
Author

ping @olomix this fixes linux builds, looks green :)

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.

1 participant