• How to conditionally patch a package based on architecture with debhelp

    From Chris Knadle@21:1/5 to All on Thu Jan 16 16:30:01 2025
    Greetings.

    I have a situation with mumble where the build is breaking on armel architecture. Upstream has identified that this bug is due to the mumble
    "link" plugin containing atomic memory operations. I would like to conditionally patch the source plugins/CMakeLists.txt file based on architecutre to not build that one plugin for armel. CDBS apparently has
    a way of doing this [1] and I would like to find a solution for doing
    this with debhelper. I've been searching and haven't found anything
    quite fitting.

    I suppose in a pinch I could build-depend on the 'patch' command and do something like this in debian/rules:

    ifeq ($(DEB_HOST_ARCH),armel)
            patch < debian/patches/armel/95-fix-build-armel.patch
    endif

    ... but I'm hoping something else already exists for doing this with the
    normal build system or debhelper/dh.

    If someone has a better solution, please let me know.

    Thanks much.

    [1] https://lists.debian.org/debian-devel/2006/11/msg01005.html

       -- Chris

    --
    Chris Knadle
    Chris.Knadle@coredump.us
    Debian developer

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andrey Rakhmatullin@21:1/5 to Chris Knadle on Thu Jan 16 16:50:01 2025
    On Thu, Jan 16, 2025 at 09:48:53AM -0500, Chris Knadle wrote:
    I have a situation with mumble where the build is breaking on armel architecture. Upstream has identified that this bug is due to the mumble "link" plugin containing atomic memory operations. I would like to conditionally patch the source plugins/CMakeLists.txt file based on architecutre to not build that one plugin for armel.

    Consider instead unconditionally patching it in a way that disables the building of that plugin on that arch.

    CDBS apparently has a way of doing this [1] and I would like to find a solution for doing this with debhelper.

    Nowadays changing the upstream source is handled by dpkg, not by d/rules.

    I suppose in a pinch I could build-depend on the 'patch' command and do something like this in debian/rules:

    ifeq ($(DEB_HOST_ARCH),armel)
            patch < debian/patches/armel/95-fix-build-armel.patch
    endif

    If you do this don't forget to do the opposite in clean, as mandated by
    the Policy.


    --
    WBR, wRAR

    -----BEGIN PGP SIGNATURE-----

    iQJhBAABCgBLFiEEolIP6gqGcKZh3YxVM2L3AxpJkuEFAmeJKQAtFIAAAAAAFQAP cGthLWFkZHJlc3NAZ251cGcub3Jnd3JhckBkZWJpYW4ub3JnAAoJEDNi9wMaSZLh Pk0P/3N9RakcJl8FcIDt6fEBYsruUoVFC7ack8CywadruVej/KaSGm+Xi/3pSZN7 5L8Ul6uODVZDqQT0so+1SGiCT99sGRMepMPFYSyRMfQBGBpzr6eGZ5Q9rgQpvXpY /m1tpuddTYQsZZZHKTIOr5rEHWi92czSA6Hq+H2QZeOgd2rAFZz6W5I8kdRCxxW9 hP//F8YGmkB2jaPI6VOL7ZdpIgVB5wM2zz9tDZPDDDXn8Hwjle39nktAAQDIxKmm TAQ2NZUzEv96jKJ9+toUyUdlIiATTCnumLuYbaV9hCDp0kxchiFime529ScmALNH DAfoMs+zL9C8chuXd2jlp4EZjixE8f70QeWCv84DXa9HcGOEYSWC4xVvxfmn1EJU GxZFcwTyI2k3cdasoeFREmcjp4H6stoac1o0v6u6xqje/tsvwo+UbZRHjywkHDfW K+iAVkKbCpmQyyvmKV+LNnBctMJHJ8vN8ipecfef+IqD0xqdThnNGZ50xa13fs5r ZLXsH5eR9nyg3pBOQJYA19eLDwhJe0GmVlzx7J7VVsrKFlq3fyka2dLo3NM1BFop Mm+up0tFDF8BjiW0HXnLOD/1JqRcA1nuICz5AYW2XfMxXGEVVb+yumYNYzvu151R lIVFkLPRCpjdUC9VqwK00MNW6AJdhupNSJe7ybVIkNJAVirZ
    =2K0T
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon Richter@21:1/5 to All on Thu Jan 16 17:00:02 2025
    Hi,

    atomic operations require linking against libatomic — always have. Some architectures inline a few functions, which is how you get away with omitting the library on amd64 most of the time, but this is incorrect.

    No architecture specific patch should be required here, adding libatomic everywhere is fine, possibly via
    -Wl,--push-options,--as-needed,-latomic,--pop-options

    (although as-needed is likely default anyway)

       Simon

    <html>
    <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
    <span dir="ltr" style="margin-top:0; margin-bottom:0;">Hi,</span>
    <br>
    <br><span dir="ltr" style="margin-top:0; margin-bottom:0;">atomic operations require linking against libatomic — always have. Some architectures inline a few functions, which is how you get away with omitting the library on amd64 most of the time,
    but this is incorrect.</span>
    <br>
    <br><span dir="ltr" style="margin-top:0; margin-bottom:0;">No architecture specific patch should be required here, adding libatomic everywhere is fine, possibly via</span>
    <br><span dir="ltr" style="margin-top:0; margin-bottom:0;"> -Wl,--push-options,--as-needed,-latomic,--pop-options</span>
    <br>
    <br><span dir="ltr" style="margin-top:0; margin-bottom:0;">(although as-needed is likely default anyway)</span>
    <br>
    <br><span dir="ltr" style="margin-top:0; margin-bottom:0;">&nbsp;&nbsp; Simon</span>
    <br>
    </body>
    </html>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ben Collins@21:1/5 to Chris Knadle on Thu Jan 16 17:20:02 2025
    On Thu, Jan 16, 2025 at 09:48:53AM -0500, Chris Knadle wrote:
    Greetings.

    I have a situation with mumble where the build is breaking on armel architecture. Upstream has identified that this bug is due to the mumble "link" plugin containing atomic memory operations. I would like to conditionally patch the source plugins/CMakeLists.txt file based on architecutre to not build that one plugin for armel. CDBS apparently has a way of doing this [1] and I would like to find a solution for doing this
    with debhelper. I've been searching and haven't found anything quite
    fitting.

    Can the patched code just look like:

    #ifdef __ARMEL__
    // Patched code
    #else
    // original code with atomic memory ops
    #endif



    --
    Ben Collins
    https://debian.org | https://ubuntu.com
    https://ben-collins.blogspot.com
    https://catchmobilehealth.com
    --
    3EC9 7598 1672 961A 1139 173A 5D5A 57C7 242B 22CF

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEEPsl1mBZylhoRORc6XVpXxyQrIs8FAmeJL4kACgkQXVpXxyQr Is8tWw//dnlH374JGmzPSK6Dd0tCgWbzNgzDc3xVDnSeyX+5HE9QFxy6SSsyBNiJ svAzWpIxOtixpTiYAnPaesvrmGV7ViH99vtuKovdeJ0jOgVZf64hJKnXMcxVSjSf oKpKkPvXmUpnA3qe/6uK2Aq+RqeHWf9Qwb4ZNQxEQCo3x96lJZUOhZw0Ryznqhiq mWzHsQ5EsnUxD8mfsOFNRfj2U/DwZ+HC8shyWljGkkmlfBC88eyKL0RwB4R7qgYh uVytJsvPGTHx0NZgzhuNc68JuSpEKt03r9gRNQf0tzbmXvZ3IIhjPyFqLIVK4hiB lx9b7eIp16UVtF0IaNyP17lYIP4fDUgKFzcP4Mnt8Lb974gRVVvDexvZXX5uFLq3 Egsk5uXU+QPRVBtKQTGxs3qrO/yMyFJgnDsJdzxfJGwsh0/kbNzkpaAFv305T2QV Eu7MKjyeSsB27ZklLnmdr5HQCgoGVQSy+wu2qZ845kTmpLP5NQuq2WeCnGbv00+0 t1CLLI0LleyarDsNtCjz0As4E8bxqqUKZOB94+pvH2v+oaGca4plNKtLklxqm4gZ aCE0lv4NC26CXXLNDzm1NNWMCtzcZ7f61qSgNQXz02a8nVpHoVuljYxpypN+8Z8c IVRm/56hFEcaZyZGvEB/qc8UWOPavXEtihvLS4bc6xazU46Ye5k=
    =k/gs
    -----END PGP SIG
  • From Chris Knadle@21:1/5 to Simon Richter on Thu Jan 16 20:00:01 2025
    On 1/16/25 10:52, Simon Richter wrote:
    Hi,

    atomic operations require linking against libatomic — always have.
    Some architectures inline a few functions, which is how you get away
    with omitting the library on amd64 most of the time, but this is
    incorrect.

    No architecture specific patch should be required here, adding
    libatomic everywhere is fine, possibly via -Wl,--push-options,--as-needed,-latomic,--pop-options

    (although as-needed is likely default anyway)

       Simon

    I'm assuming this also requires adding libatomic1 as a build dependency.
    Huh. So there's a chance this an fix the build for armel too. Nice.

    Thanks.

      -- Chris

    Chris Knadle
    Chris.Knadle@coredump.us

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andrey Rakhmatullin@21:1/5 to Chris Knadle on Thu Jan 16 19:40:01 2025
    On Thu, Jan 16, 2025 at 01:26:39PM -0500, Chris Knadle wrote:
    Looking at the manpage for dpkg-architecture, the variable I may want to conditionally build upon might be DEB_TARGET_ARCH rather than DEB_HOST_ARCH.

    No, it should be DEB_HOST_ARCH. https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html (required
    reading for everyone)


    --
    WBR, wRAR

    -----BEGIN PGP SIGNATURE-----

    iQJhBAABCgBLFiEEolIP6gqGcKZh3YxVM2L3AxpJkuEFAmeJUl8tFIAAAAAAFQAP cGthLWFkZHJlc3NAZ251cGcub3Jnd3JhckBkZWJpYW4ub3JnAAoJEDNi9wMaSZLh OBoQAIf4mBUUrhK40f08H7dUUogtqsVH0+seEeBNhDxRf2Hcl+jkH8jEwInHV7Gg sUi2B5JgSmLZh8PxQ+mOjejwteE5LEAl/qiGO9omfL3iz4V8bO2mphPJXCqz3FRE 77Fwj+3BS8DmfZDhHZ5VJER/+uWVJW+sxWIEr0Xym39JDCLwpDu3SWbHVLA84hxP 5kvJIkqQiiqQwtxWnWQl6RCx4SqHjmIHxwfAogK86wAWuxww18mXQowA4ddoxQUA L2f3LGKPp4rLGZZVIxcpfk/4MzFlKJe4DQUvmHG2tVkcnVXTZ3adkx+V8B/AL5e8 kbBfY7yI0xVQyVL5e6nyMNMRuswAI43pEheKPYeqj3MVH/6WoPnXKkN6QwMjX2KQ jN5F5eYgzfboPu7qXoN17Zj7vc75wBzOcvufIlfxtdDi1OWIbzivkS0PxGdVkx8s CuwfWS9t8IeDuktjULAp/mCcBVFL9kjID2qBU3H7/C0KqcY5b0u8zmFRqe+Rc4id n6W8CFJpUOwafI4m47M9+0XYQorowq9y8fqjXy4CtQv2WeFKX6kQukoPxvy3P+Q9 mRUJYCu+21Xk9T6yOiYbbWyl8EJ27enmPBRhMtLXinMlJy7dIIS9eQ8T2uzrSHGX 3Rm0W/4p/w1QCcGND317zNZ955f3dHl7IQBkQbm07/ih0x1f
    =aHs2
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Knadle@21:1/5 to Ben Collins on Thu Jan 16 19:30:01 2025
    On 1/16/25 11:10, Ben Collins wrote:
    On Thu, Jan 16, 2025 at 09:48:53AM -0500, Chris Knadle wrote:
    Greetings.

    I have a situation with mumble where the build is breaking on armel
    architecture. Upstream has identified that this bug is due to the mumble
    "link" plugin containing atomic memory operations. I would like to
    conditionally patch the source plugins/CMakeLists.txt file based on
    architecutre to not build that one plugin for armel. CDBS apparently has a >> way of doing this [1] and I would like to find a solution for doing this
    with debhelper. I've been searching and haven't found anything quite
    fitting.
    Can the patched code just look like:

    #ifdef __ARMEL__
    // Patched code
    #else
    // original code with atomic memory ops
    #endif

    Thank you. From this good hint I found an additional [1] piece that may
    get the rest of the way
    [And, ironic that this particular post on stackoverflow only received downvotes.]

    ----------------------

    # Store in CMAKE_DEB_HOST_ARCH var the current build architecture
    # (Note: See link [2] below for details for this section) execute_process(COMMAND
      dpkg-architecture
        -qDEB_HOST_ARCH
      OUTPUT_VARIABLE
        CMAKE_DEB_HOST_ARCH
      OUTPUT_STRIP_TRAILING_WHITESPACE
    )

    #And use that information later in CMakeLists

    if(${CMAKE_DEB_HOST_ARCH} MATCHES "armhf")
      ...
    elseif(${CMAKE_DEB_HOST_ARCH} MATCHES "i386")
      ...
    else()
      ...
    endif()

    ----------------------

    Looking at the manpage for dpkg-architecture, the variable I may want to conditionally build upon might be DEB_TARGET_ARCH rather than DEB_HOST_ARCH.

    [1] https://stackoverflow.com/questions/11944060/how-to-detect-target-architecture-using-cmake

    [2] https://cmake.org/cmake/help/latest/command/execute_process.html

       -- Chris

    --
    Chris Knadle
    Chris.Knadle@coredump.us

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johannes Schauer Marin Rodrigues@21:1/5 to All on Thu Jan 16 20:10:01 2025
    Quoting Chris Knadle (2025-01-16 19:26:39)
    Looking at the manpage for dpkg-architecture, the variable I may want to conditionally build upon might be DEB_TARGET_ARCH rather than DEB_HOST_ARCH.

    above the VARIABLES section in that man page there is the TERMS section which explains:


    target machine
    The machine the compiler is building for, or the emulator will run
    code for. This is only needed when building a cross-toolchain (or
    emulator), one that will be built on the build architecture, to be
    run on the host architecture, and to build (or run emulated) code
    for the target architecture.

    Unless you are building a compiler, you do not need to concern yourself with the "target" architecture. Debian is using the GNU terminology and wRAR already linked the relevant GNU documentation in the other mail.

    Thanks!

    cheers, josch
    --==============46497133767165428=MIME-Version: 1.0
    Content-Transfer-Encoding: 7bit
    Content-Description: signature
    Content-Type: application/pgp-signature; name="signature.asc"; charset="us-ascii"

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEElFhU6KL81LF4wVq58sulx4+9g+EFAmeJWHcACgkQ8sulx4+9 g+Gf6RAAs93xLxnwH8wBFCjefTpyLDnOIevV2fCTLC4SJoYRDcP3qh4SZs/Mv5Bj bVil8Q+YpsKKNl0JMongndMIb8SY+4PtzdmxbWSGQcWu/4gDHl0Cp/DediqEtGjU NX8/bljOvle7ycUbkUxJ+WZbM6YF7BhUPU6xrclJ1ReLfrpB/t5CH9AS/cKOXEQq wY9lmHEZSGacWZawP1E+tqyR/mChg8hc1vEzd3B/LNe1XvwgdV/LYFD1tG6vNT4W Sq7X0krSHaCZgMr5MVWnSxpftxJHBuNCy1B6735RegrZftWk3+Gu2H/WCm1sVZGM oMhHEyqBFELgWrcW7lLhoBr2xWxV47sFqrKVxtnFLn6DTFlq8pb1OfIde8kYDx6W ExfrOBsQSf/IVIw98yp5N35lYFzcQtvaAPtkfku0sX8ziqq70Y0JNQkHOyI2RE1N CxrIFXkl9LXWv6CnGKEL3tgVfhsfWNiJkZL3qxXuIjMllAL7udvoXtl51qD9Gkps ppFsiC7igwo4bym72PpqktVuTTKo1jEtUYT5JTtLWvCY4i041R7rmZlh0b2TFkJV M3f0FTNNONmK7WmMuHxuUTHeCdCyIg/n+LdX3Mg226XhUfBfS1j+ofNsNKsV7XEv fbFbJQY0PXK65XPb/Yqj71+DY55NByyzaJYv5lIeQj4wnay9qAI=
    =8Tt+
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johannes Schauer Marin Rodrigues@21:1/5 to All on Thu Jan 16 20:20:01 2025
    Hi Simon,

    Quoting Simon Richter (2025-01-16 16:52:19)
    atomic operations require linking against libatomic — always have. Some architectures inline a few functions, which is how you get away with omitting the library on amd64 most of the time, but this is incorrect.

    No architecture specific patch should be required here, adding libatomic everywhere is fine, possibly via
    -Wl,--push-options,--as-needed,-latomic,--pop-options

    (although as-needed is likely default anyway)

    I find this very interesting. I am fighting -latomic linking issues for quite a while now and what you just said makes me think that I am in severe lack of understanding here. Can you elaborate?

    My specific situation is:

    src:vcmi FTBFS on armel unless I apply this patch:

    https://sources.debian.org/src/vcmi/1.5.7%2Bdfsg-1/debian/patches/fix-armel-atomics.patch/

    After more research together with vcmi upstream involvement I found out that linking vcmi against atomic is *only* required because it uses tbb::parallel_for from oneTBB: https://github.com/uxlfoundation/oneTBB/issues/1454

    And then others have linked me to this GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81358

    So I'm at a loss at deciding who is at fault and who should be fixing something. You say this should work out-of-the-box on amd64 mostly but everything I have come across handling std::atomic types builds fine on all architectures -- except armel. So which is the thing that gets things wrong here?

    - armel?
    - g++?
    - cmake?
    - oneTBB?
    - vcmi?

    Who should be patched? Relevant Debian bugs are #1089991 and #1088922

    I'd very much welcome to be enlightened by you or anybody else on this list. :)

    Thanks!

    cheers, josch
    --==============54243699681720073=MIME-Version: 1.0
    Content-Transfer-Encoding: 7bit
    Content-Description: signature
    Content-Type: application/pgp-signature; name="signature.asc"; charset="us-ascii"

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEElFhU6KL81LF4wVq58sulx4+9g+EFAmeJWxoACgkQ8sulx4+9 g+GTIg/5AX6AlNZEcgh48Q0v3d32Oh1U8CAftPiT2r6x8oboDkC7lVDGSklPFua+ nJIhbf/i1Hv0EQzX62FPY0bSkX7yqktrt2NXRlhsLxENWU8KpEocfyo1RhScQJ+2 W4w+Xo5dsMP7T6HFOwM2I6a3wLJqXuL6mYrQgYsB+jmUD6s4oyaaQQffowRMatDA CQCP1uDBNr+DixHscV2d2y/7Eh3oMy4nh6Ee7MdX/rTcUy3d4u4Z+6fnV2KAMrp4 EpOyGJWaUPZL8qY5VhHp7FjdO/rYdRSmJz9dDD+XSk5X91MuzOeU/xIBNEU7laNJ 3Xty94LrRdjg01BDg/nMHDYduh4SglIV9ykD+/dtErqfg/wEp5LPerUE9dU8HMmS dJsvM2Ojn1YuIEuvjBAMM9ckocCPUEIQ7I29QQ12xde//lfYvbS3/IuinUeAlIId PCjnmQ65HRoAsEM7aDCA+K0fscu3RBNMewrQ94HYsUlqqO1l3+1Vm9W4Ilquxx9z QJt4mND1cAd6hJFWIyEy8wJGOdCqm7bwsvYyS9qGlL47XYp/KSwrclRfQryuptGI gMEaR9Gc5HDQmAL7hp089qrlG+c3/IlMroyDnHjYh2qU6BMigS8kZaS5gFwhsrto j+IBCqvHMTis64BonIUTizq+vxe/znMFSxABxkLaouACVsOiclw=
    =9yaU
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andrey Rakhmatullin@21:1/5 to Johannes Schauer Marin Rodrigues on Thu Jan 16 20:50:01 2025
    On Thu, Jan 16, 2025 at 08:16:46PM +0100, Johannes Schauer Marin Rodrigues wrote:
    atomic operations require linking against libatomic — always have. Some architectures inline a few functions, which is how you get away with omitting
    the library on amd64 most of the time, but this is incorrect.

    No architecture specific patch should be required here, adding libatomic everywhere is fine, possibly via
    -Wl,--push-options,--as-needed,-latomic,--pop-options

    (although as-needed is likely default anyway)

    I find this very interesting. I am fighting -latomic linking issues for quite a
    while now and what you just said makes me think that I am in severe lack of understanding here. Can you elaborate?

    My specific situation is:

    src:vcmi FTBFS on armel unless I apply this patch:

    https://sources.debian.org/src/vcmi/1.5.7%2Bdfsg-1/debian/patches/fix-armel-atomics.patch/

    After more research together with vcmi upstream involvement I found out that linking vcmi against atomic is *only* required because it uses tbb::parallel_for from oneTBB: https://github.com/uxlfoundation/oneTBB/issues/1454

    And then others have linked me to this GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81358

    So I'm at a loss at deciding who is at fault and who should be fixing something. You say this should work out-of-the-box on amd64 mostly but everything I have come across handling std::atomic types builds fine on all architectures -- except armel. So which is the thing that gets things wrong here?

    - armel?
    - g++?
    - cmake?
    - oneTBB?
    - vcmi?

    Without having any special knowledge about this and skimming through the
    linked GCC bug I assume that until (unless?) GCC starts adding -latomic implicitly (which is what the bug and patches linked in it are about)
    it's the software upstream's fault, and no upstreams actually care about
    armel (and why would they).

    See also the armel/upstream-support cell on https://release.debian.org/testing/arch_qualify.html


    --
    WBR, wRAR

    -----BEGIN PGP SIGNATURE-----

    iQJhBAABCgBLFiEEolIP6gqGcKZh3YxVM2L3AxpJkuEFAmeJYY4tFIAAAAAAFQAP cGthLWFkZHJlc3NAZ251cGcub3Jnd3JhckBkZWJpYW4ub3JnAAoJEDNi9wMaSZLh WRQQAJGKj77nClodNZkrPdBuDt4c7qEXGLU7JsjvDMp/nLEODEfa5mSMPk9vzoe/ aLHFPxRz/9/fZUyMXKtxgYKrdMcW33Ljq4VHppLbqGMLDbiQ7ponGJpk67bHQhJJ FR+26AMqY6zzmynJ2Wneb4iLrS5QlFEvqwyYP1mZ4KclJdfiHEunyK45SRS4le/o i3902iF1or9FQhWUIOW4e3uH4xm5VC4FCuJoRVoTfwXzJs/SaSOX4zhHjLcu/eLt tgW3MZR2Y5LEJ38LrIpmtHplmahd4p0jaqZk1lo0pFdbx5C4r5z5yRBuhOdCUUbb sbrDmkS2AwGX7TMlmW7nPkWd2xpruJYRlKqHs9QqEB6/+JD0RF5qlISAP4DeGBTV 1PaAd6XDMhbhiKStSBYOUC94D8qXrha8gL0fE7a9GxO+8Ij1kkGgb3CnFWY8uS+u 0yn4t9xh58lvd5q01tnI6jg+45g5qgr+EKJkdwrk6gzv8yzx+i8pKHU/HiKkqkly Ftt9yJlIFAWVWGLa+5YAow8kjPcA1FSIZ1SmuoQk3p0Q5gCjaZ1mzXU6R7v88WzF 7qBOBknf5O2TmnRdCawFZ27J2Lyb/DgZ+Vg15odcZQINmYAm6kfjG5WLP7JQYQLl +quxjtPC+54UUGW6u1uVdSsN5zj9aPh2sRmjwHUioA9BvqwJ
    =7Bs5
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andrey Rakhmatullin@21:1/5 to Chris Knadle on Thu Jan 16 21:00:02 2025
    On Thu, Jan 16, 2025 at 01:54:05PM -0500, Chris Knadle wrote:
    atomic operations require linking against libatomic — always have. Some architectures inline a few functions, which is how you get away with omitting the library on amd64 most of the time, but this is incorrect.

    No architecture specific patch should be required here, adding libatomic everywhere is fine, possibly via -Wl,--push-options,--as-needed,-latomic,--pop-options

    (although as-needed is likely default anyway)

       Simon

    I'm assuming this also requires adding libatomic1 as a build dependency.

    ITYM libgcc-14-dev, and it's in build-essential.

    --
    WBR, wRAR

    -----BEGIN PGP SIGNATURE-----

    iQJhBAABCgBLFiEEolIP6gqGcKZh3YxVM2L3AxpJkuEFAmeJYxMtFIAAAAAAFQAP cGthLWFkZHJlc3NAZ251cGcub3Jnd3JhckBkZWJpYW4ub3JnAAoJEDNi9wMaSZLh idsP/0H2Uun4USGBJuXp22P2Lly/nSKVIMwyIh7J5Pw9gEzcoxDLMnVBdbGWXxhY 6DG4kioNbFcOae1skT5sRSvCB8phxKRcedGPgLJgzvLoTn4pByetHKnSC8BjufPN +N+4p59LUmvgzR3WtyqqtK5Mww2UcW59Bvrv6Wm8tcFWE01gcPNb6R7nRIk7qu31 UtlfHnSKw0c26PkUVr2nbDKhOLvxcKeHmP20jppTiWBnReuclsHHu0YAGcQKgGmN cUAwNKpLQI49MKjBeF2B9BNd52yJoy4ZBEy+n/gsd+yyzyeHI8j4GcO+IBS+OmEc BVd9j0dcQaOOI8gX3MVYOdbqjJtJcEXR/xK2SixwX9Gax9z/c2dR6l3aHlXwb8tb Rfp1x/vUxaQJYJ67ehUYdsYafQHS/Blsur1UkU+F1dmNPbuZC5UK20S+zZ+l+4L7 SSyjF4gbyywPClidrMbqDcY8ZL7GSvCoFsfCeo1XiIZMr7v+wYHkyVXoPp9TuHfx J7fUxuMPUPnEAiBl2GKGSzRkCDqB90cuA68av2RJVe/puODViFTYmEwiVEgPD/TO GX2dwt2z5FTzrnrf0ad2aKWezE8VhxZMNPBb9LakM9sLZLicxb03VzLDOaM6F6k1 8ItPpxF6JvphJCm1nu7wQOBOltDGkldWnlZ7ydbjUEXlK4C5
    =S6sj
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Knadle@21:1/5 to Andrey Rakhmatullin on Thu Jan 16 21:30:02 2025
    On 1/16/25 14:50, Andrey Rakhmatullin wrote:
    On Thu, Jan 16, 2025 at 01:54:05PM -0500, Chris Knadle wrote:
    atomic operations require linking against libatomic — always have. Some >>> architectures inline a few functions, which is how you get away with
    omitting the library on amd64 most of the time, but this is incorrect.

    No architecture specific patch should be required here, adding libatomic >>> everywhere is fine, possibly via
    -Wl,--push-options,--as-needed,-latomic,--pop-options

    (although as-needed is likely default anyway)

       Simon
    I'm assuming this also requires adding libatomic1 as a build dependency.
    ITYM libgcc-14-dev, and it's in build-essential.

    i.e. no new build depends needed. Understood, thanks

    Chris Knadle
    Chris.Knadle@coredump.us

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Guillem Jover@21:1/5 to Chris Knadle on Fri Jan 17 01:10:01 2025
    Hi!

    On Thu, 2025-01-16 at 13:26:39 -0500, Chris Knadle wrote:
    Looking at the manpage for dpkg-architecture, the variable I may want to conditionally build upon might be DEB_TARGET_ARCH rather than DEB_HOST_ARCH.

    Others have already given pointers about this confusion. I'm more
    interested in trying to see whether we can improve the man page to
    avoid it.

    I think if you search for stuff and end up in the VARIABLES section,
    from there it's hard to notice the TERMS one, but in the past it
    seemed excessive to me to either repeat the same or back-reference
    the TERMS section on each variable definition. Perhaps a middle ground
    would be adding a reference in the DEB_BUILD_ARCH and DEB_TARGET_ARCH,
    like in the attached patch? Do you think that would have helped?

    (I've gone over those two sections to try to further clarify and update
    things I noticed, although I think the «Debian architecture» one could
    do with some major update.)

    Thanks,
    Guillem

    diff --git i/man/dpkg-architecture.pod w/man/dpkg-architecture.pod
    index ae26b6d5c..a74716fd7 100644
    --- i/man/dpkg-architecture.pod
    +++ w/man/dpkg-architecture.pod
    @@ -185,27 +185,30 @@ The machine the package is built for.

    =item target machine

    The machine the compiler is building for, or the emulator will run code for.
    This is only needed when building a cross-toolchain (or emulator), one that
    will be built on the build architecture, to be run on the host architecture, -and to build (or run emulated) code for the target architecture.
    +and that itself will build (or run emulated) code for the target architecture.

    =item Debian architecture

    -The Debian architecture string, which specifies the binary tree in the
    -FTP archive.
    +The Debian architecture string,
    +used in binary packages,
    +which specifies the binary tree in a package repository.
    +
    Examples: i386, sparc, hurd-i386.

    =item Debian architecture tuple

    A Debian architecture tuple is the fully qualified architecture with all its
    components spelled out.
    This differs with Debian architectures in that at least the I<c
  • From =?ISO-8859-1?Q?=C1ngel?=@21:1/5 to Johannes Schauer Marin Rodrigues on Fri Jan 17 00:40:01 2025
    On 2025-01-16 at 20:16 +0100, Johannes Schauer Marin Rodrigues wrote:
    Hi Simon,

    Quoting Simon Richter (2025-01-16 16:52:19)
    atomic operations require linking against libatomic — always have..
    Some
    architectures inline a few functions, which is how you get away
    with omitting
    the library on amd64 most of the time, but this is incorrect.

    No architecture specific patch should be required here, adding
    libatomic everywhere is fine, possibly via -Wl,--push-options,--as-needed,-latomic,--pop-options

    (although as-needed is likely default anyway)

    I find this very interesting. I am fighting -latomic linking issues
    for quite a while now and what you just said makes me think that I am
    in severe lack of understanding here. Can you elaborate?

    Hi Josch,

    It's not that complex.¹ If you use an atomic, you should also be
    linking with atomic (i.e. -latomic). This is similar to using
    -pthreads if you are using multiple threads, or -lresolv if you use gethostbyname()

    What makes things complicated here is that in most architectures, gcc
    is able to inline everything, and libatomic is not really needed, so
    you don't need to add -latomic and it just works.

    ...until it doesn't, such as in armel.

    Just like you can use gethostbyname() directly, since this is provided
    by libc, which is implicitly linked by default.
    But you would need to specify -lresolv in Solaris, or it won't link.

    So the solution would be just to add -latomic

    Saying instead
    -Wl,--push-options,--as-needed,-latomic,--pop-options

    is an advanced way to make the linker not to depend on libatomic if it
    isn't actually needed.





    So I'm at a loss at deciding who is at fault and who should be fixing something. You say this should work out-of-the-box on amd64 mostly but everything I have come across handling std::atomic types builds fine on all architectures -- except armel. So which is the thing that gets things wrong here?

    - armel?
    - g++?
    - cmake?
    - oneTBB?
    - vcmi?

    Who should be patched? Relevant Debian bugs are #1089991 and #1088922

    I'd very much welcome to be enlightened by you or anybody else on
    this list.. :)

    I think the bug is in oneTBB, it is that that should be patched.
    Your last patch at https://github.com/uxlfoundation/oneTBB/issues/1454#issuecomment-2267455977 seems appropriate.


    vcmi should not need to care if oneTBB uses atomics or not.


    armel is not strictly at fault (although you might blame the
    architecture for not providing a way as easy as amd does)

    g++ (actually gcc has the same issue) can be partially to blame.
    gcc made an interface which is not too usable. Then it was reused for
    g++, albeit the language specification doesn't state that requirement.
    It *should* be improved at gcc level, but at the present time the spec
    is that you will need to link to libatomic, and that's what oneTBB
    should be doing.


    Best regards


    ¹ Ok, after writing this whole email, maybe a bit 😅

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alexandre Rossi@21:1/5 to All on Fri Jan 17 09:50:01 2025
    Hi,

    It's not that complex.¹ If you use an atomic, you should also be
    linking with atomic (i.e. -latomic). This is similar to using
    -pthreads if you are using multiple threads, or -lresolv if you use gethostbyname()

    Some upstreams have gone through build system tests to assess whether
    to build with libatomic or not. Adding -latomic is simpler. I wonder if
    the build system configure stage test is overkill.

    To illustrate, that's what I thought was the right fix for transmission[1][2].

    [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1067625
    [2] https://github.com/transmission/transmission/pull/6774

    Thanks,

    Alex

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon Richter@21:1/5 to Alexandre Rossi on Fri Jan 17 11:50:01 2025
    Hi,

    On 1/17/25 17:45, Alexandre Rossi wrote:

    Some upstreams have gone through build system tests to assess whether
    to build with libatomic or not. Adding -latomic is simpler. I wonder if
    the build system configure stage test is overkill.

    Yes and no. A lot of the tests are just broken, like "compile and link a program incrementing an atomic integer, try with no extra libraries and
    with libatomic" -- in principle you'd need to repeat this with all data
    types used, then you'd get a reliable result.

    It's similar to how libm is used -- if you use fsin(), this may be a
    single assembler instruction, or a call to a function that is IEEE754 conformant and sets errno, and that implementation detail determines
    whether you want to link against libm or not, but if you test whether
    fsin() requires -lm, that doesn't tell you whether fabs() requires -lm.

    Likewise, 4-byte atomics being inlined doesn't tell you if 1-byte or
    16-byte atomics are also inlined, or whether there is special handling
    for signed or unsigned integers.

    Within Debian, always linking with --as-needed is a simple fix, but it
    depends on using a linker that understands --as-needed, so it's not
    portable enough to be submitted upstream.

    In my own packages, I check if libatomic exists, and if it does, I unconditionally link if I use any atomics. I also check if the linker
    accepts --push-flags, if it does I generate a -Wl,--push-flags,--as-needed,-latomic,--pop-flags sequence, if not, the unconditional link will generate dpkg-shlibdeps warnings about
    unnecessary linking on amd64, but that's better than failing on other platforms.

    Simon

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Wookey@21:1/5 to Simon Richter on Fri Jan 17 16:40:01 2025
    On 2025-01-17 19:43 +0900, Simon Richter wrote:
    In my own packages, I check if libatomic exists, and if it does, I unconditionally link if I use any atomics. I also check if the linker
    accepts --push-flags, if it does I generate a -Wl,--push-flags,--as-needed,-latomic,--pop-flags sequence, if not, the unconditional link will generate dpkg-shlibdeps warnings about unnecessary linking on amd64, but that's better than failing on other platforms.

    Can you explain why this:
    -Wl,--push-flags,--as-needed,-latomic,--pop-flags
    is better than
    -as-needed,-latomic
    I thought --as-needed on its own is sufficicent to avoid dpkg-shlibdeps warnings
    about unnecessary linking (because it only links the things that are needed), so
    I don't understand the need for the psuh/pop sequence (I must admit that I never
    knew that existed until your message recently).

    cheers

    Wookey
    --
    Principal hats: Debian, Wookware
    http://wookware.org/

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEER4nvI8Pe/wVWh5yq+4YyUahvnkcFAmeKeAAACgkQ+4YyUahv nkfv7RAAlvsPIID0wjA8p+JvZSv132lj4biwzK94zvHlw9fqqeaBieFql2VeP3Ru S4VlJ5ToiOH6SPnGB5y1jnRVwcSlYVwFMoqgKLrdEul2IcH1nVTd/94igwXSUH8j JR+WfSwkqVDjeYj0TH4SD3jwG5GH89IrXaoOwSDyOhzfkLlS5CDj031GNyMwq+8u a/LLIXZHGuOJmQ1lgQtRD6bS+8F+w7eYCLz97JA8QTvsJW4BLVMllJKhsOsaRzFI T/++oyexAwyoM74hWSOWn/83Mff0G29MofGswUy57qjYAxfhYYkmKBweAdtTLyqA 5aggOiOLd6aQ5V/71SNgBcY4PkzXoExlLDE3G9Qr1vaQt8t/BJ6EeNOAPhdcXBJz oeZzpAprdxerhBVvvluUrYIAogUEIz92kcwVpFWS9y5pdhV3xfJicpyLKN7b/cx1 hatKL0TxF2fElEKfOaj8eRISjgSpMdJQhC7qxXqsUWWTjk2ZDInSRpt2NpvS3Dvj xGvKEVOploxClQ+aXOrshK2xRBV1JDnBh2hZ5r51itFqNWvfHBYKv+c1nfZ4rKuI oLS6RpUIbSMMLn9P2AhxDCBaXOgHMsljtw3gh+MssSOkL4SKjHzQ2RxaevuSOZGS fv7JfatNPF5Uj75+rh7YQyaJhTG0EB5niePBma8Lv2Gljvowvyo=
    =7Mvw
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon McVittie@21:1/5 to Wookey on Fri Jan 17 17:50:01 2025
    On Fri, 17 Jan 2025 at 15:32:22 +0000, Wookey wrote:
    Can you explain why this:
    -Wl,--push-flags,--as-needed,-latomic,--pop-flags
    is better than
    -as-needed,-latomic
    I thought --as-needed on its own is sufficicent to avoid dpkg-shlibdeps warnings
    about unnecessary linking (because it only links the things that are needed), so
    I don't understand the need for the psuh/pop sequence (I must admit that I never
    knew that existed until your message recently).

    Two things, depending which difference between your two command lines
    you are thinking about:

    1. -Wl,--as-needed normally sets global state for the entire linker
    invocation. If the package you're building is one that has a
    functional requirement to *not* use -Wl,--as-needed for other library
    dependencies, the push/pop guards ensure that the -Wl,--as-needed
    only affects how libatomic is linked, without having the side-effects
    of linking every other library dependency (not just libatomic!) in
    "as needed" mode.

    For example GLib explicitly pulls in libpthread, which is (or at least
    was in the past) functionally necessary: if that wasn't done,
    dlopen()ing modules that indirectly depend on libpthread would not
    be safe, because internal locks in glibc were already initialized
    in a non-thread-safe way before libpthread was in memory, and cannot
    (or at least could not in 2009) be re-initialized with the thread-safe
    equivalent after libpthread arrived. (Reference:
    https://mail.gnome.org/archives/gtk-devel-list/2009-November/msg00096.html)

    2. -Wl is necessary to tell the compiler driver (gcc or clang)
    "it's OK that you don't understand this, just pass it through to the
    linker". --as-needed is a ld option, not a gcc option; but $LDFLAGS
    are passed to gcc, not ld.

    smcv

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Theodore Ts'o@21:1/5 to All on Tue Jan 21 16:40:01 2025
    A question about --as-needed as an upstream developer who wants to
    care about more than just Debian or Linux. Am I correct in assuming
    this will work on any system using GNU binutils? And it doesn't
    matter whether you are using gcc, clang, etc. What about other OS's
    such as *BSD, MacOS, etc.?

    I guess I could add an autoconf test to see if the linker barfs on
    --as-needed, but I'm curious how much this actually matters in
    practice.

    Thanks,

    - Ted

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Colin Watson@21:1/5 to Theodore Ts'o on Tue Jan 21 22:10:01 2025
    On Tue, Jan 21, 2025 at 10:31:29AM -0500, Theodore Ts'o wrote:
    A question about --as-needed as an upstream developer who wants to
    care about more than just Debian or Linux. Am I correct in assuming
    this will work on any system using GNU binutils? And it doesn't
    matter whether you are using gcc, clang, etc. What about other OS's
    such as *BSD, MacOS, etc.?

    I often consult Gnulib for lore on this kind of thing. https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=m4/lib-ignore.m4 seems to have some useful hints, with comments for those not fluent in
    m4.

    This also seems to be a standalone file, so if your project is using
    Autoconf but not Gnulib, then you should be able to copy it into your
    project's local macro directory, add gl_IGNORE_UNUSED_LIBRARIES to configure.ac, and add $(IGNORE_UNUSED_LIBRARIES_CFLAGS) etc. to whatever *_LDFLAGS variable is appropriate.

    --
    Colin Watson (he/him) [cjwatson@debian.org]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Matthias Klose@21:1/5 to Colin Watson on Wed Jan 22 05:10:01 2025
    On 21.01.25 22:01, Colin Watson wrote:
    On Tue, Jan 21, 2025 at 10:31:29AM -0500, Theodore Ts'o wrote:
    A question about --as-needed as an upstream developer who wants to
    care about more than just Debian or Linux. Am I correct in assuming
    this will work on any system using GNU binutils? And it doesn't
    matter whether you are using gcc, clang, etc. What about other OS's
    such as *BSD, MacOS, etc.?

    --as-needed has been there forever. The --push-state/--pop-state options
    are implemented in binutils 2014 (ld), and binutils 2016 (gold). I
    didn't look at other linkers.

    Using these in libtool still seems to be a problem, as libtool has it's
    own idea about how to re-sort command line options and libraries.

    I often consult Gnulib for lore on this kind of thing. https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=m4/lib-ignore.m4 seems to have some useful hints, with comments for those not fluent in
    m4.

    This also seems to be a standalone file, so if your project is using
    Autoconf but not Gnulib, then you should be able to copy it into your project's local macro directory, add gl_IGNORE_UNUSED_LIBRARIES to configure.ac, and add $(IGNORE_UNUSED_LIBRARIES_CFLAGS) etc. to whatever *_LDFLAGS variable is appropriate.


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon Richter@21:1/5 to Theodore Ts'o on Wed Jan 22 09:00:01 2025
    Hi,

    On 1/22/25 00:31, Theodore Ts'o wrote:

    I guess I could add an autoconf test to see if the linker barfs on --as-needed, but I'm curious how much this actually matters in
    practice.

    From an upstream perspective, I think the best approach is

    AC_CHECK_LIB([atomic],[main])

    That creates a few unnecessary dependencies, but it should work pretty
    much everywhere.

    If Debian maintainers feel annoyed by warnings about unnecessary
    dependencies, they are welcome to replace this with a hardcoded

    LDFLAGS="${LDFLAGS} -Wl,--push-state,--as-needed,-latomic,--pop-state"

    because unlike upstream, Debian can assume reasonably recent GNU tools.

    Someone GNU adjacent might want to build something more sophisticated
    for the autoconf-archive -- but I'd draw the line at

    0. if the library does not exist, assume it's not needed and explicitly
    say so in the build log
    1. if --push-state/--pop-state are supported, wrap them around --as-needed
    2. if --as-needed is supported, but no state stack, use --no-as-needed afterwards, and if any other macro wants to use --as-needed, they need
    to add their own
    3. if neither is supported, unconditionally link

    Like libm, what is actually needed at link time depends on inlining,
    which is affected by constant propagation, so it is impossible to build
    100% reliable tests.

    Simon

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johannes Schauer Marin Rodrigues@21:1/5 to All on Mon Feb 10 10:50:01 2025
    Hi,

    Quoting Simon Richter (2025-01-17 11:43:39)
    In my own packages, I check if libatomic exists, and if it does, I unconditionally link if I use any atomics. I also check if the linker accepts --push-flags, if it does I generate a -Wl,--push-flags,--as-needed,-latomic,--pop-flags sequence, if not, the unconditional link will generate dpkg-shlibdeps warnings about unnecessary linking on amd64, but that's better than failing on other platforms.

    thank you for your help! I now patched vcmi with snippets like this:

    if (CMAKE_LIBRARY_ARCHITECTURE STREQUAL "arm-linux-gnueabi")
    target_link_options(vcmi PRIVATE "-Wl,--push-flags,--as-needed,-latomic,--pop-flags")
    endif()

    I understand from the other mails that this architecture-check is not even needed and that --as-needed will let the linker do the right thing. I still like to special-case the only arch where this seems to be needed. I gave up on hoping that onetbb fixes it as neither upstream nor the Debian bug show any activity, so I'm patching my own package instead.

    But then I get the complaint:

    /usr/bin/ld: unrecognized option '--push-flags'

    You probably meant --push-state and --pop-state instead?

    Thanks!

    cheers, josch
    --==============u78752677170248125=MIME-Version: 1.0
    Content-Transfer-Encoding: 7bit
    Content-Description: signature
    Content-Type: application/pgp-signature; name="signature.asc"; charset="us-ascii"

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEElFhU6KL81LF4wVq58sulx4+9g+EFAmepy28ACgkQ8sulx4+9 g+E3eBAAn3kg9g6S5tvN5jWNZhtm84CxnHkTEtC/s7t1w1nPlNjq0AZE0AV4UIKn GTe1MK4ezf2eoLBiUBWRznoOb/J3A0Hl/bK/ijH2D0Og0m20CGIDa9CGivYLFEpY YB37bdmMdgxeA8Z5TkXrCv+x9/dpn6462AYNQ40c3xAoL2Lop8/Xe8tQY0i5LOA8 xJmwDR/0la6IFo48xtNkI9/Fc8/fLCbATK8WhDTp07FMA1kSC7SyhPKgddqPXTRf 92tvQ4PIBvpLF42wuyDMNeax09vZAEQTexTqtzkVCaf7k7p2q6AZYCk+kpGCiabp LcPDer/pAqUlI8h/gjN98U/lfTnoIL1Nkb/Yx9qeX3+HEScpJi/zoFPnH1+s/teB ft4IeSFJVt9cFJtU5RgYAC6cAhIrXPmTjhK0JT8Q/hiIok6MFi8jOQTixY4DO8zc RnQg0a7j/euwXW5XHT0UhPtpxYOtkd8hbBy17T4BaTK6k6g/80Z0f9P8mYwEM+PZ gZdt5gqsHKTDY8HyXoUBY5kZuVQqx1SfT0q/njhkWfAYsYfZhTwYTiHcglxkwLND Be4hxRKRoBx5Dqj3loLJwYP8Mz2/P5KJYSA/IQ53fo9NVU0v8bSN35dK/TnMysYN J28RWpyBFLe8IFb+ZJDD+xVzlWRA80ea7B34+9XTGSmnikPEiuQ=
    =rFTX
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon Richter@21:1/5 to Johannes Schauer Marin Rodrigues on Wed Feb 12 04:50:01 2025
    Hi,

    On 2/10/25 18:48, Johannes Schauer Marin Rodrigues wrote:

    I understand from the other mails that this architecture-check is not even needed and that --as-needed will let the linker do the right thing. I still like to special-case the only arch where this seems to be needed.

    It's not needed on RISC-V? Whoa.

    I gave up on
    hoping that onetbb fixes it as neither upstream nor the Debian bug show any activity, so I'm patching my own package instead.

    FWIW if the offending code is inlined into your package, then there
    isn't much they can do to fix it.

    /usr/bin/ld: unrecognized option '--push-flags'

    You probably meant --push-state and --pop-state instead?

    Yes, indeed.

    Simon

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johannes Schauer Marin Rodrigues@21:1/5 to All on Wed Feb 12 05:40:01 2025
    Quoting Johannes Schauer Marin Rodrigues (2025-02-10 10:48:35)
    Quoting Simon Richter (2025-01-17 11:43:39)
    In my own packages, I check if libatomic exists, and if it does, I unconditionally link if I use any atomics. I also check if the linker accepts
    --push-flags, if it does I generate a -Wl,--push-flags,--as-needed,-latomic,--pop-flags sequence, if not, the unconditional link will generate dpkg-shlibdeps warnings about unnecessary linking on amd64, but that's better than failing on other platforms.

    thank you for your help! I now patched vcmi with snippets like this:

    if (CMAKE_LIBRARY_ARCHITECTURE STREQUAL "arm-linux-gnueabi")
    target_link_options(vcmi PRIVATE "-Wl,--push-flags,--as-needed,-latomic,--pop-flags")
    endif()

    I understand from the other mails that this architecture-check is not even needed and that --as-needed will let the linker do the right thing. I still like to special-case the only arch where this seems to be needed. I gave up on
    hoping that onetbb fixes it as neither upstream nor the Debian bug show any activity, so I'm patching my own package instead.

    But then I get the complaint:

    /usr/bin/ld: unrecognized option '--push-flags'

    You probably meant --push-state and --pop-state instead?

    probably related to how to correctly link against atomic with CMake I have another follow-up question. Adding the above target_link_options() to the relevant shared libraries indeed does the trick. But for my package vcmi, I also seem to need it for an executable. Unfortunately, when I apply the same recipe, I get this:

    [100%] Linking CXX executable ../bin/vcmiclient
    cd /build/reproducible-path/vcmi-1.6.5+dfsg/obj-arm-linux-gnueabi/clientapp && /usr/bin/cmake -E cmake_link_script CMakeFiles/vcmiclient.dir/link.txt --verbose=1
    /usr/bin/c++ -g -O2 -ffile-prefix-map=/build/reproducible-path/vcmi-1.6.5+dfsg=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -Wdate-time -D_FORTIFY_SOURCE=2
    -Wall -Wextra -Wpointer-arith -Wuninitialized -Wmismatched-tags -Wno-unused-parameter -Wno-switch -Wno-reorder -Wno-sign-compare -Wno-varargs -Wl,-z,relro -Wl,-z,now -Wl,--push-state,--as-needed,-latomic,--pop-state -Wl,--dependency-file=CMakeFiles/
    vcmiclient.dir/link.d CMakeFiles/vcmiclient.dir/StdInc.cpp.o CMakeFiles/vcmiclient.dir/EntryPoint.cpp.o -o ../bin/vcmiclient -Wl,-rpath,"\$ORIGIN::::::::::::::::::::::::" ../bin/libvcmiclientcommon.a ../bin/libvcmiservercommon.a ../bin/libvcmi.so /usr/
    lib/arm-linux-gnueabi/libminizip.so /usr/lib/arm-linux-gnueabi/libz.so /usr/lib/arm-linux-gnueabi/libtbb.so.12.14 -ldl -lrt /usr/lib/arm-linux-gnueabi/libboost_filesystem.so.1.83.0 /usr/lib/arm-linux-gnueabi/libboost_program_options.so.1.83.0 /usr/lib/
    arm-linux-gnueabi/libboost_locale.so.1.83.0 /usr/lib/arm-linux-gnueabi/libboost_thread.so.1.83.0 /usr/lib/arm-linux-gnueabi/libboost_atomic.so.1.83.0 /usr/lib/arm-linux-gnueabi/libboost_chrono.so.1.83.0 /usr/lib/arm-linux-gnueabi/libboost_date_time.so.1.
    83.0 /usr/lib/arm-linux-gnueabi/libSDL2_image.so /usr/lib/arm-linux-gnueabi/libSDL2_mixer.so /usr/lib/arm-linux-gnueabi/libSDL2_ttf.so /usr/lib/arm-linux-gnueabi/libSDL2.so /usr/lib/arm-linux-gnueabi/libavutil.so /usr/lib/arm-linux-gnueabi/libswscale.so /
    usr/lib/arm-linux-gnueabi/libavformat.so /usr/lib/arm-linux-gnueabi/libavcodec.so /usr/lib/arm-linux-gnueabi/libswresample.so
    /usr/bin/ld: ../bin/libvcmiclientcommon.a(SDLImageScaler.cpp.o): undefined reference to symbol '__atomic_fetch_add_8@@LIBATOMIC_1.0'
    /usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabi/14/libatomic.so: error adding symbols: DSO missing from command line
    collect2: error: ld returned 1 exit status

    I suspect that the problem is the order in which the -latomic is added to the linker flags? Because if instead of target_link_options() with push and pop-state I just use

    target_link_libraries(vcmiclient PRIVATE atomic)

    Then that will add a -latomic right after ../bin/libvcmiclientcommon.a and then the build succeeds. Here is the relevant CMakeLists.txt:

    https://sources.debian.org/src/vcmi/1.6.5%2Bdfsg-1/clientapp/CMakeLists.txt/#L38

    So what is the canonical way to achieve the desired result with CMake? Will I instead have to globally set LDFLAGS="-Wl,--as-needed"?

    Thanks!

    cheers, josch
    --==============b53451177148606974=MIME-Version: 1.0
    Content-Transfer-Encoding: 7bit
    Content-Description: signature
    Content-Type: application/pgp-signature; name="signature.asc"; charset="us-ascii"

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEElFhU6KL81LF4wVq58sulx4+9g+EFAmesJccACgkQ8sulx4+9 g+HA4w//XdL+nizzaxeIw/OBUbocI4z3Lgh97rwYJ43I9J6nQu0cY+j3u5FPuap2 oXF8nlyz5VXWtj5WHi8s5+/Mpp5tf+wxGHPASb0k4uOnnl8F9s/p5OHA9WZW4slx Z1ZCHByA2HHoDSEjzuZLoXnnce1+e6c6raN3E1EhFJ3vH8rs0DhyU6DS2b+5BN6e 77H7CGaSdfJLqWlXo4CdoR0Z1uBd5FPpztMH5wcQLYSFSxU5Hh2AqaOf+eSv8T+q qBBfw9ojc8NXX92NHgQ2sUv2tVsF0jdQYCCJS4Zh1ZNvT6v2FyONs4o+5hZUFrok yGbNVEb9i5GHx/Y27gylrGrKQ5u2NRs9I7qbl23Bc2LBMQ9VSitS4PjtA4x4Iyhh O4uRzFQV41rUouzwTQlrZgcx3xsMMamgBTYjJULo5QRaFI3xqXmet17YvfoDOQqt oi4BVjhUwK9FXsfiINUgYnnJCK+fGAF8908H36h3PxN+UUvc1y1CIjqpw57EoeMQ pg7Rco9KU54eFP/EbnCgLH3A7xNODusrjx/SW8qO3cehBzh9hAaDHNMO4U2zpo2Y YlfjeuezUw0op81l6sqkQ1Uyr5XHFLJkm4DKsB3oFt2+Z0mfrQPAxm51N9PsGL8G XgYSPUoZ1pnK9mmQ2vz6tgKp34zZpJOOO7C8B+wtW71cQVB2/Uc=
    =F1z2
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon Richter@21:1/5 to Johannes Schauer Marin Rodrigues on Wed Feb 12 06:00:01 2025
    Hi,

    On 2/12/25 13:38, Johannes Schauer Marin Rodrigues wrote:

    ["DSO missing from command line"]

    I suspect that the problem is the order in which the -latomic is added to the linker flags?

    Yes.

    Because if instead of target_link_options() with push and
    pop-state I just use

    target_link_libraries(vcmiclient PRIVATE atomic)

    Then that will add a -latomic right after ../bin/libvcmiclientcommon.a and then
    the build succeeds.

    Yes, that is the correct approach -- that target is dependent on libatomic.

    So what is the canonical way to achieve the desired result with CMake? Will I instead have to globally set LDFLAGS="-Wl,--as-needed"?

    On Debian, that is default already, which is very annoying when working
    around #1002981 -- I need to add

    [[maybe_unused]]
    volatile int (*hack)(Display, char const *) = XMissingExtension;

    to force a symbol reference from my code to libXext and avoid unloading
    libXext before my program exits.

    The --push-state logic is more useful for sending upstream.

    Simon

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)