Skip to content

build: enable -Werror on TA translation units (opt-in via TA_WERROR)#544

Open
evaleev wants to merge 7 commits into
masterfrom
evaleev/build/werror
Open

build: enable -Werror on TA translation units (opt-in via TA_WERROR)#544
evaleev wants to merge 7 commits into
masterfrom
evaleev/build/werror

Conversation

@evaleev
Copy link
Copy Markdown
Member

@evaleev evaleev commented May 11, 2026

Summary

Add an opt-in TA_WERROR CMake option that promotes compiler warnings
to errors on TiledArray's own translation units (library, tests,
examples), default OFF, not propagated to consumers of the installed
tiledarray target. Wire it on in both CIs.

Modeled after the MADNESS counterpart, m-a-d-n-e-s-s/madness#693.

What changes

CMake — opt-in TA_WERROR, default OFF.

  • New cmake/modules/TiledArrayWarnings.cmake owns an INTERFACE
    library tiledarray_internal_warnings. With TA_WERROR=ON it
    carries -Werror (CXX/C/HIP) and -Xcompiler=-Werror (CUDA), gated
    on GNU/Clang/AppleClang/IntelLLVM (warns otherwise).
  • src/CMakeLists.txt: pulls compile options off the warnings target
    via $<TARGET_PROPERTY:tiledarray_internal_warnings,INTERFACE_COMPILE_OPTIONS>
    rather than a real link, so the (intentionally non-installed)
    warnings target does not get pulled into the tiledarray export
    set.
  • add_ta_executable: PRIVATE-links the warnings target to every
    in-tree executable, covering ta_test and all examples/.
  • examples/scalapack/CMakeLists.txt: same wiring for the one raw
    add_executable.

Verified by inspecting the generated tiledarray-targets.cmake: zero
Werror occurrences, tiledarray_internal_warnings absent from every
INTERFACE_LINK_LIBRARIES.

TA_WERROR=ON implies MADNESS_WERROR=ON via
FindOrFetchMADWorld.cmake, so MADworld TUs built as part of TA's
FetchContent tree are covered. This requires a MADNESS pin that
includes the MADNESS_WERROR option, so TA_TRACKED_MADNESS_TAG is
bumped to the head of m-a-d-n-e-s-s/madness#693 (7d8aaf9d5); this
PR is blocked on that one landing.

Scope of -Werror intentionally excludes:

  • Bundled FetchContent code (parsec, BTAS, Umpire, range-v3, blaspp,
    lapackpp) — those targets are not built via add_ta_*.
  • python-tiledarray — pybind11-generated code, built via
    pybind11_add_module.

range-v3 marked as SYSTEM include. range-v3 self-triggers
-Wdeprecated-declarations from compressed_pair.hpp using its own
deprecated ranges::compressed_tuple alias. Header-only and no
include-order risk against TA's headers, so it's carved out from the
top-level CMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE.

Source-level warning fixes:

  • Drop unused locals / type aliases / lambda captures in
    array_impl.h, binary_engine.h, cont_engine.h
    (-Wunused-{variable,local-typedef,lambda-capture}).
  • Mark header-defined free functions / type aliases in einsum/string.h
    and tensor/kernels.h [[maybe_unused]].
  • Replace umbrella range/v3/{algorithm,view}.hpp includes in
    blk_tsr_expr.h with the narrower zip.hpp / any_of.hpp actually used.
  • tests/dist_array.cpp, tests/tot_dist_array_part2.cpp: replace 8
    deprecated mktemp(3) calls (-Wdeprecated-declarations on macOS)
    with an mkstemp+close+remove helper that produces a unique filename
    race-free.
  • tests/btas.cpp: parenthesize BOOST_REQUIRE_NO_THROW(Tensor(ta_tensor))
    to dodge -Wvexing-parse.

CI — -DTA_WERROR=ON everywhere.

  • GHA: 8 matrix cells (macOS/Ubuntu × Pthreads/PaRSEC × Release/Debug).
  • GitLab: CUDA-capable runner.

Test plan

  • Local Release build (macOS arm64, AppleClang, PaRSEC, no
    ScaLAPACK/CUDA): tiledarray, ta_test, examples-tiledarray
    all build clean with -DTA_WERROR=ON.
  • tiledarray-targets.cmake: zero Werror, no
    tiledarray_internal_warnings references.
  • -Werror lands on TA src/tests/examples and MADworld; absent
    from parsec/btas/blaspp/lapackpp/umpire/range-v3.
  • GHA: all 8 cells green (covers ScaLAPACK on each).
  • GitLab: CUDA cell green.
  • Spot-check downstream build (MPQC pulling TA via FetchContent)
    does not inherit -Werror.

Blocking dependency

This PR pins MADNESS to the head of m-a-d-n-e-s-s/madness#693 so that
MADNESS_WERROR=ON propagation actually does something. Merge order:
land #693 first, then bump this PR's pin to the merge SHA before
merging here.

evaleev added 7 commits May 11, 2026 19:18
New TA_WERROR CMake option (default OFF). When ON, an INTERFACE target
tiledarray_internal_warnings carries -Werror (CXX/C/HIP) and
-Xcompiler=-Werror (CUDA), applied PRIVATE-ly to the tiledarray library
and to in-tree executables via add_ta_executable. Compile options are
pulled off the INTERFACE target via $<TARGET_PROPERTY:...> rather than
a real link, so the (non-installed) warnings target does not get pulled
into the tiledarray export set. -Werror does not propagate to consumers
of the installed tiledarray target (verified: tiledarray-targets.cmake
contains zero Werror occurrences).

Scope excludes bundled FetchContent code (parsec, btas, umpire,
range-v3, lapackpp/blaspp) and python-tiledarray (pybind11_add_module).

TA_WERROR=ON implies MADNESS_WERROR=ON so the MADworld TUs built as
part of TA's FetchContent tree are covered too; requires a MADNESS pin
that includes the MADNESS_WERROR option, so bump TA_TRACKED_MADNESS_TAG
to PR m-a-d-n-e-s-s/madness#693 head (7d8aaf9d5).

Treat range-v3 as a SYSTEM include (header-only, no ordering risk with
TA headers): range-v3 self-triggers -Wdeprecated-declarations from
compressed_pair.hpp using its own deprecated ranges::compressed_tuple
alias. Carved out specifically here despite the top-level
CMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE.
Cleanup of the warning surface on master so TA_WERROR=ON builds cleanly.

src/TiledArray:
- Drop unused locals, type aliases, and lambda captures
  (-Wunused-{variable,local-typedef,lambda-capture}).
- einsum/string.h, tensor/kernels.h: mark header-defined free functions
  / type aliases [[maybe_unused]] for TUs that include but do not use
  them.
- blk_tsr_expr.h: replace umbrella range-v3 includes with the narrower
  zip.hpp / any_of.hpp headers actually used.

tests:
- dist_array.cpp, tot_dist_array_part2.cpp: replace 8 deprecated
  mktemp(3) calls (-Wdeprecated-declarations on macOS) with a
  mkstemp+close+remove helper that produces a unique filename
  race-free.
- btas.cpp: parenthesize BOOST_REQUIRE_NO_THROW(Tensor(ta_tensor)) to
  dodge -Wvexing-parse.
GHA: 8 cells (macOS/Ubuntu * Pthreads/PaRSEC * Release/Debug).
GitLab: CUDA-capable runner.
GitLab CI (gcc-14, CUDA cell) failed compiling examples/demo with
TA_WERROR=ON because btas/generic/converge_class.h trips -Wreturn-type
on two non-void members lacking a return statement — upstream BTAS bug
TA can't fix.

Mirror the range-v3 carve-out: set INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
on the BTAS target so its headers are consumed via -isystem, taking
them out of -Werror scope. Resolve through ALIASED_TARGET first so it
works whether BTAS::BTAS is the imported target or an in-tree alias.
…sion

m-a-d-n-e-s-s/madness@f7aa1401e silences the
std::atomic_exchange(shared_ptr<T>*, ...) deprecation that breaks
gcc/libstdc++ builds with TA_WERROR=ON (MADNESS_WERROR=ON).
gcc-13/-14 inlines std::copy on a 0-length range to
__builtin_memmove(out, in, 0) and trips -Wnonnull when both pointers
are null (e.g. std::array<T, 0>::begin()), which is what the
empty_vector unit test exercises. The std::copy itself is a well-
defined no-op on empty ranges, but the optimizer can't see past the
inlined memmove's nonnull attribute. Short-circuit empty ranges so
std::copy is not called at all in that case.
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