Skip to content

Commit

Permalink
Update supported Clang to 6.0 and add support for Bionic and Mojave
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Sep 28, 2018
1 parent 3a10be4 commit 3460b17
Show file tree
Hide file tree
Showing 21 changed files with 152 additions and 87 deletions.
55 changes: 52 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,55 @@ if(CYGWIN OR NOT UNIX)
message(FATAL_ERROR "Cygwin and non-Unix platforms are NOT supported")
endif()

set(UNIX_DISTRIBUTION_ID)
set(UNIX_DISTRIBUTION_RELEASE)

if(UNIX AND NOT APPLE)
find_program(LSB_RELEASE_EXECUTABLE NAMES lsb_release)

if(NOT LSB_RELEASE_EXECUTABLE)
message(FATAL_ERROR "Could NOT find the lsb_release executable")
endif()

execute_process(COMMAND "${LSB_RELEASE_EXECUTABLE}" --id --short
RESULT_VARIABLE LSB_RELEASE_ID_SHORT_RESULT_VARIABLE
OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT_OUTPUT_VARIABLE
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(LSB_RELEASE_ID_SHORT_RESULT_VARIABLE EQUAL 0)
set(UNIX_DISTRIBUTION_ID "${LSB_RELEASE_ID_SHORT_OUTPUT_VARIABLE}")
endif()

if(NOT UNIX_DISTRIBUTION_ID STREQUAL Ubuntu)
message(FATAL_ERROR
"Distribution ${UNIX_DISTRIBUTION_ID} is NOT supported"
)
endif()

string(TOLOWER "${UNIX_DISTRIBUTION_ID}" UNIX_DISTRIBUTION_ID)

execute_process(COMMAND "${LSB_RELEASE_EXECUTABLE}" --release --short
RESULT_VARIABLE LSB_RELEASE_RELEASE_SHORT_RESULT_VARIABLE
OUTPUT_VARIABLE LSB_RELEASE_RELEASE_SHORT_OUTPUT_VARIABLE
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(LSB_RELEASE_RELEASE_SHORT_RESULT_VARIABLE EQUAL 0)
set(UNIX_DISTRIBUTION_RELEASE
"${LSB_RELEASE_RELEASE_SHORT_OUTPUT_VARIABLE}"
)
endif()

# The supported releases should match those listed in both doc/developers.rst
# and tools/workspace/os.bzl.
if(NOT UNIX_DISTRIBUTION_RELEASE MATCHES "^(16.04|18.04)$")
message(FATAL_ERROR
"Release ${UNIX_DISTRIBUTION_RELEASE} is NOT supported"
)
endif()
endif()

# The version passed to find_package(Bazel) should match the
# minimum_bazel_version value in the call to versions.check() in WORKSPACE.
set(MINIMUM_BAZEL_VERSION 0.16.1)
Expand All @@ -33,8 +82,8 @@ endif()

# The minimum compiler versions should match those listed in both
# doc/developers.rst and tools/workspace/cc/repository.bzl.
set(MINIMUM_APPLE_CLANG_VERSION 9)
set(MINIMUM_CLANG_VERSION 4)
set(MINIMUM_APPLE_CLANG_VERSION 10)
set(MINIMUM_CLANG_VERSION 6)
set(MINIMUM_GNU_VERSION 5.4)

if(CMAKE_C_COMPILER_ID STREQUAL AppleClang)
Expand Down Expand Up @@ -308,7 +357,7 @@ else()
set(CPACK_DEBIAN_PACKAGE_RELEASE 1)
set(CPACK_DEBIAN_PACKAGE_SECTION contrib/devel)

file(STRINGS setup/ubuntu/16.04/binary_distribution/packages.txt
file(STRINGS "setup/${UNIX_DISTRIBUTION_ID}/${UNIX_DISTRIBUTION_RELEASE}/binary_distribution/packages.txt"
CPACK_DEBIAN_PACKAGE_DEPENDS
)
string(REGEX REPLACE "([a-z0-9\\-]+)=([a-z0-9\\-\\.~]+)" "\\1 (= \\2)"
Expand Down
23 changes: 14 additions & 9 deletions doc/bazel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
Bazel build system
******************

The Bazel build system is officially supported for a subset of Drake on
Ubuntu Xenial and macOS.
The Bazel build system is officially supported for a subset of Drake on Ubuntu
Xenial and Bionic and macOS High Sierra and Mojave.

For more information, see:

* https://bazel.build/
Expand Down Expand Up @@ -37,19 +38,23 @@ target label (and optional configuration options if desired). We give some
typical examples below; for more reading about target patterns, see:
https://docs.bazel.build/versions/master/user-manual.html#target-patterns.

On Ubuntu Xenial, the default compiler is the first ``gcc`` compiler in the
``PATH``, usually GCC 5.4. On macOS, the default compiler is Apple Clang. To
use Clang 4.0 on Ubuntu Xenial, set the ``CC`` and ``CXX`` environment
variables before running **bazel build**, **bazel test**, or any other
**bazel** commands.
On Ubuntu, the default compiler is the first ``gcc`` compiler in the
``PATH``, usually GCC 5.4 on Xenial and GCC 7.3 on Bionic. On macOS, the
default compiler is the Apple LLVM compiler. To use Clang 6.0 on Ubuntu, set
the ``CC`` and ``CXX`` environment variables before running **bazel build**,
**bazel test**, or any other **bazel** commands.

Cheat sheet for operating on the entire project::

cd /path/to/drake
bazel build //... # Build the entire project.
bazel test //... # Build and test the entire project.
CC=clang-4.0 CXX=clang++-4.0 bazel build //... # Build using Clang 4.0 on Xenial.
CC=clang-4.0 CXX=clang++-4.0 bazel test //... # Build and test using Clang 4.0 on Xenial.

CC=clang-6.0 CXX=clang++-6.0 bazel build //... # Build using Clang 6.0 on Xenial.
CC=clang-6.0 CXX=clang++-6.0 bazel test //... # Build and test using Clang 6.0 on Xenial.

CC=clang CXX=clang++ bazel build //... # Build using Clang 6.0 on Bionic.
CC=clang CXX=clang++ bazel test //... # Build and test using Clang 6.0 on Bionic.

- The "``//``" means "starting from the root of the project".
- The "``...``" means "everything including the subdirectories' ``BUILD`` files".
Expand Down
35 changes: 21 additions & 14 deletions doc/developers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,34 @@ integration. All other configurations are provided on a best-effort basis.
Drake requires a compiler running in C++14 mode or greater. MATLAB is only
supported for CMake builds using the "Unix Makefiles" generator.

+-----------------------------+-----------------+--------------------+------------+-------------------+--------+
| Operating System | Build System | C/C++ Compiler | Java | MATLAB (Optional) | Python |
+=============================+=================+====================+============+===================+========+
+-----------------------------+-----------------+--------------------+------------+-------------------+--------+
| Ubuntu 16.04 LTS ("Xenial") | | Bazel 0.16.1 | | Clang 4.0 | OpenJDK 8 | R2017a | 2.7.11 |
| | | CMake 3.5.1 | | GCC 5.4 | | | |
+-----------------------------+-----------------+--------------------+------------+ +--------+
| macOS 10.12 ("Sierra") | | Bazel 0.16.1 | Apple Clang 9.0.0 | Oracle 10 | | 2.7.15 |
+-----------------------------+ | CMake 3.12.1 | | +-------------------+ |
| macOS 10.13 ("High Sierra") | | | | R2017b | |
+-----------------------------+-----------------+--------------------+------------+-------------------+--------+

macOS 10.13 ("High Sierra") MATLAB support is experimental and untested in continuous
+----------------------------------+-----------------+-----------------+------------+-------------------+--------+
| Operating System | Build System | C/C++ Compiler | Java | MATLAB (Optional) | Python |
+==================================+=================+=================+============+===================+========+
+----------------------------------+-----------------+-----------------+------------+-------------------+--------+
| Ubuntu 16.04 LTS (Xenial Xerus) | | Bazel 0.16.1 | | Clang 6.0 | OpenJDK 8 | R2017a | 2.7.11 |
| | | CMake 3.5.1 | | GCC 5.4 | | | |
+----------------------------------+-----------------+-----------------+------------+-------------------+--------+
| Ubuntu 18.04 LTS (Bionic Beaver) | | Bazel 0.17.2 | | Clang 6.0 | OpenJDK 11 | R2018b | 2.7.15 |
| | | CMake 3.10.2 | | GCC 7.3 | | | |
+----------------------------------+-----------------+-----------------+------------+ | |
| macOS High Sierra (10.13) | | Bazel 0.17.2 | Apple LLVM 10.0 | Oracle 11 | | |
+----------------------------------+ | CMake 3.12.2 | | | | |
| macOS Mojave (10.14) | | | | | |
+----------------------------------+-----------------+-----------------+------------+-------------------+--------+


Ubuntu Bionic C++ and Python support is experimental and has limited testing
in continuous integration. macOS Mojave C++ and Python support and macOS and
Ubuntu Bionic MATLAB support is experimental and untested in continuous
integration.

.. _binary-packages:

Binary Packages
---------------

The binary releases of Drake are built with GCC 5.4 on Ubuntu 16.04 and Apple Clang 9.0 on macOS 10.13.
The binary releases of Drake are built with GCC 5.4 on Ubuntu Xenial and Apple
LLVM 10.0 on macOS High Sierra.

The links for these packages are listed in :ref:`binary-installation`.

Expand Down
2 changes: 1 addition & 1 deletion doc/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ You look at a unittest that builds in Drake, run it, and it builds, runs, and pa

If you look at symbols in the Drake shared library (e.g. ``nm -C`` or ``objdump -TC`` with ``grep``), you see the signature ``RigidBodyTree<double>::get_position_name[abi:cxx11](int)``. However, if you look in the produced object code (which causes the linking to fail), you see ``RigidBodyTree<double>::get_position_name(int)``.

**Solution**: This is most likely due to an incompatibilty between the compiler used to produce Drake (e.g. ``clang-4.0``) and the compiler that CMake has selected (e.g. ``gcc-4.9``). Specifically, ``gcc-4.9`` or before does not tend to handle the DualABI well when linking against ``clang``-compiled code [#dual_abi]_. You may be able to use other functions, because only functions that return an ABI-dependent class (e.g. ``std::string``) are tagged with the ABI that they are using (since they cannot be distinguished in the function signature).
**Solution**: This is most likely due to an incompatibilty between the compiler used to produce Drake (e.g. ``clang``) and the compiler that CMake has selected (e.g. ``gcc-4.9``). Specifically, ``gcc-4.9`` or before does not tend to handle the DualABI well when linking against ``clang``-compiled code [#dual_abi]_. You may be able to use other functions, because only functions that return an ABI-dependent class (e.g. ``std::string``) are tagged with the ABI that they are using (since they cannot be distinguished in the function signature).

The fix is to change the compiler CMake is using. One way to do this is to set the ``CC`` and ``CXX`` environment variables to use a supported compiler. For a list of supported compilers, see :ref:`supported-configurations`. If you are using pre-compiled binaries [#binary_install]_, please refer to the :ref:`binary-packages` for the compilers used.

Expand Down
2 changes: 1 addition & 1 deletion doc/from_source.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ setup steps:
:maxdepth: 1

mac
ubuntu_xenial
ubuntu

See :ref:`supported configurations <supported-configurations>`
for the configurations and platforms that Drake officially supports.
Expand Down
6 changes: 2 additions & 4 deletions doc/mac.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ macOS

We assume that you have already installed:

* Xcode 9 or above (from the `Mac App Store <https://itunes.apple.com/us/app/xcode/id497799835>`_)
and the Command Line Tools for Xcode (``xcode-select --install``)
* `Java SE Development Kit 8 <http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html>`_
* Xcode 10 or above (from the `Mac App Store <https://itunes.apple.com/us/app/xcode/id497799835>`_)

Prerequisite setup is automated. Simply run::
Prerequisite setup is otherwise automated. Simply run::

./setup/mac/install_prereqs.sh

Expand Down
19 changes: 19 additions & 0 deletions doc/ubuntu.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.. _build_from_source_ubuntu:

******
Ubuntu
******

Prerequisite setup is automated. For Ubuntu Xenial, simply run::

sudo ./setup/ubuntu/16.04/install_prereqs.sh

For Ubuntu Bionic, simply run::

sudo ./setup/ubuntu/18.04/install_prereqs.sh

You may need to respond to interactive prompts to confirm that you agree to add
the appropriate Drake `apt` repository for your release
(``https://drake-apt.csail.mit.edu/xenial/`` or
``https://drake-apt.csail.mit.edu/bionic/``) to your system for certain
development packages.
13 changes: 0 additions & 13 deletions doc/ubuntu_xenial.rst

This file was deleted.

2 changes: 1 addition & 1 deletion setup/ubuntu/16.04/binary_distribution/packages.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
coinor-libclp1
coinor-libcoinutils3v5
coinor-libipopt1v5
default-jre
libblas3
libboost-all-dev
libexpat1
Expand Down Expand Up @@ -28,7 +29,6 @@ libtinyxml2.6.2v5
libxml2
libxt6
libyaml-cpp0.5v5
openjdk-8-jre
python
python-lxml
python-matplotlib
Expand Down
10 changes: 5 additions & 5 deletions setup/ubuntu/16.04/source_distribution/packages.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
bash-completion
clang-4.0
clang-format-4.0
clang-6.0
clang-format-6.0
coinor-libclp-dev
coinor-libipopt-dev
default-jdk
diffstat
doxygen
file
Expand All @@ -13,7 +14,7 @@ graphviz
kcov-35
libblas-dev
libbz2-dev
libclang-4.0-dev
libclang-6.0-dev
libexpat1-dev
libfreetype6-dev
libglib2.0-dev
Expand All @@ -37,8 +38,7 @@ libtool
libxml2-dev
libxt-dev
libyaml-cpp-dev
lldb-4.0
openjdk-8-jdk
lldb-6.0
patchelf
patchutils
pkg-config
Expand Down
2 changes: 1 addition & 1 deletion setup/ubuntu/18.04/binary_distribution/packages.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
coinor-libclp1
coinor-libcoinutils3v5
coinor-libipopt1v5
default-jre
libblas3
libboost-all-dev
libexpat1
Expand Down Expand Up @@ -28,7 +29,6 @@ libtinyxml2.6.2v5
libxml2
libxt6
libyaml-cpp0.5v5
openjdk-8-jre
python
python-lxml
python-matplotlib
Expand Down
6 changes: 3 additions & 3 deletions setup/ubuntu/18.04/source_distribution/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ dpkg_install_from_wget() {
}

dpkg_install_from_wget \
bazel 0.16.1 \
https://github.com/bazelbuild/bazel/releases/download/0.16.1/bazel_0.16.1-linux-x86_64.deb \
c29f9709910ee23879dffe59ad31f5babba7dcbb81244ff319a5ce81da3c9abe
bazel 0.17.2 \
https://github.com/bazelbuild/bazel/releases/download/0.17.2/bazel_0.17.2-linux-x86_64.deb \
74570692dadd05a5892990ab65f136262b572580b29789116aadfa75ea5a3e68
10 changes: 5 additions & 5 deletions setup/ubuntu/18.04/source_distribution/packages.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
bash-completion
clang-4.0
clang-format-4.0
clang
clang-format
coinor-libclp-dev
coinor-libipopt-dev
default-jdk
diffstat
doxygen
file
Expand All @@ -13,7 +14,7 @@ graphviz
kcov-35
libblas-dev
libbz2-dev
libclang-4.0-dev
libclang-6.0-dev
libexpat1-dev
libfreetype6-dev
libglib2.0-dev
Expand All @@ -37,8 +38,7 @@ libtool
libxml2-dev
libxt-dev
libyaml-cpp-dev
lldb-4.0
openjdk-8-jdk
lldb
patchelf
patchutils
pkg-config
Expand Down
15 changes: 7 additions & 8 deletions tools/dynamic_analysis/bazel.rc
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,15 @@ test:tsan_everything --test_timeout=300,1500,5400,18000
### UBSan build. ###
build:ubsan --copt -g
build:ubsan --copt -fsanitize=undefined
build:ubsan --copt -fno-sanitize=float-divide-by-zero
# Since Bazel uses clang instead of clang++, enabling -fsanitize=vptr would
# require extra linkopts that cause segmentation faults on pure C code.
build:ubsan --copt -fno-sanitize=float-divide-by-zero,vptr
build:ubsan --copt -O1
build:ubsan --copt -fno-omit-frame-pointer
# TODO(jamiesnape): Find a solution to using sanitizer blacklists with the
# autogenerated toolchain.
# build:ubsan --copt -fsanitize-blacklist=tools/dynamic_analysis/ubsan.blacklist
build:ubsan --linkopt -fsanitize=undefined
# https://groups.google.com/forum/#!topic/bazel-discuss/15h4GPixeGI
build:ubsan --linkopt /usr/lib/llvm-4.0/lib/clang/4.0.0/lib/linux/libclang_rt.ubsan_standalone_cxx-x86_64.a
build:ubsan --linkopt /usr/lib/llvm-4.0/lib/clang/4.0.0/lib/linux/libclang_rt.ubsan_standalone-x86_64.a
test:ubsan --run_under=//tools/dynamic_analysis:ubsan
test:ubsan --test_env=UBSAN_OPTIONS
test:ubsan --test_tag_filters=-gurobi,-mosek,-snopt,-no_ubsan
Expand All @@ -203,16 +202,16 @@ build:ubsan_everything --define=WITH_MOSEK=ON
build:ubsan_everything --define=WITH_SNOPT=ON
build:ubsan_everything --copt -g
build:ubsan_everything --copt -fsanitize=undefined
build:ubsan_everything --copt -fno-sanitize=float-divide-by-zero
# Since Bazel uses clang instead of clang++, enabling -fsanitize=vptr would
# require extra linkopts that cause segmentation faults on pure C code.
# TODO(jamiesnape): Enable -fsanitize=pointer-overflow when SNOPT is fixed.
build:ubsan_everything --copt -fno-sanitize=float-divide-by-zero,pointer-overflow,vptr
build:ubsan_everything --copt -O1
build:ubsan_everything --copt -fno-omit-frame-pointer
# TODO(jamiesnape): Find a solution to using sanitizer blacklists with the
# autogenerated toolchain.
# build:ubsan_everything --copt -fsanitize-blacklist=tools/dynamic_analysis/ubsan.blacklist
build:ubsan_everything --linkopt -fsanitize=undefined
# https://groups.google.com/forum/#!topic/bazel-discuss/15h4GPixeGI
build:ubsan_everything --linkopt /usr/lib/llvm-4.0/lib/clang/4.0.0/lib/linux/libclang_rt.ubsan_standalone_cxx-x86_64.a
build:ubsan_everything --linkopt /usr/lib/llvm-4.0/lib/clang/4.0.0/lib/linux/libclang_rt.ubsan_standalone-x86_64.a
test:ubsan_everything --test_tag_filters=-no_ubsan
test:ubsan_everything --run_under=//tools/dynamic_analysis:ubsan
test:ubsan_everything --test_env=UBSAN_OPTIONS
Expand Down
2 changes: 1 addition & 1 deletion tools/lint/clang_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def get_clang_format_path():
if sys.platform == "darwin":
path = "/usr/local/bin/clang-format"
else:
path = "/usr/bin/clang-format-4.0"
path = "/usr/bin/clang-format-6.0"
if os.path.isfile(path):
return path
raise RuntimeError("Could not find required clang-format at " + path)
Loading

0 comments on commit 3460b17

Please sign in to comment.