#1102074 libstdc++-12-dev: _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY differs between Debian and Raspberry Pi OS (tested on armhf)

Package:
libstdc++-12-dev
Source:
libstdc++-12-dev
Description:
GNU Standard C++ Library v3 (development files)
Submitter:
Andrew Sayers
Date:
2025-04-04 18:33:01 UTC
Severity:
normal
#1102074#5
Date:
2025-04-04 16:08:06 UTC
From:
To:
The  _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY setting differs between Debian
and Raspberry Pi OS, causing programs cross-compiled for Debian Bookworm armhf
to appear to run on Rasbperry Pi OS Bookworm armhf, then later crash
for no obvious reason.  For details, see the (now closed) upstream bug report:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119627

I'm not sure whether the Debian or Raspberry Pi OS version is correct,
but the Debian GCC Maintainers are listed as the maintainer for both,
so either way I assume this is the right place to report this issue.

# STEPS TO REPLICATE

1. Download and extract Debian's libstdc++-12-dev and libstdc++-12-dev-armhf-
cross,
   plus Raspberry Pi OS's libstdc++-12-dev:

wget
'http://ftp.debian.org/debian/pool/main/g/gcc-12/libstdc++-12-dev_12.2.0-14_armhf.deb'
\
     'http://ftp.debian.org/debian/pool/main/g/gcc-12-cross/libstdc++-12-dev-
armhf-cross_12.2.0-14cross1_all.deb' \
'http://raspbian.raspberrypi.com/raspbian/pool/main/g/gcc-12/libstdc++-12-dev_12.2.0-14+rpi1_armhf.deb'

dpkg -x libstdc++-12-dev_12.2.0-14_armhf.deb                 main
dpkg -x libstdc++-12-dev-armhf-cross_12.2.0-14cross1_all.deb cross
dpkg -x libstdc++-12-dev_12.2.0-14+rpi1_armhf.deb            rpi

2. Observe the value for _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY in all three
packages:

grep _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY \
      main/usr/include/arm-linux-gnueabihf/c++/12/bits/c++config.h \
     cross/usr/arm-linux-gnueabihf/include/c++/12/arm-linux-
gnueabihf/bits/c++config.h \
       rpi/usr/include/arm-linux-gnueabihf/c++/12/bits/c++config.h

Expected:

The Raspberry Pi value is the same as the armhf cross-compile version.

Observed:

main/usr/include/arm-linux-gnueabihf/c++/12/bits/c++config.h:#define
_GLIBCXX_HAVE_ATOMIC_LOCK_POLICY 1
cross/usr/arm-linux-gnueabihf/include/c++/12/arm-linux-
gnueabihf/bits/c++config.h:#define _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY 1
rpi/usr/include/arm-linux-gnueabihf/c++/12/bits/c++config.h:/* #undef
_GLIBCXX_HAVE_ATOMIC_LOCK_POLICY */

#1102074#10
Date:
2025-04-04 16:19:53 UTC
From:
To:
W dniu 4.04.2025 o 18:08, Andrew Sayers pisze:

Debian, like many other distributions, agreed years ago that armhf is
ARMv7 with vfp3d16.

Raspberry/Pi OS reused that name but rebuilt everything for ARMv6 to
have software running on Raspberry/Pi 1 and Zero as their SoC had only
armv6 cores.

So you cannot and should not expect binary/toolchain compatibility
between Debian and Raspberry/Pi OS.

#1102074#15
Date:
2025-04-04 16:19:53 UTC
From:
To:
W dniu 4.04.2025 o 18:08, Andrew Sayers pisze:

Debian, like many other distributions, agreed years ago that armhf is
ARMv7 with vfp3d16.

Raspberry/Pi OS reused that name but rebuilt everything for ARMv6 to
have software running on Raspberry/Pi 1 and Zero as their SoC had only
armv6 cores.

So you cannot and should not expect binary/toolchain compatibility
between Debian and Raspberry/Pi OS.

#1102074#20
Date:
2025-04-04 18:05:17 UTC
From:
To:
So to make sure I understand - cross-compiling Debian->Pi arm64 is fine,
but even generic C binaries aren't guaranteed to work on Pi armhf,
and the best way to compile a Pi armhf binary on Debian is with qemubuilder?

Given how much time this has/will cost me, I'm minded to propose a
section in https://wiki.debian.org/CrossCompiling so the next person
doesn't have the same problem.  Anywhere else I could add this?

#1102074#25
Date:
2025-04-04 18:05:17 UTC
From:
To:
So to make sure I understand - cross-compiling Debian->Pi arm64 is fine,
but even generic C binaries aren't guaranteed to work on Pi armhf,
and the best way to compile a Pi armhf binary on Debian is with qemubuilder?

Given how much time this has/will cost me, I'm minded to propose a
section in https://wiki.debian.org/CrossCompiling so the next person
doesn't have the same problem.  Anywhere else I could add this?