Merge "Got basic code building with the roboRIO compiler."
diff --git a/aos/externals/BUILD b/aos/externals/BUILD
index bd7be3c..0991067 100644
--- a/aos/externals/BUILD
+++ b/aos/externals/BUILD
@@ -19,10 +19,13 @@
]) + [
'forwpilib/dma.cc',
],
+ copts = [
+ '-Wno-error',
+ ],
hdrs = glob([d + '/*.h' for d in _header_dirs]),
includes = _header_dirs,
linkopts = [
- '-Lallwpilib/ni-libraries',
+ '-Laos/externals/allwpilib/ni-libraries',
'-lpthread',
'-lFRC_NetworkCommunication',
'-lRoboRIO_FRC_ChipObject',
diff --git a/debian/BUILD.usr b/debian/BUILD.usr
index 0815609..da3e80a 100644
--- a/debian/BUILD.usr
+++ b/debian/BUILD.usr
@@ -1,25 +1,37 @@
package(default_visibility = ['//visibility:public'])
+config_setting(
+ name = "roborio",
+ values = {
+ "cpu": "roborio",
+ }
+)
+
cc_library(
name = 'librt',
- srcs = [ 'lib/x86_64-linux-gnu/librt.so' ],
+ srcs = select({
+ ":roborio": ['arm-frc-linux-gnueabi/usr/lib/librt.so'],
+ "//conditions:default": ['lib/x86_64-linux-gnu/librt.so'],
+ }),
)
cc_library(
name = 'libdl',
- srcs = [ 'lib/x86_64-linux-gnu/libdl.so' ],
+ srcs = select({
+ ":roborio": ['arm-frc-linux-gnueabi/usr/lib/libdl.so'],
+ "//conditions:default": ['lib/x86_64-linux-gnu/libdl.so'],
+ }),
)
cc_library(
name = 'libm',
- srcs = [ 'lib/x86_64-linux-gnu/libm.so' ],
+ srcs = select({
+ ":roborio": ['arm-frc-linux-gnueabi/usr/lib/libm.so'],
+ "//conditions:default": ['lib/x86_64-linux-gnu/libm.so'],
+ }),
)
cc_library(
name = 'libpthread',
- srcs = [ 'lib/x86_64-linux-gnu/libpthread.so' ],
- linkopts = [
- '-pthread',
- ],
)
diff --git a/third_party/cddlib/BUILD b/third_party/cddlib/BUILD
index d197954..17a7fc4 100644
--- a/third_party/cddlib/BUILD
+++ b/third_party/cddlib/BUILD
@@ -1,5 +1,7 @@
licenses(['notice'])
+load('/tools/build_rules/select', 'compiler_select')
+
cc_library(
name = 'cddlib',
visibility = ['//visibility:public'],
@@ -24,5 +26,8 @@
'-Wno-switch-enum',
'-Wno-empty-body',
'-Wno-sign-compare',
- ],
+ ] + compiler_select({
+ 'gcc': ['-Wno-unused-but-set-variable'],
+ 'clang': []
+ }),
)
diff --git a/third_party/gflags/BUILD b/third_party/gflags/BUILD
index 9642c6f..bad36a9 100644
--- a/third_party/gflags/BUILD
+++ b/third_party/gflags/BUILD
@@ -20,8 +20,9 @@
'-DGFLAGS_DLL_DEFINE_FLAG=',
'-Wno-format-nonliteral',
- '-Wno-unused-local-typedef',
+ '-Wno-unused-local-typedefs',
'-Wno-sign-compare',
+ '-Wno-missing-field-initializers',
]
cc_library(
diff --git a/third_party/googletest/BUILD b/third_party/googletest/BUILD
index 861ce5d..b76b35b 100644
--- a/third_party/googletest/BUILD
+++ b/third_party/googletest/BUILD
@@ -325,6 +325,9 @@
deps = [
":googletest_main",
],
+ copts = [
+ "-Wno-empty-body",
+ ]
)
cc_test(
@@ -390,6 +393,10 @@
deps = [
":googletest_main",
],
+ copts = [
+ "-Wno-empty-body",
+ "-Wno-missing-field-initializers",
+ ]
)
cc_test(
diff --git a/third_party/libevent/BUILD b/third_party/libevent/BUILD
index 50f714a..b576f52 100644
--- a/third_party/libevent/BUILD
+++ b/third_party/libevent/BUILD
@@ -1,5 +1,7 @@
licenses(['notice'])
+load('/tools/build_rules/select', 'compiler_select')
+
cc_library(
name = 'libevent',
visibility = ['//visibility:public'],
@@ -56,7 +58,9 @@
'-Wno-unused-parameter',
'-Wno-format-nonliteral',
'-Wno-cast-qual',
- '-Wno-incompatible-pointer-types-discards-qualifiers',
'-Wno-unused-function',
- ],
+ ] + compiler_select({
+ 'gcc': [],
+ 'clang': ['-Wno-incompatible-pointer-types-discards-qualifiers']
+ }),
)
diff --git a/third_party/libevent/buffer.c b/third_party/libevent/buffer.c
index 80a9e1b..de4ab52 100644
--- a/third_party/libevent/buffer.c
+++ b/third_party/libevent/buffer.c
@@ -2749,7 +2749,7 @@
if (!chain)
return (-1);
chain->flags |= EVBUFFER_REFERENCE | EVBUFFER_IMMUTABLE;
- chain->buffer = (const u_char *)data;
+ chain->buffer = (u_char *)data;
chain->buffer_len = datlen;
chain->off = datlen;
diff --git a/third_party/seasocks/BUILD b/third_party/seasocks/BUILD
index 9dc7c61..d85e3c3 100644
--- a/third_party/seasocks/BUILD
+++ b/third_party/seasocks/BUILD
@@ -13,6 +13,7 @@
copts = [
# TODO(Brian): Don't apply this to all of the code...
'-Wno-cast-align',
+ '-Wno-cast-qual',
'-Wno-switch-enum',
'-Wno-format-nonliteral',
diff --git a/tools/cpp/BUILD b/tools/cpp/BUILD
index 43ed151..a29003c 100644
--- a/tools/cpp/BUILD
+++ b/tools/cpp/BUILD
@@ -29,6 +29,7 @@
":cc-compiler-armeabi-v7a",
":cc-compiler-local",
":cc-compiler-k8",
+ ":cc-compiler-roborio",
],
)
@@ -73,3 +74,17 @@
strip_files = ":empty",
supports_param_files = 0,
)
+
+cc_toolchain(
+ name = "cc-compiler-roborio",
+ all_files = ":empty",
+ compiler_files = ":empty",
+ cpu = "local",
+ dwp_files = ":empty",
+ dynamic_runtime_libs = [":empty"],
+ linker_files = ":empty",
+ objcopy_files = ":empty",
+ static_runtime_libs = [":empty"],
+ strip_files = ":empty",
+ supports_param_files = 0,
+)
diff --git a/tools/cpp/CROSSTOOL b/tools/cpp/CROSSTOOL
index 911ab1f..31f3633 100644
--- a/tools/cpp/CROSSTOOL
+++ b/tools/cpp/CROSSTOOL
@@ -3,8 +3,13 @@
default_target_cpu: "same_as_host"
default_toolchain {
+ cpu: "roborio"
+ toolchain_identifier: "roborio_linux"
+}
+
+default_toolchain {
cpu: "k8"
- toolchain_identifier: "local_linux"
+ toolchain_identifier: "k8_linux"
}
default_toolchain {
@@ -50,7 +55,7 @@
abi_version: "local"
abi_libc_version: "local"
builtin_sysroot: ""
- compiler: "compiler"
+ compiler: "clang"
host_system_name: "local"
needsPic: true
supports_gold_linker: false
@@ -61,9 +66,9 @@
supports_start_end_lib: false
supports_thin_archives: false
target_libc: "local"
- target_cpu: "local"
- target_system_name: "local"
- toolchain_identifier: "local_linux"
+ target_cpu: "k8"
+ target_system_name: "k8"
+ toolchain_identifier: "k8_linux"
tool_path { name: "ar" path: "/usr/bin/ar" }
tool_path { name: "compat-ld" path: "/usr/bin/ld" }
@@ -159,11 +164,13 @@
}
flag_set {
action: "preprocess-assemble"
- action: "c-compile"
+ action: "assemble"
+ action: "c++-link"
action: "c++-compile"
action: "c++-header-parsing"
action: "c++-header-preprocessing"
action: "c++-module-compile"
+ action: "c-compile"
flag_group {
# We always want to compile with -pthread semantics.
flag: "-pthread"
@@ -182,7 +189,7 @@
compiler_flag: "-D__STDC_LIMIT_MACROS"
compiler_flag: "-D_FILE_OFFSET_BITS=64"
# TODO(Brian): Rename this or something.
- #compiler_flag: "-DAOS_ARCHITECTURE_arm_frc"
+ compiler_flag: "-DAOS_ARCHITECTURE_arm_frc"
linker_flag: "-fuse-ld=gold"
@@ -235,7 +242,7 @@
compiler_flag: "-pipe"
# Have GCC return the exit code from ld.
- #linker_flag: "-pass-exit-codes"
+ linker_flag: "-pass-exit-codes"
# Stamp the binary with a unique identifier.
linker_flag: "-Wl,--build-id=md5"
@@ -268,3 +275,237 @@
linker_flag: "-Wl,--gc-sections"
}
}
+
+toolchain {
+ abi_version: "roborio"
+ abi_libc_version: "roborio"
+ builtin_sysroot: ""
+ compiler: "gcc"
+ host_system_name: "roborio"
+ 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: "roborio"
+ target_cpu: "roborio"
+ target_system_name: "roborio"
+ toolchain_identifier: "roborio_linux"
+
+ tool_path { name: "ar" path: "/usr/bin/arm-frc-linux-gnueabi-ar" }
+ tool_path { name: "compat-ld" path: "/usr/bin/arm-frc-linux-gnueabi-ld" }
+ tool_path { name: "cpp" path: "/usr/bin/arm-frc-linux-gnueabi-cpp" }
+ tool_path { name: "dwp" path: "/usr/bin/dwp" }
+ tool_path { name: "gcc" path: "/usr/bin/arm-frc-linux-gnueabi-gcc" }
+ tool_path { name: "gcov" path: "/usr/bin/arm-frc-linux-gnueabi-gcov-4.9" }
+ # C(++) compiles invoke the compiler (as that is the one knowing where
+ # to find libraries), but we provide LD so other rules can invoke the linker.
+ tool_path { name: "ld" path: "/usr/bin/arm-frc-linux-gnueabi-ld" }
+ tool_path { name: "nm" path: "/usr/bin/arm-frc-linux-gnueabi-nm" }
+ tool_path { name: "objcopy" path: "/usr/bin/arm-frc-linux-gnueabi-objcopy" }
+ objcopy_embed_flag: "-I"
+ objcopy_embed_flag: "binary"
+ tool_path { name: "objdump" path: "/usr/bin/arm-frc-linux-gnueabi-objdump" }
+ tool_path { name: "strip" path: "/usr/bin/arm-frc-linux-gnueabi-strip" }
+
+ # TODO(bazel-team): In theory, the path here ought to exactly match the path
+ # used by gcc. That works because bazel currently doesn't track files at
+ # absolute locations and has no remote execution, yet. However, this will need
+ # to be fixed, maybe with auto-detection?
+ cxx_builtin_include_directory: "/usr/lib/gcc/"
+ cxx_builtin_include_directory: "/usr/local/include"
+ cxx_builtin_include_directory: "/usr/include"
+
+ linker_flag: "-lstdc++"
+ #linker_flag: "-B/usr/bin/"
+
+ feature {
+ name: "opt"
+ implies: "all_modes"
+ flag_set {
+ action: "preprocess-assemble"
+ action: "c-compile"
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-header-preprocessing"
+ action: "c++-module-compile"
+ flag_group {
+ flag: "-DAOS_DEBUG=0"
+ }
+ }
+ }
+
+ feature {
+ name: "dbg"
+ implies: "all_modes"
+ flag_set {
+ action: "preprocess-assemble"
+ action: "c-compile"
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-header-preprocessing"
+ action: "c++-module-compile"
+ flag_group {
+ flag: "-DAOS_DEBUG=1"
+ }
+ }
+ }
+
+ feature {
+ name: "fastbuild"
+ implies: "all_modes"
+ flag_set {
+ action: "preprocess-assemble"
+ action: "c-compile"
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-header-preprocessing"
+ action: "c++-module-compile"
+ flag_group {
+ flag: "-DAOS_DEBUG=0"
+ }
+ }
+ }
+
+ feature {
+ name: "all_modes"
+ flag_set {
+ action: "c-compile"
+ flag_group {
+ flag: "-std=gnu99"
+ }
+ }
+ flag_set {
+ action: "preprocess-assemble"
+ action: "assemble"
+ action: "c++-link"
+ flag_group {
+ flag: "-std=gnu99"
+ }
+ }
+ flag_set {
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-header-preprocessing"
+ action: "c++-module-compile"
+ flag_group {
+ flag: "-std=gnu++1y"
+ }
+ }
+ flag_set {
+ action: "preprocess-assemble"
+ action: "assemble"
+ action: "c++-link"
+ action: "c++-compile"
+ action: "c++-header-parsing"
+ action: "c++-header-preprocessing"
+ action: "c++-module-compile"
+ action: "c-compile"
+ flag_group {
+ # We always want to compile with -pthread semantics.
+ flag: "-pthread"
+ }
+ }
+ }
+
+ # Anticipated future default.
+ # This makes GCC and Clang do what we want when called through symlinks.
+ unfiltered_cxx_flag: "-no-canonical-prefixes"
+ linker_flag: "-no-canonical-prefixes"
+
+ # Things that the code wants defined.
+ compiler_flag: "-D__STDC_FORMAT_MACROS"
+ compiler_flag: "-D__STDC_CONSTANT_MACROS"
+ compiler_flag: "-D__STDC_LIMIT_MACROS"
+ compiler_flag: "-D_FILE_OFFSET_BITS=64"
+ # TODO(Brian): Rename this or something.
+ #compiler_flag: "-DAOS_ARCHITECTURE_arm_frc"
+
+ #linker_flag: "-fuse-ld=gold"
+
+ # Temporary escape hatch for the Gyp->Bazel conversion.
+ # TODO(Brian): Remove this.
+ compiler_flag: "-DAOS_BAZEL"
+
+ # Make C++ compilation deterministic. Use linkstamping instead of these
+ # compiler symbols.
+ unfiltered_cxx_flag: "-Wno-builtin-macro-redefined"
+ unfiltered_cxx_flag: "-D__DATE__=\"redacted\""
+ unfiltered_cxx_flag: "-D__TIMESTAMP__=\"redacted\""
+ unfiltered_cxx_flag: "-D__TIME__=\"redacted\""
+
+ # Security hardening on by default.
+ # Conservative choice; -D_FORTIFY_SOURCE=2 may be unsafe in some cases.
+ # We need to undef it before redefining it as some distributions now have
+ # it enabled by default.
+ compiler_flag: "-U_FORTIFY_SOURCE"
+ compiler_flag: "-fstack-protector"
+ compiler_flag: "-fPIE"
+ linker_flag: "-pie"
+ linker_flag: "-Wl,-z,relro,-z,now"
+
+ # Pretty much everything needs this, including parts of the glibc STL...
+ linker_flag: "-lm"
+
+ # Enable coloring even if there's no attached terminal. Bazel removes the
+ # escape sequences if --nocolor is specified.
+ compiler_flag: "-fdiagnostics-color=always"
+
+ compiler_flag: "-Wall"
+ compiler_flag: "-Wextra"
+ compiler_flag: "-Wswitch-enum"
+ compiler_flag: "-Wpointer-arith"
+ compiler_flag: "-Wstrict-aliasing=2"
+ compiler_flag: "-Wcast-qual"
+ compiler_flag: "-Wcast-align"
+ compiler_flag: "-Wwrite-strings"
+ compiler_flag: "-Wtype-limits"
+ compiler_flag: "-Wsign-compare"
+ compiler_flag: "-Wformat=2"
+ compiler_flag: "-Werror"
+
+ # Keep stack frames for debugging, even in opt mode.
+ compiler_flag: "-fno-omit-frame-pointer"
+ compiler_flag: "-D__has_feature(x)=0"
+
+ # Don't use temp files while compiling.
+ compiler_flag: "-pipe"
+
+ # Have GCC return the exit code from ld.
+ linker_flag: "-pass-exit-codes"
+
+ # Stamp the binary with a unique identifier.
+ linker_flag: "-Wl,--build-id=md5"
+ linker_flag: "-Wl,--hash-style=gnu"
+ #linker_flag: "-Wl,--warn-execstack"
+ #linker_flag: "-Wl,--detect-odr-violations"
+
+ compilation_mode_flags {
+ mode: DBG
+ # Enable debug symbols.
+ compiler_flag: "-ggdb3"
+ }
+ compilation_mode_flags {
+ mode: OPT
+
+ # No debug symbols.
+ # Maybe we should enable https://gcc.gnu.org/wiki/DebugFission for opt or
+ # even generally? However, that can't happen here, as it requires special
+ # handling in Bazel.
+ compiler_flag: "-g0"
+
+ compiler_flag: "-Oz"
+
+ # Disable assertions
+ compiler_flag: "-DNDEBUG"
+ compiler_flag: "-D_FORTIFY_SOURCE=1"
+
+ # Removal of unused code and data at link time (can this increase binary size in some cases?).
+ compiler_flag: "-ffunction-sections"
+ compiler_flag: "-fdata-sections"
+ linker_flag: "-Wl,--gc-sections"
+ }
+}