[libcxx-commits] [PATCH] D113253: [runtimes] Fix building initial libunwind+libcxxabi+libcxx with compiler implied -lunwind

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 17 04:32:57 PST 2021


mstorsjo added a comment.

I managed to reproduce the issue. @phosek, can you advise how to proceed from here?

One part of the issue, is that setting `CMAKE_TRY_COMPILE_TARGET_TYPE` to `STATIC_LIBRARY` makes the initial detection step detect less things. In particular, if doing full link tests, cmake sets the `CMAKE_LIBRARY_ARCHITECTURE` variable to `x86_64-linux-gnu`. This seems to be vital for some parts of library detection. To show off the issue, one can execute this minimal standalone cmake snippet:

  set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
  project(Runtimes)
  cmake_minimum_required(VERSION 3.10)
  find_package(ZLIB)

On Ubuntu, it fails to find zlib, but if the `set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)` line is uncommented, it finds it as expected.

When runtimes include parts of the llvm cmake files from the main host build, from `find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)`, it executes this check which now failed, while it succeeded as part of the host build.

Secondly, in openmp/libomptarget/src/CMakeLists.txt, we have this bit:

  if (OPENMP_ENABLE_LIBOMPTARGET_PROFILING)
    # Add LLVMSupport dependency if profiling is enabled.
    # Linking with LLVM component libraries also requires
    # aligning the compile flags.
    llvm_update_compile_flags(omptarget)
    target_compile_definitions(omptarget PUBLIC OMPTARGET_PROFILE_ENABLED)
    target_link_libraries(omptarget PRIVATE LLVMSupport)
  endif()

This seems to be enabled in the default case. Thus, the runtime build of libopenmp (which could be targeting any foreign target) tries to link against the host-built LLVMSupport. As LLVMSupport is set to link against zlib, but zlib wasn't found, the build breaks.

I guess the right course of action would be to properly untangle openmp from the main host llvm build. Should `OPENMP_ENABLE_LIBOMPTARGET_PROFILING` be disabled when built as part of the runtimes build (where openmp might be built for a wildly different target anyway), as one can't expect to link against LLVMSupport in such a setup?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113253/new/

https://reviews.llvm.org/D113253



More information about the libcxx-commits mailing list