spack / spack/spack

Environment issue: spurious cmake warnings related to libgomp.so

Open
#49,050 11 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.1k
Forks
2.5k
Avg merge
3d 4h
Merged PRs (30d)
82

Description

I use spack environments and I recently noticed spurious cmake warnings like the following

CMake Warning at CMakeLists.txt:8 (add_executable):
  Cannot generate a safe runtime search path for target main because files in
  some directories may conflict with libraries in implicit directories:

    runtime library [libgomp.so.1] in /usr/lib/gcc/x86_64-linux-gnu/9 may be hidden by files in:
      /local/home/tpadiole/Codes/omp-reproducer/omp-env/.spack-env/view/lib

  Some of these libraries may not be found correctly.

The file /local/home/tpadiole/Codes/omp-reproducer/omp-env/.spack-env/view/lib/libgomp.so.1 links to /local/home/tpadiole/spack-0.22.2/opt/spack/linux-ubuntu20.04-icelake/gcc-10.5.0/gcc-runtime-10.5.0-qg536zuhbvx67he6igimmtprurxn3nvy/lib/libgomp.so.1

I created a reproducer environment for the purpose of this issue:

spack:
  specs:
  - cmake
  - openmpi
  view: true
  concretizer:
    unify: true

The bug is likely not related to openmpi, the intent is only to link to a library located in the environment.

The CMakeLists.txt used is:

cmake_minimum_required(VERSION 3.27)

project(omp-reproducer LANGUAGES CXX)

find_package(OpenMP REQUIRED COMPONENTS CXX)
find_package(MPI REQUIRED COMPONENTS CXX)

add_executable(main main.cpp)
target_link_libraries(main PRIVATE OpenMP::OpenMP_CXX MPI::MPI_CXX)

and the file main.cpp is

#include <iostream>

int main(int argc, char** argv)
{
#pragma omp parallel for
  for(int i=0; i<100; ++i)
  {
      std::cout << i << std::endl;
  }

    return 0;
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by recreating the supplied Spack environment from the YAML, then configure the project using CMakeLists.txt and main.cpp. Inspect how the environment view exposes libgomp.so.1 and how CMake derives its runtime search path; done means the reproducer no longer emits the spurious warning while still linking the environment's libraries.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.