From 8b25b3885c41a39700db9f4198f7b857bf7c1b1d Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Mon, 14 Sep 2026 11:56:36 -0400 Subject: [PATCH 1/3] Reduce concurrency during cmake c++ build to avoid ooms Signed-off-by: Robert Kruszewski --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee7a5b3aa88..24bad844281 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -679,7 +679,7 @@ jobs: -DVORTEX_SANITIZE_RUST_STD=ON \ -DVORTEX_BUILD_TESTS=ON \ -DVORTEX_BUILD_EXAMPLES=ON - cmake --build build --parallel "$(nproc)" + cmake --build build --parallel 2 - name: Run C++ tests run: ctest --test-dir build --output-on-failure - name: Run C++ examples From 872645536cccfae46653e23a19ea61087f2b48a3 Mon Sep 17 00:00:00 2001 From: Alexander Droste Date: Mon, 14 Sep 2026 18:49:35 +0200 Subject: [PATCH 2/3] cmake: expose shared debug info level Add VORTEX_DEBUG_INFO for C, C++, Rust, and Cargo native dependencies. Disable debug info in the C++ API CI build to reduce linker memory usage, and extend existing integration tests with focused propagation assertions. Signed-off-by: Alexander Droste --- .github/workflows/ci.yml | 1 + lang/cpp/CMakeLists.txt | 2 ++ lang/cpp/README.md | 6 ++++++ vortex-ffi/cmake/Configure.cmake | 12 ++++++++---- vortex-ffi/cmake/DebugInfo.cmake | 15 +++++++++++++++ vortex-ffi/cmake/tests/test_compiler_commands.py | 14 ++++++++++++-- vortex-ffi/cmake/tests/test_configure.py | 7 +++++++ 7 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 vortex-ffi/cmake/DebugInfo.cmake diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24bad844281..b6c826e6c01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -673,6 +673,7 @@ jobs: run: | cmake -S lang/cpp -B build \ -DCMAKE_BUILD_TYPE=Debug \ + -DVORTEX_DEBUG_INFO=0 \ -DCMAKE_C_COMPILER=clang \ -DCMAKE_CXX_COMPILER=clang++ \ -DVORTEX_SANITIZER=asan \ diff --git a/lang/cpp/CMakeLists.txt b/lang/cpp/CMakeLists.txt index 47d977697df..4d969b375bd 100644 --- a/lang/cpp/CMakeLists.txt +++ b/lang/cpp/CMakeLists.txt @@ -39,6 +39,8 @@ option(VORTEX_WARNINGS_AS_ERRORS "Treat warnings in Vortex-owned sources as errors" "${_vortex_top_level}") +include(../../vortex-ffi/cmake/DebugInfo.cmake) + # The Rust FFI archive comes from vortex-ffi. A standalone configure of this # directory adds it here; the repository root or a parent may already have. if(NOT TARGET Vortex::ffi_static) diff --git a/lang/cpp/README.md b/lang/cpp/README.md index 5159bb9207b..e00bc04895c 100644 --- a/lang/cpp/README.md +++ b/lang/cpp/README.md @@ -45,11 +45,17 @@ options. Defaults below are for standalone builds. | `VORTEX_RUSTUP_TOOLCHAIN` | Inferred | [Rust toolchain override](#toolchain-and-build-behavior). | | `VORTEX_SANITIZER` | Empty | [Sanitizers](#sanitizers): `asan`, `lsan`, `ubsan`, `tsan`. | | `VORTEX_SANITIZE_RUST_STD` | `OFF` | Also instrument Rust's standard library. | +| `VORTEX_DEBUG_INFO` | `2` | C/C++ and Rust debug info: `0` none, `1` limited, `2` full. | | `VORTEX_ENABLE_CUDA` | `OFF` | Linux-only [CUDA build](#cuda). | Embedded builds default `VORTEX_WARNINGS_AS_ERRORS` to `OFF`. Parents must call `enable_testing()` to register tests. +`VORTEX_DEBUG_INFO` maps to `-g` for C/C++ and `-C debuginfo=` for Rust, +independently of the build type or sanitizer selection. It covers CMake targets (including +fetched dependencies), Cargo target crates and rebuilt std, and C/C++ dependencies compiled +by `build.rs`. Rust host build tools retain their Cargo profile settings. + ### Cargo profiles Standalone builds default to `Debug`. Unless overridden, Cargo uses: diff --git a/vortex-ffi/cmake/Configure.cmake b/vortex-ffi/cmake/Configure.cmake index e51ebe3b792..7ae8ad06405 100644 --- a/vortex-ffi/cmake/Configure.cmake +++ b/vortex-ffi/cmake/Configure.cmake @@ -7,6 +7,7 @@ include_guard(GLOBAL) include("${CMAKE_CURRENT_LIST_DIR}/Cuda.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/DebugInfo.cmake") include("${CMAKE_CURRENT_LIST_DIR}/Helpers.cmake") include("${CMAKE_CURRENT_LIST_DIR}/RustToolchain.cmake") include("${CMAKE_CURRENT_LIST_DIR}/SystemDependencies.cmake") @@ -184,7 +185,6 @@ function(_vortex_resolve_sanitizer list(APPEND _rustflags -A warnings -Cunsafe-allow-abi-mismatch=sanitizer - -C debuginfo=2 -C opt-level=0 # Use the sanitizer runtime linked by the final C++ target for both languages. -Zexternal-clangrt @@ -239,8 +239,9 @@ function(_vortex_native_flags endif() # Native dependencies become part of the archive embedded in shared parents. - list(APPEND _cflags -fPIC) - list(APPEND _cxxflags -fPIC) + # Match CMake targets even when cc-rs or parent flags enable debug info. + list(APPEND _cflags -fPIC -g${VORTEX_DEBUG_INFO}) + list(APPEND _cxxflags -fPIC -g${VORTEX_DEBUG_INFO}) set(${cflags_output} "${_cflags}" PARENT_SCOPE) set(${cxxflags_output} "${_cxxflags}" PARENT_SCOPE) @@ -282,7 +283,10 @@ block(SCOPE_FOR VARIABLES) _native_cxx_flags) # Mirror .cargo/config.toml's Unix rustflags, which CARGO_ENCODED_RUSTFLAGS overrides. # Keep them in sync; PIC additionally allows embedding in shared libraries. - set(_rustflags ${_sanitizer_rustflags} -C force-frame-pointers=yes -C relocation-model=pic) + set(_rustflags ${_sanitizer_rustflags} + -C force-frame-pointers=yes + -C relocation-model=pic + -C "debuginfo=${VORTEX_DEBUG_INFO}") # Cargo owns incremental invalidation inside this CMake-build-local cache. # Registering the directory as additional clean state gives the standard diff --git a/vortex-ffi/cmake/DebugInfo.cmake b/vortex-ffi/cmake/DebugInfo.cmake new file mode 100644 index 00000000000..e683448c239 --- /dev/null +++ b/vortex-ffi/cmake/DebugInfo.cmake @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Copyright the Vortex contributors + +include_guard(DIRECTORY) + +set(VORTEX_DEBUG_INFO "2" CACHE STRING + "Debug information for C, C++, and Rust: 0 (none), 1 (limited), 2 (full)") +set_property(CACHE VORTEX_DEBUG_INFO PROPERTY STRINGS 0 1 2) +if(NOT VORTEX_DEBUG_INFO MATCHES "^[012]$") + message(FATAL_ERROR "VORTEX_DEBUG_INFO must be 0, 1, or 2") +endif() + +# Keep the override in Vortex's directories, including fetched dependencies, +# without changing unrelated targets in an embedding parent. +add_compile_options("$<$:-g${VORTEX_DEBUG_INFO}>") diff --git a/vortex-ffi/cmake/tests/test_compiler_commands.py b/vortex-ffi/cmake/tests/test_compiler_commands.py index cfad6b024cf..0d2a67c5da0 100644 --- a/vortex-ffi/cmake/tests/test_compiler_commands.py +++ b/vortex-ffi/cmake/tests/test_compiler_commands.py @@ -52,11 +52,20 @@ def setUp(self) -> None: self.command("cargo", "generate-lockfile", "--offline", cwd=self.source) def configure( - self, value=7, argument=7, policy=True, instrumentation=False, generator="Ninja", build_name=None + self, + value=7, + argument=7, + policy=True, + instrumentation=False, + generator="Ninja", + build_name=None, + debug_info=None, ) -> None: self.build_dir = self.work / (build_name or f"{generator} build directory's") self.target_dir = self.build_dir / "ffi/cargo-target" options = [] + if debug_info is not None: + options.append(f"-DVORTEX_DEBUG_INFO={debug_info}") include = self.source / "native-helper/include directory's" errors = ["-Werror", "-Werror=unused-variable", "-pedantic-errors"] if policy else [] for language, compiler in (("C", "clang"), ("CXX", "clang++")): @@ -151,12 +160,13 @@ def test_host_target_instrumentation_and_cache_boundary(self) -> None: os.execv(sys.argv[1], sys.argv[1:]) """, ) - self.configure(instrumentation=True) + self.configure(instrumentation=True, debug_info=0) self.build() calls = [json.loads(line) for line in log.read_text().splitlines()] self.assertEqual(sorted(target for target, _ in calls), [False, False, True, True]) for target, args in calls: self.assertIn(Path(args[0]).name, ("clang", "clang++")) + self.assertEqual([arg for arg in args if arg.startswith("-g")][-1:], ["-g0"], args) for flag in ("--coverage", "-fsanitize=undefined"): self.assertEqual(flag in args, target, args) objects = sorted(self.target_dir.rglob("out/*-native.o")) diff --git a/vortex-ffi/cmake/tests/test_configure.py b/vortex-ffi/cmake/tests/test_configure.py index a82b4e6739e..d7f4c6bf272 100644 --- a/vortex-ffi/cmake/tests/test_configure.py +++ b/vortex-ffi/cmake/tests/test_configure.py @@ -68,6 +68,7 @@ def test_standalone_defaults_and_ffi_default_build(self) -> None: self.assertEqual(settings[:2], ["Debug", "ON"]) if len(settings) == 3: self.assertIn("-Werror", settings[2].split(";")) + self.assertIn("$<$:-g2>", settings[2].split(";")) build = self.work / "ffi" self.cmake_build(build) @@ -76,8 +77,14 @@ def test_standalone_defaults_and_ffi_default_build(self) -> None: self.assertEqual(recorded["args"][recorded["args"].index("--profile") + 1], "dev") config = tomllib.loads((self.repo / ".cargo/config.toml").read_text()) expected = config["target"]['cfg(target_family="unix")']["rustflags"] + ["-C", "relocation-model=pic"] + expected += ["-C", "debuginfo=2"] self.assertEqual(recorded["env"]["CARGO_ENCODED_RUSTFLAGS"].split("\x1f"), expected) + self.configure("ffi", "-DVORTEX_DEBUG_INFO=0") + self.cmake_build(build) + recorded = self.cargo_recording(build / "cargo-target") + self.assertEqual(recorded["env"]["CARGO_ENCODED_RUSTFLAGS"].split("\x1f"), expected[:-1] + ["debuginfo=0"]) + def test_embedded_root_preserves_parent_variables(self) -> None: source = self.write( "parent/CMakeLists.txt", From ead491b27d14ab7985de0b49171e191a069f2601 Mon Sep 17 00:00:00 2001 From: Alexander Droste Date: Mon, 14 Sep 2026 19:00:22 +0200 Subject: [PATCH 3/3] ci: restore C++ build parallelism Use all available CPUs for the C++ API build while keeping debug info disabled, and trim the debug-info documentation. Signed-off-by: Alexander Droste --- .github/workflows/ci.yml | 2 +- lang/cpp/README.md | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6c826e6c01..42d18337af3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -680,7 +680,7 @@ jobs: -DVORTEX_SANITIZE_RUST_STD=ON \ -DVORTEX_BUILD_TESTS=ON \ -DVORTEX_BUILD_EXAMPLES=ON - cmake --build build --parallel 2 + cmake --build build --parallel "$(nproc)" - name: Run C++ tests run: ctest --test-dir build --output-on-failure - name: Run C++ examples diff --git a/lang/cpp/README.md b/lang/cpp/README.md index e00bc04895c..950f11fe001 100644 --- a/lang/cpp/README.md +++ b/lang/cpp/README.md @@ -51,11 +51,6 @@ options. Defaults below are for standalone builds. Embedded builds default `VORTEX_WARNINGS_AS_ERRORS` to `OFF`. Parents must call `enable_testing()` to register tests. -`VORTEX_DEBUG_INFO` maps to `-g` for C/C++ and `-C debuginfo=` for Rust, -independently of the build type or sanitizer selection. It covers CMake targets (including -fetched dependencies), Cargo target crates and rebuilt std, and C/C++ dependencies compiled -by `build.rs`. Rust host build tools retain their Cargo profile settings. - ### Cargo profiles Standalone builds default to `Debug`. Unless overridden, Cargo uses: