Search code examples
bazeldrake

Trouble while building Drake with Bazel


I have been attempting to build Drake from source with Bazel on Ubuntu 20.04 but the following error occurs when I run

bazel run //tutorials:mathematical_program

from the Drake root directory:

INFO: Analyzed target //tutorials:mathematical_program (0 packages loaded, 3 targets configured).
INFO: Found 1 target...
ERROR: /home/user_name/git/drake/bindings/pydrake/systems/BUILD.bazel:88:21: Compiling bindings/pydrake/systems/primitives_py.cc failed: (Exit 1): gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 273 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
gcc: fatal error: Killed signal terminated program cc1plus
compilation terminated.
Target //tutorials:mathematical_program failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 7411.763s, Critical Path: 3155.48s
INFO: 1232 processes: 53 internal, 1179 linux-sandbox.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

Solution

  • I believe you are running out of memory, presumably because bazel runs many jobs in parallel. Can you try bazel run -—jobs=1 //tutorials:mathematical_program and make sure that works? (of course you can try jobs>1 if you like.