Bazel on ARM

1,863 views
Skip to first unread message

Andrew Rossignol

unread,
Jun 30, 2015, 3:08:03 PM6/30/15
to bazel-...@googlegroups.com
Hello bazel-discuss,

I have a version of Bazel compiled for Linux running on an ARM processor. I compiled a small C++ and OpenGL project of mine for an ARM version of Ubuntu.

These are (roughly) the changes that I made for this to work:
  • Compile protoc for ARM
    • The Maven repo only produces Mac and Linux binaries for protoc (x86 and x86_64) at the moment. I don't know much about Maven so I just built it locally using automake.
  • Updated the bootstrap scripts to handle an ARM processor (added a MACHINE_IS_ARM variable) and used the ARM protoc.
  • Updated java/com/google/devtools/build/lib/util/CPU.java to have an ARM entry.
  • Updated tools/cpp/CROSSTOOL file to have a "local_linux" default_toolchain for ARM.
  • Updated third_party/BUILD to have a config_setting for ARM and added the ARM protoc to the selector in the thirdparty:protoc target.
The current setup is running on an ARM Chromebook with Crouton, but this opens up the possibility of running Bazel on a Raspberry Pi (something I haven't tested yet).

I wanted to see how the community feels about this idea. I would be interested in getting this checked in, but would like to gauge interest and see if anyone would be receptive to these changes.

Andrew

Lukács T. Berki

unread,
Jul 1, 2015, 4:51:01 AM7/1/15
to Andrew Rossignol, bazel-...@googlegroups.com
In general, I think this is a good idea. The only thing I am wary of is that since the core development team doesn't really use and ARM machines, the code will be liable to rotting until we put some reasonable test infrastructure in place. In a bit more detail:


On Tue, Jun 30, 2015 at 9:08 PM, Andrew Rossignol <aaro...@google.com> wrote:
Hello bazel-discuss,

I have a version of Bazel compiled for Linux running on an ARM processor. I compiled a small C++ and OpenGL project of mine for an ARM version of Ubuntu.

These are (roughly) the changes that I made for this to work:
  • Compile protoc for ARM
    • The Maven repo only produces Mac and Linux binaries for protoc (x86 and x86_64) at the moment. I don't know much about Maven so I just built it locally using automake.
Since we already have protoc binaries checked in, I think this is fine. 
  • Updated the bootstrap scripts to handle an ARM processor (added a MACHINE_IS_ARM variable) and used the ARM protoc.
  • Updated java/com/google/devtools/build/lib/util/CPU.java to have an ARM entry.
  • Updated third_party/BUILD to have a config_setting for ARM and added the ARM protoc to the selector in the thirdparty:protoc target.
  • Updated tools/cpp/CROSSTOOL file to have a "local_linux" default_toolchain for ARM.
No problems with these.  I'd be happy to review this change :)
 

Han-Wen Nienhuys

unread,
Jul 1, 2015, 5:05:56 AM7/1/15
to Lukács T. Berki, Andrew Rossignol, bazel-...@googlegroups.com
Also, as a practical note, Raspberry Pi systems are somewhat
underpowered. It might be more beneficial to run Bazel on x86, and use
--run_under to run tests the ARM machine instead. That said, I don't
think we mind changes to support ARM.
> --
> 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-discus...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/bazel-discuss/CAOu%2B0LWAT9OQSoD%3DUEeOx2m9YbeJn%2B68gzzVtsBPoq_kXC83Cg%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Han-Wen Nienhuys
Google Munich
han...@google.com

Andrew Rossignol

unread,
Jul 1, 2015, 1:36:08 PM7/1/15
to Han-Wen Nienhuys, Lukács T. Berki, bazel-...@googlegroups.com
I agree that cross compiling is probably the way to go, but interactive development with Bazel is quite fun. The laptop I completed this experiment on has a powerful ARM processor.

What would it take to have Maven produce an ARM binary of protoc? I know very little about how it works. Would it require an update to the pom.xml file?
--

Andrew Rossignol | Software Engineer | aaro...@google.com | 

Damien Martin-guillerez

unread,
Jul 1, 2015, 1:43:57 PM7/1/15
to Andrew Rossignol, Han-Wen Nienhuys, Lukács T. Berki, bazel-...@googlegroups.com
I don't think we really care about it being compiled by maven. We used the protoc from maven central because they are provided by the protobuf team and we don't want to be doing that.

If you can make sure that the ARM protoc is accessible on the web then it's probably enough but you have to make sure to always provide the latest version of the protoc binary. Or you could ask the protobuf team to include ARM as their target.

Andrew Rossignol

unread,
Jul 1, 2015, 2:03:35 PM7/1/15
to bazel-...@googlegroups.com, aaro...@google.com, prot...@googlegroups.com, lbe...@google.com, han...@google.com
+protobuf

What would it take to have Maven Central produce ARM binaries for protoc? Is this possible?

Thanks!

Andrew

Feng Xiao

unread,
Jul 6, 2015, 3:38:01 PM7/6/15
to Andrew Rossignol, Kun Zhang, bazel-...@googlegroups.com, Protocol Buffers, Lukács T. Berki, Han-Wen Nienhuys
+Kun who maintains the protoc binary on Maven.

On Wed, Jul 1, 2015 at 11:03 AM, 'Andrew Rossignol' via Protocol Buffers <prot...@googlegroups.com> wrote:
+protobuf

What would it take to have Maven Central produce ARM binaries for protoc? Is this possible?
We don't have ARM machines to produce ARM binaries.

For bazel, we recently added a BUILD file that can be used to build protoc with bazel. Could bazel integrate it as part of the build process when it needs protoc?
 

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.

Damien Martin-guillerez

unread,
Jul 6, 2015, 3:50:47 PM7/6/15
to Feng Xiao, Andrew Rossignol, Kun Zhang, bazel-...@googlegroups.com, Protocol Buffers, Lukács T. Berki, Han-Wen Nienhuys
There is a bootstrap problem: we need protoc compiler to bootstrap bazel but we could be baking protoc using bazel. However we probably will have to cross-compile for such a thing.


Feng Xiao

unread,
Jul 6, 2015, 4:44:37 PM7/6/15
to Damien Martin-guillerez, Andrew Rossignol, Kun Zhang, bazel-...@googlegroups.com, Protocol Buffers, Lukács T. Berki, Han-Wen Nienhuys
On Mon, Jul 6, 2015 at 12:50 PM, Damien Martin-guillerez <dmar...@google.com> wrote:
There is a bootstrap problem: we need protoc compiler to bootstrap bazel but we could be baking protoc using bazel. However we probably will have to cross-compile for such a thing.
Hmm, why does bazel need protoc to bootstrap? This seems a different design from the blaze we use internally.

Damien Martin-guillerez

unread,
Jul 6, 2015, 5:14:42 PM7/6/15
to Feng Xiao, Andrew Rossignol, Kun Zhang, bazel-...@googlegroups.com, Protocol Buffers, Lukács T. Berki, Han-Wen Nienhuys
It is the same. Bazel/Blaze have several protocol buffer to interact with various tools that needs to be compiled. See https://github.com/google/bazel/tree/master/src/main/protobuf.

Anyway that's not a problem if we cross compile.

Kun Zhang

unread,
Jul 6, 2015, 8:46:04 PM7/6/15
to Damien Martin-guillerez, Feng Xiao, Andrew Rossignol, bazel-...@googlegroups.com, Protocol Buffers, Lukács T. Berki, Han-Wen Nienhuys
On Jul 6, 2015 12:50 PM, "Damien Martin-guillerez" <dmar...@google.com> wrote:
There is a bootstrap problem: we need protoc compiler to bootstrap bazel but we could be baking protoc using bazel. However we probably will have to cross-compile for such a thing.


On Mon, Jul 6, 2015 at 9:38 PM 'Feng Xiao' via bazel-discuss <bazel-...@googlegroups.com> wrote:
+Kun who maintains the protoc binary on Maven.

On Wed, Jul 1, 2015 at 11:03 AM, 'Andrew Rossignol' via Protocol Buffers <prot...@googlegroups.com> wrote:
+protobuf

What would it take to have Maven Central produce ARM binaries for protoc? Is this possible?
We don't have ARM machines to produce ARM binaries.

It is possible if it can be cross-compiled. If you can come up with steps of cross-compiling for ARM that fit in our existing procedure, I would be happy to include it in future releases.

linux...@gmail.com

unread,
Aug 9, 2015, 9:49:08 PM8/9/15
to bazel-discuss
On Tuesday, June 30, 2015 at 12:08:03 PM UTC-7, Andrew Rossignol wrote:
> Hello bazel-discuss,
>
> I have a version of Bazel compiled for Linux running on an ARM processor. I compiled a small C++ and OpenGL project of mine for an ARM version of Ubuntu.
>
> These are (roughly) the changes that I made for this to work:
>
> Compile protoc for ARMThe Maven repo only produces Mac and Linux binaries for protoc (x86 and x86_64) at the moment. I don't know much about Maven so I just built it locally using automake.Updated the bootstrap scripts to handle an ARM processor (added a MACHINE_IS_ARM variable) and used the ARM protoc.Updated java/com/google/devtools/build/lib/util/CPU.java to have an ARM entry.Updated tools/cpp/CROSSTOOL file to have a "local_linux" default_toolchain for ARM.Updated third_party/BUILD to have a config_setting for ARM and added the ARM protoc to the selector in the thirdparty:protoc target.
>
> The current setup is running on an ARM Chromebook with Crouton, but this opens up the possibility of running Bazel on a Raspberry Pi (something I haven't tested yet).
>
>
>
> I wanted to see how the community feels about this idea. I would be interested in getting this checked in, but would like to gauge interest and see if anyone would be receptive to these changes.
> Andrew


Hi, Andrew

Do you mind sharing with me your changes? I have an octa-core ARM machine running ubuntu and I'd like to try it.

Thanks!

- Linuxer

linux...@gmail.com

unread,
Aug 11, 2015, 10:33:28 AM8/11/15
to bazel-discuss, linux...@gmail.com
Never mind, figured out myself.


v.may...@gmail.com

unread,
Nov 22, 2015, 6:45:26 AM11/22/15
to bazel-discuss, linux...@gmail.com
Hi everyone,

I'm struggling to reproduce this process. I've reported an issue at https://github.com/bazelbuild/bazel/issues/606 with my progress so far.

Can anyone advice?
Many thanks,

bor...@gmail.com

unread,
Jan 4, 2017, 4:40:49 PM1/4/17
to bazel-discuss
Please upload to github a clone that includes your changes.
I am finding I need to also get arm support int he bootstrap scripts but you've found the other places that the support needs to be made. Please post your changes somewhere.

Todd Jeffreys

unread,
Jan 4, 2017, 5:56:34 PM1/4/17
to bazel-discuss, bor...@gmail.com
Would love to see this added. I have a beefy ODroid XU4 that I'd love to get bazel running on 

combu...@gmail.com

unread,
Jan 5, 2017, 3:07:56 AM1/5/17
to bazel-discuss
On Tuesday, June 30, 2015 at 12:08:03 PM UTC-7, Andrew Rossignol wrote:
> Hello bazel-discuss,
>
> I have a version of Bazel compiled for Linux running on an ARM processor. I compiled a small C++ and OpenGL project of mine for an ARM version of Ubuntu.
>
> These are (roughly) the changes that I made for this to work:
>
> Compile protoc for ARMThe Maven repo only produces Mac and Linux binaries for protoc (x86 and x86_64) at the moment. I don't know much about Maven so I just built it locally using automake.Updated the bootstrap scripts to handle an ARM processor (added a MACHINE_IS_ARM variable) and used the ARM protoc.Updated java/com/google/devtools/build/lib/util/CPU.java to have an ARM entry.Updated tools/cpp/CROSSTOOL file to have a "local_linux" default_toolchain for ARM.Updated third_party/BUILD to have a config_setting for ARM and added the ARM protoc to the selector in the thirdparty:protoc target.
>
> The current setup is running on an ARM Chromebook with Crouton, but this opens up the possibility of running Bazel on a Raspberry Pi (something I haven't tested yet).
>
>
>
> I wanted to see how the community feels about this idea. I would be interested in getting this checked in, but would like to gauge interest and see if anyone would be receptive to these changes.
> Andrew

I've basically done the same things you've done. I was able to run Bazel on aarch64 (NVIDIA TX1) and Raspberry Pi 3 successfully. But that was a few months ago, and proved to be unwieldy, because we need to support a ton of different platforms.

We (XNOR.ai) have recently switched to a different set-up: we create toolchains using https://buildroot.org/, and package host toolchain and target libs separately. Deploy target libs on target (and add them to library path), hook up the cross-compiler toolchain on the build host, and voila -- near instantaneous and fully hermetic builds for the target platform, including a bunch of libs that'd be very difficult to juggle otherwise such as gstreamer, openblas, opencv and so forth.

If you can live with the libs Buildroot provides (or don't mind the effort of adding them yourself), this might be the most elegant, and the least painful solution to the problem of compiling for ARM.

That's not to discourage you from submitting a patch, though. IMO Bazel should at the very least work out of the box on arm32, arm64 and PPCle.

spid...@gmail.com

unread,
Sep 29, 2017, 11:42:31 AM9/29/17
to bazel-discuss
On Wednesday, 1 July 2015 00:38:03 UTC+5:30, Andrew Rossignol wrote:
> Hello bazel-discuss,
>
> I have a version of Bazel compiled for Linux running on an ARM processor. I compiled a small C++ and OpenGL project of mine for an ARM version of Ubuntu.
>
> These are (roughly) the changes that I made for this to work:
>
> Compile protoc for ARMThe Maven repo only produces Mac and Linux binaries for protoc (x86 and x86_64) at the moment. I don't know much about Maven so I just built it locally using automake.Updated the bootstrap scripts to handle an ARM processor (added a MACHINE_IS_ARM variable) and used the ARM protoc.Updated java/com/google/devtools/build/lib/util/CPU.java to have an ARM entry.Updated tools/cpp/CROSSTOOL file to have a "local_linux" default_toolchain for ARM.Updated third_party/BUILD to have a config_setting for ARM and added the ARM protoc to the selector in the thirdparty:protoc target.
>
> The current setup is running on an ARM Chromebook with Crouton, but this opens up the possibility of running Bazel on a Raspberry Pi (something I haven't tested yet).
>
>
>
> I wanted to see how the community feels about this idea. I would be interested in getting this checked in, but would like to gauge interest and see if anyone would be receptive to these changes.
> Andrew

download the binary for armv7l(pi 3) with this link below
https://drive.google.com/open?id=0B7NeIJaVzSxIZmZHUnVzZjBjVDg

dilb...@gmail.com

unread,
Jul 3, 2018, 5:33:36 AM7/3/18
to bazel-discuss
On Tuesday, June 30, 2015 at 12:08:03 PM UTC-7, Andrew Rossignol wrote:
> Hello bazel-discuss,
>
> I have a version of Bazel compiled for Linux running on an ARM processor. I compiled a small C++ and OpenGL project of mine for an ARM version of Ubuntu.

I posted a release of Bazel 0.15.0 for arm, tested on LineageOS and Ubuntu 18.04 armv7l, binary available here:
https://github.com/dilbrent/bazel/releases/tag/0.15.0-arm

I've only used it to build TensorFlow for arm, but that's a pretty reasonable test, IMHO.

-Brent

Reply all
Reply to author
Forward
0 new messages