Re: GPC doesn't build on powerpc
Peter Gerwinski writes:
> Daniel Jacobowitz wrote:
> > There's a bit of a problem with the patch to stor-layout.c:
> >
> > 64 int set_words_big_endian = BYTES_BIG_ENDIAN;
> >
> > BYTES_BIG_ENDIAN is not guaranteed to be a constant. And in fact, on
> > powerpc, it isn't one. So this fails with an 'initializer not
> > constant' error.
>
> This initialization only matters for Chill; for Pascal you can
> just drop the initialization.
untested patch follows (applies cleanly) ...
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1999-10-27 17:46 MEST by <doko@hal>.
# Source directory was `/home/itso/doko/src/gcc/gcc-2.95.2'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 8433 -rw-r--r-- debian/patches/gpc-2.95.diff
# 856 -rwxr-xr-x debian/patches/gpc-2.95.dpatch
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
if test "$gettext_dir" = FAILED && test -f $dir/gettext \
&& ($dir/gettext --version >/dev/null 2>&1)
then
set `$dir/gettext --version 2>&1`
if test "$3" = GNU
then
gettext_dir=$dir
fi
fi
if test "$locale_dir" = FAILED && test -f $dir/shar \
&& ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
then
locale_dir=`$dir/shar --print-text-domain-dir`
fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
echo=echo
else
TEXTDOMAINDIR=$locale_dir
export TEXTDOMAINDIR
TEXTDOMAIN=sharutils
export TEXTDOMAIN
echo="$gettext_dir/gettext -s"
fi
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
shar_touch=touch
else
shar_touch=:
echo
$echo 'WARNING: not restoring timestamps. Consider getting and'
$echo "installing GNU \`touch', distributed in GNU File Utilities..."
echo
fi
rm -f 1231235999 $$.touch
#
if mkdir _sh02312; then
$echo 'x -' 'creating lock directory'
else
$echo 'failed to create lock directory'
exit 1
fi
# ============= debian/patches/gpc-2.95.diff ==============
if test ! -d 'debian'; then
$echo 'x -' 'creating directory' 'debian'
mkdir 'debian'
fi
if test ! -d 'debian/patches'; then
$echo 'x -' 'creating directory' 'debian/patches'
mkdir 'debian/patches'
fi
if test -f 'debian/patches/gpc-2.95.diff' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'debian/patches/gpc-2.95.diff' '(file already exists)'
else
$echo 'x -' extracting 'debian/patches/gpc-2.95.diff' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'debian/patches/gpc-2.95.diff' &&
Changes for GCC version 2.95.1 for GNU Pascal 2.1
X
Before applying these diffs, go to the directory gcc-2.95.1
and use the command
X
X patch -p1
X
feeding it the following diffs as input.
X
*** gcc-2.95.1/expr.c.orig Thu Jul 1 00:59:55 1999
--- gcc-2.95.1/expr.c Mon Oct 18 23:49:09 1999
*************** store_constructor (exp, target, cleared)
*** 4430,4435 ****
--- 4430,4444 ----
X
X domain_min = convert (sizetype, TYPE_MIN_VALUE (domain));
X domain_max = convert (sizetype, TYPE_MAX_VALUE (domain));
+
+ #ifdef GPC
+ /* Align the set. */
+ if (set_alignment)
+ domain_min = size_binop (MINUS_EXPR, domain_min,
+ size_binop (TRUNC_MOD_EXPR, domain_min,
+ size_int (set_alignment)));
+ #endif /* GPC */
+
X bitlength = size_binop (PLUS_EXPR,
X size_binop (MINUS_EXPR, domain_max, domain_min),
X size_one_node);
*************** store_constructor (exp, target, cleared)
*** 4444,4450 ****
--- 4453,4461 ----
X if (GET_MODE (target) != BLKmode || nbits <= 2 * BITS_PER_WORD
X || (nbytes <= 32 && TREE_CHAIN (elt) != NULL_TREE))
X {
+ #ifndef GPC
X int set_word_size = TYPE_ALIGN (TREE_TYPE (exp));
+ #endif /* not GPC */
X enum machine_mode mode = mode_for_size (set_word_size, MODE_INT, 1);
X char *bit_buffer = (char *) alloca (nbits);
X HOST_WIDE_INT word = 0;
*************** store_constructor (exp, target, cleared)
*** 4456,4462 ****
--- 4467,4477 ----
X {
X if (bit_buffer[ibit])
X {
+ #ifdef GPC
+ if (set_words_big_endian)
+ #else /* not GPC */
X if (BYTES_BIG_ENDIAN)
+ #endif /* not GPC */
X word |= (1 << (set_word_size - 1 - bit_pos));
X else
X word |= 1 << bit_pos;
*************** expand_expr (exp, target, tmode, modifie
*** 7273,7282 ****
--- 7288,7311 ----
X case ABS_EXPR:
X op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
X
+ #ifdef GPC
+ /* Handle complex values specially.
+ It is the mode of the operand, not the mode of the return
+ value that is tested here. ABS(complex) does not return
+ complex type. */
+ {
+ enum machine_mode op0_mode =
+ TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)));
+ if (GET_MODE_CLASS (op0_mode) == MODE_COMPLEX_INT
+ || GET_MODE_CLASS (op0_mode) == MODE_COMPLEX_FLOAT)
+ return expand_complex_abs (op0_mode, op0, target, unsignedp);
+ }
+ #else /* not GPC */
X /* Handle complex values specially. */
X if (GET_MODE_CLASS (mode) == MODE_COMPLEX_INT
X || GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT)
X return expand_complex_abs (mode, op0, target, unsignedp);
+ #endif /* not GPC */
X
X /* Unsigned abs is simply the operand. Testing here means we don't
X risk generating incorrect code below. */
*** gcc-2.95.1/stor-layout.c.orig Thu Mar 11 14:56:20 1999
--- gcc-2.95.1/stor-layout.c Mon Oct 18 12:32:30 1999
*************** int maximum_field_alignment;
*** 53,58 ****
--- 53,69 ----
X May be overridden by front-ends. */
X int set_alignment = 0;
X
+ #ifdef GPC
+ /* The word size of a bitstring or (power-)set value, in bits.
+ Must be non-zero.
+ May be overridden by front-ends. */
+ int set_word_size = BITS_PER_UNIT;
+
+ /* If non-zero, bits in (power-)sets start with the highest bit.
+ May be overridden by front-ends. */
+ int set_words_big_endian /* = BYTES_BIG_ENDIAN */;
+ #endif /* GPC */
+
X static tree layout_record PROTO((tree));
X static void layout_union PROTO((tree));
X
*************** static tree pending_sizes;
*** 65,70 ****
--- 76,88 ----
X
X int immediate_size_expand;
X
+ #ifdef GPC
+ /* Nonzero means that the size of a type may vary
+ within one function context. */
+
+ int size_volatile = 0;
+ #endif /* GPC */
+
X tree
X get_pending_sizes ()
X {
*************** variable_size (size)
*** 102,108 ****
--- 120,131 ----
X || global_bindings_p () < 0 || contains_placeholder_p (size))
X return size;
X
+ #ifdef GPC
+ if (! size_volatile)
+ size = save_expr (size);
+ #else /* not GPC */
X size = save_expr (size);
+ #endif
X
X if (global_bindings_p ())
X {
*************** variable_size (size)
*** 119,125 ****
--- 142,152 ----
X Also, we would like to pass const0_rtx here, but don't have it. */
X expand_expr (size, expand_expr (integer_zero_node, NULL_PTR, VOIDmode, 0),
X VOIDmode, 0);
+ #ifdef GPC
+ else if (! size_volatile)
+ #else /* not GPC */
X else
+ #endif
X pending_sizes = tree_cons (NULL_TREE, size, pending_sizes);
X
X return size;
*************** layout_type (type)
*** 1040,1045 ****
--- 1067,1086 ----
X abort();
X else
X {
+ #ifdef GPC
+ int alignment = set_alignment ? set_alignment : set_word_size;
+ int lower_bound = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (type)));
+ int upper_bound = TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
+ int size_in_bits, rounded_size;
+ if (set_alignment)
+ size_in_bits = upper_bound - (lower_bound / alignment) * alignment + 1;
+ else
+ size_in_bits
+ = (TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
+ - TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) + 1);
+ rounded_size
+ = ((size_in_bits + alignment - 1) / alignment) * alignment;
+ #else /* not GPC */
X #ifndef SET_WORD_SIZE
X #define SET_WORD_SIZE BITS_PER_WORD
X #endif
*************** layout_type (type)
*** 1049,1054 ****
--- 1090,1096 ----
X - TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) + 1);
X int rounded_size
X = ((size_in_bits + alignment - 1) / alignment) * alignment;
+ #endif /* not GPC */
X if (rounded_size > alignment)
X TYPE_MODE (type) = BLKmode;
X else
*** gcc-2.95.1/tree.c.orig Wed Sep 29 19:41:05 1999
--- gcc-2.95.1/tree.c Tue Oct 19 00:04:25 1999
*************** get_set_constructor_bits (init, buffer,
*** 4986,4991 ****
--- 4986,4998 ----
X HOST_WIDE_INT domain_min
X = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (init))));
X tree non_const_bits = NULL_TREE;
+
+ #ifdef GPC
+ /* Align the set. */
+ if (set_alignment)
+ domain_min -= domain_min % set_alignment;
+ #endif /* GPC */
+
X for (i = 0; i < bit_size; i++)
X buffer[i] = 0;
X
*************** get_set_constructor_bytes (init, buffer,
*** 5038,5045 ****
--- 5045,5056 ----
X int wd_size;
X {
X int i;
+ #ifdef GPC
+ int bit_size = wd_size * BITS_PER_UNIT;
+ #else /* not GPC */
X int set_word_size = BITS_PER_UNIT;
X int bit_size = wd_size * set_word_size;
+ #endif /* not GPC */
X int bit_pos = 0;
X unsigned char *bytep = buffer;
X char *bit_buffer = (char *) alloca(bit_size);
*************** get_set_constructor_bytes (init, buffer,
*** 5050,5055 ****
--- 5061,5084 ----
X
X for (i = 0; i < bit_size; i++)
X {
+ #ifdef GPC
+ if (bit_buffer[i])
+ {
+ int k = bit_pos / BITS_PER_UNIT;
+ if (WORDS_BIG_ENDIAN)
+ k = set_word_size / BITS_PER_UNIT - 1 - k;
+ if (set_words_big_endian)
+ bytep[k] |= (1 << (BITS_PER_UNIT - 1 - bit_pos % BITS_PER_UNIT));
+ else
+ bytep[k] |= 1 << (bit_pos % BITS_PER_UNIT);
+ }
+ bit_pos++;
+ if (bit_pos >= set_word_size)
+ {
+ bit_pos = 0;
+ bytep += set_word_size / BITS_PER_UNIT;
+ }
+ #else /* not GPC */
X if (bit_buffer[i])
X {
X if (BYTES_BIG_ENDIAN)
*************** get_set_constructor_bytes (init, buffer,
*** 5060,5065 ****
--- 5089,5095 ----
X bit_pos++;
X if (bit_pos >= set_word_size)
X bit_pos = 0, bytep++;
+ #endif /* not GPC */
X }
X return non_const_bits;
X }
*** gcc-2.95.1/tree.h.orig Mon Oct 18 12:19:46 1999
--- gcc-2.95.1/tree.h Mon Oct 18 12:36:04 1999
*************** extern int maximum_field_alignment;
*** 1630,1635 ****
--- 1630,1643 ----
X /* If non-zero, the alignment of a bitstring or (power-)set value, in bits. */
X extern int set_alignment;
X
+ #ifdef GPC
+ /* The word size of a bitstring or (power-)set value, in bits. */
+ extern int set_word_size;
+
+ /* If non-zero, bits in (power-)sets start with the highest bit. */
+ extern int set_words_big_endian;
+ #endif /* GPC */
+
X /* Concatenate two lists (chains of TREE_LIST nodes) X and Y
X by making the last node in X point to Y.
X Returns X, except if X is 0 returns Y. */
SHAR_EOF
$shar_touch -am 102717411999 'debian/patches/gpc-2.95.diff' &&
chmod 0644 'debian/patches/gpc-2.95.diff' ||
$echo 'restore of' 'debian/patches/gpc-2.95.diff' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'debian/patches/gpc-2.95.diff:' 'MD5 check failed'
a3f938b961df4ea65bf4a6fef8eced4c debian/patches/gpc-2.95.diff
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'debian/patches/gpc-2.95.diff'`"
test 8433 -eq "$shar_count" ||
$echo 'debian/patches/gpc-2.95.diff:' 'original size' '8433,' 'current size' "$shar_count!"
fi
fi
# ============= debian/patches/gpc-2.95.dpatch ==============
if test -f 'debian/patches/gpc-2.95.dpatch' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'debian/patches/gpc-2.95.dpatch' '(file already exists)'
else
$echo 'x -' extracting 'debian/patches/gpc-2.95.dpatch' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'debian/patches/gpc-2.95.dpatch' &&
#! /bin/sh -e
X
# DP: The gpc patch from the gpc-19990813 tarball.
X
if [ "x$gpc_egcs_patch" = "x" ]
then
X gpc_gcc_patch=gcc-2.95.1.diff
fi
X
pdir=gcc
if [ $# -eq 3 -a "$2" = '-d' ]; then
X pdir="$3/gcc"
elif [ $# -ne 1 ]; then
X echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
X exit 1
fi
case "$1" in
X -patch)
X # keep the backup files ... to regenerate p/diffs/${gpc_egcs_patch}
X # dan@debian.org: no, don't. Apply it by hand if you need to regen.
X #patch -d $pdir -f -p1 < $pdir/p/diffs/${gpc_gcc_patch}
X pf=`echo $0 | sed 's/\.dpatch/.diff/'`
X patch -d $pdir -f -p1 < $pf
X ;;
X -unpatch)
X #patch -d $pdir -f -R -p1 < $pdir/p/diffs/${gpc_gcc_patch}
X pf=`echo $0 | sed 's/\.dpatch/.diff/'`
X patch -d $pdir -f -R -p1 < $pf
X ;;
X *)
X echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
X exit 1
esac
Xexit 0
SHAR_EOF
$shar_touch -am 102717441999 'debian/patches/gpc-2.95.dpatch' &&
chmod 0755 'debian/patches/gpc-2.95.dpatch' ||
$echo 'restore of' 'debian/patches/gpc-2.95.dpatch' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'debian/patches/gpc-2.95.dpatch:' 'MD5 check failed'
e69a4818b846e7910df7846d679bbabd debian/patches/gpc-2.95.dpatch
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'debian/patches/gpc-2.95.dpatch'`"
test 856 -eq "$shar_count" ||
$echo 'debian/patches/gpc-2.95.dpatch:' 'original size' '856,' 'current size' "$shar_count!"
fi
fi
rm -fr _sh02312
exit 0
Reply to: