From 641c2d3b7b6c2ded28399875400ffa0f1f62acc8 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sat, 12 Mar 2022 10:11:12 -0600 Subject: [PATCH 1/6] llvmPackages_14.openmp: fix install dirs patch --- .../llvm/14/openmp/gnu-install-dirs.patch | 52 ++----------------- 1 file changed, 4 insertions(+), 48 deletions(-) diff --git a/pkgs/development/compilers/llvm/14/openmp/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/14/openmp/gnu-install-dirs.patch index 352a46923115..e85fde46ca3f 100644 --- a/pkgs/development/compilers/llvm/14/openmp/gnu-install-dirs.patch +++ b/pkgs/development/compilers/llvm/14/openmp/gnu-install-dirs.patch @@ -1,17 +1,7 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 7f11a05f5622..fb90f8f6a49b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -8,6 +8,8 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_S - set(OPENMP_STANDALONE_BUILD TRUE) - project(openmp C CXX) - -+ include(GNUInstallDirs) -+ - # CMAKE_BUILD_TYPE was not set, default to Release. - if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) -@@ -19,7 +21,7 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_S +@@ -24,7 +24,7 @@ if (OPENMP_STANDALONE_BUILD) set(OPENMP_LIBDIR_SUFFIX "" CACHE STRING "Suffix of lib installation directory, e.g. 64 => lib64") # Do not use OPENMP_LIBDIR_SUFFIX directly, use OPENMP_INSTALL_LIBDIR. @@ -20,7 +10,7 @@ index 7f11a05f5622..fb90f8f6a49b 100644 # Group test settings. set(OPENMP_TEST_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING -@@ -30,7 +32,7 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_S +@@ -35,7 +35,7 @@ if (OPENMP_STANDALONE_BUILD) else() set(OPENMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR}) # If building in tree, we honor the same install suffix LLVM uses. @@ -29,10 +19,10 @@ index 7f11a05f5622..fb90f8f6a49b 100644 if (NOT MSVC) set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang) -index 0e1ce2afd154..8b3810f83713 100644 +diff --git a/libomptarget/plugins/amdgpu/CMakeLists.txt b/libomptarget/plugins/amdgpu/CMakeLists.txt --- a/libomptarget/plugins/amdgpu/CMakeLists.txt +++ b/libomptarget/plugins/amdgpu/CMakeLists.txt -@@ -80,7 +80,7 @@ add_library(omptarget.rtl.amdgpu SHARED +@@ -74,7 +74,7 @@ add_library(omptarget.rtl.amdgpu SHARED # Install plugin under the lib destination folder. # When we build for debug, OPENMP_LIBDIR_SUFFIX get set to -debug @@ -42,7 +32,6 @@ index 0e1ce2afd154..8b3810f83713 100644 if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") diff --git a/libomptarget/plugins/ve/CMakeLists.txt b/libomptarget/plugins/ve/CMakeLists.txt -index 16ce0891ca23..db30ee9c769f 100644 --- a/libomptarget/plugins/ve/CMakeLists.txt +++ b/libomptarget/plugins/ve/CMakeLists.txt @@ -32,7 +32,7 @@ if(${LIBOMPTARGET_DEP_VEO_FOUND}) @@ -54,36 +43,3 @@ index 16ce0891ca23..db30ee9c769f 100644 target_link_libraries( "omptarget.rtl.${tmachine_libname}" -diff --git a/runtime/src/CMakeLists.txt b/runtime/src/CMakeLists.txt -index e4f4e6e1e73f..1164b3b22b0e 100644 ---- a/runtime/src/CMakeLists.txt -+++ b/runtime/src/CMakeLists.txt -@@ -346,13 +346,13 @@ add_dependencies(libomp-micro-tests libomp-test-deps) - # We want to install libomp in DESTDIR/CMAKE_INSTALL_PREFIX/lib - # We want to install headers in DESTDIR/CMAKE_INSTALL_PREFIX/include - if(${OPENMP_STANDALONE_BUILD}) -- set(LIBOMP_HEADERS_INSTALL_PATH include) -+ set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}") - else() - string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION ${PACKAGE_VERSION}) - set(LIBOMP_HEADERS_INSTALL_PATH "${OPENMP_INSTALL_LIBDIR}/clang/${CLANG_VERSION}/include") - endif() - if(WIN32) -- install(TARGETS omp RUNTIME DESTINATION bin) -+ install(TARGETS omp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - install(TARGETS ${LIBOMP_IMP_LIB_TARGET} ARCHIVE DESTINATION "${OPENMP_INSTALL_LIBDIR}") - # Create aliases (regular copies) of the library for backwards compatibility - set(LIBOMP_ALIASES "libiomp5md") -diff --git a/tools/multiplex/CMakeLists.txt b/tools/multiplex/CMakeLists.txt -index 64317c112176..4002784da736 100644 ---- a/tools/multiplex/CMakeLists.txt -+++ b/tools/multiplex/CMakeLists.txt -@@ -4,7 +4,7 @@ if(LIBOMP_OMPT_SUPPORT) - add_library(ompt-multiplex INTERFACE) - target_include_directories(ompt-multiplex INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) - -- install(FILES ompt-multiplex.h DESTINATION include) -+ install(FILES ompt-multiplex.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - - add_subdirectory(tests) - endif() From 790c4f13dd8abb78f49e7ad68151602aa58209c6 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sat, 12 Mar 2022 10:22:04 -0600 Subject: [PATCH 2/6] openmp: new fix-find-tools patch --- .../llvm/14/openmp/fix-find-tool.patch | 45 ++++++------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/pkgs/development/compilers/llvm/14/openmp/fix-find-tool.patch b/pkgs/development/compilers/llvm/14/openmp/fix-find-tool.patch index b5d0e7b41775..7cdb74121377 100644 --- a/pkgs/development/compilers/llvm/14/openmp/fix-find-tool.patch +++ b/pkgs/development/compilers/llvm/14/openmp/fix-find-tool.patch @@ -1,8 +1,8 @@ diff --git a/libomptarget/DeviceRTL/CMakeLists.txt b/libomptarget/DeviceRTL/CMakeLists.txt -index 242df638f80d..a4654e96371f 100644 +index d8b9e40802b8..3a8d76ab370f 100644 --- a/libomptarget/DeviceRTL/CMakeLists.txt +++ b/libomptarget/DeviceRTL/CMakeLists.txt -@@ -25,16 +25,16 @@ endif() +@@ -25,10 +25,10 @@ endif() if (LLVM_DIR) # Builds that use pre-installed LLVM have LLVM_DIR set. @@ -13,42 +13,23 @@ index 242df638f80d..a4654e96371f 100644 - find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) + REQUIRED) + find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) - libomptarget_say("Building DeviceRTL. Using clang: ${CLANG_TOOL}") - elseif (LLVM_TOOL_CLANG_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT OPENMP_STANDALONE_BUILD) - # LLVM in-tree builds may use CMake target names to discover the tools. -- set(CLANG_TOOL $) -- set(LINK_TOOL $) -- set(OPT_TOOL $) -+ set(CLANG_TOOL $ REQUIRED) -+ set(LINK_TOOL $ REQUIRED) -+ set(OPT_TOOL $ REQUIRED) - libomptarget_say("Building DeviceRTL. Using clang from in-tree build") - else() - libomptarget_say("Not building DeviceRTL. No appropriate clang found") + if ((NOT CLANG_TOOL) OR (NOT LINK_TOOL) OR (NOT OPT_TOOL)) + libomptarget_say("Not building DeviceRTL. Missing clang: ${CLANG_TOOL}, llvm-link: ${LINK_TOOL} or opt: ${OPT_TOOL}") + return() diff --git a/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt b/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt -index 3f4c02671aeb..be9f4677d7b5 100644 +index 406013073024..7402ab1ea292 100644 --- a/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt +++ b/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt -@@ -38,16 +38,16 @@ endif() +@@ -38,9 +38,9 @@ endif() if (LLVM_DIR) # Builds that use pre-installed LLVM have LLVM_DIR set. - find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) -+ find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) - find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} -- NO_DEFAULT_PATH) +- find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) - find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) -+ REQUIRED) ++ find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) ++ find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) + find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) - libomptarget_say("Building AMDGCN device RTL. Using clang: ${CLANG_TOOL}") - elseif (LLVM_TOOL_CLANG_BUILD AND NOT CMAKE_CROSSCOMPILING AND NOT OPENMP_STANDALONE_BUILD) - # LLVM in-tree builds may use CMake target names to discover the tools. -- set(CLANG_TOOL $) -- set(LINK_TOOL $) -- set(OPT_TOOL $) -+ set(CLANG_TOOL $ REQUIRED) -+ set(LINK_TOOL $ REQUIRED) -+ set(OPT_TOOL $ REQUIRED) - libomptarget_say("Building AMDGCN device RTL. Using clang from in-tree build") - else() - libomptarget_say("Not building AMDGCN device RTL. No appropriate clang found") + if ((NOT CLANG_TOOL) OR (NOT LINK_TOOL) OR (NOT OPT_TOOL)) + libomptarget_say("Not building AMDGCN device RTL. Missing clang: ${CLANG_TOOL}, llvm-link: ${LINK_TOOL} or opt: ${OPT_TOOL}") + return() From 5e04d64aed16e8c068f7b41d2308aa450ab29dfd Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sat, 12 Mar 2022 10:21:48 -0600 Subject: [PATCH 3/6] openmp: no longer broken --- pkgs/development/compilers/llvm/14/openmp/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/development/compilers/llvm/14/openmp/default.nix b/pkgs/development/compilers/llvm/14/openmp/default.nix index 2b580a9c169c..7add0c7ed465 100644 --- a/pkgs/development/compilers/llvm/14/openmp/default.nix +++ b/pkgs/development/compilers/llvm/14/openmp/default.nix @@ -50,6 +50,5 @@ stdenv.mkDerivation rec { # "All of the code is dual licensed under the MIT license and the UIUC # License (a BSD-like license)": license = with lib.licenses; [ mit ncsa ]; - broken = true; # TODO: gnu-install-dirs.patch fails to apply }; } From 7151381aab2fab8f97033681dbb4e461b1780da1 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sat, 12 Mar 2022 10:44:46 -0600 Subject: [PATCH 4/6] openmp: tests, few failures --- .../compilers/llvm/14/openmp/default.nix | 13 +++++++++---- .../compilers/llvm/14/openmp/run-lit-directly.patch | 12 ++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 pkgs/development/compilers/llvm/14/openmp/run-lit-directly.patch diff --git a/pkgs/development/compilers/llvm/14/openmp/default.nix b/pkgs/development/compilers/llvm/14/openmp/default.nix index 7add0c7ed465..6ccfde29e28b 100644 --- a/pkgs/development/compilers/llvm/14/openmp/default.nix +++ b/pkgs/development/compilers/llvm/14/openmp/default.nix @@ -5,6 +5,7 @@ , runCommand , cmake , llvm +, lit , clang-unwrapped , perl , pkg-config @@ -26,16 +27,20 @@ stdenv.mkDerivation rec { patches = [ ./gnu-install-dirs.patch ./fix-find-tool.patch + ./run-lit-directly.patch ]; outputs = [ "out" "dev" ]; - nativeBuildInputs = [ cmake perl pkg-config clang-unwrapped ]; + nativeBuildInputs = [ cmake perl pkg-config clang-unwrapped lit ]; buildInputs = [ llvm ]; - cmakeFlags = [ - "-DLIBOMPTARGET_BUILD_AMDGCN_BCLIB=OFF" # Building the AMDGCN device RTL currently fails - ]; + doCheck = true; + checkTarget = "check-openmp"; + + preCheck = '' + patchShebangs ../tools/archer/tests/deflake.bash + ''; meta = llvm_meta // { homepage = "https://openmp.llvm.org/"; diff --git a/pkgs/development/compilers/llvm/14/openmp/run-lit-directly.patch b/pkgs/development/compilers/llvm/14/openmp/run-lit-directly.patch new file mode 100644 index 000000000000..1e952fdc36a8 --- /dev/null +++ b/pkgs/development/compilers/llvm/14/openmp/run-lit-directly.patch @@ -0,0 +1,12 @@ +diff --git a/cmake/OpenMPTesting.cmake b/cmake/OpenMPTesting.cmake +--- a/cmake/OpenMPTesting.cmake ++++ b/cmake/OpenMPTesting.cmake +@@ -185,7 +185,7 @@ function(add_openmp_testsuite target comment) + if (${OPENMP_STANDALONE_BUILD}) + set(LIT_ARGS ${OPENMP_LIT_ARGS} ${ARG_ARGS}) + add_custom_target(${target} +- COMMAND ${PYTHON_EXECUTABLE} ${OPENMP_LLVM_LIT_EXECUTABLE} ${LIT_ARGS} ${ARG_UNPARSED_ARGUMENTS} ++ COMMAND ${OPENMP_LLVM_LIT_EXECUTABLE} ${LIT_ARGS} ${ARG_UNPARSED_ARGUMENTS} + COMMENT ${comment} + DEPENDS ${ARG_DEPENDS} + USES_TERMINAL From 4f3116f7542d8937f99c312a787e50a16aae9e63 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sat, 12 Mar 2022 10:49:51 -0600 Subject: [PATCH 5/6] openmp: drop fix-find-tool patch, set *_TOOL vars directly --- .../compilers/llvm/14/openmp/default.nix | 9 +++-- .../llvm/14/openmp/fix-find-tool.patch | 35 ------------------- 2 files changed, 7 insertions(+), 37 deletions(-) delete mode 100644 pkgs/development/compilers/llvm/14/openmp/fix-find-tool.patch diff --git a/pkgs/development/compilers/llvm/14/openmp/default.nix b/pkgs/development/compilers/llvm/14/openmp/default.nix index 6ccfde29e28b..e031897c1ff3 100644 --- a/pkgs/development/compilers/llvm/14/openmp/default.nix +++ b/pkgs/development/compilers/llvm/14/openmp/default.nix @@ -26,13 +26,12 @@ stdenv.mkDerivation rec { patches = [ ./gnu-install-dirs.patch - ./fix-find-tool.patch ./run-lit-directly.patch ]; outputs = [ "out" "dev" ]; - nativeBuildInputs = [ cmake perl pkg-config clang-unwrapped lit ]; + nativeBuildInputs = [ cmake perl pkg-config lit ]; buildInputs = [ llvm ]; doCheck = true; @@ -42,6 +41,12 @@ stdenv.mkDerivation rec { patchShebangs ../tools/archer/tests/deflake.bash ''; + cmakeFlags = [ + "-DCLANG_TOOL=${clang-unwrapped}/bin/clang" + "-DOPT_TOOL=${llvm}/bin/opt" + "-DLINK_TOOL=${llvm}/bin/llvm-link" + ]; + meta = llvm_meta // { homepage = "https://openmp.llvm.org/"; description = "Support for the OpenMP language"; diff --git a/pkgs/development/compilers/llvm/14/openmp/fix-find-tool.patch b/pkgs/development/compilers/llvm/14/openmp/fix-find-tool.patch deleted file mode 100644 index 7cdb74121377..000000000000 --- a/pkgs/development/compilers/llvm/14/openmp/fix-find-tool.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/libomptarget/DeviceRTL/CMakeLists.txt b/libomptarget/DeviceRTL/CMakeLists.txt -index d8b9e40802b8..3a8d76ab370f 100644 ---- a/libomptarget/DeviceRTL/CMakeLists.txt -+++ b/libomptarget/DeviceRTL/CMakeLists.txt -@@ -25,10 +25,10 @@ endif() - - if (LLVM_DIR) - # Builds that use pre-installed LLVM have LLVM_DIR set. -- find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) -+ find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) - find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} -- NO_DEFAULT_PATH) -- find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) -+ REQUIRED) -+ find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) - if ((NOT CLANG_TOOL) OR (NOT LINK_TOOL) OR (NOT OPT_TOOL)) - libomptarget_say("Not building DeviceRTL. Missing clang: ${CLANG_TOOL}, llvm-link: ${LINK_TOOL} or opt: ${OPT_TOOL}") - return() -diff --git a/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt b/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt -index 406013073024..7402ab1ea292 100644 ---- a/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt -+++ b/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt -@@ -38,9 +38,9 @@ endif() - - if (LLVM_DIR) - # Builds that use pre-installed LLVM have LLVM_DIR set. -- find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) -- find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) -- find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) -+ find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) -+ find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) -+ find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} REQUIRED) - if ((NOT CLANG_TOOL) OR (NOT LINK_TOOL) OR (NOT OPT_TOOL)) - libomptarget_say("Not building AMDGCN device RTL. Missing clang: ${CLANG_TOOL}, llvm-link: ${LINK_TOOL} or opt: ${OPT_TOOL}") - return() From 2efcc3e297affa4f3dd20e526271faf9c2082c09 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sat, 12 Mar 2022 11:06:42 -0600 Subject: [PATCH 6/6] openmp: disable tests due to failures --- pkgs/development/compilers/llvm/14/openmp/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/llvm/14/openmp/default.nix b/pkgs/development/compilers/llvm/14/openmp/default.nix index e031897c1ff3..622072b53e18 100644 --- a/pkgs/development/compilers/llvm/14/openmp/default.nix +++ b/pkgs/development/compilers/llvm/14/openmp/default.nix @@ -34,7 +34,9 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake perl pkg-config lit ]; buildInputs = [ llvm ]; - doCheck = true; + # Unsup:Pass:XFail:Fail + # 26:267:16:8 + doCheck = false; checkTarget = "check-openmp"; preCheck = ''