Skip to content

Fix -Wunused-command-line-argument warnings on Mac OS X#1967

Merged
Dead2 merged 1 commit intozlib-ng:developfrom
ccawley2011:unused-command-line-argument
Sep 27, 2025
Merged

Fix -Wunused-command-line-argument warnings on Mac OS X#1967
Dead2 merged 1 commit intozlib-ng:developfrom
ccawley2011:unused-command-line-argument

Conversation

@ccawley2011
Copy link
Copy Markdown
Contributor

@ccawley2011 ccawley2011 commented Sep 25, 2025

Summary by CodeRabbit

  • Chores
    • Improved build reliability on macOS by handling additional compiler warnings as errors when supported.
    • Enhanced configure-time detection of compiler features, ensuring consistent application of previously discovered flags across subsequent checks.
    • Stabilized feature checks related to specific compiler optimizations to reduce false negatives during configuration.
    • No changes to runtime behavior or public interfaces.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 25, 2025

Walkthrough

Adds Apple-specific detection of -Werror=unused-command-line-argument and integrates it into ADDITIONAL_CHECK_FLAGS. Ensures subsequent compiler feature checks (notably -fno-semantic-interposition) are performed with these accumulated flags by temporarily setting and then resetting CMAKE_REQUIRED_FLAGS in CMake and propagating ADDITIONAL_CHECK_FLAGS in the configure script.

Changes

Cohort / File(s) Summary of Changes
Apple warning flag detection
CMakeLists.txt
Adds check for -Werror=unused-command-line-argument under APPLE; if supported, appends to ADDITIONAL_CHECK_FLAGS.
Flag propagation for feature checks (CMake)
CMakeLists.txt
Wraps -fno-semantic-interposition checks with CMAKE_REQUIRED_FLAGS set to ADDITIONAL_CHECK_FLAGS, then clears it after each check.
Flag detection and propagation (Autotools configure)
configure
Adds compile test for -Werror=unused-command-line-argument; if supported, appends to ADDITIONAL_CHECK_FLAGS. Injects $ADDITIONAL_CHECK_FLAGS into -fno-semantic-interposition checks in both conditional and unconditional paths.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer
  participant CMake as CMake
  participant CC as Compiler

  Dev->>CMake: Configure (APPLE)
  CMake->>CC: Test -Werror=unused-command-line-argument
  alt supported
    CMake->>CMake: ADDITIONAL_CHECK_FLAGS += flag
  else not supported
    CMake->>CMake: No change
  end

  note over CMake: Prepare -fno-semantic-interposition check
  CMake->>CMake: CMAKE_REQUIRED_FLAGS = ADDITIONAL_CHECK_FLAGS
  CMake->>CC: Test -fno-semantic-interposition
  CMake->>CMake: CMAKE_REQUIRED_FLAGS = ""
Loading
sequenceDiagram
  autonumber
  participant User as User
  participant Conf as ./configure
  participant CC as Compiler

  User->>Conf: Run configure
  Conf->>CC: Compile test with -Werror=unused-command-line-argument
  alt supported
    Conf->>Conf: ADDITIONAL_CHECK_FLAGS += flag
  else not supported
    Conf->>Conf: No change
  end

  note over Conf: Feature check uses accumulated flags
  Conf->>CC: Compile test with $ADDITIONAL_CHECK_FLAGS + -fno-semantic-interposition
  alt supported
    Conf->>Conf: Record support
  else not supported
    Conf->>Conf: Record lack of support
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly captures the core change of the pull request by indicating that it addresses the “-Wunused-command-line-argument” warnings specifically on Mac OS X, which aligns directly with the added Apple-specific compiler warning checks in the changeset. It is concise, focused on the main update, and clear to anyone reviewing the history what the primary improvement is.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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)

683-683: Remove redundant write to test.c

The subsequent heredoc writes to $test.c; this line creates an unused test.c file.

-echo "" > test.c
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7800569 and e804ca0.

📒 Files selected for processing (2)
  • CMakeLists.txt (2 hunks)
  • configure (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-04-15T09:20:52.333Z
Learnt from: mtl1979
PR: zlib-ng/zlib-ng#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
⏰ 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). (79)
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows ClangCl Win64
  • GitHub Check: macOS Clang (Target 10.10)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: EL9 GCC S390X DFLTCC ASAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: macOS GCC Symbol Prefix (ARM64)
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows GCC Compat No Opt
  • GitHub Check: Windows ClangCl Win64
  • GitHub Check: macOS Clang (Target 10.10)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: EL9 GCC S390X DFLTCC ASAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: macOS GCC Symbol Prefix (ARM64)
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows GCC Compat No Opt
  • GitHub Check: Windows ClangCl Win64
  • GitHub Check: macOS Clang (Target 10.10)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: EL9 GCC S390X DFLTCC ASAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: macOS GCC Symbol Prefix (ARM64)
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows GCC Compat No Opt
  • GitHub Check: Windows ClangCl Win64
  • GitHub Check: macOS Clang (Target 10.10)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: EL9 GCC S390X DFLTCC ASAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: macOS GCC Symbol Prefix (ARM64)
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows GCC Compat No Opt
  • GitHub Check: Windows ClangCl Win64
  • GitHub Check: macOS Clang (Target 10.10)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: EL9 GCC S390X DFLTCC ASAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: macOS GCC Symbol Prefix (ARM64)
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows GCC Compat No Opt
  • GitHub Check: Windows ClangCl Win64
  • GitHub Check: macOS Clang (Target 10.10)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: EL9 GCC S390X DFLTCC ASAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: macOS GCC Symbol Prefix (ARM64)
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows GCC Compat No Opt
  • GitHub Check: Windows ClangCl Win64
  • GitHub Check: macOS Clang (Target 10.10)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: EL9 GCC S390X DFLTCC ASAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: macOS GCC Symbol Prefix (ARM64)
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows GCC Compat No Opt
  • GitHub Check: Windows ClangCl Win64
  • GitHub Check: macOS Clang (Target 10.10)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: EL9 GCC S390X DFLTCC ASAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: macOS GCC Symbol Prefix (ARM64)
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows GCC Compat No Opt
  • GitHub Check: Windows ClangCl Win64
  • GitHub Check: macOS Clang (Target 10.10)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: EL9 GCC S390X DFLTCC ASAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: macOS GCC Symbol Prefix (ARM64)
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows GCC Compat No Opt
  • GitHub Check: Windows ClangCl Win64
  • GitHub Check: macOS Clang (Target 10.10)
  • GitHub Check: Windows MSVC 2022 v140 Win64
  • GitHub Check: EL9 GCC S390X DFLTCC ASAN
  • GitHub Check: Ubuntu GCC AARCH64 Compat No Opt UBSAN
  • GitHub Check: macOS GCC Symbol Prefix (ARM64)
🔇 Additional comments (4)
configure (2)

682-693: LGTM: detection of -Werror=unused-command-line-argument and propagation into ADDITIONAL_CHECK_FLAGS

Matches the existing pattern for the other Apple/Clang warnings and will prevent false positives when probing -fno-semantic-interposition.


1014-1019: LGTM: include ADDITIONAL_CHECK_FLAGS when probing -fno-semantic-interposition

Ensures clang’s “unused-command-line-argument” becomes an error during the probe, avoiding incorrect enablement.

CMakeLists.txt (2)

408-411: LGTM: add Apple check for -Werror=unused-command-line-argument

Properly augments ADDITIONAL_CHECK_FLAGS alongside the existing Apple-specific warnings.


527-530: LGTM: scope CMAKE_REQUIRED_FLAGS around -fno-semantic-interposition check

Using ADDITIONAL_CHECK_FLAGS here avoids false positives on Apple clang; flags are reset afterwards.

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.77%. Comparing base (7800569) to head (e804ca0).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1967      +/-   ##
===========================================
+ Coverage    81.60%   82.77%   +1.17%     
===========================================
  Files          163      163              
  Lines        14073    14074       +1     
  Branches      3165     3166       +1     
===========================================
+ Hits         11484    11650     +166     
+ Misses        1597     1432     -165     
  Partials       992      992              

☔ 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.

Copy link
Copy Markdown
Member

@Dead2 Dead2 left a comment

Choose a reason for hiding this comment

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

LGTM

@Dead2 Dead2 merged commit aa544c0 into zlib-ng:develop Sep 27, 2025
155 checks passed
@ccawley2011 ccawley2011 deleted the unused-command-line-argument branch September 27, 2025 19:09
@Dead2 Dead2 mentioned this pull request Nov 5, 2025
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