From fe91fa948042fb83836e2de481f8be3ca17bd636 Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Wed, 20 Apr 2016 13:59:23 +0100 Subject: [PATCH] Squelching bogus type pun warnings from gcc 4.7 to get a clean build in travis ci. Adding platform XCI6GC to allow faster debugging of CI builds on Mac OS X with MacPorts GCC 4.7 installed. Not otherwise supported. Copied from Perforce Change: 191357 ServerID: perforce.ravenbrook.com --- mps/code/cbs.c | 8 +++--- mps/code/cbs.h | 11 ++++++++ mps/code/mpstd.h | 23 +++++++++++++++ mps/code/poolams.c | 2 +- mps/code/poolmv.c | 1 - mps/code/poolmvff.c | 5 ++-- mps/code/poolsnc.c | 1 - mps/code/protocol.h | 8 ++++-- mps/code/xci6gc.gmk | 69 +++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 115 insertions(+), 13 deletions(-) create mode 100644 mps/code/xci6gc.gmk diff --git a/mps/code/cbs.c b/mps/code/cbs.c index 76148c292b1..d3de50a5ab6 100644 --- a/mps/code/cbs.c +++ b/mps/code/cbs.c @@ -125,7 +125,7 @@ static Bool cbsTestNode(SplayTree splay, Tree tree, void *closure) AVERT(Tree, tree); AVER(sizeP != NULL); AVER(*sizeP > 0); - AVER(IsA(CBSFast, CBSLand(cbsOfSplay(splay)))); + AVER(IsA(CBSFast, cbsOfSplay(splay))); block = cbsBlockOfTree(tree); @@ -142,7 +142,7 @@ static Bool cbsTestTree(SplayTree splay, Tree tree, AVERT(Tree, tree); AVER(sizeP != NULL); AVER(*sizeP > 0); - AVER(IsA(CBSFast, CBSLand(cbsOfSplay(splay)))); + AVER(IsA(CBSFast, cbsOfSplay(splay))); block = cbsFastBlockOfTree(tree); @@ -158,7 +158,7 @@ static void cbsUpdateFastNode(SplayTree splay, Tree tree) AVERT_CRITICAL(SplayTree, splay); AVERT_CRITICAL(Tree, tree); - AVER_CRITICAL(IsA(CBSFast, CBSLand(cbsOfSplay(splay)))); + AVER_CRITICAL(IsA(CBSFast, cbsOfSplay(splay))); maxSize = CBSBlockSize(cbsBlockOfTree(tree)); @@ -189,7 +189,7 @@ static void cbsUpdateZonedNode(SplayTree splay, Tree tree) AVERT_CRITICAL(SplayTree, splay); AVERT_CRITICAL(Tree, tree); - AVER_CRITICAL(IsA(CBSZoned, CBSLand(cbsOfSplay(splay)))); + AVER_CRITICAL(IsA(CBSZoned, cbsOfSplay(splay))); cbsUpdateFastNode(splay, tree); diff --git a/mps/code/cbs.h b/mps/code/cbs.h index 3df263908d5..0f34e6c7080 100644 --- a/mps/code/cbs.h +++ b/mps/code/cbs.h @@ -38,8 +38,19 @@ typedef struct CBSZonedBlockStruct { typedef struct CBSStruct *CBS, *CBSFast, *CBSZoned; extern Bool CBSCheck(CBS cbs); + + +/* CBSLand -- convert CBS to Land + * + * We would like to use MustBeA(Land, cbs) for this, but it produces + * bogus warnings about strict aliasing from GCC 4.7 (and probably + * 4.8). We can abolish this macro when those are no longer in use in + * MPS development. + */ + #define CBSLand(cbs) (&(cbs)->landStruct) + DECLARE_CLASS(Land, CBS, Land); DECLARE_CLASS(Land, CBSFast, CBS); DECLARE_CLASS(Land, CBSZoned, CBSFast); diff --git a/mps/code/mpstd.h b/mps/code/mpstd.h index de6d329d5c7..388032eed40 100644 --- a/mps/code/mpstd.h +++ b/mps/code/mpstd.h @@ -142,6 +142,29 @@ #define MPS_PF_ALIGN 4 /* I'm just guessing. */ +/* gcc-mp-4.7 (MacPorts gcc47 4.7.4_5) 4.7.4 + * gcc -E -dM + * Note that Clang also defines __GNUC__ since it's generally GCC compatible, + * but that doesn't fit our system so we exclude Clang here. + */ + +#elif defined(__APPLE__) && defined(__x86_64__) && defined(__MACH__) \ + && defined(__GNUC__) && !defined(__clang__) +#if defined(CONFIG_PF_STRING) && ! defined(CONFIG_PF_XCI6GC) +#error "specified CONFIG_PF_... inconsistent with detected xci6gc" +#endif +#define MPS_PF_XCI6GC +#define MPS_PF_STRING "xci6gc" +#define MPS_OS_XC +#define MPS_ARCH_I6 +#define MPS_BUILD_GC +#define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long +#define MPS_WORD_WIDTH 64 +#define MPS_WORD_SHIFT 6 +#define MPS_PF_ALIGN 8 + + /* Apple clang version 3.1, clang -E -dM */ #elif defined(__APPLE__) && defined(__i386__) && defined(__MACH__) \ diff --git a/mps/code/poolams.c b/mps/code/poolams.c index 1137c1864b3..73930e865d5 100644 --- a/mps/code/poolams.c +++ b/mps/code/poolams.c @@ -1828,7 +1828,7 @@ Bool AMSCheck(AMS ams) CHECKS(AMS, ams); CHECKC(AMSPool, ams); CHECKD(Pool, AMSPool(ams)); - CHECKL(IsA(AMSPool, AMSPool(ams))); + CHECKL(IsA(AMSPool, ams)); CHECKL(PoolAlignment(AMSPool(ams)) == AMSGrainsSize(ams, (Size)1)); CHECKL(PoolAlignment(AMSPool(ams)) == AMSPool(ams)->format->alignment); if (ams->pgen != NULL) { diff --git a/mps/code/poolmv.c b/mps/code/poolmv.c index 55538d65601..e1d4a19fe27 100644 --- a/mps/code/poolmv.c +++ b/mps/code/poolmv.c @@ -915,7 +915,6 @@ Bool MVCheck(MV mv) CHECKS(MV, mv); CHECKC(MVPool, mv); CHECKD(Pool, MVPool(mv)); - CHECKL(IsA(MVPool, MVPool(mv))); CHECKD(MFS, &mv->blockPoolStruct); CHECKD(MFS, &mv->spanPoolStruct); CHECKL(mv->extendBy > 0); diff --git a/mps/code/poolmvff.c b/mps/code/poolmvff.c index f0e6635deaf..5269f233a3e 100644 --- a/mps/code/poolmvff.c +++ b/mps/code/poolmvff.c @@ -68,8 +68,8 @@ DECLARE_CLASS(Pool, MVFFDebugPool, MVFFPool); #define PoolMVFF(pool) PARENT(MVFFStruct, poolStruct, pool) #define MVFFPool(mvff) (&(mvff)->poolStruct) -#define MVFFTotalLand(mvff) CBSLand(&(mvff)->totalCBSStruct) -#define MVFFFreePrimary(mvff) CBSLand(&(mvff)->freeCBSStruct) +#define MVFFTotalLand(mvff) (&(mvff)->totalCBSStruct.landStruct) +#define MVFFFreePrimary(mvff) (&(mvff)->freeCBSStruct.landStruct) #define MVFFFreeSecondary(mvff) FreelistLand(&(mvff)->flStruct) #define MVFFFreeLand(mvff) FailoverLand(&(mvff)->foStruct) #define MVFFLocusPref(mvff) (&(mvff)->locusPrefStruct) @@ -779,7 +779,6 @@ static Bool MVFFCheck(MVFF mvff) CHECKS(MVFF, mvff); CHECKC(MVFFPool, mvff); CHECKD(Pool, MVFFPool(mvff)); - CHECKL(IsA(MVFFPool, MVFFPool(mvff))); CHECKD(LocusPref, MVFFLocusPref(mvff)); CHECKL(mvff->extendBy >= ArenaGrainSize(PoolArena(MVFFPool(mvff)))); CHECKL(mvff->avgSize > 0); /* see .arg.check */ diff --git a/mps/code/poolsnc.c b/mps/code/poolsnc.c index d7ce8d1ff03..db0cb5f6173 100644 --- a/mps/code/poolsnc.c +++ b/mps/code/poolsnc.c @@ -698,7 +698,6 @@ static Bool SNCCheck(SNC snc) CHECKS(SNC, snc); CHECKC(SNCPool, snc); CHECKD(Pool, SNCPool(snc)); - CHECKL(ClassOfPoly(Pool, SNCPool(snc)) == CLASS(SNCPool)); if (snc->freeSegs != NULL) { CHECKD(Seg, snc->freeSegs); } diff --git a/mps/code/protocol.h b/mps/code/protocol.h index bbdcfc33983..572617ff725 100644 --- a/mps/code/protocol.h +++ b/mps/code/protocol.h @@ -74,11 +74,13 @@ * * We use the address of the static storage for the canonical class * object as the class id, suitable for fast comparison. This is not - * intended to be dereferences, so it's defined as a pointer to an - * incomplete structure. + * intended to be dereferences. We would like to define it as a + * pointer to an incomplete structure, but GCC 4.7 buggily complains + * about punning if we do that, so use void *, even though that's a + * bit more error prone. */ -typedef struct ClassIdStruct *ClassId; +typedef void *ClassId; #define CLASS_ID(klass) ((ClassId)&CLASS_STATIC(klass)) diff --git a/mps/code/xci6gc.gmk b/mps/code/xci6gc.gmk new file mode 100644 index 00000000000..fe23f76f4ad --- /dev/null +++ b/mps/code/xci6gc.gmk @@ -0,0 +1,69 @@ +# -*- makefile -*- +# +# xci6gc.gmk: BUILD FOR MAC OS X/x86_64/GCC PLATFORM +# +# $Id$ +# Copyright (c) 2001-2016 Ravenbrook Limited. See end of file for license. +# +# .prefer.xcode: The documented and preferred way to develop the MPS +# for this platform is to use the Xcode project (mps.xcodeproj). This +# makefile provides a way to compile the MPS one source file at a +# time, rather than all at once via mps.c (which can hide errors due +# to missing headers). + +PFM = xci6gc + +MPMPF = \ + lockix.c \ + prmci6xc.c \ + proti6.c \ + protix.c \ + protxc.c \ + span.c \ + ssixi6.c \ + thxc.c \ + vmix.c + +include gc.gmk +include comm.gmk + + +# C. COPYRIGHT AND LICENSE +# +# Copyright (C) 2001-2016 Ravenbrook Limited . +# All rights reserved. This is an open source license. Contact +# Ravenbrook for commercial licensing options. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Redistributions in any form must be accompanied by information on how +# to obtain complete source code for this software and any accompanying +# software that uses this software. The source code must either be +# included in the distribution or be available for no more than the cost +# of distribution plus a nominal fee, and must be freely redistributable +# under reasonable conditions. For an executable file, complete source +# code means the source code for all modules it contains. It does not +# include source code for modules or files that typically accompany the +# major components of the operating system on which the executable file +# runs. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.