[DHG_packages] 01/01: ghc: Use upstream patch for '-no-pie'
Ilias Tsitsimpis
iliastsi-guest at moszumanska.debian.org
Fri Nov 11 16:31:30 UTC 2016
This is an automated email from the git hooks/post-receive script.
iliastsi-guest pushed a commit to branch experimental
in repository DHG_packages.
commit bdc08179aba3918d13ef11c26265ae7da863950d
Author: Ilias Tsitsimpis <i.tsitsimpis at gmail.com>
Date: Fri Nov 11 17:47:48 2016 +0200
ghc: Use upstream patch for '-no-pie'
Drop our custom 'opt-pic' and 'no-pie' patches and use one provided by
the upstream developers.
---
p/ghc/debian/changelog | 8 ++
p/ghc/debian/patches/no-pie | 236 ++++++++++++++++++++++++++++++++++++++++---
p/ghc/debian/patches/opt-pic | 19 ----
p/ghc/debian/patches/series | 1 -
4 files changed, 228 insertions(+), 36 deletions(-)
diff --git a/p/ghc/debian/changelog b/p/ghc/debian/changelog
index f7a8e29..87416e2 100644
--- a/p/ghc/debian/changelog
+++ b/p/ghc/debian/changelog
@@ -1,3 +1,11 @@
+ghc (8.0.1-12) experimental; urgency=medium
+
+ * Use upstream patch for '-no-pie'.
+ Drop our custom 'opt-pic' and 'no-pie' patches and use one provided by
+ the upstream developers.
+
+ -- Ilias Tsitsimpis <i.tsitsimpis at gmail.com> Fri, 11 Nov 2016 17:45:03 +0200
+
ghc (8.0.1-11) unstable; urgency=medium
* Team upload.
diff --git a/p/ghc/debian/patches/no-pie b/p/ghc/debian/patches/no-pie
index 0530cdd..47fdde5 100644
--- a/p/ghc/debian/patches/no-pie
+++ b/p/ghc/debian/patches/no-pie
@@ -1,26 +1,230 @@
-Description: Pass -no-pie along with -Wl,-r
- GHC uncoditionally passes `-Wl,-r' to gcc in `compiler/main/DriverPipeline.hs'.
- This fails in cases where PIE is enabled by default with the following error:
- .
- /usr/bin/ld: -r and -pie may not be used together
- .
- Fix the above error by passing `-no-pie' along with `-Wl,-r' to the compiler.
-Author: Ilias Tsitsimpis <i.tsitsimpis at gmail.com>
-Bug: https://ghc.haskell.org/trac/ghc/ticket/11834
+Description: Pass -no-pie to GCC
+ Certain distributions (e.g. Debian and Ubuntu) have enabled PIE be
+ default in their GCC packaging. This breaks our abuse of GCC as a linker
+ which requires that we pass -Wl,-r, which is incompatible with
+ PIE (since the former implies that we are generating a relocatable
+ object file and the latter an executable).
+Author: Ben Gamari <bgamari.foss at gmail.com>
+Origin: upstream, https://phabricator.haskell.org/D2693
+Bug: https://ghc.haskell.org/trac/ghc/ticket/12759
Bug-Debian: https://bugs.debian.org/712228
-Forwarded: no
+Index: b/aclocal.m4
+===================================================================
+--- a/aclocal.m4
++++ b/aclocal.m4
+@@ -502,12 +502,14 @@ AC_DEFUN([FP_SETTINGS],
+ fi
+ SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2"
+ SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2"
++ SettingsCCompilerSupportsNoPie="$CONF_GCC_SUPPORTS_NO_PIE"
+ SettingsLdFlags="$CONF_LD_LINKER_OPTS_STAGE2"
+ AC_SUBST(SettingsCCompilerCommand)
+ AC_SUBST(SettingsHaskellCPPCommand)
+ AC_SUBST(SettingsHaskellCPPFlags)
+ AC_SUBST(SettingsCCompilerFlags)
+ AC_SUBST(SettingsCCompilerLinkFlags)
++ AC_SUBST(SettingsCCompilerSupportsNoPie)
+ AC_SUBST(SettingsLdCommand)
+ AC_SUBST(SettingsLdFlags)
+ AC_SUBST(SettingsArCommand)
+@@ -1254,6 +1256,25 @@ AC_SUBST(GccIsClang)
+ rm -f conftest.txt
+ ])
+
++# FP_GCC_SUPPORTS_NO_PIE
++# ----------------------
++# Does gcc support the -no-pie option? If so we should pass it to gcc when
++# joining objects since -pie may be enabled by default.
++AC_DEFUN([FP_GCC_SUPPORTS_NO_PIE],
++[
++ AC_REQUIRE([AC_PROG_CC])
++ AC_MSG_CHECKING([whether GCC supports -no-pie])
++ echo 'int main() { return 0; }' > conftest.c
++ if ${CC-cc} -o conftest -no-pie conftest.c > /dev/null 2>&1; then
++ CONF_GCC_SUPPORTS_NO_PIE=YES
++ AC_MSG_RESULT([yes])
++ else
++ CONF_GCC_SUPPORTS_NO_PIE=NO
++ AC_MSG_RESULT([no])
++ fi
++ rm -f conftest.c conftest.o conftest
++])
++
+ dnl Small feature test for perl version. Assumes PerlCmd
+ dnl contains path to perl binary.
+ dnl
Index: b/compiler/main/DriverPipeline.hs
===================================================================
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
-@@ -2145,7 +2145,8 @@ joinObjectFiles dflags o_files output_fn
- osInfo = platformOS (targetPlatform dflags)
- ld_r args cc = SysTools.runLink dflags ([
+@@ -1850,6 +1850,11 @@ linkBinary' staticLink dflags o_files de
+ ++ map SysTools.Option (
+ []
+
++ -- See Note [No PIE eating when linking]
++ ++ (if sGccSupportsNoPie mySettings
++ then ["-no-pie"]
++ else [])
++
+ -- Permit the linker to auto link _symbol to _imp_symbol.
+ -- This lets us link against DLLs without needing an "import library".
+ ++ (if platformOS platform == OSMinGW32
+@@ -2147,6 +2152,11 @@ joinObjectFiles dflags o_files output_fn
SysTools.Option "-nostdlib",
-- SysTools.Option "-Wl,-r"
-+ SysTools.Option "-Wl,-r",
-+ SysTools.Option "-no-pie"
+ SysTools.Option "-Wl,-r"
]
++ -- See Note [No PIE eating while linking] in SysTools
++ ++ (if sGccSupportsNoPie mySettings
++ then [SysTools.Option "-no-pie"]
++ else [])
++
++ (if any (cc ==) [Clang, AppleClang, AppleClang51]
then []
+ else [SysTools.Option "-nodefaultlibs"])
+Index: b/compiler/main/DynFlags.hs
+===================================================================
+--- a/compiler/main/DynFlags.hs
++++ b/compiler/main/DynFlags.hs
+@@ -943,6 +943,7 @@ data Settings = Settings {
+ sLdSupportsBuildId :: Bool,
+ sLdSupportsFilelist :: Bool,
+ sLdIsGnuLd :: Bool,
++ sGccSupportsNoPie :: Bool,
+ -- commands for particular phases
+ sPgm_L :: String,
+ sPgm_P :: (String,[Option]),
+Index: b/compiler/main/SysTools.hs
+===================================================================
+--- a/compiler/main/SysTools.hs
++++ b/compiler/main/SysTools.hs
+@@ -252,6 +252,7 @@ initSysTools mbMinusB
+ -- to make that possible, so for now you can't.
+ gcc_prog <- getSetting "C compiler command"
+ gcc_args_str <- getSetting "C compiler flags"
++ gccSupportsNoPie <- getBooleanSetting "C compiler supports -no-pie"
+ cpp_prog <- getSetting "Haskell CPP command"
+ cpp_args_str <- getSetting "Haskell CPP flags"
+ let unreg_gcc_args = if targetUnregisterised
+@@ -344,6 +345,7 @@ initSysTools mbMinusB
+ sLdSupportsBuildId = ldSupportsBuildId,
+ sLdSupportsFilelist = ldSupportsFilelist,
+ sLdIsGnuLd = ldIsGnuLd,
++ sGccSupportsNoPie = gccSupportsNoPie,
+ sProgramName = "ghc",
+ sProjectVersion = cProjectVersion,
+ sPgm_L = unlit_path,
+@@ -1601,6 +1603,15 @@ linesPlatform xs =
+
+ #endif
+
++{-
++Note [No PIE eating while linking]
++~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
++As of 2016 some Linux distributions (e.g. Debian) have started enabling -pie by
++default in their gcc builds. This is incompatible with -r as it implies that we
++are producing an executable. Consequently, we must manually pass -no-pie to gcc
++when joining object files or linking dynamic libraries. See #12759.
++-}
++
+ linkDynLib :: DynFlags -> [String] -> [UnitId] -> IO ()
+ linkDynLib dflags0 o_files dep_packages
+ = do
+@@ -1766,6 +1777,10 @@ linkDynLib dflags0 o_files dep_packages
+ ++ [ Option "-o"
+ , FileOption "" output_fn
+ ]
++ -- See Note [No PIE eating when linking]
++ ++ (if sGccSupportsNoPie (settings dflags)
++ then [Option "-no-pie"]
++ else [])
+ ++ map Option o_files
+ ++ [ Option "-shared" ]
+ ++ map Option bsymbolicFlag
+Index: b/configure
+===================================================================
+--- a/configure
++++ b/configure
+@@ -665,6 +665,7 @@ SettingsPerlCommand
+ SettingsArCommand
+ SettingsLdFlags
+ SettingsLdCommand
++SettingsCCompilerSupportsNoPie
+ SettingsCCompilerLinkFlags
+ SettingsCCompilerFlags
+ SettingsHaskellCPPFlags
+@@ -7976,6 +7977,23 @@ GccVersion=$fp_cv_gcc_version
+
+
+
++
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether GCC supports -no-pie" >&5
++$as_echo_n "checking whether GCC supports -no-pie... " >&6; }
++ echo 'int main() { return 0; }' > conftest.c
++ if ${CC-cc} -o conftest -no-pie conftest.c > /dev/null 2>&1; then
++ CONF_GCC_SUPPORTS_NO_PIE=YES
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
++ else
++ CONF_GCC_SUPPORTS_NO_PIE=NO
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++ fi
++ rm -f conftest.c conftest.o conftest
++
++
++
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler is clang" >&5
+ $as_echo_n "checking whether C compiler is clang... " >&6; }
+ $CC -x c /dev/null -dM -E > conftest.txt 2>&1
+@@ -9337,10 +9355,12 @@ fi
+ fi
+ SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2"
+ SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2"
++ SettingsCCompilerSupportsNoPie="$CONF_GCC_SUPPORTS_NO_PIE"
+ SettingsLdFlags="$CONF_LD_LINKER_OPTS_STAGE2"
+
+
+
++
+
+
+
+Index: b/configure.ac
+===================================================================
+--- a/configure.ac
++++ b/configure.ac
+@@ -647,6 +647,9 @@ dnl If gcc, make sure it's at least
+ dnl
+ FP_GCC_VERSION
+
++dnl ** See whether gcc supports -no-pie
++FP_GCC_SUPPORTS_NO_PIE
++
+ dnl ** look to see if we have a C compiler using an llvm back end.
+ dnl
+ FP_CC_LLVM_BACKEND
+Index: b/distrib/configure.ac.in
+===================================================================
+--- a/distrib/configure.ac.in
++++ b/distrib/configure.ac.in
+@@ -103,6 +103,7 @@ if test "x$BinDistNeedsLibdw" = "xyes" ;
+ fi
+
+ FP_GCC_VERSION
++FP_GCC_SUPPORTS_NO_PIE
+ AC_PROG_CPP
+
+ FP_PROG_LD_IS_GNU
+Index: b/settings.in
+===================================================================
+--- a/settings.in
++++ b/settings.in
+@@ -2,6 +2,7 @@
+ ("C compiler command", "@SettingsCCompilerCommand@"),
+ ("C compiler flags", "@SettingsCCompilerFlags@"),
+ ("C compiler link flags", "@SettingsCCompilerLinkFlags@"),
++ ("C compiler supports -no-pie", "@SettingsCCompilerSupportsNoPie@"),
+ ("Haskell CPP command","@SettingsHaskellCPPCommand@"),
+ ("Haskell CPP flags","@SettingsHaskellCPPFlags@"),
+ ("ld command", "@SettingsLdCommand@"),
diff --git a/p/ghc/debian/patches/opt-pic b/p/ghc/debian/patches/opt-pic
deleted file mode 100644
index db32e31..0000000
--- a/p/ghc/debian/patches/opt-pic
+++ /dev/null
@@ -1,19 +0,0 @@
---- a/compiler/main/DynFlags.hs
-+++ b/compiler/main/DynFlags.hs
-@@ -3631,14 +3631,8 @@
- default_PIC :: Platform -> [GeneralFlag]
- default_PIC platform =
- case (platformOS platform, platformArch platform) of
-- (OSDarwin, ArchX86_64) -> [Opt_PIC]
-- (OSOpenBSD, ArchX86_64) -> [Opt_PIC] -- Due to PIE support in
-- -- OpenBSD since 5.3 release
-- -- (1 May 2013) we need to
-- -- always generate PIC. See
-- -- #10597 for more
-- -- information.
-- _ -> []
-+ (OSLinux, ArchPPC) -> []
-+ _ -> [Opt_PIC]
-
- -- General flags that are switched on/off when other general flags are switched
- -- on
diff --git a/p/ghc/debian/patches/series b/p/ghc/debian/patches/series
index 59f3847..2662db1 100644
--- a/p/ghc/debian/patches/series
+++ b/p/ghc/debian/patches/series
@@ -6,7 +6,6 @@ buildpath-abi-stability.patch
reproducible-tmp-names
do-not-use-SHELL
add-missing-MO_WriteBarrier
-opt-pic
no-pie
find-tycon-panic
compiler-cmm-PprC-sparc-alignment.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-haskell/DHG_packages.git
More information about the Pkg-haskell-commits
mailing list