Friday, May 29, 2020

lang/ghc: more cleanups

Hi,

this is mainly for getting rid of overriding things via CONFIGURE_ENV
and CFLAGS in favor of patching aclocal.m4 and configure.ac (and
running autoconf), which may help getting this merged upstream.

It also kills some left-over -fno-pie which came from
patches/patch-configure.

I decided to drop the clang-specific

-Wno-unused-command-line-argument -Wno-expansion-to-defined

for now, because the warnings, although a little bit annoying, are
harmless, and because this should be fixed elsewhere -- it's not
specific to OpenBSD.

Tested on amd64 *and* i386 this time, by building all the hs ports
and also by giving ghci a quick try.

Does this make sense?

Ciao,
Kili

Index: Makefile
===================================================================
RCS file: /cvs/ports/lang/ghc/Makefile,v
retrieving revision 1.173
diff -u -p -r1.173 Makefile
--- Makefile 17 May 2020 18:06:07 -0000 1.173
+++ Makefile 29 May 2020 21:40:37 -0000
@@ -12,7 +12,7 @@ COMMENT = compiler for the functional l
NO_CCACHE = Yes

DISTNAME = ghc-${MODGHC_VER}
-REVISION = 3
+REVISION = 4
CATEGORIES = lang devel
HOMEPAGE = https://www.haskell.org/ghc/

@@ -43,7 +43,7 @@ BUILD_DEPENDS = archivers/bzip2 \
textproc/py-sphinx${MODPY_FLAVOR}
RUN_DEPENDS =

-# GHC build uses -Wl,-z,wxneeded on OpenBSD for amd64.
+# GHC build uses -Wl,-z,wxneeded on OpenBSD.
# XXX: wxneeded is a hack. Fix rts/Linker.c, mmapForLinker() and
# loadObj_() instead.
USE_WXNEEDED = special
@@ -106,14 +106,8 @@ SUBST_VARS += ${_i}_VER
USE_GMAKE = Yes
USE_GROFF = Yes

-.if ${MACHINE_ARCH} == "i386"
-CFLAGS += -Wl,-znotext
-# On i386, we still have to explicitely set -Wl,-z,wxneeded (in
-# addition to -Wl,-znotext).
-GHC_CC_OPTS = -Wl,-znotext -Wl,-z,wxneeded
-.endif
-
-CONFIGURE_STYLE = gnu
+AUTOCONF_VERSION = 2.69
+CONFIGURE_STYLE = gnu autoconf no-autoheader
CONFIGURE_ARGS += --with-ffi-includes=${LOCALBASE}/include \
--with-ffi-libraries=${LOCALBASE}/lib \
--with-gmp-includes=${LOCALBASE}/include \
@@ -127,13 +121,6 @@ CONFIGURE_ARGS += --with-ffi-includes=${
# with /usr/bin/ld.lld: error: cannot preempt symbol: memcpy
CONFIGURE_ARGS += --disable-ld-override

-CONFIGURE_ENV += CONF_CC_OPTS_STAGE0="${GHC_CC_OPTS}" \
- CONF_CC_OPTS_STAGE1="${GHC_CC_OPTS}" \
- CONF_CC_OPTS_STAGE2="${GHC_CC_OPTS}" \
- CONF_GCC_LINKER_OPTS_STAGE0="${GHC_CC_OPTS}" \
- CONF_GCC_LINKER_OPTS_STAGE1="${GHC_CC_OPTS}" \
- CONF_GCC_LINKER_OPTS_STAGE2="${GHC_CC_OPTS}"
-
CONFIGURE_ENV += SPHINXBUILD=${LOCALBASE}/bin/sphinx-build${MODPY_BIN_SUFFIX}

# Do not pick up gpatch
@@ -170,6 +157,11 @@ post-patch:
LD_LIBRARY_PATH=${BOOTSTRAP_SHLIBS} \
${MAKE_PROGRAM} install
rm -rf ${WRKDIR}/ghc-${BIN_VER}
+ # HACK for i386 until we have new bootstrappers. This is needed
+ # to let the bootstrapper use -Wl,-znotext building things like
+ # utils/hsc2hs.
+ sed -ie '/"C compiler flags"/s/-U__i686/-Wl,-znotext &/' \
+ ${WRKDIR}/bootstrap/lib/ghc/settings
# - Create some wrapper scripts setting LD_LIBRARY_PATH
cd ${WRKDIR}/bin && \
for f in $$(ls ../bootstrap/bin); do \
@@ -248,12 +240,3 @@ _bootstrap_finish:
pax -wzf ghc-${MODGHC_VER}.${BOOTSTRAP_DATE}-shlibs-$$(arch -s){.tar.gz,}

.include <bsd.port.mk>
-
-# Silence clang when used by ghc to process assembler files and gets
-# flags chat don't make sense for assembly mode. Also, silence warnings
-# about macro expansions producing 'defined' (occuring in
-# includes/rts/storage/ClosureMacros.h, which has already been fixed
-# upstream)
-.if ${PROPERTIES:Mclang}
-GHC_CC_OPTS += -Wno-unused-command-line-argument -Wno-expansion-to-defined
-.endif
Index: patches/patch-aclocal_m4
===================================================================
RCS file: patches/patch-aclocal_m4
diff -N patches/patch-aclocal_m4
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-aclocal_m4 29 May 2020 21:40:37 -0000
@@ -0,0 +1,19 @@
+$OpenBSD$
+
+Index: aclocal.m4
+--- aclocal.m4.orig
++++ aclocal.m4
+@@ -691,6 +691,13 @@ AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
+ $4="$$4 -z wxneeded"
+ ;;
+
++ i386-*-openbsd*)
++ # On i386, we also need -z notext in addition to -z wxneeded.
++ $2="$$2 -Wl,-z,notext"
++ $3="$$3 -Wl,-z,wxneeded -Wl,-z,notext"
++ $4="$$4 -z wxneeded -z notext"
++ ;;
++
+ esac
+
+ # If gcc knows about the stack protector, turn it off.
Index: patches/patch-configure
===================================================================
RCS file: patches/patch-configure
diff -N patches/patch-configure
--- patches/patch-configure 30 Sep 2019 11:44:18 -0000 1.19
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,30 +0,0 @@
-$OpenBSD: patch-configure,v 1.19 2019/09/30 11:44:18 kili Exp $
-Index: configure
---- configure.orig
-+++ configure
-@@ -9048,11 +9048,11 @@ OptCmd="$OPT"
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: Creating links for in-tree file handling routines." >&5
- $as_echo "$as_me: Creating links for in-tree file handling routines." >&6;}
--ln -f -v utils/fs/fs.* utils/lndir/
--ln -f -v utils/fs/fs.* utils/unlit/
--ln -f -v utils/fs/fs.* rts/
--ln -f -v utils/fs/fs.h libraries/base/include/
--ln -f -v utils/fs/fs.c libraries/base/cbits/
-+ln -f utils/fs/fs.* utils/lndir/
-+ln -f utils/fs/fs.* utils/unlit/
-+ln -f utils/fs/fs.* rts/
-+ln -f utils/fs/fs.h libraries/base/include/
-+ln -f utils/fs/fs.c libraries/base/cbits/
- { $as_echo "$as_me:${as_lineno-$LINENO}: Routines in place. Packages can now be build normally." >&5
- $as_echo "$as_me: Routines in place. Packages can now be build normally." >&6;}
-
-@@ -9296,7 +9296,7 @@ $as_echo_n "checking for extra options to pass gcc whe
- if ${fp_cv_gcc_extra_opts+:} false; then :
- $as_echo_n "(cached) " >&6
- else
-- fp_cv_gcc_extra_opts=
-+ fp_cv_gcc_extra_opts=-fno-pie
- fp_version1=$fp_cv_gcc_version; fp_version2=3.4
- fp_save_IFS=$IFS; IFS='.'
- while test x"$fp_version1" != x || test x"$fp_version2" != x
Index: patches/patch-configure_ac
===================================================================
RCS file: patches/patch-configure_ac
diff -N patches/patch-configure_ac
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-configure_ac 29 May 2020 21:40:37 -0000
@@ -0,0 +1,22 @@
+$OpenBSD$
+
+Index: configure.ac
+--- configure.ac.orig
++++ configure.ac
+@@ -678,11 +678,11 @@ dnl --------------------------------------------------
+ dnl ** Copy the files from the "fs" utility into the right folders.
+ dnl --------------------------------------------------------------
+ AC_MSG_NOTICE([Creating links for in-tree file handling routines.])
+-ln -f -v utils/fs/fs.* utils/lndir/
+-ln -f -v utils/fs/fs.* utils/unlit/
+-ln -f -v utils/fs/fs.* rts/
+-ln -f -v utils/fs/fs.h libraries/base/include/
+-ln -f -v utils/fs/fs.c libraries/base/cbits/
++ln -f utils/fs/fs.* utils/lndir/
++ln -f utils/fs/fs.* utils/unlit/
++ln -f utils/fs/fs.* rts/
++ln -f utils/fs/fs.h libraries/base/include/
++ln -f utils/fs/fs.c libraries/base/cbits/
+ AC_MSG_NOTICE([Routines in place. Packages can now be build normally.])
+
+ dnl --------------------------------------------------------------

No comments:

Post a Comment