Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 559588

Summary: sys-devel/llvm-3.7.0[clang] missing openmp runtime library
Product: Gentoo Linux Reporter: Jeremi Piotrowski <jeremi.piotrowski>
Component: Current packagesAssignee: Bernard Cafarelli <voyageur>
Status: RESOLVED FIXED    
Severity: major CC: jeremi.piotrowski, mgorny
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 559582    
Bug Blocks:    
Attachments: minimal openmp example that currently doesn't run in parallel when compiled with clang

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!