Since version 3.7.0 clang features openmp support but requires the accompanying runtime library to use it (libomp). Without it executables are linked against the system libgomp.so (by default) but for which clang can't/doesn't generate code. What you get is semantic checking of openmp constructs, linking against gcc's openmp library but no openmp functionality when the application is run. Therefore what needs to be done is the llvm project's openmp runtime library needs to be installed along with clang. There are two possibilities: 1. standalone build 2. drop the openmp folder into ${S}/projects and compile in-tree Personally I prefer option 1 because the already huge llvm build is not increased. I have prepared a separate ebuild for libomp, it will be linked to this bug. I would further suggest changing the default clang openmp runtime via the DCLANG_DEFAULT_OPENMP_RUNTIME cmake flag to libomp. That way the openmp functionality is actually present when you compile with `clang -fopenmp`. Reproducible: Always Steps to Reproduce: 1. USE="clang" emerge =llvm-3.7.0 2. compile an openmp application with clang -fopenmp 3. run said applcation 4. compile an openmp application with clang -fopenmp=libomp Actual Results: after 3: application doesn't run in openmp mode after 4: /usr/bin/x86_64-pc-linux-gnu-ld: cannot find -lomp Expected Results: Built application runs using multiple threads
Created attachment 410990 [details] minimal openmp example that currently doesn't run in parallel when compiled with clang
Thanks for both bug reports, that definitely looks like an interesting addition! I am not sure on the default runtime change though, as it would imply a link in the big-to-build llvm ebuild, and change upstream's default behaviour. But I'll definitely look into this
From upstream release notes (http://llvm.org/releases/3.7.0/tools/clang/docs/ReleaseNotes.html#openmp-support): "OpenMP 3.1 is fully supported, but disabled by default. To enable it, please use the -fopenmp=libomp command line option" So I think at least for 3.7 we will keep the current behaviour, and just add a postinstall note (with USE=clang) to note libomp is required to use OpenMP
Ebuild (with USE=clang) will now warn about sys-libs/libomp and "-fopenmp=libomp" command line option, and test applications work fine, thanks for the research!