Skip to content

OMP: Error #15 (Duplicate OpenMP runtime) when running heir-opt tests via Bazel #2591

@crockeea

Description

@crockeea

I am encountering an OpenMP runtime error when running tests for heir-opt using Bazel. The error indicates that multiple copies of the OpenMP runtime (libomp) have been linked into the binary, causing the program to abort during initialization.

Steps to Reproduce (intermittent, may need a failing test?)

Run the lwe-to-polynomial tests (or potentially any test invoking heir-opt with complex lowerings). E.g.,
bazel test //tests/Dialect/LWE/Conversions/lwe_to_polynomial:decrypt_ops.mlir.test

OMP: Error #15: Initializing libomp.so.5, but found unknown library already initialized. OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://openmp.llvm.org/ error: command failed with exit status: -6

I have reproduced this error with the tip of main.

According to AI

It appears that heir-opt is linking against the OpenMP runtime twice. This often happens if:

The toolchain provides -fopenmp implicitly.

A dependency (possibly in @llvm-project) explicitly links a static archive of OpenMP.

Expected Behavior

The tests should run without conflicting OpenMP runtimes. This error makes debugging [even] harder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions