Skip to content

build: pin K&R-compatible C standard (gnu99) for modern Autoconf/clang#25

Merged
gburd merged 1 commit into
masterfrom
build/knr-c-standard
Jun 19, 2026
Merged

build: pin K&R-compatible C standard (gnu99) for modern Autoconf/clang#25
gburd merged 1 commit into
masterfrom
build/knr-c-standard

Conversation

@gburd

@gburd gburd commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Pin a K&R-compatible C standard so the tree builds on modern toolchains

Berkeley DB is written in K&R (old-style) C: function definitions name their
parameters in a list following the parenthesis, with the prototype supplied
separately via the __P() macro.

C23 (gnu23) removed old-style definitions from the language. Autoconf

= 2.72 AC_PROG_CC probes -std=gnu23 first and adopts it when the compiler
supports it (recent gcc/clang do), so on a modern toolchain every function
definition in the tree becomes a hard compile error
(error: unknown type name 'dbp' ...). The pre-existing
-Wno-deprecated-non-prototype only silenced a warning; under gnu23 these are
errors, so the tree did not build at all with current clang/gcc.

Fix

  • Pre-seed the C11/C23 feature-test cache vars to no so AC_PROG_CC adds no
    -std flag, and strip any -std=gnu23/-std=c23 Autoconf still splices into
    $CC.
  • Pin -std=gnu99 in CFLAGS (keeps K&R definitions legal and the GNU
    extensions the tree uses).
  • Silence the two diagnostics inherent to intentional K&R style
    (-Wno-deprecated-non-prototype, -Wno-knr-promoted-parameter) behind
    compiler-support probes, so unknown-flag compilers are unaffected. All other
    warnings are kept.
  • configure regenerated with Autoconf 2.73 (the dev-flake toolchain).

Why standalone

This is a prerequisite for any branch to build on a current toolchain. It is
currently duplicated on perf/aio-stage2 (#24) and perf/cursor-shard;
landing it on master first lets those rebase onto it instead of carrying
conflicting copies of the regenerated configure.

Verified

Clean build on macOS (Apple clang 21) and via the Nix dev shell (gcc 14):
zero errors, zero source warnings.

Berkeley DB is K&R C: function definitions name parameters in a list after
the parenthesis with the prototype supplied via __P().  C23 (gnu23) removed
old-style definitions, and Autoconf >= 2.72 AC_PROG_CC probes -std=gnu23
first and adopts it, turning every definition in the tree into a hard error
on a modern toolchain.

Pre-seed the C11/C23 feature-test cache to "no", strip any -std=gnu23/c23
Autoconf splices into CC, and pin -std=gnu99 in CFLAGS.  Silence the two
inherent K&R diagnostics (-Wno-deprecated-non-prototype,
-Wno-knr-promoted-parameter) behind compiler-support probes; keep all other
warnings.  configure regenerated with Autoconf 2.73.

(Same fix as on perf/aio-stage2; should be consolidated into one master PR.)
@gburd gburd merged commit 12aeece into master Jun 19, 2026
36 of 39 checks passed
@gburd gburd deleted the build/knr-c-standard branch June 19, 2026 20:43
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