Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

including syslimits.h fails if glibc is in build inputs #8962

Closed
lucabrunox opened this issue Jul 23, 2015 · 27 comments
Closed

including syslimits.h fails if glibc is in build inputs #8962

lucabrunox opened this issue Jul 23, 2015 · 27 comments
Labels
0.kind: enhancement Add something new
Milestone

Comments

@lucabrunox
Copy link
Contributor

Failure: http://hydra.nixos.org/build/23953373/nixlog/1/raw

In file included from /tmp/nix-build-virtualbox-5.0.0-3.18.19.drv-0/VirtualBox-5.0.0/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceLibCWrappers.h:33:0,
                 from /tmp/nix-build-virtualbox-5.0.0-3.18.19.drv-0/VirtualBox-5.0.0/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/dtrace.c:71:
/nix/store/84ff6922izmz0g6akrpslibvabf7xf40-gcc-4.9.3/lib/gcc/i686-pc-linux-gnu/4.9.3/include-fixed/syslimits.h:7:25: error: no include path in which to search for limits.h
 #include_next <limits.h>

It seems to be a toolchain issue on i686 only for virtualbox:

a.c:

#include <limits.h>
#include <syslimits.h>

void main() {
}

Test: gcc a.c

OK x64: nix-shell -A linuxPackages.virtualbox

OK x86 stdenv: nix-shell -A pkgsi686Linux.utillinux

FAIL x86 for virtualbox: nix-shell -A pkgsi686Linux.linuxPackages.virtualbox

cc @vcunat @aszlig

@lucabrunox
Copy link
Contributor Author

It's a problem with NIX_CFLAGS_COMPILE, unsetting them in the nix-shell for virtualbox fixed the problem.

This one is the problem: -isystem /nix/store/rrn35v5334h8izc9g5qvzh81lf12f402-glibc-2.21/include . It's the pkgsi686Linux.glibc .

Now it's weird.

OK x64: nix-shell -A linuxPackages.virtualbox . It has glibc include in the cflags.

FAIL x64: nix-shell -A utillinux . I added the same glibc include in the cflags.

FAIL x86: nix-shell -A pkgsi686Linux.linuxPackages.virtualbox .

FAIL x86: nix-shell -A pkgsi686Linux.utillinux . I added the same glibc include in the cflags.

So it seems that the x64 virtualbox build is lucky

@vcunat
Copy link
Member

vcunat commented Jul 23, 2015

Note that these don't use standard stdenv on 64-bit but the multilib one.

@lucabrunox lucabrunox added the 1.severity: blocker This is preventing another PR or issue from being completed label Jul 23, 2015
@lucabrunox lucabrunox added this to the 15.07 milestone Jul 23, 2015
@aszlig
Copy link
Member

aszlig commented Jul 23, 2015

bisecting...

@aszlig
Copy link
Member

aszlig commented Jul 24, 2015

Done. The issue seems to be in commit e08b9ab.

@aszlig
Copy link
Member

aszlig commented Jul 24, 2015

Indeed, after reverting e08b9ab in master, VirtualBox compiles fine on i686-linux and x86_64-linux, now the interesting part is: why? Because that commit seems to be architecture-unrelated.

@lucabrunox
Copy link
Contributor Author

@aszlig I think because previously we were linking against libiconv. Now instead libiconv is glibc and it gets to NIX_CFLAGS_COMPILE and breaks the syslimits.h. After the revert, can you check echo $NIX_CFLAGS_COMPILE|grep glibc in the virtualbox nix-shell? It should be empty.

@vcunat
Copy link
Member

vcunat commented Jul 24, 2015

Ah, of course, I think the problem should be that it's a different glibc than in the stdenv it uses, because it uses a multi-lib stdenv.

@vcunat
Copy link
Member

vcunat commented Jul 24, 2015

Actually, no, that doesn't make sense, because problems occur only on 32-bit and the stdenv there is equal to the usual 32-bit one (no real multi-lib).

@lucabrunox
Copy link
Contributor Author

@vcunat if you read carefully what I (tried) explained above, that error also happens on x64 when glibc is in NIX_CFLAGS_COMPILE. But, virtualbox luckily compiles on x64 for some other reason.

vcunat added a commit that referenced this issue Jul 24, 2015
For now, until a better resolution is found.
@vcunat
Copy link
Member

vcunat commented Jul 24, 2015

OK, filtering out that glibc include path fixes the build, so I pushed that for now.

It seems some interaction with usage of #include_next, but I don't see the particular cause nor why it doesn't appear everywhere else. Perhaps having libiconv = glibc; on linux isn't a good thing.

@lucabrunox
Copy link
Contributor Author

Possible problem:

  • Without glibc in cflags: include limits.h is found in gcc include-fixed.
  • With glibc in cflags, limits.h is first found in glibc and then syslimits.h from gcc breaks.

@lucabrunox
Copy link
Contributor Author

This happens also on other systems, e.g. ubuntu when adding -isystem /usr/include. In other words, the correct fix is that glibc should not be in -isystem because limits.h must be found in gcc not in glibc.

@lucabrunox
Copy link
Contributor Author

And I wonder, why do we use -isystem instead of -I?

@lucabrunox
Copy link
Contributor Author

Relevant: 6671bb8

@lucabrunox
Copy link
Contributor Author

So @edolstra you appear to have some insight about that -isystem. Why isn't -I enough?

@lucabrunox
Copy link
Contributor Author

Possible solution: use -idirafter, which is after -I and after system dirs. While -isystem is after -I but before system dirs which breaks gcc includes.

@lucabrunox
Copy link
Contributor Author

Ok so this is what happens, with the help of @vcunat on IRC that let me understand what's going on:

By default, we have -idirafter glibc -idirafter gcc, which leads to the following default search path order for include_next: gcc, glibc.

Normal case: gcc, glibc. So syslimits.h is found in gcc, include_next limits.h is found in glibc. OK.

With -isystem glibc: glibc, gcc. As expected, because -isystem glibc comes before -idirafter gcc. So syslimits.h is found in gcc, but there's no limits.h next. KO.

With -I glibc: gcc, glibc. Unexpected, that's because -I ignores the option if it's a system directory, hence glibc is not moved! OK.

With -idirafter glibc: gcc, glibc. Not much expected, it's probably getting ignored because there's alread -idirafter glibc by default. OK.

What to do? :)

@vcunat
Copy link
Member

vcunat commented Jul 24, 2015

Some -isystem discussion: 51713fb.

@vcunat vcunat added 0.kind: enhancement Add something new and removed 1.severity: blocker This is preventing another PR or issue from being completed labels Jul 25, 2015
@vcunat
Copy link
Member

vcunat commented Jul 25, 2015

This shouldn't be a blocker now, although the -isystem situation is (still) perhaps suboptimal.

@vcunat vcunat changed the title About the ova/virtualbox syslimits.h issue including syslimits.h fails if glibc is in build inputs Jul 25, 2015
@wizeman
Copy link
Member

wizeman commented Jul 27, 2015

Maybe I'm mistaken, but gcc 4.9 seems to be failing due to what looks like a similar glibc/gcc header issue: https://hydra.nixos.org/build/24001011

@vcunat
Copy link
Member

vcunat commented Jul 27, 2015

Yes, maybe. I know this problem; notice that stdenv.cc is gcc-4.9. I consider it a bootstrapping bug that our stdenv.cc != gcc (== gcc49).

@edolstra
Copy link
Member

This can be fixed by adding gcc49 = cc to overrides in stdenvLinux in pkgs/stdenv/linux/default.nix, but we'll have to remember to keep that up to date when switching to a newer gcc.

@vcunat vcunat modified the milestones: 16.03, 15.09 Sep 25, 2015
@domenkozar
Copy link
Member

@edolstra a friendly ping so you remember about this for gcc5

@vcunat
Copy link
Member

vcunat commented Feb 29, 2016

In master we already have stdenv.cc == gcc. I suppose it was fixed with #2817.

@Mathnerd314
Copy link
Contributor

Right, now gcc != gcc49. But nothing uses gcc49 so it's not a problem.

Perhaps this issue could be fixed by setting libiconv = stdenv? Since (g)libc is included in stdenv, and stdenv acts as a no-op in buildInputs.

@fpletz
Copy link
Member

fpletz commented Jan 20, 2017

Works as of 16.09.

@fpletz fpletz closed this as completed Jan 20, 2017
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/where-is-limits-h/50535/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement Add something new
Projects
None yet
Development

No branches or pull requests

9 participants