Subject: pkg/30524: [PATCH] boost fails to build on Darwin/OS X
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <idart@performancedesign.no>
List: pkgsrc-bugs
Date: 06/14/2005 14:33:00
>Number:         30524
>Category:       pkg
>Synopsis:       [PATCH] boost fails to build on Darwin/OS X
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 14 14:33:00 +0000 2005
>Originator:     Idar Tollefsen
>Release:        boost-1.32.0
>Organization:
Performance Design
>Environment:
Darwin fulcrum.local 7.9.0 Darwin Kernel Version 7.9.0: Wed Mar 30 20:11:17 PST 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE_PPC  Power Macintosh powerpc
>Description:
First, devel/boost-build chooses bjam toolset based on compiler.
On OS X, this results in gcc, which fails because it tries to build
shared libraries using the -shared flag which gcc doesn't understand
on OS X. It should have picked the darwin toolset.

Second, it complains about not having the necessary compiler flags when
compiling the threading library in devel/boost-libs. I.e. it's asking
for something like -pthread, but this isn't required on OS X.
The problem is that BOOST_HAS_THREADS doesn't get defined during
configuration and it fails only because it lacks that definition.

Third, the link command used for the Darwin toolset fails to link
some (most?) of the test programs and finaly bombs out during linking
of the static thread library.
>How-To-Repeat:
On Darwin or OS X;
cd meta-pkgs/boost && bmake install
>Fix:
Patch against devel/boost-build/toolset.mk to get it to use the Darwin
toolset on Darwin/OS X, not gcc:
------------------------------------

--- toolset.mk.orig	Wed May 25 14:21:02 2005
+++ toolset.mk	Wed May 25 14:22:20 2005
@@ -1,8 +1,11 @@
 # $NetBSD: toolset.mk,v 1.1 2005/02/26 22:48:35 jmmv Exp $
 
 .include "../../mk/compiler.mk"
+.include "../../mk/bsd.prefs.mk"
 
-.if !empty(PKGSRC_COMPILER:Mgcc)
+.if ${OPSYS} == "Darwin"
+BOOST_TOOLSET=		darwin
+.elif !empty(PKGSRC_COMPILER:Mgcc)
 BOOST_TOOLSET=		gcc
 .elif !empty(PKGSRC_COMPILER:Mmipspro*)
 BOOST_TOOLSET=		mipspro


Patch against meta-pkgs/boost/Makefile.common to define
BOOST_HAS_THREADS on Darwin/OS X as part of the configuration:
------------------------------------

--- Makefile.common.orig	Tue Jun 14 13:31:33 2005
+++ Makefile.common	Tue Jun 14 16:06:40 2005
@@ -33,6 +33,8 @@
 USE_LANGUAGES+=		c++
 GCC_REQD+=		3.2 # if using gcc; ignored otherwise
 
+.include "../../mk/bsd.prefs.mk"
+
 # We can't do this at post-extract because the extract cookie will get a
 # future timestamp than the sources.  If this happens, print-PLIST does
 # not work.
@@ -51,6 +53,22 @@
 do-configure:
 	@cd ${WRKSRC}/libs/config && \
 	    ${SETENV} ${CONFIGURE_ENV} ${SH} ./configure
+.  if ${OPSYS} == "Darwin"
+	@${ECHO} "" >> \
+		${WRKSRC}/libs/config/user.hpp
+	@${ECHO} "//" >> \
+		${WRKSRC}/libs/config/user.hpp
+	@${ECHO} "// options added by pkgsrc" >> \
+		${WRKSRC}/libs/config/user.hpp
+	@${ECHO} "//" >> \
+		${WRKSRC}/libs/config/user.hpp
+	@${ECHO} "#ifndef BOOST_HAS_THREADS" >> \
+		${WRKSRC}/libs/config/user.hpp
+	@${ECHO} "#  define BOOST_HAS_THREADS" >> \
+		${WRKSRC}/libs/config/user.hpp
+	@${ECHO} "#endif" >> \
+		${WRKSRC}/libs/config/user.hpp
+.  endif
 	${CP} -f ${WRKSRC}/libs/config/user.hpp ${WRKSRC}/boost/config/user.hpp
 .endif
 

New patch, meta-pkgs/boost/patch-ac, against devel/boost-libs, 
${WRKSRC}/tools/build/v1/darwin-tools.jam to correct the link
command used on Darwin/OS X:
------------------------------------

--- tools/build/v1/darwin-tools.jam.orig	Tue Jun 14 10:13:01 2005
+++ tools/build/v1/darwin-tools.jam	Tue Jun 14 10:12:10 2005
@@ -135,7 +135,7 @@
 else
 {
     flags darwin LINKFLAGS <target-type>$(SHARED_TYPES) :
-        -Wl,-dynamic -nostartfiles -Wl,-dylib -Wl,-ldylib1.o ;
+        -undefined suppress -flat_namespace -Wl,-dynamic -nostartfiles -Wl,-dylib -Wl,-ldylib1.o ;
 }
 
 flags darwin .LINKFLAGS <linkflags> ;