Skip to content

ci: add Clang compilation warning check to build workflow - #1386

Merged
gaoxueyu merged 1 commit into
IvorySQL:masterfrom
messere1:ci/issue-1221-clang-warning-check
Sep 3, 2026
Merged

gaoxueyu merged 1 commit into
IvorySQL:masterfrom
messere1:ci/issue-1221-clang-warning-check

Conversation

@messere1

@messere1 messere1 commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Related Issue

Closes #1221

Motivation

Issue #1221 requests adding a Clang compilation warning check to the CI workflow, mirroring the GCC-side mechanism introduced in #999. Currently .github/workflows/build.yml only builds with GCC 14 and GCC-specific -Werror flags. This PR adds a parallel Clang build job for compiler-diversity warning coverage.

Changes

Add a new build-clang job to .github/workflows/build.yml that:

  • Installs clang (ubuntu-latest default version) alongside the existing build dependencies.
  • Runs ./configure with CC=clang and the same feature flags as the GCC job.
  • Runs make with a set of Clang-supported -Werror warning flags.

The flag list intentionally omits GCC-only flags (-Wshadow=compatible-local, -Werror=missing-variable-declarations) that Clang does not support, and instead includes Clang-equivalent diagnostics that catch the same classes of bugs (unused values/variables, missing prototypes, implicit declarations, type mismatches, format strings, etc.).

The new job runs in parallel with the existing build (GCC) job, so it does not increase overall CI latency.

How Verified

  • YAML lint: no syntax errors in the workflow file.
  • The job structure mirrors the existing proven GCC job (same runner, dependencies, configure flags), only swapping CC=clang and the warning flag set.
  • The fork's Actions run (linked below once available) will provide full validation.

Summary by CodeRabbit

  • Tests
    • Added continuous integration coverage for building with Clang 18 using a dedicated build job.
    • Clang-based builds now treat additional compiler warnings as errors, improving early detection of potential compatibility and code-quality issues.

Copilot AI review requested due to automatic review settings July 9, 2026 09:04
@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a build-clang workflow job that installs Clang 18, configures the project with Clang, and compiles it with additional warnings treated as errors.

Changes

Clang CI Build

Layer / File(s) Summary
Add build-clang CI job
.github/workflows/build.yml
Installs and selects Clang 18, applies the existing Linux configuration and dependencies, and compiles with additional Clang warning categories enforced as errors.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a Clang warning check to CI.
Linked Issues check ✅ Passed The workflow adds a parallel Clang build job, matching #1221's request for Clang warning coverage.
Out of Scope Changes check ✅ Passed The only changed file is the CI workflow, and its edits all support the Clang warning check.
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

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the CI build workflow to add a parallel Clang build job, intended to provide compiler-diversity warning coverage alongside the existing GCC-based build and -Werror checks.

Changes:

  • Added a new build-clang job to run ./configure with CC=clang and compile with a Clang-oriented -Werror flag set.
  • Extended workflow dependencies installation to include clang for the new job.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/build.yml Outdated
--with-ossp-uuid --with-libxml --with-libxslt --with-perl \
--with-icu --with-libnuma --enable-injection-points --enable-nls
- name: compile
run: make CFLAGS="$CFLAGS -Werror=unused-value -Werror=unused-but-set-variable -Werror=missing-prototypes -Werror=unused-variable -Werror=maybe-uninitialized -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=incompatible-pointer-types -Werror=format -Werror=empty-body -Werror=parentheses -Werror=pointer-sign -Werror=unsequenced"
Comment thread .github/workflows/build.yml Outdated
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: dependancy - linux

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
.github/workflows/build.yml (2)

59-59: 📐 Maintainability & Code Quality | 🔵 Trivial

Consider setting CXX=clang++ alongside CC=clang

While PostgreSQL is primarily C, explicitly setting CXX=clang++ ensures any C++ components or extensions are also compiled with Clang, maintaining compiler consistency across the build.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/build.yml at line 59, The build workflow currently sets
only CC=clang in the configure step, so C++ compilation may still use a
different default compiler. Update the configure invocation in the build
workflow to set CXX=clang++ alongside CC=clang, keeping compiler selection
consistent for any C++ components or extensions referenced by the
configure/build process.

50-51: 📐 Maintainability & Code Quality | 🔵 Trivial

Consider pinning the Clang version for reproducibility

The GCC job pins gcc-14/g++-14 and sets up alternatives, but the Clang job installs the unversioned clang package. As the ubuntu-latest image updates, the Clang version may change, potentially introducing new warnings or behavioral shifts. Consider installing a specific version (e.g., clang-18) for consistency.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/build.yml around lines 50 - 51, The Clang setup in the
build workflow is unpinned, so the version can drift on ubuntu-latest. Update
the Clang installation in the workflow job that installs build tools to use a
specific version package (for example, a versioned clang package) and make sure
the same version is used consistently in the Clang job alongside the existing
GCC pinning approach.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/build.yml:
- Line 66: The clang build configuration in the build workflow is using the
GCC-only warning group -Werror=maybe-uninitialized, which causes an
unknown-warning diagnostic under clang. Update the CFLAGS definition in the
workflow job so the clang path does not include this flag, and use the
clang-compatible equivalent warning option (or omit it entirely) while keeping
the rest of the compiler warnings unchanged.

---

Nitpick comments:
In @.github/workflows/build.yml:
- Line 59: The build workflow currently sets only CC=clang in the configure
step, so C++ compilation may still use a different default compiler. Update the
configure invocation in the build workflow to set CXX=clang++ alongside
CC=clang, keeping compiler selection consistent for any C++ components or
extensions referenced by the configure/build process.
- Around line 50-51: The Clang setup in the build workflow is unpinned, so the
version can drift on ubuntu-latest. Update the Clang installation in the
workflow job that installs build tools to use a specific version package (for
example, a versioned clang package) and make sure the same version is used
consistently in the Clang job alongside the existing GCC pinning approach.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 54dadd95-5cef-4aee-98a2-c75dca3ca981

📥 Commits

Reviewing files that changed from the base of the PR and between 7fb2571 and 9f5f162.

📒 Files selected for processing (1)
  • .github/workflows/build.yml

Comment thread .github/workflows/build.yml Resolved
@bigplaice

Copy link
Copy Markdown
Collaborator

Thanks for your patch!

messere1 added a commit to messere1/IvorySQL that referenced this pull request Jul 10, 2026
Per review feedback on PR IvorySQL#1386:

- Replace GCC-only -Werror=maybe-uninitialized with Clang's
  -Werror=uninitialized (which enables -Wsometimes-uninitialized)
- Pass CXX=clang++ to configure so C++ compilation also uses Clang
- Pin the Clang version to clang-18 via update-alternatives, mirroring
  how the GCC job pins gcc-14, to avoid toolchain drift on
  ubuntu-latest

Assisted-by: Claude Code:claude-fable-5

Co-Authored-By: Claude Fable 5 <[email protected]>
@bigplaice

Copy link
Copy Markdown
Collaborator

@messere1
Please explain the change to src/backend/commands/sequence.c
You are not only fixing the warning, but also changing the code logic.

@messere1

messere1 commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for pointing that out.This is an intentional logic fix, not merely warning suppression.

shardcnt is initialized and incremented for shard_extend, shard_noextend, and noshard, but the following condition checked keepcnt. This appears to be a copy-paste error from the preceding KEEP/NOKEEP block. As a result, shardcnt was never read, and duplicate or conflicting SHARD specifications were not rejected as the existing error message intended.

Changing the condition to shardcnt > 1 makes the check consistent with both the counter and the error message. It only changes the handling of statements containing multiple SHARD/NOSHARD specifications; valid statements with zero or one such option are unaffected.

I verified the change with the full Clang build, PostgreSQL regression tests, and IvorySQL Oracle regression tests. I should have explained this logic change explicitly in the commit message - sorry for the omission. I can also add a regression case for conflicting SHARD options if you prefer.

@bigplaice

Copy link
Copy Markdown
Collaborator

@messere1
Hi, please adress my comment about CFLAGS and Copilot's comment about typo.

@bigplaice

bigplaice commented Jul 16, 2026 •

Copy link
Copy Markdown
Collaborator

This PR will be froze until human author(NOT AI) give response to comments.

@bigplaice bigplaice self-assigned this Jul 16, 2026
@messere1

Copy link
Copy Markdown
Contributor Author

I added -Werror=unknown-warning-option so that Clang fails when a warning option is misspelled or unsupported, instead of allowing the CI job to pass with incomplete warning coverage.
I temporarily removed -Werror=unused-but-set-variable because the current master branch is not clean for that diagnostic. The sequence.c issue exposed by it is fixed separately, with regression coverage, in #1401. I agree that this warning should not be permanently disabled; after #1401 is merged, I can rebase this PR and restore the flag.
I also corrected the workflow step name from dependancy to dependency.

@bigplaice

Copy link
Copy Markdown
Collaborator

I started a review, in which I have tow comments:

  1. use COPT to replace CFLAGS.
  2. use -Werror to cover all specific warnings.

What do you think?

@messere1

Copy link
Copy Markdown
Contributor Author

I agree with both suggestions. COPT is the documented way to append build-time flags without replacing the CFLAGS selected by configure. Using a single -Werror is also simpler and promotes every warning already enabled by the configured Clang build, instead of maintaining an incomplete list of specific warning groups. I will update the compile step to use make COPT="-Werror".

@bigplaice

Copy link
Copy Markdown
Collaborator

@messere1 Hi, is there any plan of update?

@messere1

messere1 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the reminder. I have prepared the update locally: it is rebased onto the current master, uses make COPT="-Werror", and remains workflow-only with no sequence.c changes.

#1451 contains the warning fixes required for the global -Werror build, and all seven checks on that PR are passing. To avoid intentionally pushing a known-red CI update, I plan to push the refreshed #1386 immediately after #1451 is merged.

@bigplaice

Copy link
Copy Markdown
Collaborator

@messere1 Hi,#1451 has been merged, you can continue the work on this PR, thanks.

Use Clang 18 consistently and pass the global warning policy through COPT so configure-selected CFLAGS remain intact.

Assisted-by: OpenAI:gpt-5
@messere1
messere1 force-pushed the ci/issue-1221-clang-warning-check branch from 82c18c0 to 56fb8e3 Compare August 24, 2026 12:21
@messere1

Copy link
Copy Markdown
Contributor Author

Thanks for the reminder. I have now refreshed this PR on top of the latest master after #1451 was merged.

The PR is workflow-only:

  • it installs and selects Clang 18 consistently for C and C++;
  • it keeps configure-selected CFLAGS intact;
  • the compile step uses make COPT="-Werror", as suggested, so all enabled Clang warnings are treated as errors.

There are no source-code changes in this PR. I will monitor the new CI run.

@gaoxueyu
gaoxueyu merged commit f56745a into IvorySQL:master Sep 3, 2026
8 checks passed
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.

[Enhancement] Add a Clang compilation warning check in the workflow.

4 participants