Skip to content
Open
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
119 changes: 119 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,122 @@ build:dpc-private \

test:dpc-private \
--test_tag_filters="dpc,-public"


# Configuration: 'release-dpc'
# Build release artifacts including DPC++ libs.
# The //:release target automatically builds all ISA variants when
# --cpu is unset (auto). Use --cpu=<isa> to restrict for CI speed.
# bazel build //:release # CPU only, all ISAs
Comment on lines +117 to +119
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

These comments state that //:release builds “all ISA variants” when --cpu is unset/auto. In the current config, --cpu=auto expands to sse2 + the detected host ISA, not all ISAs. Please update the comment/examples to match reality (or switch examples to --cpu=all if the intent is full ISA coverage).

Suggested change
# The //:release target automatically builds all ISA variants when
# --cpu is unset (auto). Use --cpu=<isa> to restrict for CI speed.
# bazel build //:release # CPU only, all ISAs
# By default, the //:release target builds for SSE2 plus the detected host
# ISA when --cpu is unset (auto). Use --cpu=all for all ISAs, or
# --cpu=<isa> to restrict for CI speed.
# bazel build //:release # CPU only, SSE2 + host ISA
# bazel build //:release --cpu=all # CPU only, all ISAs

Copilot uses AI. Check for mistakes.
# bazel build //:release --config=release-dpc # with DPC++ libs
# bazel build //:release --cpu=avx2 # CI: avx2 only
Comment on lines +117 to +121
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

The comments here say //:release builds all ISA variants when --cpu is left at the default (auto). In the current config system, @config//:cpu defaults to auto, which resolves to a single auto-detected ISA (not all). Consider updating the comment/examples to use --cpu=all (or --cpu=modern / an explicit list) for “all ISA variants” behavior, and reserve auto for single-ISA dev builds.

Suggested change
# The //:release target automatically builds all ISA variants when
# --cpu is unset (auto). Use --cpu=<isa> to restrict for CI speed.
# bazel build //:release # CPU only, all ISAs
# bazel build //:release --config=release-dpc # with DPC++ libs
# bazel build //:release --cpu=avx2 # CI: avx2 only
# The //:release target builds multiple ISA variants when
# --cpu is set to 'all' (or another multi-ISA setting). By default,
# @config//:cpu is 'auto', which selects a single host ISA.
# bazel build //:release --cpu=all # CPU only, all ISAs
# bazel build //:release --config=release-dpc --cpu=all # with DPC++ libs
# bazel build //:release --cpu=avx2 # CI: avx2 only

Copilot uses AI. Check for mistakes.
build:release-dpc \
--release_dpc=true
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

--release_dpc=true uses a different boolean spelling/casing than the other config flags in this repo (e.g., config settings compare against "True"). For consistency (and to avoid any ambiguity in bool parsing), use True/False here as well.

Suggested change
--release_dpc=true
--release_dpc=True

Copilot uses AI. Check for mistakes.


# Configuration: 'dev'
# Fast local development build — compiles only for the host machine's
# highest ISA (auto-detected). Use this to speed up iterative builds.
# NOT suitable for release/packaging.
Comment on lines +127 to +129
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

The dev config description says it “compiles only for the host machine's highest ISA”, but --cpu=auto still includes the sse2 baseline in addition to the detected host ISA (per cpu_info implementation). Please adjust the wording so developers aren’t surprised by the extra ISA being built.

Suggested change
# Fast local development build — compiles only for the host machine's
# highest ISA (auto-detected). Use this to speed up iterative builds.
# NOT suitable for release/packaging.
# Fast local development build — compiles for the host machine's
# highest ISA (auto-detected), plus the baseline sse2 variant. Use this
# to speed up iterative builds. NOT suitable for release/packaging.

Copilot uses AI. Check for mistakes.
# bazel build //cpp/oneapi/dal:tests --config=dev
build:dev \
--cpu=auto


# =============================================================================
# Debug and Sanitizer Configurations
# Equivalent to Make REQDBG / REQSAN options
# =============================================================================

# Configuration: 'dbg'
# Debug build with assertions enabled.
# Equivalent to Make: REQDBG=1
# Adds: -g debug symbols, -DDEBUG_ASSERT, -DONEDAL_ENABLE_ASSERT
# bazel build //:release --config=dbg
# bazel test //cpp/oneapi/dal:tests --config=dbg
common:dbg \
--compilation_mode=dbg \
--enable_assert=True

# Configuration: 'dbg-symbols'
# Debug symbols only — no assertion checking, no -O0.
# Equivalent to Make: REQDBG=symbols
# Adds -g to the default opt build; preserves -O2/-O3 optimization.
# bazel build //:release --config=dbg-symbols
common:dbg-symbols \
--copt=-g \
--cxxopt=-g
Comment on lines +146 to +157
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

Using common:<config> means these options will also be applied to non-build commands when invoked with --config=... (e.g., bazel query), which can cause “unknown option” failures for flags like --compilation_mode, --copt, and --linkopt. To keep configs usable across Bazel subcommands, consider defining these as build:<config> and test:<config> (duplicated), rather than common:<config>.

Suggested change
common:dbg \
--compilation_mode=dbg \
--enable_assert=True
# Configuration: 'dbg-symbols'
# Debug symbols only — no assertion checking, no -O0.
# Equivalent to Make: REQDBG=symbols
# Adds -g to the default opt build; preserves -O2/-O3 optimization.
# bazel build //:release --config=dbg-symbols
common:dbg-symbols \
--copt=-g \
--cxxopt=-g
build:dbg \
--compilation_mode=dbg \
--enable_assert=True
test:dbg \
--compilation_mode=dbg \
--enable_assert=True
# Configuration: 'dbg-symbols'
# Debug symbols only — no assertion checking, no -O0.
# Equivalent to Make: REQDBG=symbols
# Adds -g to the default opt build; preserves -O2/-O3 optimization.
# bazel build //:release --config=dbg-symbols
build:dbg-symbols \
--copt=-g \
--cxxopt=-g
test:dbg-symbols \
--copt=-g \
--cxxopt=-g

Copilot uses AI. Check for mistakes.


# Configuration: 'asan'
# AddressSanitizer build.
# Equivalent to Make: REQSAN=address
# Note: combine with --config=dbg for best results (Make recommendation).
# bazel test //cpp/oneapi/dal:tests --config=asan --config=dbg
common:asan \
--copt=-fsanitize=address \
--copt=-fno-omit-frame-pointer \
--linkopt=-fsanitize=address \
--config=dbg-symbols

# Configuration: 'asan-static'
# AddressSanitizer with static libasan linkage.
# Equivalent to Make: REQSAN=static
common:asan-static \
--copt=-fsanitize=address \
--copt=-fno-omit-frame-pointer \
--linkopt=-fsanitize=address \
--linkopt=-static-libasan \
--config=dbg-symbols


# Configuration: 'tsan'
# ThreadSanitizer build.
# Equivalent to Make: REQSAN=thread
# bazel test //cpp/oneapi/dal:tests --config=tsan
common:tsan \
--copt=-fsanitize=thread \
--copt=-fno-omit-frame-pointer \
--linkopt=-fsanitize=thread \
--config=dbg-symbols


# Configuration: 'ubsan'
# UndefinedBehaviorSanitizer build.
# Equivalent to Make: REQSAN=undefined
# bazel test //cpp/oneapi/dal:tests --config=ubsan
common:ubsan \
--copt=-fsanitize=undefined \
--copt=-fno-omit-frame-pointer \
--linkopt=-fsanitize=undefined \
--config=dbg-symbols


# =============================================================================
# Custom flags
# For injecting arbitrary compiler/linker flags (equivalent to Make COPT/CXXFLAGS):
# bazel build //:release --copt=-march=native
# bazel build //:release --copt=-O2
# bazel build //:release --linkopt=-Wl,--as-needed
# Or persist in user-local ~/.bazelrc:
# build --copt=-your-flag
# =============================================================================

# Configuration: 'msan'
# MemorySanitizer build.
# Note: Requires Clang or ICPX. GCC does not support MSan.
# bazel test //cpp/oneapi/dal:tests --config=msan
common:msan \
--copt=-fsanitize=memory \
--copt=-fsanitize-memory-track-origins \
--copt=-fno-omit-frame-pointer \
--linkopt=-fsanitize=memory \
--config=dbg-symbols

# Configuration: 'type'
# Type sanitizer build.
common:type \
--copt=-fsanitize=type \
--copt=-fno-omit-frame-pointer \
--linkopt=-fsanitize=type \
Comment on lines +224 to +230
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

--config=type uses -fsanitize=type, which is Clang-only (GCC doesn’t support TypeSanitizer). Consider documenting that this config requires Clang/ICPX (similar to the MSan note), so users on GCC don’t get a confusing compiler error.

Copilot uses AI. Check for mistakes.
--config=dbg-symbols
157 changes: 157 additions & 0 deletions dev/bazel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,160 @@ dal_test_suite(

## What is missing in this guide
- How to get make-like release structure

## Debug and Sanitizer Builds

### Debug build with assertions

Equivalent to Make `REQDBG=1` — adds debug symbols, enables `DEBUG_ASSERT`
and `ONEDAL_ENABLE_ASSERT`:

```sh
bazel build //:release --config=dbg
bazel test //cpp/oneapi/dal:tests --config=dbg
```
Comment on lines +384 to +387
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

The guide recommends bazel test ... --config=dbg/asan/..., but .bazelrc only defines build:dbg, build:asan, etc. To ensure the configs apply to bazel test as documented, add matching test:<config> stanzas (or move these options under common:<config>).

Copilot uses AI. Check for mistakes.

### Debug symbols only (no assertion checks)

Equivalent to Make `REQDBG=symbols`:

```sh
bazel build //:release --config=dbg-symbols
```

> Note: The `libonedal_dpc.so` library does not support debug mode due to
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.

This will change in one of the PRs that is in progress.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Acknowledged. I adjusted the wording to avoid hard dependency on that in-flight PR and kept the note generic.

> excessive debug information causing long link times. Use the static library
> variant for DPC++ debugging.
Comment on lines +397 to +399
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

The note says libonedal_dpc.so “does not support debug mode”, but the Bazel release target selects :dynamic_dpc based only on release_dpc and does not gate it on dbg/opt. Unless there is an actual build-time restriction elsewhere, this reads as inaccurate. Consider rephrasing to something verifiable (e.g., “debug builds may be impractically slow/large for the DPC++ shared library”) or document the concrete limitation/condition.

Suggested change
> Note: The `libonedal_dpc.so` library does not support debug mode due to
> excessive debug information causing long link times. Use the static library
> variant for DPC++ debugging.
> Note: Debug builds of the `libonedal_dpc.so` shared library may produce
> excessive debug information and result in very long link times. For
> practical DPC++ debugging, it is recommended to use the static library
> variant instead.

Copilot uses AI. Check for mistakes.

### AddressSanitizer (ASan)

Equivalent to Make `REQSAN=address`. Sanitizers do not automatically enable assertions or unoptimized debug builds. It is highly recommended to combine them with `--config=dbg` (for full debug + assertions) or `--enable_assert=True`:

```sh
bazel test //cpp/oneapi/dal:tests --config=asan --config=dbg
```

For static libasan linkage (equivalent to Make `REQSAN=static`):

```sh
bazel test //cpp/oneapi/dal:tests --config=asan-static --config=dbg
```

### ThreadSanitizer (TSan)

Equivalent to Make `REQSAN=thread`:

```sh
bazel test //cpp/oneapi/dal:tests --config=tsan
```

### UndefinedBehaviorSanitizer (UBSan)

Equivalent to Make `REQSAN=undefined`:

```sh
bazel test //cpp/oneapi/dal:tests --config=ubsan
```

### MemorySanitizer (MSan)

Requires Clang or ICPX. GCC does not support MSan.
The `msan` config enables `-fsanitize-memory-track-origins` for better origin diagnostics.
If your toolchain requires lld for MSan/TSan linking, add:

```sh
bazel test //cpp/oneapi/dal:tests --config=msan --linkopt=-fuse-ld=lld
```

### Type Sanitizer

Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

The Type Sanitizer section doesn’t mention compiler requirements. -fsanitize=type is Clang-only; GCC users will see a hard failure. Consider adding a short note (like the MSan section) indicating this requires Clang/ICPX and may be unavailable depending on the toolchain.

Suggested change
Requires Clang or ICPX. GCC does not support the Type Sanitizer and availability may depend on your toolchain.

Copilot uses AI. Check for mistakes.
```sh
bazel test //cpp/oneapi/dal:tests --config=type
```


---

## Release Build

Build the full release artifact (all ISA variants: sse2, sse42, avx2, avx512):

```sh
bazel build //:release
```

The `//:release` target automatically compiles all ISA variants when `--cpu`
Comment on lines +448 to +458
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

This section says bazel build //:release builds “all ISA variants” and that the default --cpu=auto triggers that. In the current Bazel config, @config//:cpu defaults to auto, which selects a single auto-detected ISA. Please update the instructions to use --cpu=all (or modern / explicit ISA list) when you mean “all ISA variants”, and clarify what auto does.

Copilot uses AI. Check for mistakes.
is left at its default value (`auto`). If `--cpu` is set explicitly — e.g. in
a personal `~/.bazelrc` or passed in CI — the transition respects that value.
Comment on lines +458 to +460
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

The README claims //:release “automatically compiles all ISA variants” when --cpu is left at its default (auto). In the current Bazel config, @config//:cpu defaults to auto, which expands to sse2 + the detected host ISA (not all ISAs), and there’s no transition in the repo that forces all for //:release. Please update this section to match the actual behavior (e.g., document --cpu=all for full ISA coverage) or add the missing transition if that’s the intent.

Copilot uses AI. Check for mistakes.
To restrict ISA coverage (e.g., for faster CI):

```sh
bazel build //:release --cpu=avx2
```

To include DPC++ libraries:

```sh
bazel build //:release --config=release-dpc
```

---

### Standard Library Assertions

To enable C++ standard library assertions (e.g., `std::vector` bounds checking), inject the preprocessor macro via `--cxxopt` (C++-only flag):

```sh
bazel test //cpp/oneapi/dal:tests --config=dbg --cxxopt=-D_GLIBCXX_DEBUG
```

---

## Custom Compiler and Linker Flags

Equivalent to Make `COPT` / `CXXFLAGS`. Use `--copt` for C and C++ flags, `--cxxopt` for C++-only flags, and `--linkopt` for linker flags:

```sh
# Architecture/optimization flags (C and C++)
bazel build //:release --copt=-march=native

# Override optimization level (C and C++)
bazel build //:release --copt=-O2

# C++-only preprocessor/language flags
bazel build //:release --cxxopt=-std=c++17

# Add a linker flag
bazel build //:release --linkopt=-Wl,--as-needed
```

To make flags permanent for your local environment, add them to `~/.bazelrc`:

```
# ~/.bazelrc (user-local, not committed)
build --copt=-your-c-and-cxx-flag
build --cxxopt=-your-cxx-only-flag
build --linkopt=-your-link-flag
```

---

## Make → Bazel Flag Reference

| Make option | Bazel equivalent | Notes |
|---|---|---|
| `REQDBG=1` | `--config=dbg` | Debug symbols + assertions |
| `REQDBG=symbols` | `--config=dbg-symbols` | Debug symbols only |
| `REQSAN=address` | `--config=asan` | AddressSanitizer |
| `REQSAN=static` | `--config=asan-static` | ASan with static libasan |
| `REQSAN=thread` | `--config=tsan` | ThreadSanitizer |
| `REQSAN=undefined` | `--config=ubsan` | UBSan |
| | `--config=msan` | MemorySanitizer (Clang/ICPX only) |
| | `--config=type` | Type Sanitizer |
| `COMPILER=gnu` | `CC=gcc bazel build ...` | Override compiler via `CC` env |
| `OPTFLAG=O2` | `--copt=-O2` | Override optimization level |
| `COPT=-flag` | `--copt=-flag` (C+C++) / `--cxxopt=-flag` (C++ only) | Arbitrary compiler flag |
| `--cpu=<isa>` (Make `PLAT`) | `--cpu=<isa>` | ISA selection |
| (Make default all ISAs) | `bazel build //:release` | Transition forces all ISAs |
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

In the Make→Bazel reference table, the row stating “Transition forces all ISAs” for bazel build //:release doesn’t match the current implementation (no ISA-forcing transition present; default --cpu=auto builds sse2 + host ISA). Please correct the note to avoid misleading users.

Suggested change
| (Make default all ISAs) | `bazel build //:release` | Transition forces all ISAs |
| (Make default all ISAs) | `bazel build //:release` | Default `--cpu=auto` builds `sse2` + host ISA |

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

The “Make default all ISAs” mapping here assumes bazel build //:release forces all ISA builds, but the current --cpu default (auto) is single-ISA. Update this table row to reflect the actual flag needed for all-ISA coverage (e.g., --cpu=all).

Suggested change
| (Make default all ISAs) | `bazel build //:release` | Transition forces all ISAs |
| (Make default all ISAs) | `bazel build //:release --cpu=all` | Transition forces all ISAs |

Copilot uses AI. Check for mistakes.
| (CI: single ISA) | `--cpu=avx2` | Override for CI speed |

Loading