Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 328401 - toolchain-funcs.eclass could benefit from a function which returns bitness
Summary: toolchain-funcs.eclass could benefit from a function which returns bitness
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
: 347701 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-07-15 14:22 UTC by Anthony Basile
Modified: 2023-11-13 22:15 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Adds a proposed tc-bits() to toolchain-funcs.eclass (tc-bits.patch,820 bytes, patch)
2010-07-15 14:25 UTC, Anthony Basile
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony Basile gentoo-dev 2010-07-15 14:22:22 UTC
toolchain-funcs currently has a function tc-endian() which returns the endianness of a CTARGET or CHOST.  It would be nice to have the same for the number of bits, 32 or 64.  This is useful in situations like bug #322413 where upstream compiles with -m32 or -m64 depending user preferences.

Reproducible: Always
Comment 1 Anthony Basile gentoo-dev 2010-07-15 14:25:13 UTC
Created attachment 238895 [details, diff]
Adds a proposed tc-bits() to toolchain-funcs.eclass

I created this list by writing a script which grabs all the current stage3 tarballs, extracts /etc/make.conf and /bin/busybox, and correlates the CHOST line with the bitness as obtain from the binary.
Comment 2 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2010-07-15 15:56:01 UTC
A nasty example of why this function is usefull:

From dev-libs/{nss,nspr}:

    echo > "${T}"/test.c
    $(tc-getCC) ${CFLAGS} -c "${T}"/test.c -o "${T}"/test.o
    case $(file "${T}"/test.o) in
    *64-bit*) export USE_64=1;;
    *32-bit*) ;;
    *) die "Failed to detect whether your arch is 64bits or 32bits, disable distcc if you're using it, please";;
    esac

But, I want to warn that the sparc* checking is broken for sparc64 and sparcv9.
Comment 3 SpanKY gentoo-dev 2010-07-15 20:54:01 UTC
Comment on attachment 238895 [details, diff]
Adds a proposed tc-bits() to toolchain-funcs.eclass

it is impossible to bind "bitsizes" to CHOST.  many CHOSTs support multiple bitsizes without any difference in the CHOST value.
Comment 4 SpanKY gentoo-dev 2010-07-15 21:00:04 UTC
ive specifically left this type of function out of the eclass.  its use should never be encouraged, and adding it to the eclass would only encourage people to f-up their ebuilds royally.

any package that forces -m32/-m64 is broken.  fix it instead.  paxtest appears to be in this category.

i'm aware of the horrible mess that is nss/nspr which is why it has the code that it does today (i suggested it in Bug 210039).  the proper way of fixing that is to use autotools, but the build system is so complicated and USE_64BIT is so prevalent that rewriting it ourselves is not worth the hassle.
Comment 5 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2010-07-15 21:11:29 UTC
(In reply to comment #4)

> i'm aware of the horrible mess that is nss/nspr which is why it has the code
> that it does today (i suggested it in Bug 210039).  the proper way of fixing
> that is to use autotools, but the build system is so complicated and USE_64BIT
> is so prevalent that rewriting it ourselves is not worth the hassle.

Ah, so nss/nspr is a one-off in that regard? I see this and shudder:

    echo > "${T}"/test.c
    $(tc-getCC) -c "${T}"/test.c -o "${T}"/test.o
    case $(file "${T}"/test.o) in
        *64-bit*|*ppc64*|*x86_64*) myconf="${myconf} --enable-64bit";;
        *32-bit*|*ppc*|*i386*|*"RISC System/6000"*) ;;
        *) die "Failed to detect whether your arch is 64bits or 32bits, disable distcc if you're using it, please";;
    esac

because the original code doesn't extend to Gentoo Prefix very well. Anyway, thanks for your expertise in that area.
Comment 6 SpanKY gentoo-dev 2010-07-16 15:51:44 UTC
the original check somewhat assumed an ELF target.  i imagine non ELF targets might break under the check.

if an ELF target is breaking under the existing check, then i'd like to see why.
Comment 7 SpanKY gentoo-dev 2010-12-04 12:54:09 UTC
*** Bug 347701 has been marked as a duplicate of this bug. ***
Comment 8 Dennis Schridde 2010-12-04 16:59:53 UTC
Another package that would benefit from this is dev-java/java-service-wrapper-3.3.3. They currently do this voodoo to prevent the Java/Ant buildsystem from complaining about different bitness of JVM and the compiled-library:
    BITS="32"
    use amd64 && BITS="64"
    eant -Dbits=${BITS} jar compile-c
I figured this out when I tried to compile the package on ia64, which is very well 64bit, despite not being amd64...
Comment 9 SpanKY gentoo-dev 2010-12-06 19:40:57 UTC
and you should be spending time fixing the package in question.  perhaps add a new option like -Dbits=blowme where it causes all bit sanity checks to be skipped since the distro/package manager is taking care of it.
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-01-28 06:09:48 UTC
(In reply to SpanKY from comment #4)
> ive specifically left this type of function out of the eclass.  its use
> should never be encouraged, and adding it to the eclass would only encourage
> people to f-up their ebuilds royally.
> 
> any package that forces -m32/-m64 is broken.  fix it instead.  paxtest
> appears to be in this category.
> 
> i'm aware of the horrible mess that is nss/nspr which is why it has the code
> that it does today (i suggested it in Bug 210039).  the proper way of fixing
> that is to use autotools, but the build system is so complicated and
> USE_64BIT is so prevalent that rewriting it ourselves is not worth the
> hassle.

The problem is, there's various other pieces of software where it's not feasible to then rewrite it, but we still want to - or have to - package it. Copying the logic from nss's ebuild isn't very sustainable either.
Comment 11 Arfrever Frehtes Taifersar Arahesis 2023-01-28 08:32:07 UTC
As better solution, maybe call compiler in preprocessing-only mode (-P) and check macro __SIZEOF_POINTER__?
(https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html)

At least both GCC and Clang define this macro with correct value dependent on -m32 / -m64.

> diff -u <(gcc -m32 -E -P -dM - </dev/null) <(gcc -m64 -E -P -dM - </dev/null) | grep __SIZEOF_
> diff -u <(clang -m32 -E -P -dM - </dev/null) <(clang -m64 -E -P -dM - </dev/null) | grep __SIZEOF_
Comment 12 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-05-27 09:13:43 UTC
Actually, we really do need to do this. 32-bit arches can be used to classify time_t issues & test suite failures w/ precision.
Comment 13 Larry the Git Cow gentoo-dev 2023-05-27 09:15:43 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=76dfbd75b4d6b2fcc0c51535c7e54393c1d705e8

commit 76dfbd75b4d6b2fcc0c51535c7e54393c1d705e8
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-05-27 09:15:23 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-05-27 09:15:31 +0000

    dev-python/numpy: skip test on more 32-bit arches
    
    Bug: https://bugs.gentoo.org/907228
    Bug: https://bugs.gentoo.org/328401
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-python/numpy/numpy-1.24.3.ebuild | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
Comment 14 Larry the Git Cow gentoo-dev 2023-11-13 22:15:36 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f70ca0aa2b8c06f679e05a1b0a9509af6b5ae87a

commit f70ca0aa2b8c06f679e05a1b0a9509af6b5ae87a
Author:     James Le Cuirot <chewi@gentoo.org>
AuthorDate: 2023-11-04 23:31:57 +0000
Commit:     James Le Cuirot <chewi@gentoo.org>
CommitDate: 2023-11-13 22:12:47 +0000

    toolchain-funcs.eclass: Add functions to get pointer size in bytes
    
    tc-get-ptr-size for CHOST and tc-get-build-ptr-size for CBUILD.
    
    Closes: https://bugs.gentoo.org/328401
    Signed-off-by: James Le Cuirot <chewi@gentoo.org>

 eclass/toolchain-funcs.eclass | 14 ++++++++++++++
 1 file changed, 14 insertions(+)