Skip to content

Commit

Permalink
Merge pull request RobotLocomotion#4322 from david-german-tri/crosstool
Browse files Browse the repository at this point in the history
Add a CROSSTOOL file for clang on Ubuntu.
  • Loading branch information
david-german-tri authored Dec 2, 2016
2 parents 909f344 + 58d9819 commit 10c1330
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drake/doc/bazel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ Run a test under AddressSanitizer::

bazel test --config=asan drake/systems/framework/test/diagram_test

Build the entire project using clang (on Ubuntu)::

bazel build --config=clang ...

Run one of the compiled programs manually, from the build outputs directory
(note that ``bazel-bin`` is a directory name here)::

Expand Down
27 changes: 27 additions & 0 deletions tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,30 @@ sh_binary(
srcs = ["valgrind.sh"],
data = ["valgrind.supp"],
)

cc_toolchain_suite(
name = "default-toolchain",
toolchains = {
"k8|clang-3.9": "cc-compiler-clang-3.9-linux",
},
)

filegroup(
name = "empty",
srcs = [],
)

cc_toolchain(
name = "cc-compiler-clang-3.9-linux",
all_files = ":empty",
compiler_files = ":empty",
cpu = "k8",
dwp_files = ":empty",
dynamic_runtime_libs = [":empty"],
linker_files = ":empty",
objcopy_files = ":empty",
static_runtime_libs = [":empty"],
strip_files = ":empty",
supports_param_files = 0,
)

70 changes: 70 additions & 0 deletions tools/CROSSTOOL
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
major_version: "local"
minor_version: ""
default_target_cpu: "same_as_host"
default_toolchain {
cpu: "k8"
toolchain_identifier: "clang-3.9-linux"
}

toolchain {
abi_version: "local"
abi_libc_version: "local"
builtin_sysroot: ""
compiler: "clang-3.9"
host_system_name: "local"
needsPic: true
supports_gold_linker: false
supports_incremental_linker: false
supports_fission: false
supports_interface_shared_objects: false
supports_normalizing_ar: false
supports_start_end_lib: false
supports_thin_archives: false
target_libc: "local"
target_cpu: "k8"
target_system_name: "local"
toolchain_identifier: "clang-3.9-linux"

tool_path { name: "ar" path: "/usr/bin/ar" }
tool_path { name: "compat-ld" path: "/usr/bin/ld" }
tool_path { name: "cpp" path: "/usr/bin/cpp" }
tool_path { name: "dwp" path: "/usr/bin/dwp" }
tool_path { name: "gcc" path: "/usr/bin/clang-3.9" }
cxx_flag: "-std=c++14"
compilation_mode_flags {
mode: FASTBUILD
}
compilation_mode_flags {
mode: DBG
cxx_flag: "-g3"
compiler_flag: "-O0"
}
compilation_mode_flags {
mode: COVERAGE
}
compilation_mode_flags {
mode: OPT
compiler_flag: "-DNDEBUG"
compiler_flag: "-fno-omit-frame-pointer"
compiler_flag: "-O2"
}
linker_flag: "-lstdc++"
linker_flag: "-lm"
linker_flag: "-B/usr/bin/"

cxx_builtin_include_directory: "/usr/lib/gcc/"
cxx_builtin_include_directory: "/usr/local/include"
cxx_builtin_include_directory: "/usr/include"
cxx_builtin_include_directory: "/usr/lib/clang/3.9.1/include"
cxx_builtin_include_directory: "/usr/lib/llvm-3.9/lib/clang/3.9.1/include"

tool_path { name: "gcov" path: "/usr/bin/gcov" }
tool_path { name: "ld" path: "/usr/bin/ld" }
tool_path { name: "nm" path: "/usr/bin/nm" }
tool_path { name: "objcopy" path: "/usr/bin/objcopy" }
objcopy_embed_flag: "-I"
objcopy_embed_flag: "binary"
tool_path { name: "objdump" path: "/usr/bin/objdump" }
tool_path { name: "strip" path: "/usr/bin/strip" }
}

4 changes: 4 additions & 0 deletions tools/bazel.rc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ build --cxxopt -std=c++1y
# Test options.
test --test_output=errors

# Clang.
build:clang --compiler=clang-3.9
build:clang --crosstool_top=//tools:default-toolchain

# Coverage build.
build:coverage --strip=never
build:coverage --copt -g
Expand Down

0 comments on commit 10c1330

Please sign in to comment.