Skip to content

[configure] Fix detecting -fno-lto support#2045

Merged
Dead2 merged 1 commit intozlib-ng:developfrom
mtl1979:configure-nolto
Dec 8, 2025
Merged

[configure] Fix detecting -fno-lto support#2045
Dead2 merged 1 commit intozlib-ng:developfrom
mtl1979:configure-nolto

Conversation

@mtl1979
Copy link
Copy Markdown
Collaborator

@mtl1979 mtl1979 commented Dec 7, 2025

  • Previously -fno-lto support was assumed to be supported on non-gcc compatible or unsupported compilers. Support for it was never tested on those cases. Set the default to not supported.

* Previously -fno-lto support was assumed to be supported on non-gcc compatible or unsupported compilers.
  Support for it was never tested on those cases. Set the default to not supported.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 7, 2025

Walkthrough

The PR modifies the configure script to change how link-time optimization disabling is handled. The noltoflag variable initialization changes from a fixed default of "-fno-lto" to an empty string, with conditional assignment to "-fno-lto" only if the compiler supports it and is GCC-compatible.

Changes

Cohort / File(s) Summary
LTO flag initialization
configure
Reworked noltoflag default: changed from unconditional "-fno-lto" to empty string with runtime detection. Flag is now conditionally set to "-fno-lto" only if compiler is GCC-compatible and test succeeds.

Possibly related PRs

  • zlib-ng/zlib-ng#1850: Modifies build configuration to disable LTO during compiler checks by injecting ZNOLTOFLAG into CMake's required flags.

Suggested labels

Build Env

Suggested reviewers

  • nmoinvaz
  • Dead2

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: fixing detection of -fno-lto compiler support by changing from assumed support to testing-based detection.
Description check ✅ Passed The description directly addresses the changeset by explaining the problem (assumption of -fno-lto support without testing) and the fix (setting default to not supported).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
configure (1)

138-139: Defaulting noltoflag to empty is correct and matches optional-flag policy

Initializing noltoflag to an empty string and letting the detection logic fill it only when supported avoids untested -fno-lto on non-GCC-compatible compilers and aligns with the repo’s “optional flags default to empty; configure detects support” convention. Consider slightly rewording the comment to reflect that we now always start empty and only set it when a GCC‑compatible compiler passes the check (e.g., “Set default for noltoflag; GCC-compatible compilers may enable it below”).

Based on learnings, optional feature flags should default to empty strings.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b3ade58 and e0148d3.

📒 Files selected for processing (1)
  • configure (2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: mtl1979
Repo: zlib-ng/zlib-ng PR: 1925
File: arch/loongarch/lasxintrin_ext.h:38-65
Timestamp: 2025-07-04T16:59:44.725Z
Learning: In zlib-ng, the policy for supporting old compilers is to maintain compatibility for up to two years after GitHub removes support for them in CI, or when there is no long-time contributor left testing for the architecture if the architecture was not supported by GitHub Actions at all.
Learnt from: mtl1979
Repo: zlib-ng/zlib-ng PR: 1904
File: arch/riscv/Makefile.in:12-14
Timestamp: 2025-04-15T09:20:52.333Z
Learning: Optional feature flags in Makefile.in templates should default to empty strings. The configure script should detect feature support and update these variables accordingly during the configuration process.
📚 Learning: 2025-04-15T09:20:52.333Z
Learnt from: mtl1979
Repo: zlib-ng/zlib-ng PR: 1904
File: arch/riscv/Makefile.in:12-14
Timestamp: 2025-04-15T09:20:52.333Z
Learning: Optional feature flags in Makefile.in templates should default to empty strings. The configure script should detect feature support and update these variables accordingly during the configuration process.

Applied to files:

  • configure
📚 Learning: 2025-04-15T09:30:10.081Z
Learnt from: mtl1979
Repo: zlib-ng/zlib-ng PR: 1904
File: arch/riscv/Makefile.in:12-14
Timestamp: 2025-04-15T09:30:10.081Z
Learning: Feature detection modules like riscv_features.c should not be compiled with feature-specific flags (like RVVFLAG) because they need to be compilable on all systems regardless of feature support. These modules perform runtime detection and must initialize feature availability flags to zero on unsupported systems.

Applied to files:

  • configure
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (75)
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: Windows MSVC 2022 v140 Win32
  • GitHub Check: EL10 GCC S390X DFLTCC UBSAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: Ubuntu GCC C17
  • GitHub Check: macOS GCC UBSAN (ARM64)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: Windows MSVC 2022 v140 Win32
  • GitHub Check: EL10 GCC S390X DFLTCC UBSAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: Ubuntu GCC C17
  • GitHub Check: macOS GCC UBSAN (ARM64)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: Windows MSVC 2022 v140 Win32
  • GitHub Check: EL10 GCC S390X DFLTCC UBSAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: Ubuntu GCC C17
  • GitHub Check: macOS GCC UBSAN (ARM64)
  • GitHub Check: Windows ClangCl Win64 Native Instructions (AVX)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: Windows MSVC 2022 v140 Win32
  • GitHub Check: EL10 GCC S390X DFLTCC UBSAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: Ubuntu GCC C17
  • GitHub Check: macOS GCC UBSAN (ARM64)
  • GitHub Check: Windows ClangCl Win64 Native Instructions (AVX)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: Windows MSVC 2022 v140 Win32
  • GitHub Check: EL10 GCC S390X DFLTCC UBSAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: Ubuntu GCC C17
  • GitHub Check: macOS GCC UBSAN (ARM64)
  • GitHub Check: Windows ClangCl Win64 Native Instructions (AVX)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: Windows MSVC 2022 v140 Win32
  • GitHub Check: EL10 GCC S390X DFLTCC UBSAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: Ubuntu GCC C17
  • GitHub Check: macOS GCC UBSAN (ARM64)
  • GitHub Check: Windows ClangCl Win64 Native Instructions (AVX)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: Windows MSVC 2022 v140 Win32
  • GitHub Check: EL10 GCC S390X DFLTCC UBSAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: Ubuntu GCC C17
  • GitHub Check: macOS GCC UBSAN (ARM64)
  • GitHub Check: Windows ClangCl Win64 Native Instructions (AVX)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: Windows MSVC 2022 v140 Win32
  • GitHub Check: EL10 GCC S390X DFLTCC UBSAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: Ubuntu GCC C17
  • GitHub Check: macOS GCC UBSAN (ARM64)
  • GitHub Check: Windows ClangCl Win64 Native Instructions (AVX)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: Windows MSVC 2022 v140 Win32
  • GitHub Check: EL10 GCC S390X DFLTCC UBSAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: Ubuntu GCC C17
  • GitHub Check: macOS GCC UBSAN (ARM64)
  • GitHub Check: Windows ClangCl Win64 Native Instructions (AVX)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: Windows MSVC 2022 v140 Win32
  • GitHub Check: EL10 GCC S390X DFLTCC UBSAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: Ubuntu GCC C17
🔇 Additional comments (1)
configure (1)

1034-1045: -fno-lto probe correctly gates support to GCC-compatible compilers

The updated probe now only assigns noltoflag="-fno-lto" when a GCC‑compatible compiler actually accepts the flag, and leaves it empty otherwise, fixing the previous assumption that non‑GCC compilers supported -fno-lto without testing. The extra guard on without_optimizations preserves the “no extra flags when optimizations are disabled” behavior. This looks semantically sound and consistent with how other optional flags are handled.

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.35%. Comparing base (e2cd66c) to head (e0148d3).
⚠️ Report is 5 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2045      +/-   ##
===========================================
+ Coverage    80.64%   82.35%   +1.71%     
===========================================
  Files          162      163       +1     
  Lines        12883    12935      +52     
  Branches      3174     3192      +18     
===========================================
+ Hits         10389    10653     +264     
+ Misses        1455     1190     -265     
- Partials      1039     1092      +53     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Dead2 Dead2 merged commit 5c10a60 into zlib-ng:develop Dec 8, 2025
156 checks passed
@Dead2 Dead2 mentioned this pull request Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants