• Re: Building a package for arm64 only on amd64 machine

    From Wookey@21:1/5 to David James on Mon Jan 15 03:20:01 2024
    On 2024-01-14 20:31 +0000, David James wrote:
    Dear Mentors,

    I am trying to package a small library that will be a dependency for a larger application. The thing is the library will only be a dependency if the application is built on arm64. The CMake file has the lines:
    if ("arm64" IN_LIST ARCHITECTURE)
    add_subdirectory(oaknut EXCLUDE_FROM_ALL)endif()

    Oaknut is the library I'm trying to build. The problem stems from the fact that the tarball depends on the catch2, a package that contains Catch2WithMain.a. Oaknut won't build at all when I try to compile natively. When I try to cross compile to arm64
    on my amd64 machine it gives me errors about relocations in ELF (62) related to /usr/lib/Catch2WithMain.a. I'm guessing that it's trying to link to the amd64 Catch2WithMain.a that is installed on my machine.

    Ideally, I would like to use the arm64 version of catch2, however I don't know how to specify this in the control file. If I run sbuild with --host=arm64, it fails in the same way as above because it's trying to cross-compile but with the amd64 version
    of catch2. If I put catch2:arm64 in the control file sbuild tells me "catch2:arm64 [is] not installable."

    Debian builds (for the archive) are always native so you don't need to
    specify foreign-arch build-deps like this. You might need to qualify
    build-deps by architecture if they are actually incompatible, but in
    this case you just build-dep on catch2. So it's always available, even
    if it's only actually used for the arm64 build.

    catch.hpp is an architecture-independent file (it's just a header) and
    is exactly the same for amd64 and arm64 so installing catch2:arm64 has
    exactly the same effect as installing catch2:amd64 anyway. Any issues
    with linking are to do with cross-compilation, not what is being
    installed.

    I am clearly going about this the wrong way. I don't know how I can build an arm64 only package and ensure it only uses arm64 build dependencies. Do I need to use a VM? If I can't get this library packaged, I would have to exclude arm64 from the
    software I am packaging, which I really don't want to do unless absolutely necessary. Any advice would be warmly appreciated.

    This is debian so we try to avoid the use of bundled stuff, as you
    know. The CMAKE file has an option "OAKNUT_USE_BUNDLED_CATCH" so
    making sure that is off for your build is correct.

    To test the arm64 build you need to use either real arm64 hardware or
    a qemu chroot. Testing the cross-build is a different thing, and
    whilst it would be good to have that working too, it won't be used by
    the buildds.

    I had a quick go with a trivial packaging and yes it didn't build on x86

    /usr/bin/c++ -I/home/wookey/packages/oaknut/debian/oaknut-1.2.2/tests -I/home/wookey/packages/oaknut/debian/oaknut-1.2.2/include -g -O2 -ffile-prefix-map=/home/wookey/packages/oaknut/debian/oaknut-1.2.2=. -fstack-protector-strong -Wformat -Werror=format-
    security -Wdate-time -D_FORTIFY_SOURCE=2 -std=gnu++20 -Wall -Wextra -Wcast-qual -pedantic -pedantic-errors -Wfatal-errors -Wno-missing-braces -MD -MT CMakeFiles/oaknut-tests.dir/tests/vector_code_gen.cpp.o -MF CMakeFiles/oaknut-tests.dir/tests/vector_
    code_gen.cpp.o.d -o CMakeFiles/oaknut-tests.dir/tests/vector_code_gen.cpp.o -c /home/wookey/packages/oaknut/debian/oaknut-1.2.2/tests/vector_code_gen.cpp
    /home/wookey/packages/oaknut/debian/oaknut-1.2.2/include/oaknut/feature_detection/read_id_registers_directly.hpp: Assembler messages:
    /home/wookey/packages/oaknut/debian/oaknut-1.2.2/include/oaknut/feature_detection/read_id_registers_directly.hpp:15: Error: no such instruction: `mrs %r15,s3_0_c0_c0_0'
    ...

    because indeed
    include/oaknut/feature_detection/read_id_registers_directly.hpp
    contains an asm section which is arm64 but not architecture gated in
    any way so the scripts try to build it on x86 which is silly and won't
    work. Is this library intended to only build on arm64?

    I must admit to being a bit confused about the purpose of this
    code. What does this code-generator do that gcc doesn't do? And why
    would a complier for arm64 be written to only build on arm64?

    Does the upstream _actually_ need oaknut, or would a normal assembler do? (gcc or clang or tbb etc)

    If the library really does only build on arm64 then putting:
    Architecture: arm64
    in th control file will mean it only gets built on an arch where it will build.

    In this case the package that _depends_ on oaknut will need a
    conditional dependency because oaknut will only exist on arm64, not on
    other arches.
    The syntax is:
    Build-Depends: oaknut [arm64]


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

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

    iQIzBAABCgAdFiEER4nvI8Pe/wVWh5yq+4YyUahvnkcFAmWkk9gACgkQ+4YyUahv nkeAwRAAuknozavWJgmPnxUxEVfySVteLQUJ3vTu7L0KPIX/wJqMQe+NnwzoDaZ4 xK+1xhQYP8w/TaGC1uW1PAvvsqAmDa56t0qnTT9w14XLXz5Yo84Hnoj04r/ljnXO eer5f+Ah03lgT66mmhw/HwU5Kxq+v7qFTpNwu2mT1KISq8mAlMCEhYsCLtdvtwv6 B+/8Bdzv9OTtBxMbfP9SrMGIO0DtumSPuKLe6jgspPbtHPX0+EGm+MIRJF/igrse YNb+Ige082msfIhg0DXDQX4J1KUgUPP1xx3qVE5bCvWxI4w/c9DdB1S+FSwlmUmj nwLoL04KgcUWd/t+6pAy1g86gpo/5VQPCqC3vGjowi1l4rXNSXmrI5bUiCZcTQz3 nMvXai3/og0lFHQ6yoUXcAorcu2IOGPXau0+7V0rWffvP8NHfqtHonQ04D3xlYUo YciiNY17HaJUNjUgiyrycudm6g2MyYrKVpriTWKYOfZI5Zh0feKk8EFU+kt/OosP 75l0FaC9lKn9SByFpAJTX+1uvtx4JP0TAM72Ck3wINBTYaLJHPnXvwBCoT3sUB7Q bSsTQsIMxemapYDEIvVzlsnZ08g2daJIona+U4Ld3gSsQSATIoIF1FR+TleksePq 37mWsLI3NvXcAsrkmdP9RPhrxzFjGCJVzgCpJc3giRVyNra289Q=
    =qYYM
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David James@21:1/5 to All on Mon Jan 15 12:40:01 2024
    This is a multi-part message in MIME format.

    U29ycnkgZm9yIHRoZSBsYXRlbmVzcyBvZiBteSByZXBseS4gSSBoYWQgc29tZSB0cm91YmxlIHNl dHRpbmcgdXAgc2J1aWxkLXFlbXUgKyB0aW1lem9uZXMuIFRoZSBwYWNrYWdlIGJ1aWx0IGZpbmUg b24gYXJtNjQgd2l0aCBhbiBzYnVpbGQtcWVtdSBjcmVhdGVkIGFybTY0IGltYWdlLCBzbyB0aGFu ayB5b3UgYm90aCBmb3IgeW91IGFkdmljZSB0aGVyZS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