Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 06 Sep 2012 14:51:19 +0200
From:      Dimitry Andric <dim@FreeBSD.org>
To:        "O. Hartmann" <ohartman@mail.zedat.fu-berlin.de>
Cc:        "freebsd-performance@freebsd.org" <freebsd-performance@freebsd.org>, Ports FreeBSD <freebsd-ports@FreeBSD.org>
Subject:   Re: Help. Porting "FreeOCL" fails (atomic_ops.h missing, CLANG++ libc++ issues ...)
Message-ID:  <50489C47.4040101@FreeBSD.org>
In-Reply-To: <5047659D.8000107@mail.zedat.fu-berlin.de>
References:  <5047659D.8000107@mail.zedat.fu-berlin.de>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------090904010800010802030106
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

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.

--------------090904010800010802030106
Content-Type: text/x-diff;
 name="clangports-devel-freeocl-1.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="clangports-devel-freeocl-1.diff"

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=		ports@FreeBSD.org
+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')

--------------090904010800010802030106--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50489C47.4040101>