Skip to content

[openmp] Allow testing OpenMP without a full clang build tree#182470

Merged
mstorsjo merged 3 commits intollvm:mainfrom
mstorsjo:openmp-test-clang
Feb 23, 2026
Merged

[openmp] Allow testing OpenMP without a full clang build tree#182470
mstorsjo merged 3 commits intollvm:mainfrom
mstorsjo:openmp-test-clang

Conversation

@mstorsjo
Copy link
Member

Having a build tree with "not" and "FileCheck" is still required, but if Clang isn't configured in that build, run the tests with the same compiler CMake uses. This is how testing worked in the standalone build configurations that now have been removed.

Having a build tree with "not" and "FileCheck" is still required,
but if Clang isn't configured in that build, run the tests with
the same compiler CMake uses. This is how testing worked in the
standalone build configurations that now have been removed.
@mstorsjo mstorsjo requested a review from Meinersbur February 20, 2026 10:33
@llvmbot llvmbot added openmp:libomp OpenMP host runtime openmp:libomptarget OpenMP offload runtime labels Feb 20, 2026
Copy link
Member

@Meinersbur Meinersbur left a comment

Choose a reason for hiding this comment

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

Could you also add logic that disables testing again when OPENMP_TEST_C_COMPILER is not set despite no clang target available?

set_property(GLOBAL APPEND PROPERTY OPENMP_LIT_DEPENDS ${ARG_DEPENDS})
endif()

set(CLANG_DEPEND)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
set(CLANG_DEPEND)
set(EXTRA_CHECK_DEPENDS "")

set(CLANG_DEPEND) is equivalent to unset(CLANG_DEPEND)

`-DCMAKE_C_COMPILER=../build/bin/clang -DCMAKE_C_COMPILER=../build/bin/clang++`.
In any case, it will use Clang from `LLVM_BINARY_DIR` for running the regression
tests. `LLVM_BINARY_DIR` can also be omitted in which case testing
It will use Clang from `LLVM_BINARY_DIR` for running the regression tests, if Clang is included in that build.
Copy link
Member

Choose a reason for hiding this comment

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

Consider adding that you need OPENMP_TEST_C_COMPILER/OPENMP_TEST_CXX_COMPILER if you want testing without clang in LLVM_BINARY_DIR

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
It will use Clang from `LLVM_BINARY_DIR` for running the regression tests, if Clang is included in that build.
Clang/Flang from `LLVM_BINARY_DIR` will be used for testing if available, otherwise `CMAKE_C_COMPILER`/`CMAKE_CXX_COMPILER`/`CMAKE_Fortran_COMPILER`. Tests are also only expected to work with Clang/Flang built from the same Git commit, so `OPENMP_TEST_C_COMPILER`/`OPENMP_TEST_CXX_COMPILER`/`OPENMP_TEST_Fortran_COMPILER` can be used to explicitly set the test compilers.

Copy link
Member

@Meinersbur Meinersbur left a comment

Choose a reason for hiding this comment

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

If not too much work, could you make OPENMP_TEST_Fortran_COMPILER be handled the same way?

Extend the same logic to Flang too.

Add documentation for the cmake variables.

Apply cmake change suggestions.
@mstorsjo
Copy link
Member Author

Could you also add logic that disables testing again when OPENMP_TEST_C_COMPILER is not set despite no clang target available?

As we implicitly set OPENMP_TEST_C_COMPILER from CMAKE_C_COMPILER, so the only case that would hit is if the user manually sets OPENMP_TEST_C_COMPILER to an empty string. So we shouldn't need that, as configuring the project does require a working CMAKE_C_COMPILER to begin with.

If not too much work, could you make OPENMP_TEST_Fortran_COMPILER be handled the same way?

Sure, I tried to make that mostly consistent. There's some extra logic for printing/disabling that if that's unavailable, that I left untouched for now.

Now whether a build with LLVM_ENABLE_PROJECTS="clang;flang" LLVM_ENABLE_RUNTIMES=openmp will build flang before attempting to configure openmp or not, I'm not sure; currently it builds clang before configuring openmp at least. (That might require changes to llvm-project/llvm/runtimes if we'd want to add such an implicit dependency there. But I feel that's out of scope for this PR in any case.)

set_property(GLOBAL APPEND PROPERTY OPENMP_LIT_DEPENDS ${ARG_DEPENDS})
endif()

unset(EXTRA_CHECK_DEPENDS)
Copy link
Member

@Meinersbur Meinersbur Feb 20, 2026

Choose a reason for hiding this comment

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

Suggested change
unset(EXTRA_CHECK_DEPENDS)
set(EXTRA_CHECK_DEPENDS "")

By set(EXTRA_CHECK_DEPENDS) and unset(EXTRA_CHECK_DEPENDS) being equivalent I meant to not use it. unsettin the value will mean that the value of outer namespace becomes visible:

function(foo)
  set(EXTRA_CHECK_DEPENDS) # or unset(EXTRA_CHECK_DEPENDS) 
  message("EXTRA_CHECK_DEPENDS='${EXTRA_CHECK_DEPENDS}'")
endfunction()


set(EXTRA_CHECK_DEPENDS "Outer namespace value" CACHE STRING "Example variable")
foo()
$ cmake -P unset.cmake
EXTRA_CHECK_DEPENDS='Outer namespace value'

The CMake manual puts it like this:

Image

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, right, sorry, I missed the point there! Will fix.

`-DCMAKE_C_COMPILER=../build/bin/clang -DCMAKE_C_COMPILER=../build/bin/clang++`.
In any case, it will use Clang from `LLVM_BINARY_DIR` for running the regression
tests. `LLVM_BINARY_DIR` can also be omitted in which case testing
It will use Clang from `LLVM_BINARY_DIR` for running the regression tests, if Clang is included in that build.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
It will use Clang from `LLVM_BINARY_DIR` for running the regression tests, if Clang is included in that build.
Clang/Flang from `LLVM_BINARY_DIR` will be used for testing if available, otherwise `CMAKE_C_COMPILER`/`CMAKE_CXX_COMPILER`/`CMAKE_Fortran_COMPILER`. Tests are also only expected to work with Clang/Flang built from the same Git commit, so `OPENMP_TEST_C_COMPILER`/`OPENMP_TEST_CXX_COMPILER`/`OPENMP_TEST_Fortran_COMPILER` can be used to explicitly set the test compilers.

Copy link
Member

@Meinersbur Meinersbur left a comment

Choose a reason for hiding this comment

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

LGTM, thank you

@mstorsjo mstorsjo merged commit 48a5119 into llvm:main Feb 23, 2026
11 checks passed
@mstorsjo mstorsjo deleted the openmp-test-clang branch February 23, 2026 21:01
@mstorsjo
Copy link
Member Author

Thanks for the reviews!

Would you consider this patch for a backport to 22.x? It wouldn't be a direct match though, but would need to be adjusted to how the code was before removing the standalone build mode. My desire would be to have a single way to run the tests (in my setup) for both the 22.x and main branches.

@Meinersbur
Copy link
Member

22.1 has just been released: https://discourse.llvm.org/t/llvm-22-1-0-released/89950

If you want to prepare a PR for 22.1.1, I would review it. It will depend on the release manager whether they will accept non-bugfix build system changes.

mstorsjo added a commit to mstorsjo/llvm-project that referenced this pull request Feb 24, 2026
… build tree

Having a build tree with "not" and "FileCheck" is still required, but if
Clang/Flang isn't configured in that build, run the tests with the same
compiler CMake uses. This is how testing worked in the standalone build
configurations that now have been removed.

This is a manually adapted backport of
48a5119 / llvm#182470 to the 22.x
release branch.

This allows testing OpenMP in the same way on both git main
and the 22.x release branch.
mstorsjo added a commit to mstorsjo/llvm-project that referenced this pull request Feb 27, 2026
… build tree

Having a build tree with "not" and "FileCheck" is still required, but if
Clang/Flang isn't configured in that build, run the tests with the same
compiler CMake uses. This is how testing worked in the standalone build
configurations that now have been removed.

This is a manually adapted backport of
48a5119 / llvm#182470 to the 22.x
release branch.

This allows testing OpenMP in the same way on both git main
and the 22.x release branch.
dyung pushed a commit to mstorsjo/llvm-project that referenced this pull request Mar 5, 2026
… build tree

Having a build tree with "not" and "FileCheck" is still required, but if
Clang/Flang isn't configured in that build, run the tests with the same
compiler CMake uses. This is how testing worked in the standalone build
configurations that now have been removed.

This is a manually adapted backport of
48a5119 / llvm#182470 to the 22.x
release branch.

This allows testing OpenMP in the same way on both git main
and the 22.x release branch.
HendrikHuebner pushed a commit to HendrikHuebner/llvm-project that referenced this pull request Mar 10, 2026
…82470)

Having a build tree with "not" and "FileCheck" is still required, but if
Clang/Flang isn't configured in that build, run the tests with the same
compiler CMake uses. This is how testing worked in the standalone build
configurations that now have been removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

openmp:libomp OpenMP host runtime openmp:libomptarget OpenMP offload runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants