Bug 234050 - devel/cmake: find_package(OpenMP) doesn't find the openmp package (when clang from devel/llvm70 is used)
Summary: devel/cmake: find_package(OpenMP) doesn't find the openmp package (when clang...
Status: Closed DUPLICATE of bug 223678
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-kde (group)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-16 08:25 UTC by Yuri Victorovich
Modified: 2019-03-10 22:44 UTC (History)
4 users (show)

See Also:


Attachments
testcase-broken-OpenMP-detection.shar (2.28 KB, text/plain)
2018-12-16 17:35 UTC, Yuri Victorovich
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer freebsd_triage 2018-12-16 08:25:38 UTC
llvm70 contains OpenMP, and it isn't properly found by find_package(OpenMP).

Testcase: In the port math/combblas of rev.487559 remove the line LDFLAGS+=...

Build of the port now fails because libomp.so isn't found, see log below.
I think this is a regression with llbm70, I don't recall this happening with llvm60.


---log---
 && /usr/local/bin/clang++70  -O2 -pipe -fno-omit-frame-pointer -fstack-protector -isystem /usr/local/include -fno-strict-aliasing -fno-omit-frame-pointer  -isystem /usr/local/include -O2 -pipe -fno-omit-frame-pointer -fstack-protector -isystem /usr/local/include -fno-strict-aliasing -fno-omit-frame-pointer  -isystem /usr/local/include  -fstack-protector -L/usr/local/lib ReleaseTests/CMakeFiles/IndexingTest.dir/IndexingTest.cpp.o  -o ReleaseTests/IndexingTest  -Wl,-rpath,/usr/ports/math/combblas/work/.build:/usr/ports/math/combblas/work/.build/usort:/usr/ports/math/combblas/work/.build/graph500-1.2/generator libCombBLAS.so.1.16.0 -Wl,-rpath=/usr/local/lib/gcc7 -Wl,-rpath -Wl,/usr/local/lib -L/usr/local/lib/gcc7 /usr/local/lib/libmpicxx.so /usr/local/lib/libmpi.so usort/libUsortlib.so graph500-1.2/generator/libGraphGenlib.so && :
ReleaseTests/CMakeFiles/IndexingTest.dir/IndexingTest.cpp.o: In function `.omp_outlined.':
IndexingTest.cpp:(.text+0x35d3): undefined reference to `__kmpc_global_thread_num'
IndexingTest.cpp:(.text+0x362b): undefined reference to `__kmpc_for_static_init_4'
Comment 1 Yuri Victorovich freebsd_committer freebsd_triage 2018-12-16 08:29:06 UTC
See also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223678
Comment 2 Yuri Victorovich freebsd_committer freebsd_triage 2018-12-16 08:37:46 UTC
Small correction: cmake says that it has found OpenMP, but it doesn't contain the proper libomp.so anywhere in the resulting cmake variables.

Removing OpenMP from devel/llvm70 might be one possible solution. (Why was it added there anyway?)
Comment 3 Rainer Hurling freebsd_committer freebsd_triage 2018-12-16 11:35:57 UTC
Hi Yuri,

Don't know, if I understand you right. In math/saga[1] I use the following to find libomp.so of clang60:

# lines 65-67, and 71-72
CPP=		clang-cpp60
CC=		clang60
CXX=		clang++60
CONFIGURE_ENABLE=	openmp
LDFLAGS=		-L${LOCALBASE}/lib -lm -L${LOCALBASE}/llvm60/lib -lomp

This also works also pretty nice for clang70.


[1] https://svnweb.freebsd.org/ports/head/math/saga/Makefile?revision=487272&view=markup
Comment 4 Yuri Victorovich freebsd_committer freebsd_triage 2018-12-16 17:35:48 UTC
Created attachment 200160 [details]
testcase-broken-OpenMP-detection.shar

(In reply to Rainer Hurling from comment #3)

Hi Rainer,

I'm attaching the testcase that demonstrates that OpenMP detection is broken with clang70.

1. Extract the attached case: sh testcase-broken-OpenMP-detection.shar
2. cd testcase-broken-OpenMP-detection
3. sh run
4. Observe the failure: helloworld.cpp:(.text+0x2d): undefined reference to `__kmpc_fork_call'

It closely follows the recommended way: https://cliutils.gitlab.io/modern-cmake/chapters/packages/OpenMP.html

Yuri
Comment 5 Rainer Hurling freebsd_committer freebsd_triage 2018-12-20 16:18:19 UTC
(In reply to Yuri Victorovich from comment #4)

Hi Yuri,

Sorry for the long delay. You are right, the testcase fails for clang70. But this is also true for clang60 (at least on HEAD), which is only in ports, not in base any more.
Comment 6 Adriaan de Groot freebsd_committer freebsd_triage 2018-12-24 14:01:20 UTC
Both PR 234050 and PR 223678 need someone to chase what CMake is doing exactly -- you may find the cmake flags --debug-trycompile and --trace useful -- and to propose a patch. This isn't something we have time for right now.
Comment 7 Adriaan de Groot freebsd_committer freebsd_triage 2019-03-10 15:28:47 UTC
The changes posted in PR 223678 don't help at all with clang++70. I notice that when it links, (e.g. through `make VERBOSE=1`) no openmp flags are passed to the compiler (linker) at all. If I copy the command used and insert `-fopenmp`, then the final link step completes properly. So with clang++70, **something** eats the flags which doesn't happen with base clang (it also happens with clang++60, for instance).
Comment 8 Adriaan de Groot freebsd_committer freebsd_triage 2019-03-10 22:44:25 UTC
I'm going to merge this one with PR 223678. Over there, I have a patched FindOpenMP (I'll refresh the patches in a moment) that successfully builds (and runs) the test case on 12.0-R with clang60, clang70 and base clang.

*** This bug has been marked as a duplicate of bug 223678 ***