]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix longstanding bug in dual-arch support, which originated in
authorJulian Seward <jseward@acm.org>
Fri, 19 Sep 2008 09:02:19 +0000 (09:02 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 19 Sep 2008 09:02:19 +0000 (09:02 +0000)
memcheck/tests/Makefile.am and was copied into drd/tests/Makefile.am.

When building regtests for a 32-bit only build on a 64-bit CPU, the
use of $(VG_ARCH) in these Makefiles is incorrect, because VG_ARCH
will be set to the 64-bit architecture, not the 32-bit architecture.

See comments on VG_ARCH_PRI and VG_ARCH_MAX in configure.in for more
details.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8623

configure.in
docs/internals/multiple-architectures.txt
drd/tests/Makefile.am
memcheck/tests/Makefile.am
none/tests/x86/Makefile.am
tests/Makefile.am

index 001c45c5063bbd95b43f373ff80aa1a36c940cbe..422406cb0773ec6cccb937c472cdbf31ad625e8a 100644 (file)
@@ -126,15 +126,22 @@ case "${gcc_version}" in
 esac
 
 
-# Checks for the platform, with the aim of setting VG_ARCH.  Note
-# that VG_ARCH must be set to reflect the most that this CPU can
-# do: for example if it is a 64-bit capable PowerPC, then it must
-# be set to ppc64 and not ppc32.  Ditto for amd64.
+# Checks for the platform, with the aim of setting VG_ARCH_MAX.  Note
+# that VG_ARCH_MAX must be set to reflect the most that this CPU can
+# do: for example if it is a 64-bit capable PowerPC, then it must be
+# set to ppc64 and not ppc32.  Ditto for amd64.
+#
+# We will later in this file set VG_ARCH_PRI, which is the arch for
+# the primary target.  For example, suppose we do a build on an amd64
+# machine, but --enable-only32bit has been requested.  Then
+# VG_ARCH_MAX will be "amd64" since that reflects the most that this
+# cpu can do, but VG_ARCH_PRI will be "x86", since that reflects the
+# arch corresponding to the primary build (VG_PLATFORM_PRI).
 
 AC_CANONICAL_HOST
 
 AC_MSG_CHECKING([for a supported CPU])
-AC_SUBST(VG_ARCH)
+AC_SUBST(VG_ARCH_MAX)
 
 AC_SUBST(VG_ARCH_ALL)
 VG_ARCH_ALL="amd64 ppc32 ppc64 x86"
@@ -144,14 +151,14 @@ AC_SUBST(VALT_LOAD_ADDRESS)
 case "${host_cpu}" in
      i?86) 
        AC_MSG_RESULT([ok (${host_cpu})])
-        VG_ARCH="x86"
+        VG_ARCH_MAX="x86"
         valt_load_address_normal="0x38000000"
         valt_load_address_inner="0x28000000"
         ;;
 
      x86_64) 
         AC_MSG_RESULT([ok (${host_cpu})])
-        VG_ARCH="amd64"
+        VG_ARCH_MAX="amd64"
         valt_load_address_normal="0x38000000"
         valt_load_address_inner="0x28000000"
         ;;
@@ -159,7 +166,7 @@ case "${host_cpu}" in
      powerpc64)
 #       This value can only happen on Linux, not on AIX
         AC_MSG_RESULT([ok (${host_cpu})])
-        VG_ARCH="ppc64"
+        VG_ARCH_MAX="ppc64"
         valt_load_address_normal="0x38000000"
         valt_load_address_inner="0x28000000"
         ;;
@@ -170,10 +177,10 @@ case "${host_cpu}" in
         AC_MSG_RESULT([ok (${host_cpu})])
        case "${host_os}" in
           aix5.*)
-             VG_ARCH="ppc64"
+             VG_ARCH_MAX="ppc64"
               ;;
            *)
-              VG_ARCH="ppc32"
+              VG_ARCH_MAX="ppc32"
               ;;
         esac
         valt_load_address_normal="0x38000000"
@@ -287,7 +294,7 @@ esac
 # supports building 32 bit programs and disable 32 bit support if it
 # does not support building 32 bit programs
 
-case "$VG_ARCH-$VG_OS" in
+case "$VG_ARCH_MAX-$VG_OS" in
      amd64-linux|ppc64-linux)
         AC_MSG_CHECKING([for 32 bit build support])
         safe_CFLAGS=$CFLAGS
@@ -317,12 +324,23 @@ fi
 # possible.  The system will also be built for this target, but not
 # the regression or performance tests.
 #
+# Also establish VG_ARCH_PRI, which is the arch for the primary
+# build target.  The various makefiles building regression tests
+# sometimes need to see this.
 AC_MSG_CHECKING([for a supported CPU/OS combination])
 
 AC_SUBST(VG_PLATFORM_PRI)
 AC_SUBST(VG_PLATFORM_SEC)
+AC_SUBST(VG_ARCH_PRI)
+
+# By default, the primary arch is the same as the "max" arch, as
+# commented above (at the definition of VG_ARCH_MAX).  We may choose
+# to downgrade it in the big case statement just below here, in the
+# case where we're building on a 64 bit machine but have been
+# requested only to do a 32 bit build.
+VG_ARCH_PRI=$VG_ARCH_MAX
 
-case "$VG_ARCH-$VG_OS" in
+case "$VG_ARCH_MAX-$VG_OS" in
      x86-linux)
        VG_PLATFORM_PRI="X86_LINUX"
        VG_PLATFORM_SEC=""
@@ -335,6 +353,7 @@ case "$VG_ARCH-$VG_OS" in
        elif test x$vg_cv_only32bit = xyes; then
           VG_PLATFORM_PRI="X86_LINUX"
           VG_PLATFORM_SEC=""
+          VG_ARCH_PRI="x86"
        else
           VG_PLATFORM_PRI="AMD64_LINUX"
           VG_PLATFORM_SEC="X86_LINUX"
@@ -353,6 +372,7 @@ case "$VG_ARCH-$VG_OS" in
        elif test x$vg_cv_only32bit = xyes; then
           VG_PLATFORM_PRI="PPC32_AIX5"
           VG_PLATFORM_SEC=""
+          VG_ARCH_PRI="ppc32"
        else
           VG_PLATFORM_PRI="PPC64_AIX5"
           VG_PLATFORM_SEC="PPC32_AIX5"
@@ -366,6 +386,7 @@ case "$VG_ARCH-$VG_OS" in
        elif test x$vg_cv_only32bit = xyes; then
           VG_PLATFORM_PRI="PPC32_LINUX"
           VG_PLATFORM_SEC=""
+          VG_ARCH_PRI="ppc32"
        else
           VG_PLATFORM_PRI="PPC64_LINUX"
           VG_PLATFORM_SEC="PPC32_LINUX"
@@ -1529,9 +1550,12 @@ AC_OUTPUT(
 
 cat<<EOF
 
-   Primary build target: ${VG_PLATFORM_PRI}
- Secondary build target: ${VG_PLATFORM_SEC}
-     Default supp files: ${DEFAULT_SUPP}
+ configure.in: VG_ARCH_MAX = ${VG_ARCH_MAX}
+ configure.in: VG_ARCH_PRI = ${VG_ARCH_PRI}
+
+       Primary build target: ${VG_PLATFORM_PRI}
+     Secondary build target: ${VG_PLATFORM_SEC}
+         Default supp files: ${DEFAULT_SUPP}
 
 EOF
 
index 0c27a3cbb0caf7feb7002f3f026fbdf566e28adf..5c5eece1d5c2d93687eec02cbd2cf83df297f051 100644 (file)
@@ -158,5 +158,7 @@ whether -m32 or -m64 is the right thing to specify.  So instead of
 messing with AM_FLAG_M3264_PRI, these directories merely specific
 @FLAG_M32@ or @FLAG_M64@ directly.  (These two symbols are also
 automagically set up by configure.in.  Do not use -m32 and -m64
-directly - older compilers barf on them).
-
+directly - older compilers barf on them).  Another reason not to
+use -m32 and -m64 directly is that they are called -maix32 and 
+-maix64 on AIX; once again this is taken care of properly if you
+use @FLAG_M32@ and @FLAG_M64@ instead.
index 88ee58c565fc7f94d5559bcd192f6e1053cf5362..8dce8bc88ce7a78549ccb0c7ae8558ce368ee9ee 100644 (file)
@@ -179,8 +179,8 @@ EXTRA_DIST =                                        \
        trylock.vgtest
 
 AM_CFLAGS   = $(WERROR) -Wall @FLAG_W_EXTRA@ -Wno-inline -Wno-unused-parameter\
-              -g $(AM_FLAG_M3264_PRI) -DVGA_$(VG_ARCH)=1 -DVGO_$(VG_OS)=1 \
-              -DVGP_$(VG_ARCH)_$(VG_OS)=1
+              -g $(AM_FLAG_M3264_PRI) -DVGA_$(VG_ARCH_PRI)=1 -DVGO_$(VG_OS)=1 \
+              -DVGP_$(VG_ARCH_PRI)_$(VG_OS)=1
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include \
               -I$(top_builddir)/include -I$(top_srcdir)/VEX/pub
 AM_CXXFLAGS = $(AM_CFLAGS)
index f5c5c0bf277a3adf879f655d6c27faa5dd96e9de..c11149f4ef99d53104be3f5812c0bc21cd8ec7d3 100644 (file)
@@ -236,8 +236,8 @@ AM_CXXFLAGS = $(AM_CFLAGS)
 # Extra stuff for C tests
 memcmptest_CFLAGS      = $(AM_FLAG_M3264_PRI) $(AM_CFLAGS) -fno-builtin-memcmp
 oset_test_CFLAGS       = $(AM_FLAG_M3264_PRI) \
-                               -DVGA_$(VG_ARCH)=1 -DVGO_$(VG_OS)=1 \
-                               -DVGP_$(VG_ARCH)_$(VG_OS)=1
+                               -DVGA_$(VG_ARCH_PRI)=1 -DVGO_$(VG_OS)=1 \
+                               -DVGP_$(VG_ARCH_PRI)_$(VG_OS)=1
 linux_timerfd_syscall_LDADD = -lrt
 vcpu_bz2_CFLAGS                = $(AM_FLAG_M3264_PRI) $(AM_CFLAGS) -O2 -g
 vcpu_fbench_CFLAGS     = $(AM_FLAG_M3264_PRI) $(AM_CFLAGS) -O2 -g
@@ -363,6 +363,6 @@ endif
 #hello_DEPENDENCIES    = $(top_builddir)/valt_load_address.lds
 
 # vgtest_ume is not working
-#vgtest_ume_CFLAGS     = -DVGA_$(VG_ARCH) -DVGO_$(VG_OS)
+#vgtest_ume_CFLAGS     = -DVGA_$(VG_ARCH_PRI) -DVGO_$(VG_OS)
 #vgtest_ume_LDADD      = ../../coregrind/m_ume.o
 
index e68e1dab0baeb8c23a0939f49441d22aebbcb64e..f9893a4930b913a02eab429cad8e75138b15ed65 100644 (file)
@@ -100,7 +100,7 @@ insn_sse2_SOURCES   = insn_sse2.def
 insn_sse2_LDADD                = -lm
 insn_sse3_SOURCES      = insn_sse3.def
 insn_sse3_LDADD                = -lm
-yield_CFLAGS           = $(AM_CFLAGS) -D__$(VG_ARCH)__
+yield_CFLAGS           = $(AM_CFLAGS) -D__$(VG_ARCH_MAX)__
 yield_LDADD            = -lpthread
 
 .def.c: $(srcdir)/gen_insn_test.pl
index 0cc96e1ea572af58f758f02b12c8a670abb1b529..5dfdf562dffd7d562d4c6ffab2a8b43bf92c2c1b 100644 (file)
@@ -24,7 +24,7 @@ AM_CXXFLAGS = $(AM_CFLAGS)
 
 # generic C ones
 cputest_SOURCES        = cputest.c
-cputest_CFLAGS         = $(AM_CFLAGS) -D__$(VG_ARCH)__
+cputest_CFLAGS         = $(AM_CFLAGS) -D__$(VG_ARCH_MAX)__
 cputest_DEPENDENCIES   = 
 cputest_LDADD          = 
 toobig_allocs_SOURCES  = toobig-allocs.c