ros-infrastructure / ros_buildfarm

ROS buildfarm based on Docker
Apache License 2.0
81 stars 96 forks source link

Setup bazel single compilation thread in release deb/rpm #1016

Closed j-rivero closed 6 months ago

j-rivero commented 9 months ago

For preparing the buildfarm to host Bazel builds, one of the requirements is to have a single compilation thread during the release buildings. The is usually accomplish in deb creation by relying in the default behaviour of dpkg-buildpackage of using a single thread builds when using make.

In Bazel, we can setup the jobs limits by having a user configuration user.bazelrc in HOME. The PR adds these files to the deb and rpm release Dockerfiles.

An alternative considered was to use environment variables to setup this preference (ala MAKEJOBS/MAKEFLAGS) but I was able to find any documentation in Bazel that supports this use case.

j-rivero commented 8 months ago

Tested in the test buildfarm for Drake. Build Status

Expected results were good:

I can see in the logs that bazel is reading the configuration:

[32mINFO: Reading 'startup' options from /tmp/binarydeb/ros-rolling-drake-vendor-1.25.5/.obj-x86_64-linux-gnu/drake-prefix/src/drake-build/drake_build_cwd/.bazelrc: --output_base=/tmp/binarydeb/ros-rolling-drake-vendor-1.25.5/.obj-x86_64-linux-gnu/drake-prefix/src/drake-build/_bazel_/54c7e0b241e3ddac25283e0b95a56108
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=0 --terminal_columns=80
INFO: Reading rc options for 'info' from /tmp/binarydeb/ros-rolling-drake-vendor-1.25.5/.obj-x86_64-linux-gnu/drake-prefix/src/drake/tools/bazel.rc:
  Inherited 'common' options: --enable_bzlmod=false
INFO: Reading rc options for 'info' from /tmp/binarydeb/ros-rolling-drake-vendor-1.25.5/.obj-x86_64-linux-gnu/drake-prefix/src/drake-build/drake_build_cwd/.bazelrc:
  Inherited 'common' options: --announce_rc=yes --repo_env=CC=/usr/bin/cc --repo_env=CXX=/usr/bin/c++
INFO: Reading rc options for 'info' from /etc/bazel.bazelrc:
  Inherited 'build' options: --jobs=1
INFO: Reading rc options for 'info' from /tmp/binarydeb/ros-rolling-drake-vendor-1.25.5/.obj-x86_64-linux-gnu/drake-prefix/src/drake/tools/bazel.rc:
  Inherited 'build' options: -c opt --strip=never --strict_system_includes --test_output=errors --test_summary=terse --test_tag_filters=-gurobi,-mosek,-snopt --test_env=DISPLAY --test_env=GRB_LICENSE_FILE --test_env=MOSEKLM_LICENSE_FILE --test_env=LCM_DEFAULT_URL=memq:// --test_env=MPLBACKEND=Template
INFO: Reading rc options for 'info' from /tmp/binarydeb/ros-rolling-drake-vendor-1.25.5/.obj-x86_64-linux-gnu/drake-prefix/src/drake/tools/ubuntu.bazelrc:
  Inherited 'build' options: --force_pic --fission=dbg --features=per_object_debug_info --action_env=PATH=/usr/bin:/bin --action_env=PYTHONNOUSERSITE=1 --test_env=PYTHONNOUSERSITE=1
INFO: Reading rc options for 'info' from /tmp/binarydeb/ros-rolling-drake-vendor-1.25.5/.obj-x86_64-linux-gnu/drake-prefix/src/drake/tools/ubuntu-jammy.bazelrc:
  Inherited 'build' options: --cxxopt=-std=c++20 --host_cxxopt=-std=c++20
INFO: Reading rc options for 'info' from /tmp/binarydeb/ros-rolling-drake-vendor-1.25.5/.obj-x86_64-linux-gnu/drake-prefix/src/drake-build/drake_build_cwd/.bazelrc:
  Inherited 'build' options: --symlink_prefix=/ --color=yes --subcommands=yes --package_path=%workspace%:/tmp/binarydeb/ros-rolling-drake-vendor-1.25.5/.obj-x86_64-linux-gnu/drake-prefix/src/drake --notrim_test_configuration --action_env=CCACHE_DISABLE=1 --config=Release