gcc49-libs: Make this function correctly on Darwin. trunk
authorjperkin <jperkin@pkgsrc.org>
Wed, 11 Jul 2018 11:21:26 +0000
branchtrunk
changeset 310317 391e9583c24b
parent 310316 ba519a58c355
child 310318 aa2509ad0a81
gcc49-libs: Make this function correctly on Darwin. Firstly we need to modify the copied libraries so that their install_name matches the new location, otherwise check-shlibs thinks that they still come from the main gcc49 package. Secondly we need to avoid the stub libgcc_ext libraries that are used by default as we are unable to modify their install_name, just link directly to libgcc. Bump PKGREVISION.
lang/gcc49-libs/Makefile
lang/gcc49-libs/buildlink3.mk
--- a/lang/gcc49-libs/Makefile	Wed Jul 11 11:11:52 2018 +0000
+++ b/lang/gcc49-libs/Makefile	Wed Jul 11 11:21:26 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.15 2018/04/08 06:06:13 wiz Exp $
+# $NetBSD: Makefile,v 1.16 2018/07/11 11:21:26 jperkin Exp $
 
 GCC_PKGNAME=	gcc49
 .include	"../../lang/${GCC_PKGNAME}/version.mk"
@@ -9,7 +9,7 @@
 ## The PKGREVISION of this package needs to be at least 1 more than the
 ## PKGREVISION of the lang/gcc49 package so that with the dependence pattern
 ## '{gcc49,gcc49-libs}>=4.9.*' pkg_add will choose gcc49-libs over gcc49.
-PKGREVISION=	7
+PKGREVISION=	8
 
 CATEGORIES=	lang
 MASTER_SITES=	# empty
@@ -60,6 +60,12 @@
 		${MKDIR} ${DESTDIR}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE}/lib
 	cd ${LIBGCC_PREFIX} && 						\
 	  ${PAX} -rw ${DESTDIR}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE} <${LIBRARY_FILES}
+.if ${OPSYS} == "Darwin"
+	while read lib; do \
+	  install_name_tool -id ${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE}/$${lib} \
+	    ${DESTDIR}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE}/$${lib}; \
+	done <${LIBRARY_FILES}
+.endif
 
 .include "../../mk/dlopen.buildlink3.mk"
 .include "../../mk/pthread.buildlink3.mk"
--- a/lang/gcc49-libs/buildlink3.mk	Wed Jul 11 11:11:52 2018 +0000
+++ b/lang/gcc49-libs/buildlink3.mk	Wed Jul 11 11:21:26 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: buildlink3.mk,v 1.3 2018/01/01 18:16:37 rillig Exp $
+# $NetBSD: buildlink3.mk,v 1.4 2018/07/11 11:21:26 jperkin Exp $
 
 BUILDLINK_TREE+=	gcc49-libs
 
@@ -27,9 +27,17 @@
 LIBGCC_PREFIX=		${BUILDLINK_PREFIX.gcc49-libs}/${LIBGCC_SUBPREFIX}
 GCC_TARGET_MACHINE?=	${MACHINE_GNU_PLATFORM}
 
+# On Darwin we need to modify the libgcc linkage, by default it will try to
+# use stub libraries which we cannot change the library name for, leading to
+# check-shlibs failures as it thinks they come from the main gcc49 package.
 ${SPECS_LIBGCC}:
 	@${ECHO} "*link_libgcc:" >${SPECS_LIBGCC}
 	@${ECHO} "%D ${LINKER_RPATH_FLAG}${LIBGCC_PREFIX}/${GCC_TARGET_MACHINE}/lib/%M" >>${SPECS_LIBGCC}
+.  if ${OPSYS} == "Darwin"
+	@${ECHO} "" >>${SPECS_LIBGCC}
+	@${ECHO} "*libgcc:" >>${SPECS_LIBGCC}
+	@${ECHO} "%{static-libgcc|static: -lgcc_eh -lgcc; shared-libgcc|fexceptions|fgnu-runtime: -lgcc; : -lgcc }" >>${SPECS_LIBGCC}
+.  endif
 
 _WRAP_EXTRA_ARGS.CC+=	-specs=${SPECS_LIBGCC}
 _WRAP_EXTRA_ARGS.CXX+=	-specs=${SPECS_LIBGCC}