Skip to content

CI/CD: Enhance the build system #22

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

Merged
merged 2 commits into from
Aug 3, 2025
Merged

CI/CD: Enhance the build system #22

merged 2 commits into from
Aug 3, 2025

Conversation

haochengxia
Copy link
Collaborator

No description provided.

@haochengxia haochengxia merged commit a31ef0e into main Aug 3, 2025
@haochengxia haochengxia deleted the hxia/user branch August 3, 2025 04:24
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @haochengxia, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the project's build system by improving how dependencies are managed and installed, particularly for user-specific environments. My goal is to streamline the setup process for developers by providing an automated script to install common tools and libraries into a local directory. Concurrently, I've made the CMake configuration more flexible and resilient in finding these dependencies, ensuring a smoother build experience across different setups. These changes aim to reduce friction in getting the project up and running, especially for new contributors or in environments where system-wide installations are not preferred.

Highlights

  • Automated User-Level Dependency Installation: I've introduced a new shell script, scripts/install_deps_user.sh, which automates the installation of essential build tools (CMake, Ninja) and key project dependencies (Zstd, Google Perftools, XGBoost, LightGBM) into a user's local ~/local directory. This script also configures environment variables and generates CMake config files to ensure these locally installed components are discoverable by the build system.
  • Improved CMake Dependency Resolution: I've significantly enhanced the CMakeLists.txt to better handle user-installed dependencies. This includes setting up CMAKE_PREFIX_PATH and related variables to search ~/local, and implementing more robust find_package logic for ZSTD, TCMalloc, XGBoost, and LightGBM. The build system will now attempt multiple methods (e.g., pkg-config, manual path searching) to locate these libraries, making TCMalloc and XGBoost optional and providing clearer error messages if they are not found.
  • Python 3 Migration and Compiler Flag Adjustments: I've updated the CMakeLists.txt to use find_package(Python3 ...) instead of find_package(Python ...) to explicitly target Python 3, and switched from python_add_library to pybind11_add_module for creating the Python module. Additionally, I've added -Wno-type-limits to the GNU compiler flags to suppress specific warnings.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request significantly enhances the build system by improving dependency detection in CMakeLists.txt and adding a new script to install dependencies in a user-local environment. The changes make the project easier to build, especially for users without root permissions.

My review focuses on modernizing CMake practices, improving the robustness of the new installation script, and ensuring consistency between the build configuration and the helper scripts. I've identified a few areas for improvement, such as removing legacy CMake commands, cleaning up unused variables, and pinning dependencies to stable versions in the installation script for better reproducibility.

# Install CMake
install_cmake() {
log_step "Installing CMake..."
local cmake_version="3.31.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The script is set to install CMake version 3.31.0. However, the CMakeLists.txt file specifies a maximum compatible version of 3.27 (cmake_minimum_required(VERSION 3.15...3.27)). Building with CMake 3.31.0 will result in an error. Please align the CMake version in this script with the range specified in CMakeLists.txt to ensure compatibility. A version like 3.27.9 would be suitable.

Suggested change
local cmake_version="3.31.0"
local cmake_version="3.27.9"

Comment on lines +31 to +32
include_directories("${USER_PREFIX}/include")
link_directories("${USER_PREFIX}/lib")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using include_directories and link_directories at the top-level is a legacy practice in CMake and is generally discouraged as it affects all subsequent targets globally. This can lead to unexpected behavior, such as picking up the wrong headers. This advice applies to other uses of these commands in this file as well (e.g., for ZSTD).

The modern approach is to associate include directories and libraries with specific targets using target_include_directories and target_link_libraries. Since the target libcachesim_python is defined much later, you could collect all required include paths in a list variable and then apply it to the target once it's defined.

Comment on lines +174 to +178
set(USER_PREFIX_PATHS
"$ENV{HOME}/local"
"$ENV{HOME}/.local"
"/usr/local"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The variable USER_PREFIX_PATHS is defined here but it is not used anywhere else in the file. This appears to be dead code. Please either use it (e.g., by appending it to CMAKE_PREFIX_PATH) or remove it to avoid confusion.

endif()

if(xgboost_FOUND)
include_directories(${XGBOOST_INCLUDE_DIR})
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The include_directories(${XGBOOST_INCLUDE_DIR}) call is redundant. The xgboost::xgboost target is created as an imported target with INTERFACE_INCLUDE_DIRECTORIES. When you link against xgboost::xgboost, CMake automatically adds the necessary include directories to the target. You can safely remove this line.

Comment on lines +246 to +247
git pull origin master
git submodule update --init --recursive
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Building XGBoost directly from the master branch can lead to instability and non-reproducible builds, as master may contain breaking changes. It is recommended to check out and build a specific, stable release tag.

Suggested change
git pull origin master
git submodule update --init --recursive
git fetch --all --tags
git checkout tags/v2.1.0 # Or another stable release tag
git submodule update --init --recursive

Comment on lines +272 to +273
git pull origin master
git submodule update --init --recursive
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Building LightGBM directly from the master branch can lead to instability and non-reproducible builds, as master may contain breaking changes. It is recommended to check out and build a specific, stable release tag.

Suggested change
git pull origin master
git submodule update --init --recursive
git fetch --all --tags
git checkout tags/v4.4.0 # Or another stable release tag
git submodule update --init --recursive

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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy