[Openmp-commits] [PATCH] D125370: Make LIBOMP_CONFIGURED_LIBFLAGS a list instead of string

Mikael Simberg via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed May 11 03:40:25 PDT 2022


msimberg created this revision.
Herald added a subscriber: mgorny.
Herald added a project: All.
msimberg requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.

When configuring llvm with the openmp subproject, the build for the omp target
fails if LIBOMP_CONFIGURED_LIBFLAGS contains more than one item.
LIBOMP_CONFIGURED_LIBFLAGS should be a semicolon-separated list instead of a
string with items separated by spaces for this call to target_link_libraries:
https://reviews.llvm.org/source/llvm-github/browse/main/openmp/runtime/src/CMakeLists.txt$148.

I can reproduce the failure with both the "Unix Makefiles" and "Ninja"
generators on Linux and from what I understand CMake does really expect a
semicolon-separated list and not a space-separated string (indirectly based on
the help text under "A generator expression" here:
https://cmake.org/cmake/help/latest/command/target_link_libraries.html?highlight=target_link_libraries#overview).

I'm assuming this can be reproduced quite easily in many setups but I can for
example reproduce it with a nix environment with the following shell.nix:

{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {

  buildInputs = with pkgs; [ hwloc ];

}

and then entering the shell with nix-shell shell.nix and configuring llvm e.g. as follows:

cmake -DLLVM_ENABLE_PROJECTS="clang;openmp" -DLIBOMP_USE_HWLOC=ON -DCMAKE_BUILD_TYPE=Release ../llvm

Configuration passes but compilation fails. With Ninja:

$ ninja omp
ninja: error: '/nix/store/8d3mc9m48w8bg118aw4dpvifn9zm59r9-hwloc-2.7.1-lib/lib/libhwloc.so -lm', needed by 'lib/libomp.so', missing and no known rule to make it

and with make:

$ make omp
Built target libomp-needed-headers
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_alloc.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_atomic.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_csupport.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_debug.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_itt.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_environment.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_error.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_global.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_i18n.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_io.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_runtime.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_settings.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_str.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_tasking.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_threadprivate.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_utility.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_barrier.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_wait_release.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_affinity.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_dispatch.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_lock.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_sched.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/z_Linux_util.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_gsupport.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/thirdparty/ittnotify/ittnotify_static.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_taskdeps.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_cancel.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_ftn_cdecl.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_ftn_extra.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_version.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/ompt-general.cpp.o
Building CXX object projects/openmp/runtime/src/CMakeFiles/omp.dir/ompd-specific.cpp.o
Building C object projects/openmp/runtime/src/CMakeFiles/omp.dir/z_Linux_asm.S.o
make[3]: *** No rule to make target '/nix/store/8d3mc9m48w8bg118aw4dpvifn9zm59r9-hwloc-2.7.1-lib/lib/libhwloc.so -lm', needed by 'lib/libomp.so'.  Stop.
make[2]: *** [CMakeFiles/Makefile2:30563: projects/openmp/runtime/src/CMakeFiles/omp.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:30570: projects/openmp/runtime/src/CMakeFiles/omp.dir/rule] Error 2
make: *** [Makefile:7638: omp] Error 2

In my understanding not all flags need to (or can) be lists, so I've only made a
local change in libomp_get_libflags and not made the change in e.g.
libomp_setup_flags
(https://reviews.llvm.org/source/llvm-github/browse/main/openmp/runtime/cmake/LibompHandleFlags.cmake$14)
which would apply to all libomp_get_*flags functions.

If in a particular configuration LIBOMP_CONFIGURED_LIBFLAGS ends up having only
one or zero items all is fine, e.g. if hwloc is not used.

I have not made any attempts to look for other places where this may need
fixing as I'm not otherwise familiar with the codebase.

This is also my first contribution so apologies in advance if I've missed
something.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125370

Files:
  openmp/runtime/cmake/LibompHandleFlags.cmake


Index: openmp/runtime/cmake/LibompHandleFlags.cmake
===================================================================
--- openmp/runtime/cmake/LibompHandleFlags.cmake
+++ openmp/runtime/cmake/LibompHandleFlags.cmake
@@ -144,7 +144,8 @@
   endif()
   set(libflags_local ${libflags_local} ${LIBOMP_LIBFLAGS})
   libomp_setup_flags(libflags_local)
-  set(${libflags} ${libflags_local} PARENT_SCOPE)
+  libomp_string_to_list("${libflags_local}" libflags_local_list)
+  set(${libflags} ${libflags_local_list} PARENT_SCOPE)
 endfunction()
 
 # Fortran flags


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125370.428614.patch
Type: text/x-patch
Size: 554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220511/a4b27f9e/attachment-0001.bin>


More information about the Openmp-commits mailing list