Bazel and Yocto

2,252 views
Skip to first unread message

Giuseppe Di Guglielmo

unread,
May 5, 2017, 8:02:16 PM5/5/17
to bazel-discuss
Hi all,
I am trying to (cross-)compile Bazel 0.4.5 in the Yocto system. The target is an ARMv7 and the Linux distro is Poky.

I am getting this compilation error:
---
| �  Building Bazel with Bazel.
| ................................
| ____Loading package: src
| ____Loading package: @bazel_tools//tools/cpp
| ____Loading package: @local_config_xcode//
| ERROR: in target '//external:cc_toolchain': no such package '@local_config_cc//': Traceback (most recent call last):
|       File "/home/giuseppe/.cache/bazel/_bazel_giuseppe/32d64188b76850bf1edfd4141b911134/external/bazel_tools/tools/cpp/cc_configure.bzl", line 584
|               _find_cc(repository_ctx)
|       File "/home/giuseppe/.cache/bazel/_bazel_giuseppe/32d64188b76850bf1edfd4141b911134/external/bazel_tools/tools/cpp/cc_configure.bzl", line 383, in _find_cc
|               repository_ctx.which(cc_name)
| Program argument of which() may not contains a / or a \ ('arm-poky-linux-gnueabi-gcc  -march=armv7-a -marm -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/home/giuseppe/research/projects/zynq/yocto/build/tmp/sysroots/zc702-zynq7' given).
| ____Elapsed time: 3.851s
---

Do you have any suggestions?

Thank you,
Giuseppe

Brian Silverman

unread,
May 5, 2017, 9:26:33 PM5/5/17
to Giuseppe Di Guglielmo, bazel-discuss
Looks like you're setting CC='arm-poky-linux-gnueabi-gcc  -march=armv7-a -marm -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/home/giuseppe/research/projects/zynq/yocto/build/tmp/sysroots/zc702-zynq7'? tools/cpp/cc_configure.bzl isn't expecting compiler flags there, and I actually don't see any way to get flags into it right now. You could add a COPTS or something environment variable pretty easily if you want.

Taking a step back though, I'm pretty sure this isn't going to do what you want. Bazel expects that the C/C++ compiler it finds (via the CC environment variable or any other way) builds binaries it can then run as part of the build process. A cross compiler isn't going to do that. You should be able to get cross compiling to work by writing a custom CROSSTOOL and doing the build with a --cpu= argument to tell it the target compiler to use, with the host one using the auto-detected CPU setting. If you want, making cc_configure.bzl take CC and HOST_CC environment variables (and maybe COPTS and HOST_COPTS too) and do the right thing with them should be possible, but it's not going to happen automatically without a decent amount of Bazel-specific work. I see no reason a patch implementing that wouldn't be accepted if somebody's interested though. I'm not sure how Yocto deals with this kind of thing "normally". About the CROSSTOOLBuilding with a custom toolchain, and the files in tools/cpp in the Bazel source tree are good places to start if you want to go down that route.

Also, are you using compile.sh to attempt a bootstrap? The standard way to do it now is by downloading the latest release binary and `bazel build -c opt //src:bazel` (or one of the packages if that's what you want). The Compile Bazel from Source page looks a bit out of date...

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/bdd9c7e1-af71-4388-8672-702d771eee0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

gopina...@gmail.com

unread,
Sep 4, 2017, 5:36:22 AM9/4/17
to bazel-discuss
Hi,
I am also getting the same error.. Did you get any breakthrough on how to resolve it.

rgopin...@gmail.com

unread,
Sep 22, 2017, 6:13:03 AM9/22/17
to bazel-discuss
Hi,

I am trying to use bazel on my board which is armv7l architecture and i am using poky distro builded from yocto.

While compiling bazel source code i need to provide cxx flags as my libstd++ is optimized for 'cortex-a15'.

So i need to add '-mcpu=cortex-a15' to my cxx flags while compiling bazel from source but i don't know in which file i have to provide the compiler options.

rakesh...@gmail.com

unread,
Dec 10, 2017, 6:31:17 PM12/10/17
to bazel-discuss

Hi,

Snipsco seem to have a patch for tensorflow which basically is for bazel to be able to cross compile tensorflow.
https://github.com/snipsco/tensorflow-build/blob/master/tf-crosscompile.patch

Apologies if its not directly related to this problem.

- Rakesh

paradi...@gmail.com

unread,
Mar 31, 2019, 4:17:37 PM3/31/19
to bazel-discuss
Bootstrapping `bazel` is not easy. There seems to be a qemu bug which prevents correct cross-compiling of `bazel` (for bazel versions later than 0.5.4): https://github.com/bazelbuild/bazel/issues/7135
Reply all
Reply to author
Forward
0 new messages