https://bugs.kde.org/show_bug.cgi?id=483711

John Reiser <jrei...@bitwagon.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jrei...@bitwagon.com

--- Comment #6 from John Reiser <jrei...@bitwagon.com> ---
TLDR: RFE: configure script should support 32-bit arm targets on 64-bit Linux
for arm64 (aarch64)

Details:
The `configure` script for valgrind believes that specifying "gcc -m32" is all
that is necessary to build a valgrind that analyzes 32-bit programs.  This may
be true on amd64 (x86_64 hardware and OS running i686 targets) and perhaps
other "big iron" machines such as SPARC, but is false for arm64 (aarch64 and
OS) running arm ("arm32") targets.  In particular, "gcc -m32" fails on Debian
trixie Linux (now version "testing", will become "stable" Debian-13 in summer
2025 [7 months from now]).  So this Comment is a RFE (Request For Enhancement)
to handle "Secondary build architecture" for arm64/arm32.

Running 64-bit  Debian-testing Linux operating system (version "trixie") on 
RaspberryPi model 3 B V1.2 hardware ("arm64" or Aarch64-A), the valgrind
configure script ends with output:
=====
                    Version: 3.25.0.GIT
         Maximum build arch: arm64
         Primary build arch: arm64
       Secondary build arch: 
                   Build OS: linux
     Link Time Optimisation: no
       Primary build target: ARM64_LINUX
     Secondary build target: 
           Platform variant: vanilla
      Primary -DVGPV string: -DVGPV_arm64_linux_vanilla=1
         Default supp files: ./xfree-3.supp ./xfree-4.supp glibc-2.X-drd.supp
glibc-2.X-helgrind.supp glibc-2.X.supp
=====
Note that the Secondary build arch is empty. The RFE: there should be a way for
the configure script to decide that "arm32" is a legitimate target.
Unfortunately it's complicated, because there are at least two 32-bit arm
targets: 'arm' (base level "vanilla" hardware, v7 and above, sometimes called
'arm7hl' ) and 'armhf' (v7 plus hardware instructions for floating point
arithmetic), and the procedure calling conventions are DIFFERENT for
floating-point values.  [Things would be simpler if valgrind (or at least
memcheck) would guarantee not to use any floating point values internally, so
that the same compiled binary 32-bit code for memcheck would run identically on
both 32-bit flavors.]

On my RPi with 64-bit Debian "trixie", I have the packages:
=====
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  gcc-12         12.4.0-2     arm64        GNU C compiler
ii  gcc-13         13.3.0-8     arm64        GNU C compiler
ii  gcc-14         14.2.0-8     arm64        GNU C compiler
=====
and each of them fails to recognize "-m32":
=====
$ gcc-12 -m32 --version
gcc-12: error: unrecognized command-line option '-m32'
gcc-12 (Debian 12.4.0-2) 12.4.0
$ gcc-13 -m32 --version
gcc-13: error: unrecognized command-line option '-m32'
gcc-13 (Debian 13.3.0-8) 13.3.0
$ gcc -m32 --version
gcc: error: unrecognized command-line option '-m32'
gcc (Debian 14.2.0-8) 14.2.0
=====

For compiling 32-bit arm software on arm64, I have the packages
   gcc-arm-linux-gnueabihf: /usr/bin/arm-linux-gnueabihf-gcc
   gcc-arm-linux-gnueabi: /usr/bin/arm-linux-gnueabi-gcc
which already generate 32-bit code without requiring "-m32" parameter, and also
=====
$ /usr/bin/clang-14 -m32 --version
Debian clang version 14.0.6
Target: arm-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ /usr/bin/clang-16 -m32 --version
Debian clang version 16.0.6 (20)
Target: arm-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
=====
So clang DOES recognize "-m32".  But clang  says that another parameter
should be specified, too:
=====
$ clang-16 -m32 hello.c
clang: warning: unknown platform, assuming -mfloat-abi=soft
clang: warning: unknown platform, assuming -mfloat-abi=soft
clang: warning: unknown platform, assuming -mfloat-abi=soft
clang: warning: unknown platform, assuming -mfloat-abi=soft
clang: warning: unknown platform, assuming -mfloat-abi=soft
=====

Workaround:  Before running the configure script, then I will
   export GCC=$HOME/bin/my gcc-32-or-64
so that $(GCC) designates a shell script
that figures out which compiler to run:
=====
   new_args=""
   mode="-m64"  # default on this 64-bit machine

   # Pick the last explicit -m32 or -m64 specifier (and delete it)
   for arg in "$*"; do case "$arg" in
    -m32) mode="-m32" ;;
    -m64) mode="-m64" ;;
    *)  new_args = "$new_args $arg"
  esac
  case "$mode" in
    -m32) exec  gcc-arm-linux-gnueabi  $new_args ;;
    -m64) exec gcc-14  $new_args ;;
  esac
=====
[and figure ou thow to handle embedded whitespace within an arg.]

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to