Search code examples
ubuntuvmwaredrake

Building Drake on Ubuntu VM


I have been trying to install Drake on a virtual machine running Ubuntu 18.04.5 . Neither the binary installation nor the from-source one worked, unfortunately. In the source installation case, the following error has been popping up after I ran bazel build //... (and the install_prereqs) script:

username@ubuntu:~/code/drake$ bazel build //...
INFO: Analyzed 7909 targets (0 packages loaded, 0 targets configured).
INFO: Found 7909 targets...
ERROR: /home/username/code/drake/multibody/plant/BUILD.bazel:56:17: C++ compilation of rule '//multibody/plant:multibody_plant_core' failed (Exit 4): 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 309 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox 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 309 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
gcc: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
INFO: Elapsed time: 131.608s, Critical Path: 109.56s
INFO: 81 processes: 56 internal, 25 linux-sandbox.
FAILED: Build did NOT complete successfully

I thought that the problem might be resolved by installing gcc 8 like it was in this thread. I followed this guide to install multiple versions og gcc, set it to 8, and got this error after doing so:

username@ubuntu:~/code/drake$ bazel build //...
INFO: Analyzed 7909 targets (0 packages loaded, 0 targets configured).
INFO: Found 7909 targets...
ERROR: /home/username/.cache/bazel/_bazel_/129b6ae6fdda880475e3f0ac2268ff1a/external/lcm/BUILD.bazel:133:10: undeclared inclusion(s) in rule '@lcm//:lcm-logplayer':
this rule is missing dependency declarations for the following files included by 'lcm/lcm-logger/lcm_logplayer.c':
  '/usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h'
  '/usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h'
  '/usr/lib/gcc/x86_64-linux-gnu/8/include/stdint.h'
INFO: Elapsed time: 2.600s, Critical Path: 0.73s
INFO: 18 processes: 12 internal, 5 linux-sandbox, 1 worker.
FAILED: Build did NOT complete successfully

In case this information helps, I have the Mac binaries installed on my host machine and they seem to run correctly.

Any help would be greatly appreciated!


Solution

  • It's not a GCC 8 problem (you should undo the GCC 8 installation changes).

    The error message "gcc: internal compiler error: Killed (program cc1plus)" indicates that the compiler crashed. Most likely, this is because it ran out of memory (RAM).

    If the build was using multiple cores to compile, then compiling with less concurrency should help. Try bazel build //... -j 1, perhaps. If that helps, you could put that into a dotfile via https://docs.bazel.build/versions/master/guide.html#bazelrc-the-bazel-configuration-file so that jobs are always limited when building on that machine.

    However, if only one file is being compiled at a time and you still run of memory, then you'll probably need to increase the memory allocation of the virtual machine.