Skip to content

fix(build): silence OpenWrt _FORTIFY_SOURCE redefinition warnings - #759

Closed
stackia wants to merge 2 commits into
mainfrom
cursor/fix-fortify-source-warning-1d69
Closed

fix(build): silence OpenWrt _FORTIFY_SOURCE redefinition warnings#759
stackia wants to merge 2 commits into
mainfrom
cursor/fix-fortify-source-warning-1d69

Conversation

@stackia

@stackia stackia commented Sep 9, 2026

Copy link
Copy Markdown
Owner

CI release job OpenWRT 24.10.8-powerpc_464fp (and the other OpenWrt architectures) compiled successfully, but every .c file warned:

<command-line>: warning: "_FORTIFY_SOURCE" redefined

CI findings

  • No compiler errors on Linux musl, macOS, FreeBSD, or OpenWrt (including powerpc_464fp).
  • The only project-owned compiler warning was _FORTIFY_SOURCE redefined: CMake always added -D_FORTIFY_SOURCE=2, while OpenWrt CFLAGS already pass -D_FORTIFY_SOURCE=1. The later flag wins, so the warning also meant we were not getting level 2 on OpenWrt.
  • OpenWrt SDK noise (missing firmware package deps, libgomp, kconfig) is SDK infrastructure, not rtp2httpd.
  • Linux static / macOS / FreeBSD logs had no rtp2httpd compiler warnings.

While reproducing locally with Clang and -ffast-math (the same aggressive-opt flags used in release CI), isfinite() also triggered -Wnan-infinity-disabled. GCC does not warn, but -ffinite-math-only can still constant-fold isfinite() to true, so Scale/NPT parsing is safer with a bit-pattern check.

Changes

  1. Probe whether the toolchain already defines _FORTIFY_SOURCE; only add level 2 when it does not. Avoids the redefinition warning and does not downgrade Debian/Ubuntu gcc’s default level 3.
  2. Replace isfinite() with double_is_finite() that inspects IEEE-754 exponent bits, so NaN/Inf rejection still works under -ffast-math.

Verification

  • GCC 13.3 Release + ENABLE_AGGRESSIVE_OPT=ON: Fortify = toolchain default, 0 warnings.
  • Clang + OpenWrt-like CFLAGS=-D_FORTIFY_SOURCE=1: Fortify = toolchain default, compile uses only =1, 0 warnings (including no _FORTIFY_SOURCE redefined).
  • Clang native: Fortify = 2 (project), 0 warnings (including no -Wnan-infinity-disabled).
  • double_is_finite() under -ffast-math: rejects ±Inf/NaN, accepts 0 / 1.5 / 1e300 on both gcc and clang.
  • ./scripts/run-e2e.sh test_rtsp_transport.py: 26 passed.
Open in Web Open in Cursor 

cursoragent and others added 2 commits September 9, 2026 10:13
OpenWrt SDK CFLAGS and Debian/Ubuntu gcc already define
_FORTIFY_SOURCE. Forcing =2 on every translation unit produced
"<command-line>: warning: _FORTIFY_SOURCE redefined" on all OpenWrt
architectures and could weaken a higher distro default. Probe the
toolchain first and only add level 2 when nothing is predefined.

Co-authored-by: Stackie Jia <jsq2627@gmail.com>
Release builds enable -ffast-math, which implies -ffinite-math-only.
isfinite() is then treated as always-true and Clang warns with
-Wnan-infinity-disabled. Inspect IEEE-754 exponent bits instead so
Scale/NPT parsing still rejects NaN and Inf.

Co-authored-by: Stackie Jia <jsq2627@gmail.com>
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Documentation preview

The documentation preview has been deployed for this pull request.

@stackia
stackia marked this pull request as ready for review September 9, 2026 10:16
@cursor

cursor Bot commented Sep 9, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_5b926852-5c0a-4f99-b2c1-c31820292c91)

@stackia stackia closed this Sep 9, 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.

2 participants