(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 (@JasperSiepkes@mastodon.social
).
Create a SmartOS container (joyent brand if you are on Triton). To build and use Bazel you need an image which has GCC 9. This guide assumes you use image e44ed3e0-910b-11ed-a5d4-00151714048c
(22.4.0) with GCC 9. Beware that currently the GCC 9.3.0
path is hardcoded in Bazel path (see known issues).
Install required build packages:
# pkgin -y install git-base zip unzip openjdk11 libtool cmake automake ninja-build autoconf gmake gcc9
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 checkout smartos-6.3.2
# 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 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.
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
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"
This port is dependent on the platforms definition repository.
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 example7.3.0
is configured in Bazel instead of7.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.
{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.
-
Follow our tutorials:
- Bazel command line
- Rule reference
- Use the query command
- Extend Bazel
- Write tests
- Roadmap
- Who is using Bazel?
To report a security issue, please email security@bazel.build 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.
See CONTRIBUTING.md