OpenMP header path?

Hi!

I'm trying to build file with enabled OpenMP support by trunk Clang
with GCC STL. Compilation is failing because of:

fatal error: 'omp.h' file not found
#include <omp.h>

Clang options:

-stdlib=libstdc++ --gcc-toolchain=<GCC 6.3.0 path> -fopenmp

Search path reported by -v:

#include <...> search starts here:

<GCC 6.3.0 path>/lib/gcc/x86_64-redhat-linux/6.3.0/../../../../include/c++/6.3.0
<GCC 6.3.0 path>/lib/gcc/x86_64-redhat-linux/6.3.0/../../../../include/c++/6.3.0/x86_64-redhat-linux/32
<GCC 6.3.0 path>/lib/gcc/x86_64-redhat-linux/6.3.0/../../../../include/c++/6.3.0/backward

Location of omp.h:

<GCC 6.3.0 path>/lib/gcc/x86_64-redhat-linux/6.3.0/include/omp.h

Eugene.

Hi!

I'm trying to build file with enabled OpenMP support by trunk Clang
with GCC STL. Compilation is failing because of:

fatal error: 'omp.h' file not found
#include <omp.h>

Clang is normally looking for it's own omp.h
It won't find it unless you actually install clang.
It won't work out of build dir.
https://bugs.llvm.org/show_bug.cgi?id=40139

Also, you need to build libomp for that header to be build, IIRC.

Clang options:

-stdlib=libstdc++ --gcc-toolchain=<GCC 6.3.0 path> -fopenmp

Search path reported by -v:

#include <...> search starts here:

<GCC 6.3.0 path>/lib/gcc/x86_64-redhat-linux/6.3.0/../../../../include/c++/6.3.0
<GCC 6.3.0 path>/lib/gcc/x86_64-redhat-linux/6.3.0/../../../../include/c++/6.3.0/x86_64-redhat-linux/32
<GCC 6.3.0 path>/lib/gcc/x86_64-redhat-linux/6.3.0/../../../../include/c++/6.3.0/backward

Location of omp.h:

<GCC 6.3.0 path>/lib/gcc/x86_64-redhat-linux/6.3.0/include/omp.h

Eugene.

Roman.

Hi, Roman!

>
> Hi!
>
> I'm trying to build file with enabled OpenMP support by trunk Clang
> with GCC STL. Compilation is failing because of:
>
> fatal error: 'omp.h' file not found
> #include <omp.h>
Clang is normally looking for it's own omp.h
It won't find it unless you actually install clang.
It won't work out of build dir.
https://bugs.llvm.org/show_bug.cgi?id=40139

Also, you need to build libomp for that header to be build, IIRC.

It was my first thought, so I built and install OpenMP. I use
installed Clang, not build directory. omp.h is in include directory in
installation path, but Clang could not find it.

Only <Clang installation dir>/lib64/clang/9.0.0/include is in search
path reported by -v.

> Clang options:
>
> -stdlib=libstdc++ --gcc-toolchain=<GCC 6.3.0 path> -fopenmp
>
> Search path reported by -v:
>
> #include <...> search starts here:
>
> <GCC 6.3.0 path>/lib/gcc/x86_64-redhat-linux/6.3.0/../../../../include/c++/6.3.0
> <GCC 6.3.0 path>/lib/gcc/x86_64-redhat-linux/6.3.0/../../../../include/c++/6.3.0/x86_64-redhat-linux/32
> <GCC 6.3.0 path>/lib/gcc/x86_64-redhat-linux/6.3.0/../../../../include/c++/6.3.0/backward
>
> Location of omp.h:
>
> <GCC 6.3.0 path>/lib/gcc/x86_64-redhat-linux/6.3.0/include/omp.h
>
> Eugene.
Roman.

> _______________________________________________
> cfe-dev mailing list
> cfe-dev@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

Eugene.

Hi, Eugene,

Have you built and installed LLVM's OpenMP runtime library? Even when
using GCC's libstdc++, you should be using LLVM's OpenMP runtime and
LLVM's omp.h.

-Hal

Hi, Hal!

Hi, Hal!

Hi, Eugene,

Have you built and installed LLVM's OpenMP runtime library? Even when
using GCC's libstdc++, you should be using LLVM's OpenMP runtime and
LLVM's omp.h.

-Hal

Yes, I built and installed LLVM's OpenMP runtime library, but this didn't help.

That should have installed an omp.h, did it not? Is the relevant path
one that Clang searches by default?

-Hal

Ok, so what you need to do is run this in your terminal: find / -iname “omp.h”

then check all of the results for LLVM’s header copyright info, once you find the correct OpenMP header, add that to Clang’s search path with either -i (but capitalized) or -system-header-prefix.

I’m not entirely clear on this part.

Hi, Marcus!

Ok, so what you need to do is run this in your terminal: find / -iname "omp.h"

then check all of the results for LLVM's header copyright info, once you find the correct OpenMP header, add that to Clang's search path with either -i (but capitalized) or -system-header-prefix.

I'm not entirely clear on this part.

But isn't -fopenmp should add omp.h location (<Clang installation

/include) to list of <> search paths?

Eugene.

Hi, Marcus!

Ok, so what you need to do is run this in your terminal: find / -iname "omp.h"

then check all of the results for LLVM's header copyright info, once you find the correct OpenMP header, add that to Clang's search path with either -i (but capitalized) or -system-header-prefix.

I'm not entirely clear on this part.

But isn't -fopenmp should add omp.h location (<Clang installation
>/include) to list of <> search paths?

This seems like a larger problem, not something OpenMP specific. Perhaps
Clang should add it's installation-prefix include directory to its list
of system include paths? Alternatively, or in addition, we should make
sure that omp.h is installed into Clang's lib/include directory along
with other compiler-specific headers.

-Hal

This works iff you build the OpenMP runtime in-tree, so checking out to projects/openmp or using LLVM_ENABLE_PROJECTS. When building standalone, we cannot do much because CMake doesn't know about the Clang version and cannot put the header into lib/clang/<<<version>>>/include.
For reference: There's https://reviews.llvm.org/D55725 which adds OPENMP_CLANG_VERSION so that you can tell CMake where to put the header. For now I'd say you're responsible that Clang can find both the header and the shared library if you're building the OpenMP runtime separately.

Jonas