Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 326693 - sys-libs/glibc: add pkg_config check for CONFIG_IA32_EMULATION when USE=multilib and CTARGET=x86_64-*
Summary: sys-libs/glibc: add pkg_config check for CONFIG_IA32_EMULATION when USE=multi...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: High enhancement (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
: 335927 393479 396721 508688 544642 545014 546960 572196 583228 626254 637302 (view as bug list)
Depends on:
Blocks: 192286 glibc-2.27
  Show dependency tree
 
Reported: 2010-07-02 23:08 UTC by kavol
Modified: 2018-02-03 01:38 UTC (History)
13 users (show)

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


Attachments
Add check for CONFIG_IA32_EMULATION if using multilib and amd64 and not cross-compiling (enable-IA32_EMULATION-check.patch,1.39 KB, patch)
2014-10-09 02:17 UTC, Steven Presser
Details | Diff
Performs a test of compiling and running a 32-bit elf to determine if IA32_EMULATION is set in running kernel (enable-IA32_EMULATION-check.patch,1017 bytes, patch)
2014-10-09 17:38 UTC, Steven Presser
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description kavol 2010-07-02 23:08:06 UTC
If multilib profile is set, glibc needs the kernel built with IA32 Emulation enabled, otherwise it fails to emerge with "cannot execute binary file". (I refer to bug #325031)

Please add to pkg_setup the function to check the required kernel config option if multilib is activated. Many of the existing ebuilds, like for example nvidia and ati drivers, already use the function linux_chkconfig_present to ensure sane setup before trying to compile ...

Reproducible: Always
Comment 1 SpanKY gentoo-dev 2010-07-05 23:04:11 UTC
kernel eclasses like to pull in kernel sources, so that's out

a simple -m32 compile & execute test like the existing ones should be easy
Comment 2 SpanKY gentoo-dev 2012-01-02 05:56:28 UTC
*** Bug 396721 has been marked as a duplicate of this bug. ***
Comment 3 Paweł Hajdan, Jr. (RETIRED) gentoo-dev 2012-01-02 07:43:44 UTC
(In reply to comment #1)
> a simple -m32 compile & execute test like the existing ones should be easy

Yup, there is an example posted here: http://forums.gentoo.org/viewtopic-p-6916504.html#6916504 by "Hu":

check_ia32_emulation_works() { 
   use amd64 || return 0 
   echo 'int main(){return 0;}' > "${T}/check-ia32-emulation.c" 
   "${CC-${CHOST}-gcc}" ${CFLAGS_x86} "${T}/check-ia32-emulation.c" -o "${T}/check-ia32-emulation.elf32" 
   "${T}/check-ia32-emulation.elf32" || die "IA32 emulation is broken.  Check your kernel and C library." 
   rm -f "${T}/check-ia32-emulation.elf32" 
}
Comment 4 SpanKY gentoo-dev 2012-01-04 19:36:05 UTC
i don't want to add explicit open coded logic for every single ABI
Comment 5 SpanKY gentoo-dev 2014-04-26 21:43:39 UTC
*** Bug 508688 has been marked as a duplicate of this bug. ***
Comment 6 Steven Presser 2014-10-09 02:17:29 UTC
Created attachment 386268 [details, diff]
Add check for CONFIG_IA32_EMULATION if using multilib and amd64 and not cross-compiling

I ran into this issue tonight and created the following patch which (I believe) circumvents the objections raised to this check.  I used the linux-info eclass to check if CONFIG_IA32_EMULATION is set, but only if it isn't a cross compile (I'm not entirely sure I got that conditional right, to be honest) and if the multilib and amd64 use flags are set.

No runtime-compilation of anything, nothing more ABI-specific than it needs to be.  All the checks I added are flexible enough that additional kernel flag checks can be added without modification, reducing the complexity of adding similar checks in the future.

If there are any issues with this patch (especially my check for cross-compilation...) I would be happy to take feedback and resubmit.

Steve
Comment 7 Anthony Basile gentoo-dev 2014-10-09 11:31:53 UTC
(In reply to Steven Presser from comment #6)
> Created attachment 386268 [details, diff] [details, diff]
> Add check for CONFIG_IA32_EMULATION if using multilib and amd64 and not
> cross-compiling
> 
> I ran into this issue tonight and created the following patch which (I
> believe) circumvents the objections raised to this check.  I used the
> linux-info eclass to check if CONFIG_IA32_EMULATION is set, but only if it
> isn't a cross compile (I'm not entirely sure I got that conditional right,
> to be honest) and if the multilib and amd64 use flags are set.
> 
> No runtime-compilation of anything, nothing more ABI-specific than it needs
> to be.  All the checks I added are flexible enough that additional kernel
> flag checks can be added without modification, reducing the complexity of
> adding similar checks in the future.
> 
> If there are any issues with this patch (especially my check for
> cross-compilation...) I would be happy to take feedback and resubmit.
> 
> Steve

Using linux-info is not a good idea.  It makes loose assumptions about which kernel config files to look at.  It looks in /usr/src/linux if it fails to find /proc/config.gz and the two are often mismatched on people's systems.

Mike's idea of a simple gcc -m32 test goes straight to the point.
Comment 8 Steven Presser 2014-10-09 17:38:05 UTC
Created attachment 386308 [details, diff]
Performs a test of compiling and running a 32-bit elf to determine if IA32_EMULATION is set in running kernel

(In reply to Anthony Basile from comment #7)
> (In reply to Steven Presser from comment #6)
> > Created attachment 386268 [details, diff] [details, diff] [details, diff]
> > Add check for CONFIG_IA32_EMULATION if using multilib and amd64 and not
> > cross-compiling
> > 
> > I ran into this issue tonight and created the following patch which (I
> > believe) circumvents the objections raised to this check.  I used the
> > linux-info eclass to check if CONFIG_IA32_EMULATION is set, but only if it
> > isn't a cross compile (I'm not entirely sure I got that conditional right,
> > to be honest) and if the multilib and amd64 use flags are set.
> > 
> > No runtime-compilation of anything, nothing more ABI-specific than it needs
> > to be.  All the checks I added are flexible enough that additional kernel
> > flag checks can be added without modification, reducing the complexity of
> > adding similar checks in the future.
> > 
> > If there are any issues with this patch (especially my check for
> > cross-compilation...) I would be happy to take feedback and resubmit.
> > 
> > Steve
> 
> Using linux-info is not a good idea.  It makes loose assumptions about which
> kernel config files to look at.  It looks in /usr/src/linux if it fails to
> find /proc/config.gz and the two are often mismatched on people's systems.
> 
> Mike's idea of a simple gcc -m32 test goes straight to the point.

Fair enough, I did notice that about linux-info. On my box it seems to skip /proc/config.gz entirely.  It just seemed to be in pretty common use:
# grep -R linux-info /usr/portage/* | awk -F'/' '{print $1 "/" $2}' | sort | uniq | wc -l
276

Anyway, updated patch using the -m32 test.  I more or less ripped the test from comment 3.  However, I modified it to always clean up and to always print the result.
Comment 9 SpanKY gentoo-dev 2014-10-20 17:05:54 UTC
(In reply to Steven Presser from comment #8)

using linux-info in the wider tree makes sense when you have packages that need to build kernel code or otherwise check config settings & warn.  but the C library shouldn't be depending on the kernel like those others can.

also, can you guys please stop full quoting messages.  it spams bugzilla and makes it hard to actually read comments.
Comment 10 Steven Presser 2014-10-24 21:47:15 UTC
(In reply to SpanKY from comment #9)
> also, can you guys please stop full quoting messages.  it spams bugzilla and
> makes it hard to actually read comments.

Fair 'nough.

> using linux-info in the wider tree makes sense when you have packages that
> need to build kernel code or otherwise check config settings & warn.  but
> the C library shouldn't be depending on the kernel like those others can.

Okay, linux-info aside, obviously the C library *does* depend on the kernel, at least during the build process.  libc is also a core part of the system and therefore should not bomb out in unusual ways, even in odd (or, in this case, invalid) configurations.

Since this is the case, there are two solutions:
1) adjust it so it doesn't
2) check these dependencies (in conditions in which it makes sense to do so)

Option 1 seems like a significant amount of work (as well as setting up a situation in which we completely ignore the multilib flag).  I therefore elected to ignore it in favor of option 2.

Option 2 doesn't come without restriction however.  libc is often cross-compiled to run on new hardware or a new system.  In this situation, it doesn't make sense to check kernel configuration - it simply will not match that of the system glibc will be running on.  For this reason, I have copied similar checks elsewhere in the package and restricted the checks to non-cross-compiled instantiations of the ebuild and then only on x86_64 hardware.

Additionally, as discussed above, using linux-info for this purpose is unsuitable.  Therefore, the most recent patch includes a directly compiled check for the prerequisite.  So far I have no comments on this patch.  Are there any?

I'm happy to bow to experience about which dependency checking method is superior.  I'm happy to go off and work on removing the dependency on the kernel if the patch will be accepted.  However, I am not happy with leaving glibc bombing out with an inscrutable error message.  I'm trying to solve that problem, and would appreciate guidance.

Thanks for the assistance,
Steve
Comment 11 kavol 2014-10-25 11:16:32 UTC
(In reply to Steven Presser from comment #10)
> I'm happy to bow to experience about which dependency checking method is
> superior.  I'm happy to go off and work on removing the dependency on the
> kernel if the patch will be accepted.  However, I am not happy with leaving
> glibc bombing out with an inscrutable error message.  I'm trying to solve
> that problem, and would appreciate guidance.

I'm in the position of a dumb user here so I cannot provide any experience or guidance, however I can provide some kind words that I'm happy that someone tries to solve this, thanks!
Comment 12 Steven Presser 2015-03-02 12:41:35 UTC
It's been 4 months.  Any comment on my most recent proposed patch?

Steve
Comment 13 SpanKY gentoo-dev 2015-03-27 20:36:57 UTC
*** Bug 335927 has been marked as a duplicate of this bug. ***
Comment 14 SpanKY gentoo-dev 2015-03-27 20:37:24 UTC
*** Bug 393479 has been marked as a duplicate of this bug. ***
Comment 15 SpanKY gentoo-dev 2015-03-27 20:37:32 UTC
*** Bug 544642 has been marked as a duplicate of this bug. ***
Comment 16 SpanKY gentoo-dev 2015-04-03 01:00:25 UTC
*** Bug 545014 has been marked as a duplicate of this bug. ***
Comment 17 SpanKY gentoo-dev 2015-04-27 03:14:34 UTC
*** Bug 546960 has been marked as a duplicate of this bug. ***
Comment 18 SpanKY gentoo-dev 2016-01-18 09:39:52 UTC
*** Bug 572196 has been marked as a duplicate of this bug. ***
Comment 19 SpanKY gentoo-dev 2016-05-23 16:05:19 UTC
*** Bug 583228 has been marked as a duplicate of this bug. ***
Comment 20 Andreas K. Hüttel archtester gentoo-dev 2017-11-11 17:13:28 UTC
*** Bug 626254 has been marked as a duplicate of this bug. ***
Comment 21 Andreas K. Hüttel archtester gentoo-dev 2017-11-13 10:09:56 UTC
*** Bug 637302 has been marked as a duplicate of this bug. ***
Comment 22 Larry the Git Cow gentoo-dev 2018-01-20 17:36:23 UTC
The bug has been closed via the following commit(s):

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

commit 4dfbdb5451ec3041b206bc057b5c1a2eb2a6b774
Author:     Andreas K. Hüttel <dilfridge@gentoo.org>
AuthorDate: 2018-01-20 17:35:27 +0000
Commit:     Andreas K. Hüttel <dilfridge@gentoo.org>
CommitDate: 2018-01-20 17:36:07 +0000

    sys-libs/glibc: Test for IA32 emulation before building amd64 multilib glibc, bug 326693.
    
    Based on the patch by Steven Presser.
    
    Closes: https://bugs.gentoo.org/326693
    Package-Manager: Portage-2.3.19, Repoman-2.3.6

 sys-libs/glibc/glibc-9999.ebuild | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
Comment 23 Larry the Git Cow gentoo-dev 2018-02-03 01:38:58 UTC
The bug has been referenced in the following commit(s):

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

commit 2b297eb4b3b9114b1663b5affd9e3a9f0c22fedd
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2018-02-03 01:38:38 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2018-02-03 01:38:38 +0000

    sys-libs/glibc: restore ability to switch single->multiple ABIs
    
    To recover broken system automatically from bug #646424
    we need to skip IA32 ABI checks as those require multiabi
    glibc checks at glibc build time.
    
    There is no need to impose it as a requirement. Fail test
    only if it compiled successfully and failed at runtime.
    
    Bug: https://bugs.gentoo.org/326693
    Bug: https://bugs.gentoo.org/646424
    Package-Manager: Portage-2.3.20, Repoman-2.3.6

 sys-libs/glibc/glibc-2.27-r1.ebuild | 14 ++++++++++----
 sys-libs/glibc/glibc-9999.ebuild    | 14 ++++++++++----
 2 files changed, 20 insertions(+), 8 deletions(-)}