Skip to content

SmartOS / illumos / Solaris port of Bazel; A fast, scalable, multi-language and extensible build system

License

Notifications You must be signed in to change notification settings

siepkes/bazel-smartos

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Bazel illumos (and somewhat Solaris) port

(Scroll down for original Bazel README.md)

This repo contains a illumos port of Bazel. This port currently assumes the use of pkgsrc.

Previous versions of this port used Solaris as a target name but this version specifically targets illumos. Among things because I don't want to hijack the Solaris target name since this is acutally a illumos port. With a little effort (couple of ifdef's) it can probably also be made to work on Solaris. Since I personally don't have a need for such a port it's not here. However if you would like to adopt this port for use on Solaris and run into any issues while doing so please feel free to reach out to me via issues or Mastodon (@[email protected]).

Building Bazel on SmartOS

Create a SmartOS container (joyent brand if you are on Triton). To build and use Bazel you need an image which has GCC 13. This guide assumes you use image 8adac45a-aca7-11ee-b53e-00151714048c (23.4.0) with GCC 13. Be sure to fully update your container (pkgin -y upgrade).

Install required build packages:

# pkgin -y install git-base zip unzip openjdk11 libtool cmake automake ninja-build autoconf gmake gcc13 python311

Next we need to download the Bazel distribution and apply the changes of this forked repo. The reason why we need the Bazel distribution and can't simply compile the cloned fork is because in order to compile Bazel you need a working Bazel installation (usually an older version). The Bazel distribution contains things like pre-compiled protobuf messages (ie. java files generated by the protobuf compiler).

Download bazel-6.3.2-dist.zip (the Bazel distribution) from the Bazel releases page.

Next we will prepare our source tree by putting everything together:

# mkdir bazel-6.3.2
# unzip bazel-6.3.2-dist.zip -d bazel-6.3.2
# git clone https://github.com/siepkes/bazel-smartos.git
# cd bazel-smartos
# git switch -c smartos-6.3.2-gcc13 origin/smartos-6.3.2-gcc13
# git format-patch -1
# cd ../bazel-6.3.2
# patch -p1 < ../bazel-smartos/0001-Modifications-to-port-Bazel-6.3.2-to-illumos-SmartOS.patch

We are now ready to build Bazel!

# export LANG=en_US.UTF-8
# export JAVA_HOME="/opt/local/java/openjdk11"
# export EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk"
# ./compile.sh

Grab a <INSERT FAVORITE BEVERAGE HERE> and wait for the build to complete.

Debugging Bazel build problems

When encountering issues with building Bazel the following EXTRA_BAZEL_ARGS can be set to get more information during the build. See the Bazel Command Line Reference for more flags.

# export EXTRA_BAZEL_ARGS="--subcommands --verbose_failures --tool_java_runtime_version=local_jdk"
# export CC_CONFIGURE_DEBUG=1

Troubleshooting

Package '@local_jdk//': Package '' contains errors

If you run in to an error like this:

ERROR: /root/.cache/bazel/_bazel_root/b3ceecd93235c3ff2b5d18da2360ca56/external/local_jdk/BUILD.bazel:183:10: @local_jdk//:jdk-lib: invalid label 'lib/perl5/man/man3/App::Cpan.3.gz' in element 7182 of attribute 'srcs' in 'filegroup' rule: invalid target name 'lib/perl5/man/man3/App::Cpan.3.gz': target names may not contain ':'
ERROR: Analysis of target '//main:hello-world' failed; build aborted: error loading package '@local_jdk//': Package '' contains errors

You probably need to specify where Java home is. For example:

$ export JAVA_HOME="/opt/local/java/openjdk11"

Notes on porting to illumos

This port is dependent on the platforms definition repository.

Known issues

  • bazel/tools/cpp/CROSSTOOL contains a hardcoded GCC version number in some paths. For example /opt/local/gcc7/lib/gcc/x86_64-sun-solaris2.11/7.5.0/include-fixed. This can break with GCC updates and will result in errors like when for example 7.3.0 is configured in Bazel instead of 7.5.0:
ERROR: /root/.cache/bazel/_bazel_root/7558a64af10a6eb79f74e70211660103/external/com_google_protobuf/BUILD:414:1: undeclared inclusion(s) in rule '@com_google_protobuf//:protoc':
this rule is missing dependency declarations for the following files included by 'external/com_google_protobuf/src/google/protobuf/compiler/main.cc':
  '/opt/local/gcc7/lib/gcc/x86_64-sun-solaris2.11/7.5.0/include/stddef.h'
  '/opt/local/gcc7/lib/gcc/x86_64-sun-solaris2.11/7.5.0/include/stdint.h'
Target //source/exe:envoy-static failed to build
  • There are some FIXME: entries added to the code base which describe ugly hacks which have been applied. If these changes are ever to be upstreamed these would likely need to be addressed.

Original Bazel README.md

{Fast, Correct} - Choose two

Build and test software of any size, quickly and reliably.

  • Speed up your builds and tests: Bazel rebuilds only what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.

  • One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.

  • Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.

  • Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.

Getting Started

Documentation

Reporting a Vulnerability

To report a security issue, please email [email protected] with a description of the issue, the steps you took to create the issue, affected versions, and, if known, mitigations for the issue. Our vulnerability management team will respond within 3 working days of your email. If the issue is confirmed as a vulnerability, we will open a Security Advisory. This project follows a 90 day disclosure timeline.

Contributing to Bazel

See CONTRIBUTING.md

Build status

About

SmartOS / illumos / Solaris port of Bazel; A fast, scalable, multi-language and extensible build system

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 83.6%
  • Python 7.4%
  • Shell 5.4%
  • C++ 3.3%
  • C 0.1%
  • Smarty 0.1%
  • Other 0.1%