fix(build): silence OpenWrt _FORTIFY_SOURCE redefinition warnings - #759
Closed
stackia wants to merge 2 commits into
Closed
fix(build): silence OpenWrt _FORTIFY_SOURCE redefinition warnings#759stackia wants to merge 2 commits into
stackia wants to merge 2 commits into
Conversation
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>
Contributor
Documentation previewThe documentation preview has been deployed for this pull request. |
stackia
marked this pull request as ready for review
September 9, 2026 10:16
Bugbot couldn't run - usage limit reachedBugbot 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CI release job OpenWRT 24.10.8-powerpc_464fp (and the other OpenWrt architectures) compiled successfully, but every
.cfile warned:CI findings
_FORTIFY_SOURCEredefined: 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.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-onlycan still constant-foldisfinite()to true, so Scale/NPT parsing is safer with a bit-pattern check.Changes
_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.isfinite()withdouble_is_finite()that inspects IEEE-754 exponent bits, so NaN/Inf rejection still works under-ffast-math.Verification
ENABLE_AGGRESSIVE_OPT=ON: Fortify = toolchain default, 0 warnings.CFLAGS=-D_FORTIFY_SOURCE=1: Fortify = toolchain default, compile uses only=1, 0 warnings (including no_FORTIFY_SOURCEredefined).-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.