Skip to content

[runtimes] [openmp] -nostdlib++ added to CMAKE_REQUIRED_FLAGS breaks hwloc detection for OMPT #90332

@mgorny

Description

To reproduce:

$ cmake -G Ninja -DLLVM_ENABLE_RUNTIMES=openmp -DLIBOMP_USE_HWLOC=ON ${path_to_llvm_project}/runtimes
[…]
-- Looking for hwloc.h
-- Looking for hwloc.h - not found
-- Looking for hwloc_topology_init in /usr/lib64/libhwloc.so
-- Looking for hwloc_topology_init in /usr/lib64/libhwloc.so - not found
-- LIBOMP: Could not find hwloc
CMake Error at /home/mgorny/git/llvm-project/openmp/runtime/cmake/LibompUtils.cmake:26 (message):
  LIBOMP: Hwloc requested but not available
Call Stack (most recent call first):
  /home/mgorny/git/llvm-project/openmp/runtime/CMakeLists.txt:387 (libomp_error_say)


-- Configuring incomplete, errors occurred!

CMakeFiles/CMakeConfigureLog.yaml hints at the problem:

  -
    kind: "try_compile-v1"
    backtrace:
      - "/usr/share/cmake/Modules/CheckIncludeFile.cmake:90 (try_compile)"
      - "/home/mgorny/git/llvm-project/openmp/runtime/cmake/config-ix.cmake:351 (check_include_file)"
      - "/home/mgorny/git/llvm-project/openmp/runtime/CMakeLists.txt:276 (include)"
    checks:
      - "Looking for hwloc.h"
    directories:
      source: "/home/mgorny/git/llvm-project/build/CMakeFiles/CMakeScratch/TryCompile-EEYwvY"
      binary: "/home/mgorny/git/llvm-project/build/CMakeFiles/CMakeScratch/TryCompile-EEYwvY"
    cmakeVariables:
      CMAKE_C_FLAGS: " -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wno-comment -fdiagnostics-color -Wall -Wcast-qual -Wimplicit-fallthrough -Wsign-compare -Wno-extra -Wno-pedantic -Wno-maybe-uninitialized -fno-semantic-interposition -fdata-sections"
      CMAKE_C_FLAGS_DEBUG: "-g"
      CMAKE_EXE_LINKER_FLAGS: ""
      CMAKE_MODULE_PATH: "/home/mgorny/git/llvm-project/openmp/runtime/cmake;/home/mgorny/git/llvm-project/openmp/cmake;/home/mgorny/git/llvm-project/openmp/../cmake/Modules;/home/mgorny/git/llvm-project/runtimes/cmake;/home/mgorny/git/llvm-project/runtimes/cmake/modules;/home/mgorny/git/llvm-project/runtimes/../cmake;/home/mgorny/git/llvm-project/runtimes/../cmake/Modules;/home/mgorny/git/llvm-project/runtimes/../llvm/cmake;/home/mgorny/git/llvm-project/runtimes/../llvm/cmake/modules"
    buildResult:
      variable: "LIBOMP_HAVE_HWLOC_H"
      cached: true
      stdout: |
        Change Dir: '/home/mgorny/git/llvm-project/build/CMakeFiles/CMakeScratch/TryCompile-EEYwvY'
        
        Run Build Command(s): /usr/bin/ninja -v cmTC_5eb96
        [1/2] /usr/bin/cc   -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wno-comment -fdiagnostics-color -Wall -Wcast-qual -Wimplicit-fallthrough -Wsign-compare -Wno-extra -Wno-pedantic -Wno-maybe-uninitialized -fno-semantic-interposition -fdata-sections  -nostdlib++ -nostdinc++ -o CMakeFiles/cmTC_5eb96.dir/CheckIncludeFile.c.o -c /home/mgorny/git/llvm-project/build/CMakeFiles/CMakeScratch/TryCompile-EEYwvY/CheckIncludeFile.c
        FAILED: CMakeFiles/cmTC_5eb96.dir/CheckIncludeFile.c.o 
        /usr/bin/cc   -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wno-comment -fdiagnostics-color -Wall -Wcast-qual -Wimplicit-fallthrough -Wsign-compare -Wno-extra -Wno-pedantic -Wno-maybe-uninitialized -fno-semantic-interposition -fdata-sections  -nostdlib++ -nostdinc++ -o CMakeFiles/cmTC_5eb96.dir/CheckIncludeFile.c.o -c /home/mgorny/git/llvm-project/build/CMakeFiles/CMakeScratch/TryCompile-EEYwvY/CheckIncludeFile.c
        cc: error: unrecognized command-line option ‘-nostdlib++’
        ninja: build stopped: subcommand failed.
        
      exitCode: 1

i.e. the nostdlib++ flags gets appended to both C and C++ compiler flags, effectively breaking all compilations done in C mode.

CC @mstorsjo as the one who added the logic

Activity

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

Metadata

Assignees

Labels

cmakeBuild system in general and CMake in particularopenmp

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions