[all-commits] [llvm/llvm-project] f1eb86: [Offload][UnitTests] Build device code as C++ (#15...

Leandro Lacerda via All-commits all-commits at lists.llvm.org
Mon Aug 4 05:01:13 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f1eb869bae2ab86726ee3a5a5c7980d5b2acbd5d
      https://github.com/llvm/llvm-project/commit/f1eb869bae2ab86726ee3a5a5c7980d5b2acbd5d
  Author: Leandro Lacerda <leandrolcampos at yahoo.com.br>
  Date:   2025-08-04 (Mon, 04 Aug 2025)

  Changed paths:
    M offload/unittests/CMakeLists.txt
    M offload/unittests/Conformance/device_code/CMakeLists.txt
    R offload/unittests/Conformance/device_code/LLVMLibm.c
    A offload/unittests/Conformance/device_code/LLVMLibm.cpp
    M offload/unittests/OffloadAPI/device_code/CMakeLists.txt
    R offload/unittests/OffloadAPI/device_code/bar.c
    A offload/unittests/OffloadAPI/device_code/bar.cpp
    R offload/unittests/OffloadAPI/device_code/foo.c
    A offload/unittests/OffloadAPI/device_code/foo.cpp
    R offload/unittests/OffloadAPI/device_code/global.c
    A offload/unittests/OffloadAPI/device_code/global.cpp
    R offload/unittests/OffloadAPI/device_code/global_ctor.c
    A offload/unittests/OffloadAPI/device_code/global_ctor.cpp
    R offload/unittests/OffloadAPI/device_code/global_dtor.c
    A offload/unittests/OffloadAPI/device_code/global_dtor.cpp
    R offload/unittests/OffloadAPI/device_code/localmem.c
    A offload/unittests/OffloadAPI/device_code/localmem.cpp
    R offload/unittests/OffloadAPI/device_code/localmem_reduction.c
    A offload/unittests/OffloadAPI/device_code/localmem_reduction.cpp
    R offload/unittests/OffloadAPI/device_code/localmem_static.c
    A offload/unittests/OffloadAPI/device_code/localmem_static.cpp
    R offload/unittests/OffloadAPI/device_code/noargs.c
    A offload/unittests/OffloadAPI/device_code/noargs.cpp
    R offload/unittests/OffloadAPI/device_code/sequence.c
    A offload/unittests/OffloadAPI/device_code/sequence.cpp

  Log Message:
  -----------
  [Offload][UnitTests] Build device code as C++ (#151714)

This commit refactors the `add_offload_test_device_code` CMake function
to compile device code using the C++ compiler (`CMAKE_CXX_COMPILER`)
instead of the C compiler.

This change enables the use of C++ features, such as templates, within
device-side test kernels. This will allow for more advanced and reusable
kernel wrappers, reducing boilerplate code in the conformance test
suite.

As part of this change:
- All `.c` files for device code in `unittests/` have been renamed to
`.cpp`.
- Kernel definitions are now wrapped in `extern "C"` to ensure C linkage
and prevent name mangling.

This change affects the `OffloadAPI` and `Conformance` test suites.

cc @callumfare @RossBrunton @jhuber6



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list