pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/lang/ghc90



Module Name:    pkgsrc
Committed By:   pho
Date:           Sun Feb  6 05:31:58 UTC 2022

Modified Files:
        pkgsrc/lang/ghc90: Makefile bootstrap.mk buildlink3.mk options.mk

Log Message:
When the LLVM backend is enabled, use clang as the assembler

This turned out to be necessary because LLVM 13 emits assembly code that is
incompatible with "as" from Binutils < 2.36.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 pkgsrc/lang/ghc90/Makefile
cvs rdiff -u -r1.11 -r1.12 pkgsrc/lang/ghc90/bootstrap.mk
cvs rdiff -u -r1.5 -r1.6 pkgsrc/lang/ghc90/buildlink3.mk
cvs rdiff -u -r1.4 -r1.5 pkgsrc/lang/ghc90/options.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/lang/ghc90/Makefile
diff -u pkgsrc/lang/ghc90/Makefile:1.17 pkgsrc/lang/ghc90/Makefile:1.18
--- pkgsrc/lang/ghc90/Makefile:1.17     Tue Jan 18 02:22:49 2022
+++ pkgsrc/lang/ghc90/Makefile  Sun Feb  6 05:31:57 2022
@@ -1,8 +1,9 @@
-# $NetBSD: Makefile,v 1.17 2022/01/18 02:22:49 pho Exp $
+# $NetBSD: Makefile,v 1.18 2022/02/06 05:31:57 pho Exp $
 # -----------------------------------------------------------------------------
 # Package metadata
 #
 DISTNAME=      ghc-9.0.2-src
+PKGREVISION=   1
 PKGNAME=       ${DISTNAME:S/-src$//}
 CATEGORIES=    lang
 MASTER_SITES=  https://downloads.haskell.org/~ghc/${PKGVERSION_NOREV}/
@@ -26,6 +27,10 @@ BROKEN_EXCEPT_ON_PLATFORM+=  NetBSD-*-aar
 BROKEN_EXCEPT_ON_PLATFORM+=    NetBSD-*-x86_64
 BROKEN_EXCEPT_ON_PLATFORM+=    SunOS-*-x86_64
 
+# We are going to do a PIE build on our responsibility. Do not put -pie in
+# wrappers, as that would prevent us from building stage-1 compiler.
+PKGSRC_OVERRIDE_MKPIE= yes
+
 .include "options.mk"
 
 
@@ -51,13 +56,12 @@ USE_LIBTOOL=                        yes
 # -----------------------------------------------------------------------------
 # Configuration
 #
-CONFIGURE_ARGS.common= \
+CONFIGURE_ARGS.common+= \
        --with-curses-libraries=${BUILDLINK_PREFIX.curses}/${BUILDLINK_LIBDIRS.curses:Q} \
        --with-gmp-includes=${BUILDLINK_PREFIX.gmp}/${BUILDLINK_INCDIRS.gmp:Q} \
        --with-gmp-libraries=${BUILDLINK_PREFIX.gmp}/${BUILDLINK_LIBDIRS.gmp:Q} \
        --with-iconv-includes=${BUILDLINK_PREFIX.iconv}/${BUILDLINK_INCDIRS.iconv:Q} \
        --with-iconv-libraries=${BUILDLINK_PREFIX.iconv}/${BUILDLINK_LIBDIRS.iconv:Q} \
-       --with-system-libffi \
        --with-ffi-includes=${BUILDLINK_PREFIX.libffi}/${BUILDLINK_INCDIRS.libffi:Q} \
        --with-ffi-libraries=${BUILDLINK_PREFIX.libffi}/${BUILDLINK_LIBDIRS.libffi:Q}
 
@@ -73,25 +77,23 @@ CONFIGURE_ARGS.common+=     --enable-libffi-
 # See rts/adjustor/NativeAmd64.c and rts/adjustor/LibffiAdjustor.c
 .endif
 
-CONFIGURE_ARGS+=       ${CONFIGURE_ARGS.common}
-
 # We must pass non-wrapper tools to ./configure because they will be
 # embedded in the compiler (actually ${WRKSRC}/settings).
-CONFIGURE_ENV+= \
-       ac_cv_prog_fp_prog_ar=${AR:Q} \
-       ac_cv_prog_LIBTOOL=libtool \
-       CC=${CC:Q} \
-       LD=${LD:Q}
-
-# LDFLAGS is currently not honored by "./configure". Since LDFLAGS
-# contains rpath flags it's very important to force GHC to honor
-# it. Otherwise neither GHC itself nor executables it produces will
-# have any rpaths so users will have to put "${PREFIX}/lib" into their
+CONFIGURE_ENV+=                ac_cv_prog_fp_prog_ar=${AR:Q}
+CONFIGURE_ENV+=                ac_cv_prog_LIBTOOL=libtool
+CONFIGURE_ARGS.common+=        LD=${LD:Q}
+
+CONFIGURE_ARGS+=       ${CONFIGURE_ARGS.common}
+CONFIGURE_ARGS+=       --with-system-libffi
+
+# CFLAGS and LDFLAGS are currently not honored by "./configure". Since
+# LDFLAGS contains rpath flags it's very important to force GHC to honor
+# it. Otherwise neither GHC itself nor executables it produces will have
+# any rpaths so users will have to put "${PREFIX}/lib" into their
 # "/etc/ld-elf.so.conf". See
 # http://hackage.haskell.org/trac/ghc/ticket/2933
 .for stage in 0 1 2
-CONFIGURE_ENV+= \
-       CONF_GCC_LINKER_OPTS_STAGE${stage}=${LDFLAGS:M*:Q}
+CONFIGURE_ENV+=        CONF_GCC_LINKER_OPTS_STAGE${stage}=${LDFLAGS:M*:Q}
 # Note that CONF_LD_LINKER_OPTS_STAGE{0,1,2} are only used for
 # creating static GHCi libraries (HS*.o). Setting them to ${LDFLAGS}
 # does more harm than good because our ${LDFLAGS} contains -Wl,*
@@ -101,25 +103,37 @@ CONFIGURE_ENV+= \
 # the buildlink.
 .endfor
 
+# The use of internal variable in mk/bsd.prefs.mk is not very satisfying,
+# but the current infrastructure does not export a public variable
+# indicating whether a PIE build is requested or not. Note that we can't
+# build stage-1 compiler as PIE, because our bootkit libraries aren't
+# necessarily built as PIC.
+.for stage in 0 1 2
+.  if ${stage} == 0
+CONFIGURE_ENV+=        CONF_CC_OPTS_STAGE${stage}=${CFLAGS:M*:Q}
+.  else
+CONFIGURE_ENV+=        CONF_HC_OPTS_STAGE${stage}=-fPIC\ -pie
+CONFIGURE_ENV+=        CONF_CC_OPTS_STAGE${stage}=${CFLAGS:M*:Q}\ -fPIC
+.  endif
+.endfor
+
 
 # -----------------------------------------------------------------------------
 # Security
 #
-# The runtime system of GHC (rts) has a functionality called "RTS
-# linker" whose job is to load and execute *static* objects (.a and .o
-# files) at run time. It cannot survive PaX MPROTECT because
-# preloadObjectFile() in rts/linker.c tries to mmap pages with w+x. It
-# doesn't play nice with ASLR either because mmapForLinker() in
-# rts/linker.c wants to mmap pages in the lower 32-bit area on 64-bit
-# platforms.
-#
-# Luckily for us, the RTS linker is only used when the GHC executable
-# (or any user programs which uses GHC API as an interpreter, not a
-# compiler) is statically linked, which is no longer the case except
-# for ghc-iserv and ghc-iesrv-prof. They are launched when ghci is
-# started with -fexternal-interpreter without -dynamic, and their
-# purpose is to run non-PIC code from a dynamically linked ghci using
-# the evil RTS linker.
+# The runtime system of GHC (rts) has a functionality called "RTS linker"
+# whose job is to load and execute *static* objects (.a and .o files) at
+# run time. It cannot survive PaX MPROTECT because preloadObjectFile() in
+# rts/linker.c tries to mmap pages with w+x. It doesn't play nice with ASLR
+# either because mmapForLinker() in rts/linker.c wants to always mmap pages
+# in the lower 32-bit area on 64-bit platforms.
+#
+# Luckily for us, the RTS linker is only used when the GHC executable (or
+# any user programs which uses GHC API as an interpreter, not a compiler)
+# is statically linked, which is no longer the case except for ghc-iserv
+# and ghc-iesrv-prof. They are launched when ghci is started with
+# -fexternal-interpreter without -dynamic, and their purpose is to run
+# non-PIC code from a dynamically linked ghci using the evil RTS linker.
 .for f in ghc-iserv ghc-iserv-prof
 NOT_PAX_MPROTECT_SAFE+=        lib/${PKGNAME_NOREV}/bin/${f}
 NOT_PAX_ASLR_SAFE+=    lib/${PKGNAME_NOREV}/bin/${f}
@@ -168,18 +182,6 @@ post-configure:
        ${RUN} ${ECHO} "SplitSections  = YES" >> ${WRKSRC}/mk/build.mk
 .endif
 
-# The use of internal variable in mk/bsd.prefs.mk is not very satisfying, but
-# the current infrastructure does not export a public variable indicating
-# whether a PIE build is requested or not. Note that we can't build stage-1
-# compiler as PIE, because our bootkit libraries aren't built as PIC.
-.if ${_PKGSRC_MKPIE} == "yes"
-       ${RUN} ${ECHO} "SRC_HC_OPTS_STAGE1 += -fPIC -pie" >> ${WRKSRC}/mk/build.mk
-       ${RUN} ${ECHO} "SRC_HC_OPTS_STAGE2 += -fPIC -pie" >> ${WRKSRC}/mk/build.mk
-.endif
-
-# We are going to do a PIE build on our responsibility. Do not put -pie in
-# wrappers, as that would prevent us from building stage-1 compiler.
-PKGSRC_OVERRIDE_MKPIE= yes
 
 # -----------------------------------------------------------------------------
 # Installation/removal hooks

Index: pkgsrc/lang/ghc90/bootstrap.mk
diff -u pkgsrc/lang/ghc90/bootstrap.mk:1.11 pkgsrc/lang/ghc90/bootstrap.mk:1.12
--- pkgsrc/lang/ghc90/bootstrap.mk:1.11 Thu Sep 30 15:32:53 2021
+++ pkgsrc/lang/ghc90/bootstrap.mk      Sun Feb  6 05:31:57 2022
@@ -1,4 +1,4 @@
-# $NetBSD: bootstrap.mk,v 1.11 2021/09/30 15:32:53 jperkin Exp $
+# $NetBSD: bootstrap.mk,v 1.12 2022/02/06 05:31:57 pho Exp $
 # -----------------------------------------------------------------------------
 # Select a bindist of bootstrapping compiler on a per-platform basis.
 #
@@ -114,7 +114,7 @@ pre-configure:
        @${PHASE_MSG} "Preparing bootstrapping compiler for ${PKGNAME}"
        ${RUN}cd ${WRKDIR}/bootkit-dist/ghc-${BOOT_VERSION}-boot && \
                ${PKGSRC_SETENV} ${CONFIGURE_ENV} ${SH} ./configure \
-                       --prefix=${TOOLS_DIR:Q} && \
+                       --prefix=${TOOLS_DIR:Q} ${CONFIGURE_ARGS.boot} && \
                ${PKGSRC_SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} install
 
 

Index: pkgsrc/lang/ghc90/buildlink3.mk
diff -u pkgsrc/lang/ghc90/buildlink3.mk:1.5 pkgsrc/lang/ghc90/buildlink3.mk:1.6
--- pkgsrc/lang/ghc90/buildlink3.mk:1.5 Tue Jan 18 02:22:49 2022
+++ pkgsrc/lang/ghc90/buildlink3.mk     Sun Feb  6 05:31:57 2022
@@ -1,4 +1,4 @@
-# $NetBSD: buildlink3.mk,v 1.5 2022/01/18 02:22:49 pho Exp $
+# $NetBSD: buildlink3.mk,v 1.6 2022/02/06 05:31:57 pho Exp $
 
 BUILDLINK_TREE+=       ghc
 
@@ -6,7 +6,7 @@ BUILDLINK_TREE+=        ghc
 GHC_BUILDLINK3_MK:=
 
 BUILDLINK_API_DEPENDS.ghc+=    ghc>=9.0
-BUILDLINK_ABI_DEPENDS.ghc+=    ghc>=9.0.2
+BUILDLINK_ABI_DEPENDS.ghc+=    ghc>=9.0.2nb1
 BUILDLINK_PKGSRCDIR.ghc?=      ../../lang/ghc90
 
 .include "../../converters/libiconv/buildlink3.mk"

Index: pkgsrc/lang/ghc90/options.mk
diff -u pkgsrc/lang/ghc90/options.mk:1.4 pkgsrc/lang/ghc90/options.mk:1.5
--- pkgsrc/lang/ghc90/options.mk:1.4    Tue Jan 18 02:22:49 2022
+++ pkgsrc/lang/ghc90/options.mk        Sun Feb  6 05:31:57 2022
@@ -1,17 +1,31 @@
-# $NetBSD: options.mk,v 1.4 2022/01/18 02:22:49 pho Exp $
+# $NetBSD: options.mk,v 1.5 2022/02/06 05:31:57 pho Exp $
 
 PKG_OPTIONS_VAR=       PKG_OPTIONS.ghc
 
 .include "../../mk/bsd.prefs.mk"
 
-# GHC has a native implementation of codegen for some platforms. On
-# those platforms LLVM is optional. It's a requirement anywhere else.
-# See compiler/GHC/Driver/Backend.hs
+# GHC has a native implementation of codegen for some platforms. On those
+# platforms LLVM is optional. It's a requirement anywhere else.  See
+# compiler/GHC/Driver/Backend.hs
+#
+# The LLVM backend tends to produce slightly faster code than what NCG
+# produces, but it is much slower than NCG. It is therefore not the default
+# backend on platforms where NCG is available. On platforms where NCG is
+# available, LLVM should be disabled by default because it's a huge
+# dependency that takes hours to compile.
+#
+# Note that bootkits also require LLVM/Clang on platforms lacking NCG. This
+# can cause a transitional problem when a new compiler arrives with NCG for
+# a platform which used to lack one. In this case we have to either (1)
+# build a new bootkit for the platform with LLVM backend disabled, or (2)
+# reuse the old bootkit by putting llvm/clang in BUILD_DEPENDS (regardless
+# of user choice) and arrange parameters so that they are used only by the
+# stage-0 compiler. We don't have an infrastructure for (2), as it's not
+# worth the additional complexity, so (1) is the only option atm.
 
 GHC_NCG_SUPPORTED=     i386 x86_64 powerpc powerpc64 sparc
 .if !empty(GHC_NCG_SUPPORTED:M${MACHINE_ARCH})
 PKG_SUPPORTED_OPTIONS+=        llvm
-PKG_SUGGESTED_OPTIONS+=        llvm
 GHC_LLVM_REQUIRED=     no
 .else
 GHC_LLVM_REQUIRED=     yes
@@ -22,30 +36,30 @@ GHC_LLVM_REQUIRED=  yes
 .endif
 
 .if !empty(PKG_OPTIONS:Mllvm) || ${GHC_LLVM_REQUIRED} == "yes"
-DEPENDS+=      llvm-[0-9]*:../../lang/llvm
-CONFIGURE_ENV+=        LLC=${PREFIX:Q}/bin/llc
-CONFIGURE_ENV+=        OPT=${PREFIX:Q}/bin/opt
+DEPENDS+=              llvm-[0-9]*:../../lang/llvm
+CONFIGURE_ARGS.common+=        LLC=${PREFIX:Q}/bin/llc
+CONFIGURE_ARGS.common+=        OPT=${PREFIX:Q}/bin/opt
+
+# When we use the LLVM backend, we *have* to use Clang's integrated
+# assembler because llc emits assembly source files incompatible with
+# Binutils < 2.36 (see https://reviews.llvm.org/D97448). It also requires
+# Clang on Darwin (see runClang in compiler/GHC/SysTools/Tasks.hs).
+DEPENDS+=              clang-[0-9]*:../../lang/clang
+CONFIGURE_ARGS.common+=        CLANG=${PREFIX:Q}/bin/clang
+CONFIGURE_ARGS.common+=        CC=${PREFIX:Q}/bin/clang
 
 # Maybe GHC doesn't like this but it's the only option available to us.
 LLVM_VERSION_CMD=      ${PKG_INFO} -E llvm | ${SED} -E 's/^llvm-([0-9]*)\..*/\1/'
 LLVM_MAX_VERSION_CMD=  ${EXPR} ${LLVM_VERSION_CMD:sh} + 1
 SUBST_CLASSES+=                llvm
 SUBST_STAGE.llvm=      post-extract
-SUBST_MESSAGE.llvm=    Accept whichever version of LLVM installed via pkgsrc
+SUBST_MESSAGE.llvm=    Modifying configure.ac to accept whichever version of LLVM installed via pkgsrc
 SUBST_FILES.llvm=      configure.ac
 SUBST_SED.llvm=                -e 's/LlvmMaxVersion=[0-9]*/LlvmMaxVersion=${LLVM_MAX_VERSION_CMD:sh}/'
 
-# Clang is also required on Darwin.
-# See compiler/GHC/SysTools/Tasks.hs (runClang).
-.  if ${OPSYS} == "Darwin"
-DEPENDS+=      clang-[0-9]*:../../lang/clang
-CONFIGURE_ENV+=        CLANG=${PREFIX:Q}/bin/clang
-.  else
-CONFIGURE_ENV+=        CLANG=${FALSE}
-.  endif
-
 .else
-CONFIGURE_ENV+=        LLC=${FALSE:Q}
-CONFIGURE_ENV+=        OPT=${FALSE:Q}
-CONFIGURE_ENV+=        CLANG=${FALSE:Q}
+CONFIGURE_ARGS.common+=        LLC=${FALSE:Q}
+CONFIGURE_ARGS.common+=        OPT=${FALSE:Q}
+CONFIGURE_ARGS.common+=        CLANG=${FALSE:Q}
+CONFIGURE_ARGS.common+=        CC=${CC:Q}
 .endif



Home | Main Index | Thread Index | Old Index