Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Upgrade to LLVM Clang 16 to support C++20 features on macOS 13 and 14; Ensure LLVM Toolchain Consistency; Add macOS 15 to GitHub workflow. #745

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

Bill-hbrhbr
Copy link
Contributor

@Bill-hbrhbr Bill-hbrhbr commented Mar 5, 2025

Description

To meet the requirements of ystdlib-cpp, we must use Clang/AppleClang version 16 or later.

On macOS 13 and 14, a good solution is to install LLVM v16 compilers. However, by default CMake only picks up the new toolchain's llvm-ranlib, while still using /usr/bin/ar for AR, which creates a mismatch in tool versions. For instance, after running brew install llvm@16 on macOS 14:

-- CMAKE_AR: /usr/bin/ar
-- CMAKE_RANLIB: /opt/homebrew/opt/llvm@16/bin/llvm-ranlib

It’s essential that both AR and RANLIB originate from the same LLVM distribution, otherwise linker errors will arise.

While one could technically use /usr/bin/ar together with /usr/bin/ranlib, since we're using LLVM's clang and clang++, it's best to ensure consistency by using llvm-ar and llvm-ranlib from the same distribution.

Therefore, the code has been updated to provide all four LLVM tool overrides needed to guarantee successful compilation with a matching toolchain.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  • Existing workflows run successfully.

Summary by CodeRabbit

  • New Features
    • Improved macOS build support now covers additional versions for enhanced compatibility and performance.
    • Added flexible configuration options for custom tool selection during project builds, ensuring a more robust and tailored build process.

Copy link
Contributor

coderabbitai bot commented Mar 5, 2025

Walkthrough

The changes update the macOS build workflow and enhance the CMake project configuration script. The workflow now uses an updated job matrix that replaces the "runner" key with "os", adding "macos-15" and introducing a conditional step for installing LLVM Clang on "macos-13" and "macos-14". Concurrently, the build-and-run unit tests script has been modified to accept optional command-line arguments for specifying custom archiver and ranlib tools, which are then passed as extra CMake configuration parameters.

Changes

File Change Summary
.github/workflows/.../clp-core-build-macos.yaml Updated job matrix: replaced runner with os (adding "macos-15"); updated runs-on to use ${{matrix.os}}; added conditional step to install LLVM Clang 16 and set corresponding environment variables for "macos-13"/"macos-14".
components/core/.../build-and-run-unit-tests.py Modified _config_cmake_project signature to include optional ar and ranlib parameters; appended CMake flags if provided; added new command-line arguments --ar and --ranlib in the main function.

Sequence Diagram(s)

sequenceDiagram
    participant Workflow as GitHub Workflow
    participant Runner as macOS Runner
    Workflow->>Runner: Evaluate matrix OS (macos-13, macos-14, macos-15)
    alt OS is macos-13/14
        Runner->>Workflow: Install LLVM Clang 16 and set env variables
        Workflow->>Runner: Execute build with LLVM flags
    else OS is macos-15
        Workflow->>Runner: Execute standard build process
    end
Loading
sequenceDiagram
    participant User as Command-line User
    participant Script as Build Script
    participant CMake as CMake Process
    User->>Script: Execute with --ar and --ranlib arguments
    Script->>Script: Parse and validate CLI options
    Script->>Script: Append -DCMAKE_AR and -DCMAKE_RANLIB if provided
    Script->>CMake: Invoke CMake with additional configuration flags
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5078ee9 and f62ad45.

📒 Files selected for processing (2)
  • .github/workflows/clp-core-build-macos.yaml (2 hunks)
  • components/core/tools/scripts/utils/build-and-run-unit-tests.py (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: centos-stream-9-static-linked-bins
  • GitHub Check: ubuntu-jammy-static-linked-bins
  • GitHub Check: ubuntu-jammy-dynamic-linked-bins
  • GitHub Check: centos-stream-9-dynamic-linked-bins
  • GitHub Check: build-macos (macos-14, false)
  • GitHub Check: lint-check (ubuntu-latest)
  • GitHub Check: build-macos (macos-13, false)
  • GitHub Check: lint-check (macos-latest)
  • GitHub Check: build-macos (macos-13, true)
  • GitHub Check: build (macos-latest)
🔇 Additional comments (8)
components/core/tools/scripts/utils/build-and-run-unit-tests.py (4)

24-30: Well-structured function signature update

The updated signature with optional ar and ranlib parameters is well-designed and properly typed with Optional[Path]. This change supports the goal of maintaining toolchain consistency.


40-43: Clean implementation of conditional CMake options

The conditional logic to append archiver and ranlib tools to the CMake command is cleanly implemented and follows best practices.


95-96: Command-line arguments properly implemented

The new command-line arguments are well-integrated with the existing argument structure and include helpful descriptions.


104-107: Clean integration of new parameters

The variable declarations and updated function call properly integrate the new parameters, maintaining consistency with the existing code style.

.github/workflows/clp-core-build-macos.yaml (4)

44-49: Matrix configuration update improves clarity and adds macOS 15 support

The change from runner to os in the matrix configuration is more semantically clear, and the addition of "macos-15" ensures forward compatibility with the latest macOS version.


73-80: Appropriate conditional installation of LLVM Clang 16

The conditional step correctly installs LLVM Clang 16 specifically on macOS 13 and 14 where the compiler inconsistency issue exists. Setting environment variables through GITHUB_ENV is the recommended approach.


86-92: Well-implemented conditional compiler configuration

The conditional environment variable setup for CC and CXX ensures that LLVM Clang is properly used when available, addressing the C++20 feature support requirement.


99-104: Critical fix for toolchain consistency

This change addresses the core issue described in the PR by ensuring both AR and RANLIB tools come from the same LLVM distribution, preventing the toolchain mismatch that was causing linker errors.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Bill-hbrhbr Bill-hbrhbr changed the title Upgrade apple clang 16 ci: Use Apple Clang 16 to support C++20 features on macOS 13 & 14. Mar 5, 2025
@Bill-hbrhbr Bill-hbrhbr changed the title ci: Use Apple Clang 16 to support C++20 features on macOS 13 & 14. ci: Upgrade to LLVM Clang 16 to support C++20 features on macOS before version 15. Mar 6, 2025
@Bill-hbrhbr Bill-hbrhbr changed the title ci: Upgrade to LLVM Clang 16 to support C++20 features on macOS before version 15. ci: Upgrade to LLVM Clang 16 to support C++20 features on macOS 13 and 14; Ensure LLVM Toolchain Consistency; Add macOS 15 to GitHub workflow. Mar 6, 2025
@Bill-hbrhbr Bill-hbrhbr marked this pull request as ready for review March 6, 2025 14:59
@Bill-hbrhbr Bill-hbrhbr requested a review from a team as a code owner March 6, 2025 14:59
@Bill-hbrhbr
Copy link
Contributor Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Mar 6, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

1 participant