• [gentoo-dev] [PATCH] toolchain-funcs.eclass: Add tc-has-64bit-time_t

    From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Thu Jun 13 17:30:01 2024
    Add a helper function to check whether time_t is 64-bit. This could
    be used e.g. to deselect tests that rely on timestamps exceeding Y2k38.
    It is meant to be more future-proof than hardcoding a list of 32-bit architectures, given the necessity of switching to 64-bit time_t
    in the future.

    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/toolchain-funcs.eclass | 12 +++++++++++-
    1 file changed, 11 insertions(+), 1 deletion(-)

    Pull-Request: https://github.com/gentoo/gentoo/pull/37142

    diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index cde84e6f34c8..3e20e956e9c2 100644
    --- a/eclass/toolchain-funcs.eclass
    +++ b/eclass/toolchain-funcs.eclass
    @@ -1,4 +1,4 @@
    -# Copyright 2002-2023 Gentoo Authors
    +# Copyright 2002-2024 Gentoo Authors
    # Distributed under the terms of the GNU General Public License v2

    # @ECLASS: toolchain-funcs.eclass
    @@ -1251,4 +1251,14 @@ tc-is-lto() {
    return 1
    }

    +# @FUNCTION: tc-has-64bit-time_t
    +# @RETURN: Shell true if time_t is at least 64 bits long, false otherwise +tc-has-64bit-time_t() {
    + "$(tc-getCC)" ${CFLAGS} ${CPPFLAGS} -c -x c - -o /dev/null <<-EOF &>/dev/null
    + #include <sys/types.h>
    + int test[sizeof(time_t) >= 8 ? 1 : -1];
    + EOF
    + return $?
    +}
    +
    fi
    --
    2.45.2

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ulrich Mueller@21:1/5 to All on Thu Jun 13 18:50:01 2024
    On Thu, 13 Jun 2024, Michał Górny wrote:

    + "$(tc-getCC)" ${CFLAGS} ${CPPFLAGS} -c -x c - -o /dev/null <<-EOF &>/dev/null

    IIUC, tc-getCC can return values like "x86_64-pc-linux-gnu-gcc -m32 -mfpmath=sse", so probably you want to lose the quotes there.

    Ulrich

    --=-=-Content-Type: application/pgp-signature; name="signature.asc"

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

    iQFDBAEBCAAtFiEEtDnZ1O9xIP68rzDbUYgzUIhBXi4FAmZrIuoPHHVsbUBnZW50 b28ub3JnAAoJEFGIM1CIQV4uuHEH/0obPLg7gTf0Rm96MypuVX+x56lxul9EUcOe c1o5vJnR7UAlC4GpqCb4jxpkU2OwPC847T4OTcsRFI6RnRqCQCLcEqZrC+uBAaDM I1XrEsJivXttJ7yYLxv+KKCoz+3redNm7QzL14hUwuBmfr9ke2DdgHWMNvzStGTl qvA5Iuk4qsmpwwESl501KcCTsxM4xhhcZLLOFz6HwYiOQTzXoLRJgix4cXYRqcFK j7O2zXl9KElab8fFX52A65Z8qEuIzivu2S4M3zctvEuh7N8Bb1klBunaMJoAM8Yy 7NqNdDAWKrEnkD/4dA2EAlKaSIIWOPOgZrWmb3gXhh/6DefR3H4=lFu7
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From James Le Cuirot@21:1/5 to All on Thu Jun 13 18:50:01 2024
    On Thu, 2024-06-13 at 17:23 +0200, Michał Górny wrote:
    Add a helper function to check whether time_t is 64-bit. This could
    be used e.g. to deselect tests that rely on timestamps exceeding Y2k38.
    It is meant to be more future-proof than hardcoding a list of 32-bit architectures, given the necessity of switching to 64-bit time_t
    in the future.

    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/toolchain-funcs.eclass | 12 +++++++++++-
    1 file changed, 11 insertions(+), 1 deletion(-)

    Pull-Request: https://github.com/gentoo/gentoo/pull/37142

    diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index cde84e6f34c8..3e20e956e9c2 100644
    --- a/eclass/toolchain-funcs.eclass
    +++ b/eclass/toolchain-funcs.eclass
    @@ -1,4 +1,4 @@
    -# Copyright 2002-2023 Gentoo Authors
    +# Copyright 2002-2024 Gentoo Authors
    # Distributed under the terms of the GNU General Public License v2

    # @ECLASS: toolchain-funcs.eclass
    @@ -1251,4 +1251,14 @@ tc-is-lto() {
    return 1
    }

    +# @FUNCTION: tc-has-64bit-time_t
    +# @RETURN: Shell true if time_t is at least 64 bits long, false otherwise +tc-has-64bit-time_t() {
    + "$(tc-getCC)" ${CFLAGS} ${CPPFLAGS} -c -x c - -o /dev/null <<-EOF &>/dev/null
    + #include <sys/types.h>
    + int test[sizeof(time_t) >= 8 ? 1 : -1];
    + EOF
    + return $?
    +}
    +
    fi

    I take it this can't be done with tc-cpp-is-true because you need more than just the preprocessor?

    Please don't quote $(tc-getCC), CC can have additional arguments in some
    cases. We don't quote $(tc-getTARGET_CPP) in tc-cpp-is-true.

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

    iQJFBAABCAAvFiEEPxcZ3tkwcedKm2a8EiZBXQDdMTcFAmZrId8RHGNoZXdpQGdl bnRvby5vcmcACgkQEiZBXQDdMTf6oA//ZmGlCGwf9kRivm0SzMdhI4wvD8jYQyy2 naue6Qg5SEsWI/ECj36VZHl35NX8WZbhhECHRie5fs15IVyzfc83nBWpcvzqi/AZ slYieshzW+X1mpLlvq9tG87aWvu1zj1nl7w4hWlbiJ4s2IJEdnaaENdwtd2Gtfdd qFgd8fctnh21HuA45JzpC1ykeqIVC2+AcOqID1s/Ndyyl1SieB6nXmzv1XjQ4D9c CfuXds8zx41tu6SW6v1QCw60cCYMoZxZV4neXekGN1VU4xL+mRyJ5Yw1WYk9Bg60 mrTgcsjdMbI04c4IjGuIQqjIPDSWKg/OPBVdcl4IcgaxsEGB38lBEON2LMci4F3q Nrj7AhlHRsRRPd5Qik6VVsXH4hpnRQF6w+1IO0Pq35CTjFENDaVqMvGSRrStxNW5 4q40dyH6LCQ8PvOpYQmyxxU+X+N5iIyKrqC4mvn20pKXsh4HoWhObH+zMX/lorbT /fWgheX9o7jY6UnpQmPyDlJPRBqfp1IM+5RunqJ9yPnrB8HSfikYHF8VNJGwWnlN QgQTANymgGmjV6M37pRl49wojOuWyFmI7hzQsn2Rb6qkoNGJqOwIF4TLsGtrqQyR asAobT9V2XyNUHUJX2DHE27gvAl0u/52HXtGBfliwu+u3xCUlZqbUb1onXTZO0wC
    +tLAcf1Cy1w=
    =q55j
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?=@21:1/5 to James Le Cuirot on Thu Jun 13 19:10:01 2024
    On Thu, 2024-06-13 at 17:44 +0100, James Le Cuirot wrote:
    On Thu, 2024-06-13 at 17:23 +0200, Michał Górny wrote:
    Add a helper function to check whether time_t is 64-bit. This could
    be used e.g. to deselect tests that rely on timestamps exceeding Y2k38.
    It is meant to be more future-proof than hardcoding a list of 32-bit architectures, given the necessity of switching to 64-bit time_t
    in the future.

    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/toolchain-funcs.eclass | 12 +++++++++++-
    1 file changed, 11 insertions(+), 1 deletion(-)

    Pull-Request: https://github.com/gentoo/gentoo/pull/37142

    diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index cde84e6f34c8..3e20e956e9c2 100644
    --- a/eclass/toolchain-funcs.eclass
    +++ b/eclass/toolchain-funcs.eclass
    @@ -1,4 +1,4 @@
    -# Copyright 2002-2023 Gentoo Authors
    +# Copyright 2002-2024 Gentoo Authors
    # Distributed under the terms of the GNU General Public License v2

    # @ECLASS: toolchain-funcs.eclass
    @@ -1251,4 +1251,14 @@ tc-is-lto() {
    return 1
    }

    +# @FUNCTION: tc-has-64bit-time_t
    +# @RETURN: Shell true if time_t is at least 64 bits long, false otherwise +tc-has-64bit-time_t() {
    + "$(tc-getCC)" ${CFLAGS} ${CPPFLAGS} -c -x c - -o /dev/null <<-EOF &>/dev/null
    + #include <sys/types.h>
    + int test[sizeof(time_t) >= 8 ? 1 : -1];
    + EOF
    + return $?
    +}
    +
    fi

    I take it this can't be done with tc-cpp-is-true because you need more than just the preprocessor?

    Please don't quote $(tc-getCC), CC can have additional arguments in some cases. We don't quote $(tc-getTARGET_CPP) in tc-cpp-is-true.

    Right, thx.

    --
    Best regards,
    Michał Górny


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

    iQFGBAABCgAwFiEEx2qEUJQJjSjMiybFY5ra4jKeJA4FAmZrJwwSHG1nb3JueUBn ZW50b28ub3JnAAoJEGOa2uIyniQOWrIH/38GIAzq+Y71OXp4K8rsd8MkIFBbGngt g5ZAkAu7ze8qUXeMlqEiAhtEoa/J+gLTNQwEBqfVJulBzKhtX1PkMjDV4nFHfech OmFViyuKRUO8DqkHqaV9SRqW3Ns/QcrzE8fvtBvOxND7QSB4zb+QeKtDDhbLX052 xXvuMa51T9jBiIJiA1r7QlU7/XBgCaFdmFRmPouyqGuQW6IIPcwbB2aV9UIthHA8 v1h3O1jHwWHUiWWjsfN4j99Y4TeLr+EV7Bs5m/cfYKLep2n72i5LKEnb1zg6EDl6 iCjv8tOmas+AIHBT6ebGZBhOYWsET2K9oRkAHB6Hl0xhijVVv4xLGO4=
    =hc5W
    -----END PGP SIGNATURE-----

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