Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-15]

steps:
- uses: actions/checkout@v4
Expand Down
34 changes: 21 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,23 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(BASE_C_FLAGS "-fPIC -fno-strict-overflow -fno-strict-aliasing")
set(BASE_CXX_FLAGS "-fPIC -fno-strict-overflow -fno-strict-aliasing")

# Compiler-specific flags
# Compiler-specific flags.
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(COMPILER_SPECIFIC_FLAGS "-Wno-cast-user-defined -Wno-array-bounds -Wno-type-limits")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(COMPILER_SPECIFIC_FLAGS "-Wno-array-bounds")
set(COMPILER_SPECIFIC_C_FLAGS "-Wno-array-bounds -Wno-type-limits")
set(COMPILER_SPECIFIC_CXX_FLAGS "-Wno-cast-user-defined ${COMPILER_SPECIFIC_C_FLAGS}")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# GLCache/segment.c stores INT64_MAX into a double field; AppleClang 21 flags the
# value change as -Wimplicit-const-int-float-conversion and -Werror makes it fatal.
set(COMPILER_SPECIFIC_C_FLAGS "-Wno-array-bounds -Wno-implicit-const-int-float-conversion")
set(COMPILER_SPECIFIC_CXX_FLAGS "${COMPILER_SPECIFIC_C_FLAGS}")
else()
set(COMPILER_SPECIFIC_FLAGS "")
set(COMPILER_SPECIFIC_C_FLAGS "")
set(COMPILER_SPECIFIC_CXX_FLAGS "")
endif()

# Apply flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${BASE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${BASE_C_FLAGS} ${COMPILER_SPECIFIC_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_CXX_FLAGS}")

# =============================================================================
# Git Submodule Management
Expand Down Expand Up @@ -80,13 +85,16 @@ endif()
function(build_libcachesim)
message(STATUS "Building libCacheSim...")

# Prepare CMake arguments for subproject
# Prepare CMake arguments for subproject.
# The C flags carry the compiler-specific suppressions too: libCacheSim is mostly
# C, and passing them only to the C++ compiler left its C sources exposed to
# upstream's -Werror.
set(CMAKE_ARGS
"-DCMAKE_C_FLAGS=${BASE_C_FLAGS}"
"-DCMAKE_CXX_FLAGS=${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_FLAGS}"
"-DCMAKE_CXX_FLAGS_DEBUG=-g ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_FLAGS}"
"-DCMAKE_CXX_FLAGS_RELEASE=-O3 ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_FLAGS}"
"-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O2 -g -DNDEBUG ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_FLAGS}"
"-DCMAKE_C_FLAGS=${BASE_C_FLAGS} ${COMPILER_SPECIFIC_C_FLAGS}"
"-DCMAKE_CXX_FLAGS=${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_CXX_FLAGS}"
"-DCMAKE_CXX_FLAGS_DEBUG=-g ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_CXX_FLAGS}"
"-DCMAKE_CXX_FLAGS_RELEASE=-O3 ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_CXX_FLAGS}"
"-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O2 -g -DNDEBUG ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_CXX_FLAGS}"
)

# Configure libCacheSim
Expand Down
6 changes: 6 additions & 0 deletions docs/src/en/getting_started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

Windows is not supported.

!!! note "macOS wheels"
The published macOS wheels are Apple Silicon (arm64) only and require **macOS 15 or
newer**. They bundle Homebrew libraries, which are built for the macOS version of the
release runner and set that floor. On an Intel Mac or an older macOS, `pip` falls back
to [building from source](#install-from-source).

## Install from PyPI

Pre-built wheels are published to [PyPI](https://pypi.org/project/libcachesim/), so in most
Expand Down
5 changes: 5 additions & 0 deletions docs/src/zh/getting_started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

不支持 Windows。

!!! note "关于 macOS wheel"
发布的 macOS wheel 仅面向 Apple Silicon(arm64),且要求 **macOS 15 及以上**。这些 wheel
捆绑了 Homebrew 的动态库,而 Homebrew 只为发布机所用的 macOS 版本构建这些库,因此下限由此
决定。在 Intel Mac 或更旧的 macOS 上,`pip` 会回退到“从源码安装”。

## 从 PyPI 安装

我们已将预编译的 wheel 发布到 [PyPI](https://pypi.org/project/libcachesim/),因此大多数情况下无需编译器:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ build-dir = "build"
[tool.scikit-build.cmake]
build-type = "Release"
args = ["-G", "Ninja"]
define = { CMAKE_OSX_DEPLOYMENT_TARGET = "11.0" }
define = { CMAKE_OSX_DEPLOYMENT_TARGET = "15.0" }
version = ">=3.15"
source-dir = "."

Expand All @@ -83,7 +83,7 @@ skip = ["*-win32", "*-manylinux_i686", "*-musllinux*", "pp*"]
# Set the environment variable for the wheel build step.
# NOTE(haocheng): we enable all the optional features for the wheel build.
# And MACOSX_DEPLOYMENT_TARGET should be kept in sync with [tool.scikit-build.cmake].define.CMAKE_OSX_DEPLOYMENT_TARGET
environment = { LCS_BUILD_DIR = "{project}/src/libCacheSim/build", MACOSX_DEPLOYMENT_TARGET = "11.0", CMAKE_ARGS = "-DENABLE_3L_CACHE=ON -DENABLE_GLCACHE=ON -DENABLE_LRB=ON" }
environment = { LCS_BUILD_DIR = "{project}/src/libCacheSim/build", MACOSX_DEPLOYMENT_TARGET = "15.0", CMAKE_ARGS = "-DENABLE_3L_CACHE=ON -DENABLE_GLCACHE=ON -DENABLE_LRB=ON" }

# Test that the wheel can be imported
test-command = "python -c 'import libcachesim; print(\"Import successful\")'; cp -r {project}/tests .; python -m pytest tests/ -v -m 'not optional'; python -m pytest tests/ -v -m 'optional'"
Expand Down
29 changes: 23 additions & 6 deletions scripts/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,21 @@ install_zstd() {
# Install XGBoost from source
install_xgboost() {
log_info "Installing XGBoost from source..."
# Pinned, not tracking master: XGBoost removed the deprecated XGBoosterPredict
# after v3.3.0, and libCacheSim's GLCache/inference.c still calls it, so a clone
# of master fails to compile with "implicit declaration of function". v3.3.0 is
# also what Homebrew installs, so the Linux and macOS wheels build against the
# same API. The directory carries the version so a checkout left in /tmp by an
# older run of this script is not silently reused.
local xgboost_version="v3.3.0"
local xgboost_dir="xgboost-${xgboost_version}"

pushd /tmp/ >/dev/null
if [[ ! -d "xgboost" ]]; then
git clone --recursive https://github.com/dmlc/xgboost
if [[ ! -d "${xgboost_dir}" ]]; then
git clone --recursive --depth 1 --branch "${xgboost_version}" \
https://github.com/dmlc/xgboost "${xgboost_dir}"
fi
pushd xgboost >/dev/null
pushd "${xgboost_dir}" >/dev/null
mkdir -p build
pushd build >/dev/null
cmake -G Ninja ..
Expand All @@ -139,11 +149,18 @@ install_xgboost() {
# Install LightGBM from source
install_lightgbm() {
log_info "Installing LightGBM from source..."
# Pinned for the same reason as XGBoost above -- an unpinned clone means the
# build depends on whatever master happens to be that day. v4.7.0 matches the
# version Homebrew installs for the macOS wheels.
local lightgbm_version="v4.7.0"
local lightgbm_dir="LightGBM-${lightgbm_version}"

pushd /tmp/ >/dev/null
if [[ ! -d "LightGBM" ]]; then
git clone --recursive https://github.com/microsoft/LightGBM
if [[ ! -d "${lightgbm_dir}" ]]; then
git clone --recursive --depth 1 --branch "${lightgbm_version}" \
https://github.com/microsoft/LightGBM "${lightgbm_dir}"
fi
pushd LightGBM >/dev/null
pushd "${lightgbm_dir}" >/dev/null
mkdir -p build
pushd build >/dev/null
cmake -G Ninja ..
Expand Down
24 changes: 18 additions & 6 deletions scripts/install_deps_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,22 @@ EOF
install_xgboost() {
log_step "Installing XGBoost..."

# Pinned rather than tracking master: XGBoost removed the deprecated
# XGBoosterPredict after v3.3.0, which libCacheSim's GLCache/inference.c still
# calls, so master no longer compiles. See install_deps.sh for the full note.
local xgboost_version="v3.3.0"

pushd "${HOME}/src" >/dev/null

if [[ ! -d "xgboost" ]]; then
git clone --recursive https://github.com/dmlc/xgboost.git
fi

pushd xgboost >/dev/null
git pull origin master
# Fetch and check out the tag instead of pulling master -- this also repoints a
# checkout that an older version of this script left on master.
git fetch --tags origin
git checkout --quiet "${xgboost_version}"
git submodule update --init --recursive

mkdir -p build
Expand All @@ -262,14 +270,18 @@ install_xgboost() {
install_lightgbm() {
log_step "Installing LightGBM..."

# Pinned for the same reason as XGBoost above; v4.7.0 matches Homebrew's version.
local lightgbm_version="v4.7.0"

pushd "${HOME}/src" >/dev/null

if [[ ! -d "LightGBM" ]]; then
git clone --recursive https://github.com/microsoft/LightGBM.git
fi

pushd LightGBM >/dev/null
git pull origin master
git fetch --tags origin
git checkout --quiet "${lightgbm_version}"
git submodule update --init --recursive

mkdir -p build
Expand Down
Loading