[Git][ghc/ghc][ghc-8.10] 9 commits: Force -fPIC for intree GMP (fix #17799)

Ben Gamari gitlab at gitlab.haskell.org
Mon Apr 20 21:22:33 UTC 2020



Ben Gamari pushed to branch ghc-8.10 at Glasgow Haskell Compiler / GHC


Commits:
07c0d148 by Sylvain Henry at 2020-04-13T17:57:19-04:00
Force -fPIC for intree GMP (fix #17799)

Configure intree GMP with `--with-pic` instead of patching it. Moreover
the correct patching was only done for x86_64/darwin (see #17799).

(cherry picked from commit e1e329448f3742b2024ca6bc2c78f36fe282b606)

- - - - -
64fb49c9 by Ben Gamari at 2020-04-13T17:57:19-04:00
gitlab-ci: Add FreeBSD release job

- - - - -
d1464459 by Ben Gamari at 2020-04-13T17:57:19-04:00
Mention -Wunused-packages in release notes

- - - - -
9ba0cd3e by Ben Gamari at 2020-04-13T17:57:19-04:00
testsuite: Don't ask sed to operate in-place on symlinks

Some sed implementations (e.g. FreeBSD) refuse to operate in-place on
symlinks.

(cherry picked from commit e5ee07ab565c1bf7a33d3bd4bcd3fb6c7b100d1c)

- - - - -
c0b4e2cc by Ben Gamari at 2020-04-13T17:57:19-04:00
testsuite/T16930: Don't rely on gnu grep specific --include

In BSD grep this flag only affects directory recursion.

- - - - -
2daee665 by Ben Gamari at 2020-04-13T17:57:19-04:00
testsuite: Mark T6132 as broken on FreeBSD

- - - - -
12bb9912 by Ben Gamari at 2020-04-13T17:57:20-04:00
Pass -Wno-unused-command-line-arguments during link on FreeBSD

FreeBSD cc throws a warning if we pass -pthread without actually using
any pthread symbols.

- - - - -
3717c610 by Ben Gamari at 2020-04-13T17:57:20-04:00
base: Always clamp reads/writes to 2GB in length

Previously we did this only on Darwin due to #17414. However, even on
other platforms >2GB writes are on shaky ground. POSIX explicitly says
that the result is implementation-specified and Linux will write at most
0x7ffff000, even on 64-bit platforms. Moreover, getting the sign
of the syscall result correct is tricky, as demonstrated by the fact
that T17414 currently fails on FreeBSD.

For simplicity we now just uniformly clamp to 0x7ffff000 on all
platforms.

- - - - -
9ff90fd8 by Ben Gamari at 2020-04-13T17:57:20-04:00
configure: Fix sphinx version test

The check for the "v" prefix is redundant.

- - - - -


12 changed files:

- .gitlab-ci.yml
- compiler/main/DynFlags.hs
- configure.ac
- docs/users_guide/8.10.1-notes.rst
- hadrian/src/Settings/Builders/Configure.hs
- libraries/base/GHC/IO/FD.hs
- libraries/integer-gmp/gmp/ghc.mk
- libraries/integer-gmp/gmp/gmpsrc.patch
- testsuite/tests/cmm/should_compile/Makefile
- testsuite/tests/cmm/should_compile/T16930.stdout
- testsuite/tests/driver/T16608/Makefile
- testsuite/tests/runghc/all.T


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -344,6 +344,11 @@ nightly-x86_64-freebsd:
   extends: .build-x86_64-freebsd
   stage: full-build
 
+release-x86_64-freebsd:
+  <<: *release
+  extends: .build-x86_64-freebsd
+  stage: full-build
+
 .build-x86_64-freebsd-hadrian:
   extends: .validate-hadrian
   stage: full-build


=====================================
compiler/main/DynFlags.hs
=====================================
@@ -1817,7 +1817,9 @@ wayOptl :: Platform -> Way -> [String]
 wayOptl _ (WayCustom {}) = []
 wayOptl platform WayThreaded =
         case platformOS platform of
-        OSFreeBSD  -> ["-pthread"]
+        -- N.B. FreeBSD cc throws a warning if we pass -pthread without
+        -- actually using any pthread symbols.
+        OSFreeBSD  -> ["-pthread", "-Wno-unused-command-line-argument"]
         OSOpenBSD  -> ["-pthread"]
         OSNetBSD   -> ["-pthread"]
         _          -> []


=====================================
configure.ac
=====================================
@@ -836,7 +836,7 @@ AC_PATH_PROG(SPHINXBUILD,sphinx-build)
 AC_CACHE_CHECK([for version of sphinx-build], fp_cv_sphinx_version,
 changequote(, )dnl
 [if test -n "$SPHINXBUILD"; then
-  fp_cv_sphinx_version=`"$SPHINXBUILD" --version 2>&1 | sed 's/.* v\?\([0-9]\.[0-9]\.[0-9]\)/\1/' | head -n1`;
+  fp_cv_sphinx_version=`"$SPHINXBUILD" --version 2>&1 | sed 's/.* \([0-9]\.[0-9]\.[0-9]\)/\1/' | head -n1`;
 fi;
 changequote([, ])dnl
 ])


=====================================
docs/users_guide/8.10.1-notes.rst
=====================================
@@ -187,6 +187,8 @@ Compiler
   has been removed. From this point forth GHC will only support floating point
   via SSE2.
 
+- New :ghc-flag:`-Wunused-packages` warning reports unused packages.
+
 - Add new flags :ghc-flag:`-Wunused-record-wildcards` and
   :ghc-flag:`-Wredundant-record-wildcards`  which warn users when they have
   redundant or unused uses of a record wildcard match.


=====================================
hadrian/src/Settings/Builders/Configure.hs
=====================================
@@ -13,6 +13,7 @@ configureBuilderArgs = do
                 hostPlatform  <- getSetting HostPlatform
                 buildPlatform <- getSetting BuildPlatform
                 pure [ "--enable-shared=no"
+                     , "--with-pic=yes"
                      , "--host=" ++ hostPlatform
                      , "--build=" ++ buildPlatform ]
 


=====================================
libraries/base/GHC/IO/FD.hs
=====================================
@@ -67,16 +67,13 @@ import System.Posix.Types
 c_DEBUG_DUMP :: Bool
 c_DEBUG_DUMP = False
 
--- Darwin limits the length of writes to 2GB. See
--- #17414.
+-- Darwin limits the length of writes to 2GB. See #17414.
+-- Moreover, Linux will only transfer up to 0x7ffff000 and interpreting the
+-- result of write/read is tricky above 2GB due to its signed type. For
+-- simplicity we therefore clamp on all platforms.
 clampWriteSize, clampReadSize :: Int -> Int
-#if defined(darwin_HOST_OS)
-clampWriteSize = min 0x7fffffff
-clampReadSize  = min 0x7fffffff
-#else
-clampWriteSize = id
-clampReadSize  = id
-#endif
+clampWriteSize = min 0x7ffff000
+clampReadSize  = min 0x7ffff000
 
 -- -----------------------------------------------------------------------------
 -- The file-descriptor IO device


=====================================
libraries/integer-gmp/gmp/ghc.mk
=====================================
@@ -131,7 +131,7 @@ libraries/integer-gmp/gmp/libgmp.a libraries/integer-gmp/gmp/gmp.h:
 	#       run is the 'target' platform of the compiler we're building.
 	cd libraries/integer-gmp/gmp/gmpbuild; \
 	    CC=$(CCX) CXX=$(CCX) NM=$(NM) AR=$(AR_STAGE1) ./configure \
-	          --enable-shared=no \
+	          --enable-shared=no --with-pic=yes \
 	          --host=$(TARGETPLATFORM) --build=$(BUILDPLATFORM)
 	$(MAKE) -C libraries/integer-gmp/gmp/gmpbuild MAKEFLAGS=
 	$(CP) libraries/integer-gmp/gmp/gmpbuild/gmp.h libraries/integer-gmp/gmp/


=====================================
libraries/integer-gmp/gmp/gmpsrc.patch
=====================================
@@ -1,27 +1,6 @@
 diff -Naur gmp-6.1.2/configure gmpbuild/configure
 --- gmp-6.1.2/configure	2016-12-16 10:45:32.000000000 -0500
 +++ gmpbuild/configure	2017-01-29 15:18:01.037775639 -0500
-@@ -4087,8 +4087,8 @@
- #
- cclist="gcc cc"
- 
--gcc_cflags="-O2 -pedantic"
--gcc_64_cflags="-O2 -pedantic"
-+gcc_cflags="-O2 -pedantic -fPIC"
-+gcc_64_cflags="-O2 -pedantic -fPIC"
- cc_cflags="-O"
- cc_64_cflags="-O"
- 
-@@ -27273,6 +27273,9 @@
- 	  case $host in
- 	    *-*-darwin*)
- 
-+echo "define(<PIC_ALWAYS>,<yes>)" >> $gmp_tmpconfigm4
-+
-+
- echo "include_mpn(\`x86_64/darwin.m4')" >> $gmp_tmpconfigm4i
-  ;;
- 	    *-*-mingw* | *-*-cygwin)
 @@ -28181,7 +28181,7 @@
  # FIXME: Upcoming version of autoconf/automake may not like broken lines.
  #        Right now automake isn't accepting the new AC_CONFIG_FILES scheme.
@@ -63,27 +42,3 @@ diff -Naur gmp-6.1.2/Makefile.in gmpbuild/Makefile.in
  
  # The "test -f" support for srcdir!=builddir is similar to the automake .c.o
  # etc rules, but with each foo.c explicitly, since $< is not portable
-diff -Naur gmp-6.1.2/configure.ac gmpbuild/configure.ac
---- gmp-6.1.2/configure.ac	2016-12-16 10:45:27.000000000 -0500
-+++ gmpbuild/configure.ac	2017-01-29 22:47:28.469558006 -0500
-@@ -3698,7 +3698,8 @@
-           AC_DEFINE(HAVE_HOST_CPU_FAMILY_x86_64)
- 	  case $host in
- 	    *-*-darwin*)
-+	      GMP_DEFINE_RAW(["define(<PIC_ALWAYS>,<yes>)"])
- 	      GMP_INCLUDE_MPN(x86_64/darwin.m4) ;;
- 	    *-*-mingw* | *-*-cygwin)
- 	      GMP_INCLUDE_MPN(x86_64/dos64.m4) ;;
- 	    *-openbsd*)
-diff -Naur gmp-6.1.2/mpn/asm-defs.m4 gmpbuild/mpn/asm-defs.m4
---- gmp-6.1.2/mpn/asm-defs.m4	2016-12-16 10:45:27.000000000 -0500
-+++ gmpbuild/mpn/asm-defs.m4	2017-01-29 22:46:26.025176258 -0500
-@@ -1051,7 +1051,7 @@
- dnl  systems which are always PIC.  PIC_ALWAYS established in config.m4
- dnl  identifies these for us.
- 
--ifelse(`PIC_ALWAYS',`yes',`define(`PIC')')
-+ifelse(PIC_ALWAYS,yes,`define(`PIC')')
- 
- 
- dnl  Various possible defines passed from the Makefile that are to be tested


=====================================
testsuite/tests/cmm/should_compile/Makefile
=====================================
@@ -7,9 +7,9 @@ include $(TOP)/mk/test.mk
 T16930:
 	echo "testing -ddump-cmm-verbose for T16930 ..."
 	'$(TEST_HC)' $(TEST_HC_OPTS) T16930.hs -fforce-recomp -ddump-cmm-verbose -ddump-to-file
-	grep -rl "CAFEnv" . --include=\T16930.*
-	grep -rl "Post control-flow optimisations" . --include=\T16930.*
-	grep -rl "Post CPS Cmm" . --include=\T16930.*
-	grep -rl "after setInfoTableStackMap" . --include=\T16930.*
-	grep -rl "Layout Stack" . --include=\T16930.*
-	grep -rl "Post switch plan" . --include=\T16930.*
+	grep -rl "CAFEnv" `ls T16930.*`
+	grep -rl "Post control-flow optimisations" `ls T16930.*`
+	grep -rl "Post CPS Cmm" `ls T16930.*`
+	grep -rl "after setInfoTableStackMap" `ls T16930.*`
+	grep -rl "Layout Stack" `ls T16930.*`
+	grep -rl "Post switch plan" `ls T16930.*`


=====================================
testsuite/tests/cmm/should_compile/T16930.stdout
=====================================
@@ -1,9 +1,9 @@
 testing -ddump-cmm-verbose for T16930 ...
 [1 of 1] Compiling Main             ( T16930.hs, T16930.o )
 Linking T16930 ...
-./T16930.dump-cmm-caf
-./T16930.dump-cmm-cfg
-./T16930.dump-cmm-cps
-./T16930.dump-cmm-info
-./T16930.dump-cmm-sp
-./T16930.dump-cmm-switch
+T16930.dump-cmm-caf
+T16930.dump-cmm-cfg
+T16930.dump-cmm-cps
+T16930.dump-cmm-info
+T16930.dump-cmm-sp
+T16930.dump-cmm-switch


=====================================
testsuite/tests/driver/T16608/Makefile
=====================================
@@ -3,6 +3,8 @@ include $(TOP)/mk/boilerplate.mk
 include $(TOP)/mk/test.mk
 
 T16608_1:
+	# FreeBSD's sed doesn't like operating in-place on symlinks. Un-symlinkify.
+	mv MyInteger.hs tmp.hs; cp tmp.hs MyInteger.hs
 	'$(TEST_HC)' $(TEST_HC_OPTS) --make -O0 T16608_1.hs
 	./T16608_1
 	sleep 1
@@ -11,6 +13,8 @@ T16608_1:
 	./T16608_1
 
 T16608_2:
+	# FreeBSD's sed doesn't like operating in-place on symlinks. Un-symlinkify.
+	mv MyInteger.hs tmp.hs; cp tmp.hs MyInteger.hs
 	'$(TEST_HC)' $(TEST_HC_OPTS) --make -O0 T16608_2.hs
 	./T16608_2
 	sleep 1


=====================================
testsuite/tests/runghc/all.T
=====================================
@@ -4,7 +4,9 @@ test('T8601', req_interp, makefile_test, [])
 
 test('T11247', [req_interp, expect_broken(11247)], makefile_test, [])
 
-test('T6132', [when(opsys('darwin'), expect_broken(6132))], compile, [''])
+test('T6132', [
+     when(opsys('darwin') or opsys('freebsd'), expect_broken(6132))],
+     compile, [''])
 
 test('T17171a', [req_interp, expect_fail], makefile_test, [])
 test('T17171b', req_interp, makefile_test, [])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c3cadf5db0d7eb859ff2c278ab07585c7df17b5...9ff90fd85e2c611a97ba36357ec50972d32db850

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c3cadf5db0d7eb859ff2c278ab07585c7df17b5...9ff90fd85e2c611a97ba36357ec50972d32db850
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200420/795201b9/attachment-0001.html>


More information about the ghc-commits mailing list