This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix alignment for darwin with -Dusemorebits.
authorAndy Dougherty <doughera@lafayette.edu>
Tue, 4 Sep 2012 21:13:34 +0000 (17:13 -0400)
committerAndy Dougherty <doughera@lafayette.edu>
Fri, 7 Sep 2012 18:23:54 +0000 (14:23 -0400)
By default, the darwin build assumes a "multiarchitecture" build.
Configure has a hardwired default of '8' for alignbytes (and then
proceeds to ignore it with another hard-wired '8' in config.h).
That '8' was supposed to be a safe value, in case perl was built
on one architecture but run on another with a stricter constraint.
With darwin and -Dusemorebits, however, the alignment should be on
16-byte boundaries.  We don't want to penalize all darwin builds for
this unlikely configuration, but we do want to allow it.

This patch causes Configure to compute alignbytes even for multiarch
builds, but if the result is less than 8, it sets it to 8 (which preserves
the previous behavior).  If, however, alignbytes is 16, Configure won't
decrease it.  Then, this patch also fixes config_h.SH so that it uses
the value determined by Configure instead of the previous hardwired value.

Configure
config_h.SH
uconfig.h

index a1ba981..7fa1804 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -19022,11 +19022,10 @@ Revision='$Revision'
 
 : check for alignment requirements
 echo " "
-case "$usecrosscompile$multiarch" in
+case "$usecrosscompile" in
 *$define*)
        $cat <<EOM
-You seem to be either cross-compiling or doing a multiarchitecture build,
-skipping the memory alignment check.
+You seem to be cross-compiling.  Skipping the memory alignment check.
 
 EOM
        case "$alignbytes" in
@@ -19064,6 +19063,17 @@ EOCP
                        dflt='8'
                        echo "(I can't seem to compile the test program...)"
                fi
+               case "$multiarch" in
+               *$define*)
+                       : The usual safe value is 8, but Darwin with -Duselongdouble
+                       : needs 16.  Hence, we will take 8 as a minimum, but allow
+                       : Configure to pick a larger value if needed.
+                       if $test "$dflt" -lt 8; then
+                           dflt='8'
+                               echo "Setting alignment to 8 for multiarch support.">&4
+                       fi
+                       ;;
+               esac
                ;;
        *) dflt="$alignbytes"
                ;;
index 988273f..3267fee 100755 (executable)
@@ -949,13 +949,10 @@ sed <<!GROK!THIS! >$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un
 /* MEM_ALIGNBYTES:
  *     This symbol contains the number of bytes required to align a
  *     double, or a long double when applicable. Usual values are 2,
- *     4 and 8. The default is eight, for safety.
+ *     4 and 8. The default is eight, for safety.  For cross-compiling
+ *     or multiarch support, Configure will set a minimum of 8.
  */
-#if defined(USE_CROSS_COMPILE) || defined(MULTIARCH)
-#  define MEM_ALIGNBYTES 8
-#else
 #define MEM_ALIGNBYTES $alignbytes
-#endif
 
 /* ARCHLIB:
  *     This variable, if defined, holds the name of the directory in
index ddae7ca..c606e6e 100644 (file)
--- a/uconfig.h
+++ b/uconfig.h
 /* MEM_ALIGNBYTES:
  *     This symbol contains the number of bytes required to align a
  *     double, or a long double when applicable. Usual values are 2,
- *     4 and 8. The default is eight, for safety.
+ *     4 and 8. The default is eight, for safety.  For cross-compiling
+ *     or multiarch support, Configure will set a minimum of 8.
  */
-#if defined(USE_CROSS_COMPILE) || defined(MULTIARCH)
-#  define MEM_ALIGNBYTES 8
-#else
 #define MEM_ALIGNBYTES 4
-#endif
 
 /* ARCHLIB:
  *     This variable, if defined, holds the name of the directory in
 #endif
 
 /* Generated from:
- * 55f6d0595668c028fe4021a469971587307b23080241f008057ee1aba71a73c9 config_h.SH
+ * b715233966bd9d5369e407526f95e2d6a28d5e6d8a9501ea859304bbe4fd4524 config_h.SH
  * 0b6320512dbf7572c05acf6d6add343230d232f287d02f6d32a7a32edadd97b9 uconfig.sh
  * ex: set ro: */