dev-haskell/gtk2hs-buildtools: add support for '__builtin_offsetof (struct sigcontext, sc_gr[0])', bug #498638

Bug: https://bugs.gentoo.org/498638

Package-Manager: portage-2.2.20
This commit is contained in:
Sergei Trofimovich
2015-09-26 00:23:57 +01:00
parent 375b1578ab
commit 62c9551162
2 changed files with 85 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
ia64 is is a special showflake.
Technically does nothing bad,
but it alone uses '__builtin_offsetof (struct sigcontext'
in system headers. c2hs does not handle that.
https://bugs.gentoo.org/498638
diff --git a/c2hs/c/C.hs b/c2hs/c/C.hs
index f79b6d9..aa1b5e4 100644
--- a/c2hs/c/C.hs
+++ b/c2hs/c/C.hs
@@ -1 +1,2 @@
+{-# LANGUAGE CPP, PatternGuards #-}
-- C->Haskell Compiler: interface to C processing routines
@@ -94,2 +95,20 @@ isuffix = ".i"
+-- This stanza workarounds very specific limitation
+-- of c2hs of not being able to expang __builtin_offsetof
+-- used by all glib/gtk headers at least on ia64.
+raw_mangle :: String -> String
+raw_mangle s = case s of
+ [] -> []
+#ifdef ia64_HOST_ARCH
+ _ | Just (h, rest) <- chop_head "__builtin_offsetof (struct sigcontext, sc_gr[0])"
+ "200" -- ia64/linux/glibc, sigh
+ -> h ++ raw_mangle rest
+#endif /* ia64_HOST_ARCH */
+ (h:t) -> h : raw_mangle t
+ where chop_head prefix new_prefix =
+ case splitAt p_len s of
+ (h, t) | h == prefix -> Just (new_prefix, t)
+ _ -> Nothing
+ where p_len = length prefix
+
-- given a file name (with suffix), parse that file as a C header and do the
@@ -106,3 +124,3 @@ loadAttrC fname = do
traceInfoRead fname
- contents <- readFileCIO fname
+ contents <- raw_mangle `fmap` readFileCIO fname
@@ -126,4 +144,4 @@ loadAttrC fname = do
errmsgs <- showErrors
- fatal ("C header contains \
- \errors:\n\n" ++ errmsgs) -- fatal error
+ fatal ("C header contains " ++
+ "errors:\n\n" ++ errmsgs) -- fatal error
else do

View File

@@ -0,0 +1,38 @@
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
EAPI=5
# ebuild generated by hackport 0.4.5.9999
CABAL_FEATURES="bin"
inherit haskell-cabal
DESCRIPTION="Tools to build the Gtk2Hs suite of User Interface libraries"
HOMEPAGE="http://projects.haskell.org/gtk2hs/"
SRC_URI="mirror://hackage/packages/archive/${PN}/${PV}/${P}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~ia64 ~ppc ~ppc64 ~sparc ~x86"
IUSE="+closuresignals"
RDEPEND="dev-haskell/random:=
>=dev-lang/ghc-7.4.1:=
|| ( ( >=dev-lang/ghc-7.7:= dev-haskell/hashtables:= ) <dev-lang/ghc-7.7:= )
"
DEPEND="${RDEPEND}
dev-haskell/alex
>=dev-haskell/cabal-1.8
dev-haskell/happy
"
src_prepare() {
epatch "${FILESDIR}"/${P}-ia64.patch
}
src_configure() {
haskell-cabal_src_configure \
$(cabal_flag closuresignals closuresignals)
}