Skip to content

gnugrep: fix cross-compilation (buildInputs -> nativeBuildInputs)#8433

Closed
bjornfor wants to merge 1 commit intoNixOS:stagingfrom
bjornfor:gnugrep-fix-cross-compile
Closed

gnugrep: fix cross-compilation (buildInputs -> nativeBuildInputs)#8433
bjornfor wants to merge 1 commit intoNixOS:stagingfrom
bjornfor:gnugrep-fix-cross-compile

Conversation

@bjornfor
Copy link
Contributor

Now I can finally build bootstrap-tools-cross:

$ nix-build pkgs/stdenv/linux/make-bootstrap-tools-cross.nix -A armv7l
/nix/store/59zrljz7hrjfliychv62r386y3yrfrah-build
/nix/store/4701h00w1rynd0n8s1ax490ygl8v75z5-busybox-1.23.2-armv7l-unknown-linux-gnueabi
/nix/store/37bsa3sk07lp714gryny9z8q0pj6bfha-coreutils-8.23-armv7l-unknown-linux-gnueabi
/nix/store/wy9xvcfd6mwlzskpc0wf0zv6wm88haaz-curl-7.42.1-armv7l-unk

Instead of this (current) build error:

$ nix-build pkgs/stdenv/linux/make-bootstrap-tools-cross.nix -A armv7l
...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... no
configure: error: in /tmp/nix-build-gnugrep-2.21-armv7l-unknown-linux-gnueabi.drv-4/grep-2.21': configure: error: C compiler cannot create executables Seeconfig.log' for more details

config.log shows that it failed due to host glibc being used instead of target
glibc.


Questions:

  • The gnugrep expression seems to have had this buildInput for a long time. How did you NixOS + ARM users out there bootstrap this thing (without this fix)?
  • According to the NixOS wiki[1],
nativeBuildInputs: derivations built for the build system (native builds), needed for the actual cross-build.
buildInputs: derivations built for the host-system (to be run in the target), needed for the actual cross-build.

Well that sounds to me like the opposite of what's really happening; cross-compiling gnugrep fails because host glibc is picked up from buildInputs. To fix it I had to change it to nativeBuildInputs. Confused :-/ Well, it could be a special case since it's the cross-compiler that fails... I don't know.

[1] https://nixos.org/wiki/CrossCompiling

Now I can finally build bootstrap-tools-cross:

  $ nix-build pkgs/stdenv/linux/make-bootstrap-tools-cross.nix -A armv7l
  /nix/store/59zrljz7hrjfliychv62r386y3yrfrah-build
  /nix/store/4701h00w1rynd0n8s1ax490ygl8v75z5-busybox-1.23.2-armv7l-unknown-linux-gnueabi
  /nix/store/37bsa3sk07lp714gryny9z8q0pj6bfha-coreutils-8.23-armv7l-unknown-linux-gnueabi
  /nix/store/wy9xvcfd6mwlzskpc0wf0zv6wm88haaz-curl-7.42.1-armv7l-unk

Instead of this (current) build error:

  $ nix-build pkgs/stdenv/linux/make-bootstrap-tools-cross.nix -A armv7l
  ...
  checking whether we are cross compiling... yes
  checking for suffix of object files... o
  checking whether we are using the GNU C compiler... no
  configure: error: in `/tmp/nix-build-gnugrep-2.21-armv7l-unknown-linux-gnueabi.drv-4/grep-2.21':
  configure: error: C compiler cannot create executables
  See `config.log' for more details

config.log shows that it failed due to host glibc being used instead of target
glibc.
@bjornfor
Copy link
Contributor Author

CC @viric @dezgeg

dezgeg referenced this pull request in wkennington/nixpkgs Jun 20, 2015
@dezgeg
Copy link
Contributor

dezgeg commented Jun 20, 2015

I guess it's just that nobody's tried to recompile the bootstrap tools before. Normally there's no need to do it, since the prebuilt tarball of the tools is used: https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/linux/bootstrap/armv7l.nix

BTW, @wkennington has a PR to refactor the cross-build scripts, it has some other fixes to the bootstrap tools builder as well: #8081

@bjornfor
Copy link
Contributor Author

@dezgeg: Thanks for the info.

Btw, this confuses me, dezgeg@6d0f474

because we have buildInputs, nativeBuildInputs AND derivation + derivation.crossDrv. So when specifying what kind of a dependency something is (host or target), there is seemingly multiple ways to do it.

@bjornfor
Copy link
Contributor Author

Still, the bootstrap tools would have to had to be built at some point :-)

@wkennington
Copy link
Contributor

I think this has to do with the grep update maybe? I've built them not that
long ago but was running into this issue today and thought it was due to
some other changes I made.

On Sat, Jun 20, 2015, 06:50 Bjørn Forsman notifications@github.com wrote:

Still, the bootstrap tools would have to had to be built at some point
:-)


Reply to this email directly or view it on GitHub
#8433 (comment).

@wkennington
Copy link
Contributor

Wait this pr doesn't make sense, pcre is something grep links against so it
should be a build input not native build input.

On Sat, Jun 20, 2015, 10:54 William Kennington william@wkennington.com
wrote:

I think this has to do with the grep update maybe? I've built them not
that long ago but was running into this issue today and thought it was due
to some other changes I made.

On Sat, Jun 20, 2015, 06:50 Bjørn Forsman notifications@github.com
wrote:

Still, the bootstrap tools would have to had to be built at some point
:-)


Reply to this email directly or view it on GitHub
#8433 (comment).

@wkennington
Copy link
Contributor

Fixed by d4f176f

@bjornfor
Copy link
Contributor Author

@wkennington: Thanks. I knew there was something odd with my change.

@bjornfor
Copy link
Contributor Author

@wkennington: Ugh, it still fails in latest staging branch. But now for completely different reasons:

$ nix-build pkgs/stdenv/linux/make-bootstrap-tools-cross.nix -A armv7l
...
Sparse_Row.inlines.hh:51:72: note: candidate is:
In file included from /nix/store/s7vl9h5xyryz2yi3awaw6k2wv0l1difs-gcc-4.9.2-armv7l-unknown-linux-gnueabi-stage-final/armv7l-unknown-linux-gnueabi/include/c++/4.9.2/bits/stl_algobase.h:66:0,
                 from /nix/store/s7vl9h5xyryz2yi3awaw6k2wv0l1difs-gcc-4.9.2-armv7l-unknown-linux-gnueabi-stage-final/armv7l-unknown-linux-gnueabi/include/c++/4.9.2/bits/char_traits.h:39,
                 from /nix/store/s7vl9h5xyryz2yi3awaw6k2wv0l1difs-gcc-4.9.2-armv7l-unknown-linux-gnueabi-stage-final/armv7l-unknown-linux-gnueabi/include/c++/4.9.2/ios:40,
                 from /nix/store/s7vl9h5xyryz2yi3awaw6k2wv0l1difs-gcc-4.9.2-armv7l-unknown-linux-gnueabi-stage-final/armv7l-unknown-linux-gnueabi/include/c++/4.9.2/ostream:38,
                 from /nix/store/s7vl9h5xyryz2yi3awaw6k2wv0l1difs-gcc-4.9.2-armv7l-unknown-linux-gnueabi-stage-final/armv7l-unknown-linux-gnueabi/include/c++/4.9.2/iostream:39,
                 from checked.defs.hh:28,
                 from Checked_Number.defs.hh:28,
                 from Coefficient.types.hh:16,
                 from Linear_Expression.defs.hh:36,
                 from Constraint.defs.hh:36,
                 from Constraint.cc:25:
/nix/store/s7vl9h5xyryz2yi3awaw6k2wv0l1difs-gcc-4.9.2-armv7l-unknown-linux-gnueabi-stage-final/armv7l-unknown-linux-gnueabi/include/c++/4.9.2/bits/stl_iterator_base_funcs.h:114:5: note: template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator)
     distance(_InputIterator __first, _InputIterator __last)
     ^
/nix/store/s7vl9h5xyryz2yi3awaw6k2wv0l1difs-gcc-4.9.2-armv7l-unknown-linux-gnueabi-stage-final/armv7l-unknown-linux-gnueabi/include/c++/4.9.2/bits/stl_iterator_base_funcs.h:114:5: note:   substitution of deduced template arguments resulted in errors seen above
guessing yes
checking for __xpg4... no
checking dynamic linker characteristics... no
checking whether link(2) dereferences a symlink... guessing no
checking whether linkat(,AT_SYMLINK_FOLLOW) works... Makefile:1342: recipe for target 'Constraint.lo' failed
make[3]: *** [Constraint.lo] Error 1
make[3]: Leaving directory '/tmp/nix-build-ppl-1.0-armv7l-unknown-linux-gnueabi.drv-0/ppl-1.0/src'
Makefile:1128: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/tmp/nix-build-ppl-1.0-armv7l-unknown-linux-gnueabi.drv-0/ppl-1.0/src'
need runtime check
Makefile:471: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/tmp/nix-build-ppl-1.0-armv7l-unknown-linux-gnueabi.drv-0/ppl-1.0'
checking whether linkat handles trailing slash correctly... Makefile:400: recipe for target 'all' failed
make: *** [all] Error 2
guessing yes
checking whether locale.h conforms to POSIX:2001... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for shl_load... yes
checking whether locale.h defines locale_t... builder for ‘/nix/store/g2xfwyb36xj2ssc287y5gmdv87fjqbx7-ppl-1.0-armv7l-unknown-linux-gnueabi.drv’ failed with exit code 2
cannot build derivation ‘/nix/store/b7vdz6q4spq9jvqhazy34j75mlyqdbna-cloog-ppl-0.15.11-armv7l-unknown-linux-gnueabi.drv’: 1 dependencies couldn't be built
cannot build derivation ‘/nix/store/sqjicrchpm2b9f3v6ln8mp8xz8fygshv-build.drv’: 1 dependencies couldn't be built
error: build of ‘/nix/store/sqjicrchpm2b9f3v6ln8mp8xz8fygshv-build.drv’ failed

@bjornfor bjornfor mentioned this pull request Jun 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants