Skip to content

Conversation

@ro-i
Copy link
Contributor

@ro-i ro-i commented Nov 14, 2025

(The tests in TestKmpStr.cpp are an automatically generated POC to make sure things work.)

@ro-i ro-i requested review from jhuber6, mjklemm and shiltian November 14, 2025 13:56
@llvmbot llvmbot added the openmp:libomp OpenMP host runtime label Nov 14, 2025
@ro-i ro-i force-pushed the users/ro-i/check-libomp-unit branch from 4c9e176 to c801cb4 Compare November 14, 2025 13:57
@ro-i ro-i force-pushed the users/ro-i/check-libomp-unit branch from 2f30670 to b12ff59 Compare December 16, 2025 15:47
@ro-i ro-i requested a review from Meinersbur December 16, 2025 16:08
Copy link
Contributor

@shiltian shiltian left a comment

Choose a reason for hiding this comment

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

LGTM in geenral.

set_target_properties(OpenMPUnitTests PROPERTIES FOLDER "OpenMP/Tests")

if(WIN32 OR STUBS_LIBRARY)
message(WARNING "OpenMP unittests disabled due to stub library or Windows")
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason this doesn't work on Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. But since the CMake changes are already complicated enough to review and test as they are, I thought it might be best to get things working first and then add something like the Windows support in a follow-up

Copy link
Contributor

@jplehr jplehr left a comment

Choose a reason for hiding this comment

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

+1 for adding unit tests here!

target_link_libraries(omp_testing PUBLIC default_gtest)
target_link_libraries(omp_testing PUBLIC ${LIBOMP_TEST_LIBFLAGS} ${LIBOMP_DL_LIBS})
set_target_properties(omp_testing PROPERTIES
PREFIX "" SUFFIX "" OUTPUT_NAME "libomp_testing${LIBOMP_LIBRARY_SUFFIX}"
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
PREFIX "" SUFFIX "" OUTPUT_NAME "libomp_testing${LIBOMP_LIBRARY_SUFFIX}"
PREFIX ""
SUFFIX ""
OUTPUT_NAME "libomp_testing${LIBOMP_LIBRARY_SUFFIX}"

Why override SUFFIX/PREFIX? Would

  PREFIX ""
  SUFFIX "${LIBOMP_LIBRARY_SUFFIX}"

get the same result?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just used

set_target_properties(omp PROPERTIES
PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_LIB_FILE}"
LINK_FLAGS "${LIBOMP_CONFIGURED_LDFLAGS}"
LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE}
)

PREFIX "" SUFFIX "" OUTPUT_NAME "libomp_testing${LIBOMP_LIBRARY_SUFFIX}"
LINK_FLAGS "${LIBOMP_TEST_LDFLAGS}"
LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE}
EXCLUDE_FROM_ALL TRUE # Don't build by default, only when tests need it
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
EXCLUDE_FROM_ALL TRUE # Don't build by default, only when tests need it

EXCLUDE_FROM_ALL can be also just part of add_library:

add_library(omp_testing ... EXCLUDE_FROM_ALL)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

add_library(omp_testing SHARED $<TARGET_OBJECTS:obj.omp> EXCLUDE_FROM_ALL)

whould lead to

CMake Error at .../llvm-project/openmp/runtime/unittests/CMakeLists.txt:17 (add_library):
  Cannot find source file:

    EXCLUDE_FROM_ALL


CMake Error at .../llvm-project/openmp/runtime/unittests/CMakeLists.txt:17 (add_library):
  No SOURCES given to target: omp_testing

tho

Comment on lines +41 to +45
if(TARGET default_gtest)
target_link_libraries(${test_name} PRIVATE default_gtest_main default_gtest)
else ()
target_link_libraries(${test_name} PRIVATE llvm_gtest_main llvm_gtest)
endif ()
Copy link
Member

Choose a reason for hiding this comment

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

[not a change request] default_gtest exists to make this switch unnecessary. I assume you have it here for standalone builds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

openmp:libomp OpenMP host runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants