Skip to content

Commit

Permalink
[setup] Restructure Ubuntu dependencies on clang-9 (#16622)
Browse files Browse the repository at this point in the history
On Ubuntu, move clang-9 into a separate "--with-clang" designation,
which is enabled by default to maintain our current behavior. In the
future, we should probably switch it off by default, to save download
time and disk space during builds.

Note that we still unconditionally require Clang's parsing library
and clang-format binary to be installed during a source build,
because we use those during the pydrake build.

Add libomp-9-dev alongside clang-9. That allows us to use -fopenmp;
otherwise, we would have linker errors.

Remove vestigial and broken --without-doc-only option.
  • Loading branch information
jwnimmer-tri authored Feb 21, 2022
1 parent 2adcd40 commit a743198
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 7 deletions.
2 changes: 2 additions & 0 deletions setup/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ exports_files([
"ubuntu/binary_distribution/packages-bionic.txt",
"ubuntu/binary_distribution/packages-focal.txt",
"ubuntu/source_distribution/packages-bionic.txt",
"ubuntu/source_distribution/packages-bionic-clang.txt",
"ubuntu/source_distribution/packages-bionic-doc-only.txt",
"ubuntu/source_distribution/packages-bionic-maintainer-only.txt",
"ubuntu/source_distribution/packages-bionic-test-only.txt",
"ubuntu/source_distribution/packages-focal.txt",
"ubuntu/source_distribution/packages-focal-clang.txt",
"ubuntu/source_distribution/packages-focal-doc-only.txt",
"ubuntu/source_distribution/packages-focal-maintainer-only.txt",
"ubuntu/source_distribution/packages-focal-test-only.txt",
Expand Down
15 changes: 10 additions & 5 deletions setup/ubuntu/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,21 @@ while [ "${1:-}" != "" ]; do
--with-kcov)
source_distribution_args+=(--with-kcov)
;;
# Install prerequisites that are only needed to when CC=clang-9, i.e.,
# opts-in to the ability to compile Drake's C++ code using Clang.
--with-clang)
source_distribution_args+=(--with-clang)
;;
# Do NOT install prerequisites that are only needed to when CC=clang-9,
# i.e., opts-out of the ability to compile Drake's C++ code using Clang.
--without-clang)
source_distribution_args+=(--without-clang)
;;
# Install prerequisites that are only needed to run select maintainer
# scripts. Most developers will not need to install these dependencies.
--with-maintainer-only)
source_distribution_args+=(--with-maintainer-only)
;;
# Do NOT install prerequisites that are only needed to build documentation,
# i.e., those prerequisites that are dependencies of bazel run //doc:build.
--without-doc-only)
source_distribution_args+=(--without-doc-only)
;;
# Do NOT install prerequisites that are only needed to build and/or run
# unit tests, i.e., those prerequisites that are not dependencies of
# bazel { build, run } //:install.
Expand Down
18 changes: 18 additions & 0 deletions setup/ubuntu/source_distribution/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ set -euo pipefail
with_doc_only=0
with_kcov=0
with_maintainer_only=0
with_clang=1
with_test_only=1
with_update=1
with_asking=1

# TODO(jwnimmer-tri) Eventually we should default to with_clang=0.

while [ "${1:-}" != "" ]; do
case "$1" in
# Install prerequisites that are only needed to build documentation,
Expand All @@ -29,6 +32,16 @@ while [ "${1:-}" != "" ]; do
--with-kcov)
with_kcov=1
;;
# Install prerequisites that are only needed to when CC=clang-9, i.e.,
# opts-in to the ability to compile Drake's C++ code using Clang.
--with-clang)
with_clang=1
;;
# Do NOT install prerequisites that are only needed to when CC=clang-9,
# i.e., opts-out of the ability to compile Drake's C++ code using Clang.
--without-clang)
with_clang=0
;;
# Install prerequisites that are only needed to run select maintainer
# scripts. Most developers will not need to install these dependencies.
--with-maintainer-only)
Expand Down Expand Up @@ -124,6 +137,11 @@ if [[ "${with_doc_only}" -eq 1 ]]; then
apt-get install ${maybe_yes} --no-install-recommends ${packages}
fi

if [[ "${with_clang}" -eq 1 ]]; then
packages=$(cat "${BASH_SOURCE%/*}/packages-${codename}-clang.txt")
apt-get install ${maybe_yes} --no-install-recommends ${packages}
fi

if [[ "${with_test_only}" -eq 1 ]]; then
packages=$(cat "${BASH_SOURCE%/*}/packages-${codename}-test-only.txt")
# Suppress Python 3.8 warnings when installing python3-pandas on Focal.
Expand Down
2 changes: 2 additions & 0 deletions setup/ubuntu/source_distribution/packages-bionic-clang.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
clang-9
libomp-9-dev
1 change: 0 additions & 1 deletion setup/ubuntu/source_distribution/packages-bionic.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
clang-9
clang-format-9
coinor-libclp-dev
coinor-libcoinutils-dev
Expand Down
2 changes: 2 additions & 0 deletions setup/ubuntu/source_distribution/packages-focal-clang.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
clang-9
libomp-9-dev
1 change: 0 additions & 1 deletion setup/ubuntu/source_distribution/packages-focal.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
clang-9
clang-format-9
coinor-libclp-dev
coinor-libcoinutils-dev
Expand Down

0 comments on commit a743198

Please sign in to comment.