From f803c7fcd7aaea877d4ad68a1e459c191adb4769 Mon Sep 17 00:00:00 2001 From: pho Date: Tue, 3 Feb 2015 02:32:05 +0000 Subject: Fix build failure that occurs when pkgsrc devel/ncurses is being used * Formerly we were passing "--with-curses-includes=${BUILDLINK_PREFIX.curses}/include" to "${WRKSRC}/libraries/terminfo/configure". This is problematic because pkgsrc devel/ncurses installs headers into ${PREFIX}/include/ncurses, not ${PREFIX}/include, while ghc-cabal expects "ncurses.h" and "term.h" in ${PREFIX}/include (because we said so) and then it emits an error. The fix is to use ${BUILDLINK_INCDIRS.curses} instead of "include". Note that this requires my recent changes to ../../mk/curses.buildlink3.mk (r1.21) * The "bootstrap" target now uses buildlink wrapper not to pick up random libraries which happened to be in "${PREFIX}/lib". Bootstrap binary kits should be linked with a predictable set of libraries. * The "bootstrap" target now automatically runs through the wrapper phase. You no longer have to run "${MAKE} patch" manually. --- lang/ghc7/Makefile | 19 +++++----- lang/ghc7/TODO | 2 +- lang/ghc7/bootstrap.mk | 74 ++++++++++++++++++++++++-------------- lang/ghc7/files/bootstrap.build.mk | 4 --- 4 files changed, 58 insertions(+), 41 deletions(-) (limited to 'lang/ghc7') diff --git a/lang/ghc7/Makefile b/lang/ghc7/Makefile index 594591be3f2..ff0558a4caa 100644 --- a/lang/ghc7/Makefile +++ b/lang/ghc7/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.12 2014/08/03 08:14:38 obache Exp $ +# $NetBSD: Makefile,v 1.13 2015/02/03 02:32:05 pho Exp $ # ----------------------------------------------------------------------------- # Package metadata # @@ -60,10 +60,10 @@ USE_GNU_CONFIGURE_HOST= no CONFIGURE_ARGS+= \ --with-gcc=${CC:Q} \ - --with-gmp-includes=${BUILDLINK_PREFIX.gmp:Q}/include \ - --with-gmp-libraries=${BUILDLINK_PREFIX.gmp:Q}/lib \ - --with-iconv-includes=${BUILDLINK_PREFIX.iconv:Q}/include \ - --with-iconv-libraries=${BUILDLINK_PREFIX.iconv:Q}/lib + --with-gmp-includes=${BUILDLINK_PREFIX.gmp:Q}/${BUILDLINK_INCDIRS.gmp:Q} \ + --with-gmp-libraries=${BUILDLINK_PREFIX.gmp:Q}/${BUILDLINK_LIBDIRS.gmp:Q} \ + --with-iconv-includes=${BUILDLINK_PREFIX.iconv:Q}/${BUILDLINK_INCDIRS.iconv:Q} \ + --with-iconv-libraries=${BUILDLINK_PREFIX.iconv:Q}/${BUILDLINK_LIBDIRS.iconv:Q} CONFIGURE_ENV+= \ CONF_CC_OPTS_STAGE0=${CFLAGS:Q} \ @@ -107,8 +107,9 @@ post-configure: # in a non-standard path. Without that, the resulting GHC tries to # link programs by executing ld(1) without passing it -L${PREFIX:Q}/lib. ${RUN} ${ECHO} "libraries/terminfo_CONFIGURE_OPTS += \ - --configure-option=--with-curses-includes=${BUILDLINK_PREFIX.curses:Q}/include \ - --configure-option=--with-curses-libraries=${BUILDLINK_PREFIX.curses:Q}/lib" >> ${WRKSRC:Q}/mk/build.mk + --configure-option=--with-curses-includes=${BUILDLINK_PREFIX.curses:Q}/${BUILDLINK_INCDIRS.curses:Q} \ + --configure-option=--with-curses-libraries=${BUILDLINK_PREFIX.curses:Q}/${BUILDLINK_LIBDIRS.curses:Q}" \ + >> ${WRKSRC:Q}/mk/build.mk # The ghc compiler does normally split the generated asm files into small # parts before sending them to gcc, to enable the linker to eliminate @@ -120,8 +121,8 @@ post-configure: # Disable file splitting until pkgsrc gets improved. ${RUN} ${ECHO} "SplitObjs = NO" >> ${WRKSRC:Q}/mk/build.mk -# If there is HsColour is in the PATH, GHC's build system tries to use -# it without even checking if it really works. That's not what we +# If there is HsColour in the PATH, GHC's build system tries to use it +# without even checking if it really works. That's not what we # appreciate. ${RUN} ${ECHO} "HSCOLOUR_SRCS = NO" >> ${WRKSRC:Q}/mk/build.mk diff --git a/lang/ghc7/TODO b/lang/ghc7/TODO index 31d0f86838b..b0af4873ebe 100644 --- a/lang/ghc7/TODO +++ b/lang/ghc7/TODO @@ -26,5 +26,5 @@ bindists for your platform, you may need to cross-build a compiler yourself: `Cross-compiling GHC `_ -Assuming you have a working ghc in your PATH, just run ``bmake patch +Assuming you have a working ghc in your PATH, just run ``bmake clean && bmake bootstrap`` and see if you are lucky enough. diff --git a/lang/ghc7/bootstrap.mk b/lang/ghc7/bootstrap.mk index 8708e6a5b16..e1a8ce32349 100644 --- a/lang/ghc7/bootstrap.mk +++ b/lang/ghc7/bootstrap.mk @@ -1,4 +1,4 @@ -# $NetBSD: bootstrap.mk,v 1.11 2014/09/26 07:00:50 obache Exp $ +# $NetBSD: bootstrap.mk,v 1.12 2015/02/03 02:32:05 pho Exp $ # ----------------------------------------------------------------------------- # Select a bindist of bootstrapping compiler based on a per-platform # basis. @@ -48,7 +48,6 @@ BUILD_DEPENDS+= ncurses>=5.0:../../devel/ncurses BOOT_TARBALL= ${BOOT_ARCHIVE:C/\.xz$//} - # ----------------------------------------------------------------------------- # The "pre-configure" hook # @@ -81,24 +80,52 @@ pre-configure: # dependencies, otherwise the resulting binary can easily get # unusable. # -.PHONY: bootstrap -#BUILDLINK_PASSTHRU_DIRS= ${PREFIX}/lib/${PKGNAME_NOREV} +# Compiler wrappers must not remove -I/-L flags for this directory +# tree, otherwise the GHC we are going to use for building our +# bootstraping kit will not work at all. Ideally it should be added to +# BUILDLINK_PASSTHRU_DIRS only .if make(bootstrap), but then running +# "${MAKE} wrapper" before "${MAKE} bootstrap" will result in a +# cryptic error which we can't easily catch. +BOOTSTRAP_GHC_LIBDIR_CMD= ghc --print-libdir +.if !defined(BOOTSTRAP_GHC_LIBDIR) +BOOTSTRAP_GHC_LIBDIR!= ${BOOTSTRAP_GHC_LIBDIR_CMD} 2>/dev/null || ${ECHO} +.endif +MAKEVARS+= BOOTSTRAP_GHC_LIBDIR +BUILDLINK_PASSTHRU_DIRS+= ${BOOTSTRAP_GHC_LIBDIR} +# Default values for BUILDLINK_INCDIRS. are only generated in the +# barrier. See ../../mk/buildlink3/bsd.buildlink3.mk and +# ../../mk/bsd.pkg.barrier.mk +.PHONY: bootstrap +.if make(bootstrap) +_BARRIER_CMDLINE_TARGETS+= bootstrap +.endif +.if !defined(_PKGSRC_BARRIER) +bootstrap: barrier +.else bootstrap: pre-bootstrap .WAIT ${WRKDIR}/${BOOT_ARCHIVE} @${PHASE_MSG} "Done creating" ${WRKDIR}/${BOOT_ARCHIVE} - +.endif .PHONY: pre-bootstrap -pre-bootstrap: - @${TEST} \! -f ${_COOKIE.configure} || \ - (${ERROR_MSG} "You have already configured the package in a way\ +pre-bootstrap: wrapper +.if empty(BOOTSTRAP_GHC_LIBDIR) + @if ${BOOTSTRAP_GHC_LIBDIR_CMD} 2>/dev/null 1>&2; then \ + ${ERROR_MSG} "Running \"${BOOTSTRAP_GHC_LIBDIR_CMD}\" has failed during wrapper phase."; \ + ${FAIL_MSG} "Plase run \"${MAKE} clean\" and try again."; \ + else \ + ${ERROR_MSG} "Failed to run \"${BOOTSTRAP_GHC_LIBDIR_CMD}\":"; \ + ${BOOTSTRAP_GHC_LIBDIR_CMD}; \ + ${ERROR_MSG} "You don't seem to have a working GHC in your PATH."; \ + ${FAIL_MSG} "Please install one and then run \"${MAKE} clean bootstrap\"."; \ + fi +.endif + @if ${TEST} -f ${_COOKIE.configure}; then \ + ${ERROR_MSG} "You have already configured the package in a way\ that building bootstrapping compiler is impossible."; \ - ${FAIL_MSG} "Please run \"${MAKE} clean patch\" first."); - @${TEST} -f ${_COOKIE.patch} || \ - ${FAIL_MSG} "Please run \"${MAKE} patch\" first." - @${DO_NADA} - + ${FAIL_MSG} "Please run \"${MAKE} clean\" first."; \ + fi ${WRKDIR}/lndir: @${PHASE_MSG} "Building lndir(1) to duplicate the source tree." @@ -116,20 +143,13 @@ ${WRKDIR}/stamp-configure-boot: ${WRKDIR}/stamp-lndir-boot @${PHASE_MSG} "Configuring bootstrapping compiler ${PKGNAME_NOREV}" ${MKDIR} ${WRKDIR:Q}/build-boot cd ${WRKDIR:Q}/build-boot && \ - ${PKGSRC_SETENV} PATH=${PATH} \ - CONF_CC_OPTS_STAGE0=${CFLAGS:Q} \ - CONF_GCC_LINKER_OPTS_STAGE0="-L${PREFIX}/lib ${COMPILER_RPATH_FLAG}${PREFIX}/lib" \ - CONF_LD_LINKER_OPTS_STAGE0="-L${PREFIX}/lib ${LINKER_RPATH_FLAG}${PREFIX}/lib" \ - CONF_CC_OPTS_STAGE1=${CFLAGS:Q} \ - CONF_GCC_LINKER_OPTS_STAGE1="-L${PREFIX}/lib ${COMPILER_RPATH_FLAG}${PREFIX}/lib" \ - CONF_LD_LINKER_OPTS_STAGE1="-L${PREFIX}/lib ${LINKER_RPATH_FLAG}${PREFIX}/lib" \ - CONF_CC_OPTS_STAGE2=${CFLAGS:Q} \ - CONF_GCC_LINKER_OPTS_STAGE2="-L${PREFIX}/lib ${COMPILER_RPATH_FLAG}${PREFIX}/lib" \ - CONF_LD_LINKER_OPTS_STAGE2="-L${PREFIX}/lib ${LINKER_RPATH_FLAG}${PREFIX}/lib" \ - ${SH} ./configure && \ - ${SED} -e "s,@CURSES_INCDIR@,${BUILDLINK_PREFIX.curses:Q}/${BUILDLINK_INCDIRS.ncurses:Uinclude},g" \ - -e "s,@CURSES_LIBDIR@,${BUILDLINK_PREFIX.curses:Q}/lib,g" \ - ${FILESDIR:Q}/bootstrap.build.mk > mk/build.mk + ${PKGSRC_SETENV} ${CONFIGURE_ENV} ${SH} ./configure ${CONFIGURE_ARGS} && \ + ${CP} -f ${FILESDIR:Q}/bootstrap.build.mk mk/build.mk && \ + ${ECHO} >> mk/build.mk && \ + ${ECHO} "libraries/terminfo_CONFIGURE_OPTS += \ + --configure-option=--with-curses-includes=${BUILDLINK_PREFIX.curses:Q}/${BUILDLINK_INCDIRS.curses:Q} \ + --configure-option=--with-curses-libraries=${BUILDLINK_PREFIX.curses:Q}/${BUILDLINK_LIBDIRS.curses:Q}" \ + >> mk/build.mk ${TOUCH} ${.TARGET} ${WRKDIR}/stamp-build-boot: ${WRKDIR}/stamp-configure-boot diff --git a/lang/ghc7/files/bootstrap.build.mk b/lang/ghc7/files/bootstrap.build.mk index ef8e1c3735d..0155930344b 100644 --- a/lang/ghc7/files/bootstrap.build.mk +++ b/lang/ghc7/files/bootstrap.build.mk @@ -29,7 +29,3 @@ INTEGER_LIBRARY = integer-simple # We'd like to distinguish bootstrapping bindists from normal ones. BIN_DIST_NAME = ghc-$(ProjectVersion)-boot - -libraries/terminfo_CONFIGURE_OPTS += \ - --configure-option=--with-curses-includes=@CURSES_INCDIR@ \ - --configure-option=--with-curses-libraries=@CURSES_LIBDIR@ -- cgit v1.2.3