I tried to get boost to build with clang, but failed pretty miserably
because I don't know what I'm doing.
If anybody wants to look into this, here's what I got:
* Configure with --with-toolset=clang
* Fix boost_has_nl_types_h.ipp, from upstream.
* Some haphazard changes to clang-linux.jam, patterned after those
to gcc.jam. Likely incomplete.
I got stumped at the first non-trivial problem:
./boost/type_traits/is_convertible.hpp:86:63: error: too many arguments
provided to function-like macro invocation
static decltype(test_aux<To1>(boost::declval<From1>()), one()) test(int);
^
/usr/include/c++/v1/__config:673:11: note: macro 'decltype' defined here
# define decltype(__x) __decltype(__x)
^
As far as I can google, decltype(a, b) is valid, but it fails due
to our macro. FreeBSD somehow doesn't run into this, but I don't
know why.
Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/boost/Makefile,v
retrieving revision 1.61
diff -u -p -r1.61 Makefile
--- Makefile 10 Apr 2017 11:45:25 -0000 1.61
+++ Makefile 18 Apr 2017 18:11:22 -0000
@@ -1,6 +1,8 @@
# $OpenBSD: Makefile,v 1.61 2017/04/10 11:45:25 sthen Exp $
-ONLY_FOR_ARCHS= ${GCC4_ARCHS}
+ONLY_FOR_ARCHS= ${CLANG_ARCHS} ${GCC4_ARCHS}
+
+DPB_PROPERTIES= parallel
COMMENT= free peer-reviewed portable C++ source libraries
@@ -84,7 +86,7 @@ BOOTSTRAP= --with-bjam=${WRKSRC}/bjam \
--with-python=${MODPY_BIN} \
--with-python-root=${LOCALBASE} \
--with-python-version=${MODPY_VERSION} \
- --with-toolset=gcc \
+ --with-toolset=${TOOLSET} \
--without-icu \
--without-libraries=context,coroutine
@@ -93,8 +95,6 @@ CONFIGURE_STYLE= none
CONFIGURE_ENV= BJAM_CONFIG="${BJAM_CONFIG}" \
CXX="${CXX}" CXXFLAGS="${CXXFLAGS}"
-DPB_PROPERTIES= parallel
-
NO_TEST= Yes
SUBST_VARS+= SO_VERSION
@@ -124,5 +124,14 @@ do-install:
find boost -type d -exec ${INSTALL_DATA_DIR} ${PREFIX}/include/{} \;
@cd ${WRKSRC} && \
find boost ! -name \*.orig -type f -exec ${INSTALL_DATA} {}
${PREFIX}/include/{} \;
+
+.include <bsd.port.arch.mk>
+
+# assumes that CC/CXX is not overridden with a different compiler
+.if ${PROPERTIES:Mclang}
+TOOLSET= clang
+.elif ${PROPERTIES:Mgcc4}
+TOOLSET= gcc
+.endif
.include <bsd.port.mk>
Index: patches/patch-libs_config_test_boost_has_nl_types_h_ipp
===================================================================
RCS file: patches/patch-libs_config_test_boost_has_nl_types_h_ipp
diff -N patches/patch-libs_config_test_boost_has_nl_types_h_ipp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-libs_config_test_boost_has_nl_types_h_ipp 18 Apr 2017
18:11:22 -0000
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- libs/config/test/boost_has_nl_types_h.ipp.orig Tue Mar 24 19:27:48 2015
++++ libs/config/test/boost_has_nl_types_h.ipp Tue Apr 18 16:02:33 2017
+@@ -17,7 +17,7 @@ namespace boost_has_nl_types_h{
+ int test()
+ {
+ nl_catd cat = catopen("foo", 0);
+- if(cat >= 0) catclose(cat);
++ if(cat != (nl_catd)-1) catclose(cat);
+ return 0;
+ }
+
Index: patches/patch-tools_build_src_tools_clang-linux_jam
===================================================================
RCS file: patches/patch-tools_build_src_tools_clang-linux_jam
diff -N patches/patch-tools_build_src_tools_clang-linux_jam
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-tools_build_src_tools_clang-linux_jam 18 Apr 2017 18:11:22
-0000
@@ -0,0 +1,31 @@
+$OpenBSD$
+--- tools/build/src/tools/clang-linux.jam.orig Sat Apr 4 19:25:07 2015
++++ tools/build/src/tools/clang-linux.jam Tue Apr 18 16:29:59 2017
+@@ -70,7 +70,7 @@ toolset.flags clang-linux.compile OPTIONS <cflags> ;
+ toolset.flags clang-linux.compile.c++ OPTIONS <cxxflags> ;
+
+ toolset.flags clang-linux.compile OPTIONS <optimization>off : ;
+-toolset.flags clang-linux.compile OPTIONS <optimization>speed : -O3 ;
++toolset.flags clang-linux.compile OPTIONS <optimization>speed : ;
+ toolset.flags clang-linux.compile OPTIONS <optimization>space : -Os ;
+
+ # note: clang silently ignores some of these inlining options
+@@ -180,6 +180,7 @@ rule link ( targets * : sources * : properties * ) {
+ }
+
+ actions link bind LIBRARIES {
++ echo "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)"
-Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" $(START-GROUP) "$(>)"
"$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX)
-l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
+ "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)"
-Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" $(START-GROUP) "$(>)"
"$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX)
-l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
+ }
+
+@@ -207,8 +208,8 @@ rule setup-threading ( targets * : sources * : propert
+ }
+ }
+
+-# Differ from 'link' above only by -shared.
++# Differ from 'link' above only by -shared and -fPIC.
+ actions link.dll bind LIBRARIES {
+- "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o
"$(<)" -Wl,-soname$(SPACE)-Wl,$(<[1]:D=) -shared $(START-GROUP) "$(>)"
"$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX)
-l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
++ "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o
"$(<)" -Wl,-soname$(SPACE)-Wl,$(<[1]:D=) -shared -fPIC $(START-GROUP) "$(>)"
"$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX)
-l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
+ }
+
--
Christian "naddy" Weisgerber [email protected]