Port to FreeBSD.
--
Change-Id: I4e65cc583e758d2f7e45209ffcb37f6a871e2ed7
Reviewed-on: https://bazel-review.git.corp.google.com/#/c/1840
MOS_MIGRATED_REVID=101462155
diff --git a/scripts/bootstrap/compile.sh b/scripts/bootstrap/compile.sh
index 1715316..1dbc287 100755
--- a/scripts/bootstrap/compile.sh
+++ b/scripts/bootstrap/compile.sh
@@ -68,8 +68,13 @@
ZIPOPTS="$ZIPOPTS"
# TODO: CC target architecture needs to match JAVA_HOME.
-CC=${CC:-gcc}
-CXX=${CXX:-g++}
+if [ "${PLATFORM}" = "freebsd" ]; then
+ CC=${CC:-clang}
+ CXX=${CXX:-clang++}
+else
+ CC=${CC:-gcc}
+ CXX=${CXX:-g++}
+fi
CXXSTD="c++0x"
unset JAVA_TOOL_OPTIONS
@@ -101,6 +106,18 @@
fi
;;
+freebsd)
+ LDFLAGS="-lprocstat -lz -lrt $LDFLAGS"
+ JNILIB="libunix.so"
+ MD5SUM="md5sum"
+ # JAVA_HOME must point to a Java installation.
+ JAVA_HOME="${JAVA_HOME:-/usr/local/openjdk8}"
+ # Note: the linux protoc binary works on freebsd using linux emulation.
+ # We choose the 32-bit version for maximum compatiblity since 64-bit
+ # linux binaries are only supported in FreeBSD-11.
+ PROTOC=${PROTOC:-third_party/protobuf/protoc-linux-x86_32.exe}
+ ;;
+
darwin)
JNILIB="libunix.dylib"
MD5SUM="md5"
diff --git a/scripts/release/relnotes.sh b/scripts/release/relnotes.sh
index ce256b2..15abbd1 100755
--- a/scripts/release/relnotes.sh
+++ b/scripts/release/relnotes.sh
@@ -97,14 +97,14 @@
done
}
-# fmt behaves a bit different on GNU/Linux than on darwin.
-if [ "$(uname -s | tr 'A-Z' 'a-z')" = "darwin" ]; then
+# fmt behaves a bit different on GNU/Linux than on BSDs.
+if [ "$(uname -s | tr 'A-Z' 'a-z')" = "linux" ]; then
function wrap_text() {
- fmt -w $1
+ fmt -w $1 -g $1
}
else
function wrap_text() {
- fmt -w $1 -g $1
+ fmt -w $1
}
fi
diff --git a/src/BUILD b/src/BUILD
index c3623c3..994eab5 100644
--- a/src/BUILD
+++ b/src/BUILD
@@ -117,3 +117,9 @@
values = {"cpu": "darwin"},
visibility = ["//visibility:public"],
)
+
+config_setting(
+ name = "freebsd",
+ values = {"cpu": "freebsd"},
+ visibility = ["//visibility:public"],
+)
diff --git a/src/main/cpp/BUILD b/src/main/cpp/BUILD
index dc1b732..c604272 100644
--- a/src/main/cpp/BUILD
+++ b/src/main/cpp/BUILD
@@ -8,6 +8,10 @@
"blaze_util_darwin.cc",
"blaze_util_posix.cc",
],
+ "//src:freebsd": [
+ "blaze_util_freebsd.cc",
+ "blaze_util_posix.cc",
+ ],
"//conditions:default": [
"blaze_util_linux.cc",
"blaze_util_posix.cc",
@@ -36,6 +40,9 @@
linkopts = select({
"//src:darwin": [
],
+ "//src:freebsd": [
+ "-lprocstat",
+ ],
"//conditions:default": [
"-lrt",
],
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc
index ad6b476..b3ec5ae 100644
--- a/src/main/cpp/blaze.cc
+++ b/src/main/cpp/blaze.cc
@@ -152,6 +152,7 @@
globals = new GlobalVariables;
globals->server_pid = -1;
globals->sigint_count = 0;
+ globals->received_signal = 0;
globals->startup_time = 0;
globals->extract_data_time = 0;
globals->command_wait_time = 0;
diff --git a/src/main/cpp/blaze_util.cc b/src/main/cpp/blaze_util.cc
index a6d96de..0eade65 100644
--- a/src/main/cpp/blaze_util.cc
+++ b/src/main/cpp/blaze_util.cc
@@ -27,7 +27,6 @@
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <sys/xattr.h>
#include <unistd.h>
#include <sstream>
diff --git a/src/main/cpp/blaze_util_freebsd.cc b/src/main/cpp/blaze_util_freebsd.cc
new file mode 100644
index 0000000..0d167cf
--- /dev/null
+++ b/src/main/cpp/blaze_util_freebsd.cc
@@ -0,0 +1,156 @@
+// Copyright 2015 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <limits.h>
+#include <pwd.h>
+#include <string.h> // strerror
+#include <sys/mount.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/socket.h>
+#include <sys/sysctl.h>
+#include <sys/types.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <signal.h>
+#include <libprocstat.h>
+
+#include "src/main/cpp/blaze_util.h"
+#include "src/main/cpp/blaze_util_platform.h"
+#include "src/main/cpp/util/errors.h"
+#include "src/main/cpp/util/exit_code.h"
+#include "src/main/cpp/util/file.h"
+#include "src/main/cpp/util/port.h"
+#include "src/main/cpp/util/strings.h"
+
+namespace blaze {
+
+using blaze_util::die;
+using blaze_util::pdie;
+using std::string;
+
+string GetOutputRoot() {
+ char buf[2048];
+ struct passwd pwbuf;
+ struct passwd *pw = NULL;
+ int uid = getuid();
+ int r = getpwuid_r(uid, &pwbuf, buf, 2048, &pw);
+ if (r != -1 && pw != NULL) {
+ return blaze_util::JoinPath(pw->pw_dir, ".cache/bazel");
+ } else {
+ return "/tmp";
+ }
+}
+
+void WarnFilesystemType(const string &output_base) {
+ struct statfs buf = {};
+ if (statfs(output_base.c_str(), &buf) < 0) {
+ fprintf(stderr,
+ "WARNING: couldn't get file system type information for '%s': %s\n",
+ output_base.c_str(), strerror(errno));
+ return;
+ }
+
+ if (strcmp(buf.f_fstypename, "nfs") == 0) {
+ fprintf(stderr,
+ "WARNING: Output base '%s' is on NFS. This may lead "
+ "to surprising failures and undetermined behavior.\n",
+ output_base.c_str());
+ }
+}
+
+string GetSelfPath() {
+ char buffer[PATH_MAX] = {};
+ ssize_t bytes = readlink("/proc/curproc/file", buffer, sizeof(buffer));
+ if (bytes == sizeof(buffer)) {
+ // symlink contents truncated
+ bytes = -1;
+ errno = ENAMETOOLONG;
+ }
+ if (bytes == -1) {
+ pdie(blaze_exit_code::INTERNAL_ERROR, "error reading /proc/curproc/file");
+ }
+ buffer[bytes] = '\0'; // readlink does not NUL-terminate
+ return string(buffer);
+}
+
+pid_t GetPeerProcessId(int socket) { return -1; }
+
+uint64_t MonotonicClock() {
+ struct timespec ts = {};
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return ts.tv_sec * 1000000000LL + ts.tv_nsec;
+}
+
+uint64_t ProcessClock() {
+ struct timespec ts = {};
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
+ return ts.tv_sec * 1000000000LL + ts.tv_nsec;
+}
+
+void SetScheduling(bool batch_cpu_scheduling, int io_nice_level) {
+ // Move ourself into a low priority CPU scheduling group if the
+ // machine is configured appropriately. Fail silently, because this
+ // isn't available on all kernels.
+
+ if (io_nice_level >= 0) {
+ if (blaze_util::sys_ioprio_set(
+ IOPRIO_WHO_PROCESS, getpid(),
+ IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, io_nice_level)) < 0) {
+ pdie(blaze_exit_code::INTERNAL_ERROR,
+ "ioprio_set() with class %d and level %d failed", IOPRIO_CLASS_BE,
+ io_nice_level);
+ }
+ }
+}
+
+string GetProcessCWD(int pid) {
+ if (kill(pid, 0) < 0) return "";
+ auto procstat = procstat_open_sysctl();
+ unsigned int n;
+ auto p = procstat_getprocs(procstat, KERN_PROC_PID, pid, &n);
+ string cwd;
+ if (p) {
+ if (n != 1) {
+ pdie(blaze_exit_code::INTERNAL_ERROR,
+ "expected exactly one process from procstat_getprocs, got %d", n);
+ }
+ auto files = procstat_getfiles(procstat, p, false);
+ filestat *entry;
+ STAILQ_FOREACH(entry, files, next) {
+ if (entry->fs_uflags & PS_FST_UFLAG_CDIR) {
+ cwd = entry->fs_path;
+ }
+ }
+ procstat_freefiles(procstat, files);
+ procstat_freeprocs(procstat, p);
+ }
+ procstat_close(procstat);
+ return cwd;
+}
+
+bool IsSharedLibrary(const string &filename) {
+ return blaze_util::ends_with(filename, ".so");
+}
+
+string GetDefaultHostJavabase() {
+ // if JAVA_HOME is defined, then use it as default.
+ const char *javahome = getenv("JAVA_HOME");
+ if (javahome != NULL) {
+ return string(javahome);
+ }
+ return "/usr/local/openjdk8";
+}
+
+} // namespace blaze
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
index f3694b5..4cf3b12 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
@@ -399,6 +399,8 @@
switch (OS.getCurrent()) {
case DARWIN:
return "darwin";
+ case FREEBSD:
+ return "freebsd";
case LINUX:
switch (CPU.getCurrent()) {
case X86_32:
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE
index 82def35..2421b45 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE
@@ -30,6 +30,11 @@
)
bind(
+ name = "jni_md_header-freebsd",
+ actual = "@local-jdk//:jni_md_header-freebsd",
+)
+
+bind(
name = "java",
actual = "@local-jdk//:java",
)
diff --git a/src/main/java/com/google/devtools/build/lib/util/OS.java b/src/main/java/com/google/devtools/build/lib/util/OS.java
index 97e6c3a..e425936 100644
--- a/src/main/java/com/google/devtools/build/lib/util/OS.java
+++ b/src/main/java/com/google/devtools/build/lib/util/OS.java
@@ -18,6 +18,7 @@
*/
public enum OS {
DARWIN("osx", "Mac OS X"),
+ FREEBSD("freebsd", "FreeBSD"),
LINUX("linux", "Linux"),
WINDOWS("windows", "Windows"),
UNKNOWN("unknown", "");
diff --git a/src/main/native/BUILD b/src/main/native/BUILD
index f090a6f..97a4e9a 100644
--- a/src/main/native/BUILD
+++ b/src/main/native/BUILD
@@ -2,6 +2,7 @@
name = "copy_link_jni_md_header",
srcs = select({
"//src:darwin": ["//tools/jdk:jni_md_header-darwin"],
+ "//src:freebsd": ["//tools/jdk:jni_md_header-freebsd"],
"//conditions:default": ["//tools/jdk:jni_md_header-linux"],
}),
outs = ["jni_md.h"],
@@ -19,6 +20,7 @@
name = "jni_os",
srcs = select({
"//src:darwin": ["unix_jni_darwin.cc"],
+ "//src:freebsd": ["unix_jni_freebsd.cc"],
"//conditions:default": ["unix_jni_linux.cc"],
}),
)
diff --git a/src/main/native/unix_jni.h b/src/main/native/unix_jni.h
index 6667001..426e205 100644
--- a/src/main/native/unix_jni.h
+++ b/src/main/native/unix_jni.h
@@ -31,8 +31,8 @@
} \
} while (0)
-#if defined(__APPLE__)
-// stat64 is deprecated on OS X.
+#if defined(__APPLE__) || defined(__FreeBSD__)
+// stat64 is deprecated on OS X/BSD.
typedef struct stat portable_stat_struct;
#define portable_stat ::stat
#define portable_lstat ::lstat
@@ -42,6 +42,10 @@
#define portable_lstat ::lstat64
#endif
+#if defined(__FreeBSD__)
+#define ENODATA ENOATTR
+#endif
+
// Posts a JNI exception to the current thread with the specified
// message; the exception's class is determined by the specified UNIX
// error number. See package-info.html for details.
diff --git a/src/main/native/unix_jni_freebsd.cc b/src/main/native/unix_jni_freebsd.cc
new file mode 100644
index 0000000..56e0c9d
--- /dev/null
+++ b/src/main/native/unix_jni_freebsd.cc
@@ -0,0 +1,81 @@
+// Copyright 2015 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "src/main/native/unix_jni.h"
+
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/extattr.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <string>
+
+const int PATH_MAX2 = PATH_MAX * 2;
+
+using std::string;
+
+// See unix_jni.h.
+string ErrorMessage(int error_number) {
+ char buf[1024] = "";
+ if (strerror_r(error_number, buf, sizeof buf) < 0) {
+ snprintf(buf, sizeof buf, "strerror_r(%d): errno %d", error_number, errno);
+ }
+
+ return string(buf);
+}
+
+int portable_fstatat(int dirfd, char *name, portable_stat_struct *statbuf,
+ int flags) {
+ return fstatat(dirfd, name, statbuf, flags);
+}
+
+int StatSeconds(const portable_stat_struct &statbuf, StatTimes t) {
+ switch (t) {
+ case STAT_ATIME:
+ return statbuf.st_atime;
+ case STAT_CTIME:
+ return statbuf.st_ctime;
+ case STAT_MTIME:
+ return statbuf.st_mtime;
+ default:
+ CHECK(false);
+ }
+}
+
+int StatNanoSeconds(const portable_stat_struct &statbuf, StatTimes t) {
+ switch (t) {
+ case STAT_ATIME:
+ return statbuf.st_atimespec.tv_nsec;
+ case STAT_CTIME:
+ return statbuf.st_ctimespec.tv_nsec;
+ case STAT_MTIME:
+ return statbuf.st_mtimespec.tv_nsec;
+ default:
+ CHECK(false);
+ }
+}
+
+ssize_t portable_getxattr(const char *path, const char *name, void *value,
+ size_t size) {
+ return extattr_get_file(path, EXTATTR_NAMESPACE_SYSTEM, name, value, size);
+}
+
+ssize_t portable_lgetxattr(const char *path, const char *name, void *value,
+ size_t size) {
+ return extattr_get_link(path, EXTATTR_NAMESPACE_SYSTEM, name, value, size);
+}
diff --git a/src/main/tools/BUILD b/src/main/tools/BUILD
index 02f0b8d..67b3888 100644
--- a/src/main/tools/BUILD
+++ b/src/main/tools/BUILD
@@ -24,6 +24,7 @@
name = "namespace-sandbox",
srcs = select({
"//src:darwin": ["namespace-sandbox-dummy.c"],
+ "//src:freebsd": ["namespace-sandbox-dummy.c"],
"//conditions:default": ["namespace-sandbox.c"],
}),
copts = ["-std=c99"],
diff --git a/src/main/tools/jdk.BUILD b/src/main/tools/jdk.BUILD
index f67ac2f..2828add 100644
--- a/src/main/tools/jdk.BUILD
+++ b/src/main/tools/jdk.BUILD
@@ -16,6 +16,11 @@
)
filegroup(
+ name = "jni_md_header-freebsd",
+ srcs = ["include/freebsd/jni_md.h"],
+)
+
+filegroup(
name = "java",
srcs = ["bin/java"],
)
diff --git a/src/test/shell/unittest.bash b/src/test/shell/unittest.bash
index e7af5b2..82aeb5d 100644
--- a/src/test/shell/unittest.bash
+++ b/src/test/shell/unittest.bash
@@ -458,14 +458,14 @@
}
# Multi-platform timestamp function
-if [ "$(uname -s | tr 'A-Z' 'a-z')" = "darwin" ]; then
+if [ "$(uname -s | tr 'A-Z' 'a-z')" = "linux" ]; then
function timestamp() {
- # OS X does not have %N so python is the best we can do
- python -c 'import time; print int(round(time.time() * 1000))'
+ echo $(($(date +%s%N)/1000000))
}
else
function timestamp() {
- echo $(($(date +%s%N)/1000000))
+ # OS X and FreeBSD do not have %N so python is the best we can do
+ python -c 'import time; print int(round(time.time() * 1000))'
}
fi
diff --git a/third_party/BUILD b/third_party/BUILD
index 5c59287..39704c1 100644
--- a/third_party/BUILD
+++ b/third_party/BUILD
@@ -15,6 +15,7 @@
":k8": ["protobuf/protoc-linux-x86_64.exe"],
":piii": ["protobuf/protoc-linux-x86_32.exe"],
":arm": ["protobuf/protoc-linux-arm32.exe"],
+ ":freebsd": ["protobuf/protoc-linux-x86_32.exe"],
}),
)
@@ -375,3 +376,8 @@
name = "arm",
values = {"host_cpu": "arm"},
)
+
+config_setting(
+ name = "freebsd",
+ values = {"host_cpu": "freebsd"},
+)
diff --git a/third_party/ijar/test/testenv.sh b/third_party/ijar/test/testenv.sh
index e14aadf..0cb2c21 100755
--- a/third_party/ijar/test/testenv.sh
+++ b/third_party/ijar/test/testenv.sh
@@ -23,16 +23,16 @@
source "${TEST_SRCDIR}/src/test/shell/unittest.bash" || \
{ echo "Failed to source unittest.bash" >&2; exit 1; }
-## Mac OS X stat and MD5
+## OSX/BSD stat and MD5
PLATFORM="$(uname -s | tr 'A-Z' 'a-z')"
-if [[ "$PLATFORM" = "darwin" ]]; then
+if [[ "$PLATFORM" = "linux" ]]; then
function statfmt() {
- stat -f "%z" $1
+ stat -c "%s" $1
}
MD5SUM=/sbin/md5
else
function statfmt() {
- stat -c "%s" $1
+ stat -f "%z" $1
}
MD5SUM=md5sum
fi
diff --git a/tools/cpp/BUILD b/tools/cpp/BUILD
index 6599bc2..f5407ca 100644
--- a/tools/cpp/BUILD
+++ b/tools/cpp/BUILD
@@ -28,6 +28,7 @@
srcs = [
":cc-compiler-armeabi-v7a",
":cc-compiler-darwin",
+ ":cc-compiler-freebsd",
":cc-compiler-local",
":empty",
],
@@ -89,6 +90,20 @@
supports_param_files = 0,
)
+cc_toolchain(
+ name = "cc-compiler-freebsd",
+ 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,
+)
+
filegroup(
name = "srcs",
srcs = glob(["**"]),
diff --git a/tools/cpp/CROSSTOOL b/tools/cpp/CROSSTOOL
index 86442c9..c3de9c6 100644
--- a/tools/cpp/CROSSTOOL
+++ b/tools/cpp/CROSSTOOL
@@ -15,6 +15,10 @@
toolchain_identifier: "local_darwin"
}
default_toolchain {
+ cpu: "freebsd"
+ toolchain_identifier: "local_freebsd"
+}
+default_toolchain {
cpu: "armeabi-v7a"
toolchain_identifier: "stub_armeabi-v7a"
}
@@ -316,6 +320,129 @@
abi_version: "local"
abi_libc_version: "local"
builtin_sysroot: ""
+ compiler: "compiler"
+ 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: "freebsd"
+ target_system_name: "local"
+ toolchain_identifier: "local_freebsd"
+
+ 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" }
+ cxx_flag: "-std=c++0x"
+ linker_flag: "-lstdc++"
+ linker_flag: "-B/usr/bin/"
+
+ # 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/local/include"
+ cxx_builtin_include_directory: "/usr/include"
+ tool_path { name: "gcov" path: "/usr/bin/gcov" }
+
+ # 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/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" }
+
+ # Anticipated future default.
+ unfiltered_cxx_flag: "-no-canonical-prefixes"
+
+ # 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: "-D_FORTIFY_SOURCE=1"
+ compiler_flag: "-fstack-protector"
+ compiler_flag: "-fPIE"
+ linker_flag: "-pie"
+ linker_flag: "-Wl,-z,relro,-z,now"
+
+ # Enable coloring even if there's no attached terminal. Bazel removes the
+ # escape sequences if --nocolor is specified. This isn't supported by gcc
+ # on Ubuntu 14.04.
+ # compiler_flag: "-fcolor-diagnostics"
+
+ # All warnings are enabled. Maybe enable -Werror as well?
+ compiler_flag: "-Wall"
+ # Enable a few more warnings that aren't part of -Wall.
+ #compiler_flag: "-Wunused-but-set-parameter"
+ # But disable some that are problematic.
+ #compiler_flag: "-Wno-free-nonheap-object" # has false positives
+
+ # Keep stack frames for debugging, even in opt mode.
+ compiler_flag: "-fno-omit-frame-pointer"
+
+ # Anticipated future default.
+ linker_flag: "-no-canonical-prefixes"
+ # 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"
+ # Gold linker only? Can we enable this by default?
+ # linker_flag: "-Wl,--warn-execstack"
+ # linker_flag: "-Wl,--detect-odr-violations"
+
+ compilation_mode_flags {
+ mode: DBG
+ # Enable debug symbols.
+ compiler_flag: "-g"
+ }
+ 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"
+
+ # Conservative choice for -O
+ # -O3 can increase binary size and even slow down the resulting binaries.
+ # Profile first and / or use FDO if you need better performance than this.
+ compiler_flag: "-O2"
+
+ # Disable assertions
+ compiler_flag: "-DNDEBUG"
+
+ # 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"
+ }
+}
+
+toolchain {
+ abi_version: "local"
+ abi_libc_version: "local"
+ builtin_sysroot: ""
compiler: "windows_mingw"
host_system_name: "local"
needsPic: false
diff --git a/tools/jdk/BUILD b/tools/jdk/BUILD
index 58db282..2ee3d68 100644
--- a/tools/jdk/BUILD
+++ b/tools/jdk/BUILD
@@ -16,6 +16,11 @@
)
filegroup(
+ name = "jni_md_header-freebsd",
+ srcs = ["//external:jni_md_header-freebsd"],
+)
+
+filegroup(
name = "java",
srcs = ["//external:java"],
)