Re: Help. Porting "FreeOCL" fails (atomic_ops.h missing, CLANG++ libc++ issues ...)

Dimitry Andric <[email protected]>
Newsgroups gmane.os.freebsd.devel.ports,gmane.os.freebsd.performance
Organization The FreeBSD Project
Message-ID <[email protected]>
On 2012-09-05 16:45, O. Hartmann wrote:
...
> Well, I tried LLVM/CLANG, but Cmake of the sources fairly fails many
> checks especuially for OpenMP.

Yes, it is currently not supported.  I am not sure if there are serious
attempts to add it.


> Using clang++ requisites the usage of the
> new libc++ (CXXFLAGS+= -stdlib=libc++). But this fails with this error:
...
> /usr/ports/devel/freeocl/work/FreeOCL-0.3.6-Source/src/parser/parser.h:118:15:
> error: no viable conversion from 'std::__1::basic_istream<char>' to
> 'const bool'
>                          const bool ok = in.get(c);
>                                     ^    ~~~~~~~~~

This is a bug in FreeOCL.  The istream::get() function returns an
istream reference, which can't be cast directly to bool.  However, there
is a negation operator defined for istream, so the line can be changed
to:

                          const bool ok = !!in.get(c);

I have attached a patch for the port as I have built it here with clang.
I didn't add the dependency on atomic_ops yet, but it should be fairly
trivial.

Note I also needed a fix for Mk/bsd.cmake.mk, otherwise the required
${CPPFLAGS} would not be passed along to CMake, and then the build would
still fail to find the atomic_ops headers in /usr/local/include.

_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "[email protected]"
clangports-devel-freeocl-1.diff (text/x-diff, 2.5 KB)
Index: Mk/bsd.cmake.mk
===================================================================
--- Mk/bsd.cmake.mk	(revision 303593)
+++ Mk/bsd.cmake.mk	(working copy)
@@ -50,12 +50,12 @@ BUILD_DEPENDS+=	${CMAKE_BIN}:${CMAKE_PORT}
 CMAKE_ENV?=		${CONFIGURE_ENV}
 CMAKE_ARGS+=	-DCMAKE_C_COMPILER:STRING="${CC}" \
 				-DCMAKE_CXX_COMPILER:STRING="${CXX}" \
-				-DCMAKE_C_FLAGS:STRING="${CFLAGS}" \
-				-DCMAKE_C_FLAGS_DEBUG:STRING="${CFLAGS}" \
-				-DCMAKE_C_FLAGS_RELEASE:STRING="${CFLAGS}" \
-				-DCMAKE_CXX_FLAGS:STRING="${CXXFLAGS}" \
-				-DCMAKE_CXX_FLAGS_DEBUG:STRING="${CXXFLAGS}" \
-				-DCMAKE_CXX_FLAGS_RELEASE:STRING="${CXXFLAGS}" \
+				-DCMAKE_C_FLAGS:STRING="${CPPFLAGS} ${CFLAGS}" \
+				-DCMAKE_C_FLAGS_DEBUG:STRING="${CPPFLAGS} ${CFLAGS}" \
+				-DCMAKE_C_FLAGS_RELEASE:STRING="${CPPFLAGS} ${CFLAGS}" \
+				-DCMAKE_CXX_FLAGS:STRING="${CPPFLAGS} ${CXXFLAGS}" \
+				-DCMAKE_CXX_FLAGS_DEBUG:STRING="${CPPFLAGS} ${CXXFLAGS}" \
+				-DCMAKE_CXX_FLAGS_RELEASE:STRING="${CPPFLAGS} ${CXXFLAGS}" \
 				-DCMAKE_EXE_LINKER_FLAGS:STRING="${LDFLAGS}" \
 				-DCMAKE_MODULE_LINKER_FLAGS:STRING="${LDFLAGS}" \
 				-DCMAKE_SHARED_LINKER_FLAGS:STRING="${LDFLAGS}" \
Index: devel/freeocl/Makefile
===================================================================
--- devel/freeocl/Makefile	(revision 0)
+++ devel/freeocl/Makefile	(working copy)
@@ -0,0 +1,22 @@
+PORTNAME=		freeocl
+PORTVERSION=		0.3.6
+CATEGORIES=		devel
+
+MAINTAINER=		[email protected]
+COMMENT=		FreeOCL - a free OpenCL implementation for CPU
+
+#MASTER_SITES=		http://freeocl.googlecode.com/files/FreeOCL-0.3.6-src.tar.gz
+MASTER_SITES=		http://freeocl.googlecode.com/files/
+DISTNAME=		FreeOCL-${PORTVERSION}-src
+
+WRKSRC=			${WRKDIR}/FreeOCL-${PORTVERSION}-Source
+
+USE_CMAKE=		YES
+CMAKE_BUILD_TYPE=	Release
+
+#USE_GCC=		4.7+
+
+CPPFLAGS+=		-I${LOCALBASE}/include
+CXXFLAGS+=		-stdlib=libc++
+
+.include <bsd.port.mk>
Index: devel/freeocl/files/patch-src__parser__parser.h
===================================================================
--- devel/freeocl/files/patch-src__parser__parser.h	(revision 0)
+++ devel/freeocl/files/patch-src__parser__parser.h	(working copy)
@@ -0,0 +1,11 @@
+--- src/parser/parser.h.orig	2012-09-02 19:00:41.000000000 +0200
++++ src/parser/parser.h	2012-09-06 14:14:01.000000000 +0200
+@@ -115,7 +115,7 @@ namespace FreeOCL
+ 		inline std::istream &get(char &c)
+ 		{
+ 			c = 0;
+-			const bool ok = in.get(c);
++			const bool ok = !!in.get(c);
+ 			if (c == '\n')
+ 				++line;
+ 			if (!current_line.empty() && *current_line.rbegin() == '\n')
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.