Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 559588 - sys-devel/llvm-3.7.0[clang] missing openmp runtime library
Summary: sys-devel/llvm-3.7.0[clang] missing openmp runtime library
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal major (vote)
Assignee: Bernard Cafarelli
URL:
Whiteboard:
Keywords:
Depends on: 559582
Blocks:
  Show dependency tree
 
Reported: 2015-09-04 12:01 UTC by Jeremi Piotrowski
Modified: 2015-09-07 15:18 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
minimal openmp example that currently doesn't run in parallel when compiled with clang (omp.c,99 bytes, text/x-c)
2015-09-04 12:05 UTC, Jeremi Piotrowski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremi Piotrowski 2015-09-04 12:01:02 UTC
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
Comment 1 Jeremi Piotrowski 2015-09-04 12:05:20 UTC
Created attachment 410990 [details]
minimal openmp example that currently doesn't run in parallel when compiled with clang
Comment 2 Bernard Cafarelli gentoo-dev 2015-09-04 15:33:26 UTC
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
Comment 3 Bernard Cafarelli gentoo-dev 2015-09-05 21:56:10 UTC
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
Comment 4 Bernard Cafarelli gentoo-dev 2015-09-07 15:18:00 UTC
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!