Skip to content
Closed
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
80 changes: 80 additions & 0 deletions .codex/skills/bolt-build/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
name: bolt-build
description: Use when working on the Bolt repository and you need to configure or compile code correctly and efficiently. This skill defines the canonical Bolt build workflow, including when to run `make <TARGET> BOLT_CONAN_CONFIGURE_ONLY=1`, when to switch to `cmake --build --preset conan-<build type> --target <TARGET>`, and when reconfiguration is required because the build type or test inclusion has changed.
---

# Bolt Build

Use this skill for any Bolt task that requires configuring or compiling the repository.

## Core rule

Do not use `make` for routine incremental compilation once the build is configured.

## Configure

To configure a build, run:

```bash
make <TARGET> BOLT_CONAN_CONFIGURE_ONLY=1
```

This chooses the active configuration, including:
- Build type: `debug`, `release`, or `relwithdebinfo`
- Whether tests are included for that target/configuration

## Build

If the build is already configured for the needed target and build type, compile with:

```bash
cmake --build --preset conan-<build type> --target <TARGET>
```

Valid preset suffixes:
- `debug`
- `release`
- `relwithdebinfo`

## When to reconfigure

Run `make <TARGET> BOLT_CONAN_CONFIGURE_ONLY=1` again only if:
- The required build type is different from the current one
- The desired target does not exist in the current configuration
- You need to include or exclude tests and the current configuration does not match

## Detecting the current build type

Check `_build/.build_type` to determine the currently configured build type:

```bash
cat _build/.build_type
```

This returns one of: `debug`, `release`, or `relwithdebinfo`.

Use this to decide whether you can reuse the existing preset or need to reconfigure for a different build type.

## Working rules

- Prefer the narrowest target that validates the change.
- Reuse the current configured preset whenever possible.
- If a compile fails, fix the smallest coherent issue and re-run the same narrow build first.
- In status updates and final summaries, state whether you reused an existing configured preset or had to reconfigure.

## Finding the narrowest target

To identify the smallest target that contains an edited compilation unit:

1. Locate the edited `*.cpp` file's directory.
2. Find the `CMakeLists.txt` in that directory (or the nearest parent directory).
3. Search for the target that lists the edited `*.cpp` file in its source list.
4. Build that target.

Example:
- Edited file: `bolt/core/execution/ExecutionPlan.cpp`
- Check: `bolt/core/execution/CMakeLists.txt` (or `bolt/core/CMakeLists.txt`)
- Look for: `add_library(bolt_core ... ExecutionPlan.cpp ...)` or `add_executable(bolt_core_tests ...)`
- Build: `cmake --build --preset conan-release --target bolt_core`

This ensures you compile only what's necessary to validate your change.
140 changes: 140 additions & 0 deletions .devcontainer/clang/Dockerfile.clang
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
FROM debian:bookworm

ENV CMAKE_VERSION=3.31.8
ENV MOLD_VERSION=2.40.4

ARG DEB_REGION=""
ARG https_proxy=""
ARG no_proxy=""

# check if deb region is not empty string. If it is, replace the default debian repository with the one for the region.
RUN if [ "$DEB_REGION" != "" ]; then \
sed -i "s|http://deb.debian.org/debian|http://ftp.${DEB_REGION}.debian.org/debian|g" /etc/apt/sources.list.d/debian.sources; \
fi

RUN apt-get update && \
apt-get install -y \
curl \
tar

RUN arch=$(arch) && \
https_proxy=${https_proxy} \
curl -L -# -o /tmp/cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-linux-${arch}.tar.gz && \
tar -xzvf /tmp/cmake.tar.gz -C /opt && \
ln -s /opt/cmake-$CMAKE_VERSION-linux-${arch}/bin/cmake /usr/local/bin/cmake && \
ln -s /opt/cmake-$CMAKE_VERSION-linux-${arch}/bin/ctest /usr/local/bin/ctest && \
rm /tmp/cmake.tar.gz

RUN apt-get update && apt-get install -y \
sudo \
bash \
vim-tiny \
vim \
sudo \
git \
gdb \
python3 \
python3-pip \
python3-virtualenv \
ssh-client \
ninja-build \
bison \
maven \
net-tools \
telnet \
ssh \
rsync \
openssh-server \
lld \
ccache \
binutils-dev \
make \
automake \
autoconf \
htop \
less \
man \
nodejs \
npm \
bsdextrautils \
locales \
clang-19 \
clang++-19 \
&& update-alternatives --install /usr/bin/clang clang /usr/bin/clang-19 100 \
&& update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 100 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN ln -sf /bin/bash /bin/sh

RUN https_proxy=${https_proxy} curl -L -O --output-dir /tmp https://github.com/rui314/mold/releases/download/v$MOLD_VERSION/mold-$MOLD_VERSION-$(arch)-linux.tar.gz
RUN cd /tmp && \
sudo tar -C /usr/local --strip-components=1 -xzf mold-$MOLD_VERSION-$(arch)-linux.tar.gz

# Add mold's ld as the first on the path
env PATH=/usr/local/libexec/mold:$PATH

# License header check tool
RUN https_proxy=${https_proxy} curl -L -# -o /tmp/skywalking-eyes-bin.tgz https://dlcdn.apache.org/skywalking/eyes/0.8.0/skywalking-license-eye-0.8.0-bin.tgz && \
mkdir -p /opt/skywalking-license-eye && \
sudo tar -C /opt/skywalking-license-eye --strip-components=1 -xzf /tmp/skywalking-eyes-bin.tgz

ENV PATH="/opt/skywalking-license-eye/bin/linux:${PATH}"

RUN export arch=$(arch | sed 's/^aarch64$/arm64/; s/^x86_64$/amd64/') && \
export https_proxy=${https_proxy} && \
export filename=go1.25.5.linux-${arch}.tar.gz && \
curl -L -O --output-dir /tmp https://go.dev/dl/${filename} && \
sudo rm -rf /usr/local/bin/go && tar -C /usr/local -xzf /tmp/${filename} && \
rm /tmp/${filename}
ENV PATH="/usr/local/go/bin:${PATH}"

# Set up default python virtualenv, and make it the default on PATH
RUN virtualenv -p python3 /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt && \
rm -f requirements.txt

ARG USERNAME=code
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

USER $USERNAME

# Configure default conan profile to use the mold linker
RUN arch=$(uname -m) && mkdir -p ~/.conan2/profiles && cat > ~/.conan2/profiles/default <<EOF
[settings]
arch=$( [ "$arch" = "aarch64" ] && echo "armv8" || echo "$arch" )
build_type=Release
compiler=clang
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=19
os=Linux

[conf]
tools.build:compiler_executables={"c": "clang", "cpp": "clang++"}
tools.build:exelinkflags=['-fuse-ld=mold', '-Wl,--allow-multiple-definition']
tools.build:sharedlinkflags=['-fuse-ld=mold', '-Wl,--allow-multiple-definition']

EOF

# Generate Locales
RUN sudo sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen && \
sudo locale-gen && \
echo "export LC_ALL=en_US.UTF-8" >> ~/.bashrc && \
echo "export LANG=en_US.UTF-8" >> ~/.bashrc && \
echo "export LANGUAGE=en_US.UTF-8" >> ~/.bashrc


ENV SHELL=/bin/bash

WORKDIR /workspace

ENTRYPOINT ["/bin/bash", "-c"]
37 changes: 37 additions & 0 deletions .devcontainer/clang/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "Bolt Clang Development Container",
"build": {
"dockerfile": "Dockerfile.clang",
"context": "../../.github/runners",
"args": {
"DEB_REGION": "",
"https_proxy": "",
"no_proxy": ""
}
},
"containerEnv": {
"https_proxy": "",
"no_proxy": "",
"SHELL": "/bin/bash"
},
"remoteUser": "code",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [],
// Use 'portsAttributes' to set default properties for specific forwarded ports.
"portsAttributes": {},
// Use 'remoteEnv' to set environment variables that are only available inside the container.
"remoteEnv": {},
// Use 'mounts' to make files or directories from your local machine available inside the container.
"mounts": [
"source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
"source=conan-cache,target=/home/code/.conan2/p",
"source=ccache-cache,target=/home/code/.ccache"
],
"runArgs": [
"--security-opt",
"label=disable"
],
// Configure tool-specific properties.
"features": {},
"postCreateCommand": ".devcontainer/post_create_command.sh"
}
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions(-D OS_MACOSX)
endif()

# Only use compiler-rt when building with Clang on Linux for ARM/AArch64
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND OS_LINUX AND (ARCH_AARCH64 OR ARCH_ARM))
add_compile_options(-rtlib=compiler-rt)
add_link_options(-rtlib=compiler-rt)
endif()

list(PREPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake"
"${PROJECT_SOURCE_DIR}/CMake/third-party"
)
Expand Down
Loading