Skip to content

Instantly share code, notes, and snippets.

@siepkes
Created August 11, 2018 13:09
Show Gist options
  • Save siepkes/0d144125974b2a84a92433e0282804b2 to your computer and use it in GitHub Desktop.
Save siepkes/0d144125974b2a84a92433e0282804b2 to your computer and use it in GitHub Desktop.
Patch to make Bazel 0.16.0 dist build on SmartOS (aka Illumos, aka Solaris)
--- bazel-0.16-orig/scripts/bootstrap/buildenv.sh 2018-08-10 12:06:01.259567341 +0000
+++ bazel-0.16/scripts/bootstrap/buildenv.sh 2018-08-10 12:09:09.651970713 +0000
@@ -83,6 +83,10 @@
JAVA_HOME="${JAVA_HOME:-/usr/local/openjdk8}"
;;
+solaris)
+ JAVA_HOME="${JAVA_HOME:-/opt/local/java/openjdk8}"
+ ;;
+
darwin)
if [[ -z "$JAVA_HOME" ]]; then
JAVA_HOME="$(/usr/libexec/java_home -v ${JAVA_VERSION}+ 2> /dev/null)" \
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/scripts/packages/BUILD bazel-0.16/scripts/packages/BUILD
--- bazel-0.16-orig/scripts/packages/BUILD 2018-08-10 12:06:01.261376138 +0000
+++ bazel-0.16/scripts/packages/BUILD 2018-08-10 12:09:56.380027846 +0000
@@ -20,6 +20,7 @@
":zip-bazel-exe_with_jdk",
],
"//src/conditions:freebsd": [],
+ "//src/conditions:solaris": [],
"//src/conditions:darwin": [
":with-jdk/install.sh",
":without-jdk/install.sh",
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/scripts/packages/template_bin.sh bazel-0.16/scripts/packages/template_bin.sh
--- bazel-0.16-orig/scripts/packages/template_bin.sh 2018-08-10 12:06:01.262275739 +0000
+++ bazel-0.16/scripts/packages/template_bin.sh 2018-08-10 12:10:25.252187363 +0000
@@ -115,6 +115,10 @@
JAVA_HOME="/usr/local/openjdk8"
BASHRC="~/.bashrc"
;;
+ solaris)
+ JAVA_HOME="/opt/local/java/openjdk8"
+ BASHRC="~/.bashrc"
+ ;;
darwin)
JAVA_HOME="$(/usr/libexec/java_home -v ${JAVA_VERSION}+ 2> /dev/null)" || true
BASHRC="~/.bash_profile"
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/conditions/BUILD bazel-0.16/src/conditions/BUILD
--- bazel-0.16-orig/src/conditions/BUILD 2018-08-10 12:06:01.278600059 +0000
+++ bazel-0.16/src/conditions/BUILD 2018-08-10 12:11:14.381105798 +0000
@@ -41,6 +41,12 @@
)
config_setting(
+ name = "solaris",
+ values = {"cpu": "solaris"},
+ visibility = ["//visibility:public"],
+)
+
+config_setting(
name = "windows",
values = {"cpu": "x64_windows"},
visibility = ["//visibility:public"],
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/conditions/BUILD.tools bazel-0.16/src/conditions/BUILD.tools
--- bazel-0.16-orig/src/conditions/BUILD.tools 2018-08-10 12:06:01.278655399 +0000
+++ bazel-0.16/src/conditions/BUILD.tools 2018-08-10 12:12:08.644092146 +0000
@@ -5,6 +5,12 @@
)
config_setting(
+ name = "solaris",
+ values = {"cpu": "solaris"},
+ visibility = ["//visibility:public"],
+)
+
+config_setting(
name = "darwin",
values = {"cpu": "darwin"},
visibility = ["//visibility:public"],
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/cpp/BUILD bazel-0.16/src/main/cpp/BUILD
--- bazel-0.16-orig/src/main/cpp/BUILD 2018-08-10 12:06:01.309987795 +0000
+++ bazel-0.16/src/main/cpp/BUILD 2018-08-10 12:13:02.676056206 +0000
@@ -30,6 +30,10 @@
"blaze_util_freebsd.cc",
"blaze_util_posix.cc",
],
+ "//src/conditions:solaris": [
+ "blaze_util_solaris.cc",
+ "blaze_util_posix.cc",
+ ],
"//src/conditions:windows": [
"blaze_util_windows.cc",
],
@@ -51,6 +55,8 @@
],
"//src/conditions:freebsd": [
],
+ "//src/conditions:solaris": [
+ ],
"//src/conditions:windows": WIN_LINK_OPTS,
"//conditions:default": [
"-lrt",
@@ -91,6 +97,8 @@
"-lprocstat",
"-lm",
],
+ "//src/conditions:solaris": [
+ ],
"//src/conditions:windows": [
],
"//conditions:default": [
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/cpp/blaze_util_posix.cc bazel-0.16/src/main/cpp/blaze_util_posix.cc
--- bazel-0.16-orig/src/main/cpp/blaze_util_posix.cc 2018-08-10 12:06:01.310911484 +0000
+++ bazel-0.16/src/main/cpp/blaze_util_posix.cc 2018-08-10 12:14:56.052351963 +0000
@@ -33,6 +33,9 @@
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
+#if defined(__sun)
+#include <sys/termios.h> // TIOCGWINSZ
+#endif
#include <cassert>
#include <cinttypes>
@@ -615,6 +618,9 @@
// fails to take the lock, but not parsed otherwise.
(void) ftruncate(lockfd, 0);
lseek(lockfd, 0, SEEK_SET);
+#if defined(__sun)
+// TODO: Implement for Illumos / Solaris. Illumos does not support dprintf (POSIX 2008).
+#else
// Arguably we should ensure this fits in the 4KB we lock. In practice no one
// will have a cwd long enough to overflow that, and nothing currently uses
// the rest of the lock file anyway.
@@ -624,6 +630,7 @@
if (const char *tty = ttyname(STDIN_FILENO)) { // NOLINT (single-threaded)
dprintf(lockfd, "tty=%s\n", tty);
}
+#endif
blaze_lock->lockfd = lockfd;
return wait_time;
}
@@ -758,7 +765,9 @@
bool UnlimitResources() {
bool success = true;
success &= UnlimitResource(RLIMIT_NOFILE);
+#if defined(RLIMIT_NPROC)
success &= UnlimitResource(RLIMIT_NPROC);
+#endif
return success;
}
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/cpp/blaze_util_solaris.cc bazel-0.16/src/main/cpp/blaze_util_solaris.cc
--- bazel-0.16-orig/src/main/cpp/blaze_util_solaris.cc 1970-01-01 00:00:00.000000000 +0000
+++ bazel-0.16/src/main/cpp/blaze_util_solaris.cc 2018-08-10 14:30:28.878994434 +0000
@@ -0,0 +1,255 @@
+// Copyright 2014 The Bazel Authors. 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.
+
+// Copied from the Linux version since Solaris also supports /proc.
+//
+// TODO: Needs to be checked for correctness.
+//
+// Following methods implemented specifically for Solaris:
+// - GetSelfPath
+// - GetStartTime (internal)
+// - WriteSystemSpecificProcessIdentifier
+// - VerifyServerProcess
+// - GetProcessCWD
+
+#include <errno.h> // errno, ENAMETOOLONG
+#include <limits.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h> // strerror
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <procfs.h> // psinfo
+#include <time.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/logging.h"
+#include "src/main/cpp/util/path.h"
+#include "src/main/cpp/util/port.h"
+#include "src/main/cpp/util/strings.h"
+
+namespace blaze {
+
+using blaze_util::GetLastErrorString;
+using std::string;
+using std::vector;
+
+string GetOutputRoot() {
+ string base;
+ string home = GetHomeDir();
+ if (!home.empty()) {
+ base = home;
+ } else {
+ 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) {
+ base = pw->pw_dir;
+ }
+ }
+
+ if (!base.empty()) {
+ return blaze_util::JoinPath(base, ".cache/bazel");
+ }
+
+ return "/tmp";
+}
+
+void WarnFilesystemType(const string& output_base) {
+ // TODO: Implement on Solaris
+}
+
+string GetSelfPath() {
+ char buffer_link[PATH_MAX] = {};
+ char buffer_target[PATH_MAX] = {};
+ auto pid = getpid();
+ if (kill(pid, 0) < 0) return "";
+
+ snprintf(buffer_link, PATH_MAX, "/proc/%u/path/a.out", pid);
+ ssize_t bytes = readlink(buffer_link, buffer_target, PATH_MAX - 1);
+ if (bytes == PATH_MAX - 1) {
+ // symlink contents truncated
+ bytes = -1;
+ errno = ENAMETOOLONG;
+ }
+ if (bytes == -1) {
+ BAZEL_DIE(blaze_exit_code::INTERNAL_ERROR)
+ << "error reading /proc/PID/path/a.out";
+ }
+ buffer_target[bytes] = '\0'; // readlink does not NUL-terminate
+ return string(buffer_target);
+}
+
+uint64_t GetMillisecondsMonotonic() {
+ struct timespec ts = {};
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return ts.tv_sec * 1000LL + (ts.tv_nsec / 1000000LL);
+}
+
+uint64_t GetMillisecondsSinceProcessStart() {
+ struct timespec ts = {};
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
+ return ts.tv_sec * 1000LL + (ts.tv_nsec / 1000000LL);
+}
+
+void SetScheduling(bool batch_cpu_scheduling, int io_nice_level) {
+ // TODO: Implement setting CPU and IO scheduling hints.
+}
+
+string GetProcessCWD(int pid) {
+ char server_cwd[PATH_MAX] = {};
+ if (readlink(
+ ("/proc/" + ToString(pid) + "/cwd").c_str(),
+ server_cwd, sizeof(server_cwd)) < 0) {
+ return "";
+ }
+
+ return string(server_cwd);
+}
+
+bool IsSharedLibrary(const string &filename) {
+ return blaze_util::ends_with(filename, ".so");
+}
+
+static string Which(const string &executable) {
+ string path(GetEnv("PATH"));
+ if (path.empty()) {
+ return "";
+ }
+
+ vector<string> pieces = blaze_util::Split(path, ':');
+ for (auto piece : pieces) {
+ if (piece.empty()) {
+ piece = ".";
+ }
+
+ struct stat file_stat;
+ string candidate = blaze_util::JoinPath(piece, executable);
+ if (access(candidate.c_str(), X_OK) == 0 &&
+ stat(candidate.c_str(), &file_stat) == 0 &&
+ S_ISREG(file_stat.st_mode)) {
+ return candidate;
+ }
+ }
+ return "";
+}
+
+string GetSystemJavabase() {
+ // if JAVA_HOME is defined, then use it as default.
+ string javahome = GetEnv("JAVA_HOME");
+ if (!javahome.empty()) {
+ return javahome;
+ }
+
+ // which javac
+ string javac_dir = Which("javac");
+ if (javac_dir.empty()) {
+ return "";
+ }
+
+ // Resolve all symlinks.
+ char resolved_path[PATH_MAX];
+ if (realpath(javac_dir.c_str(), resolved_path) == NULL) {
+ return "";
+ }
+ javac_dir = resolved_path;
+
+ // dirname dirname
+ return blaze_util::Dirname(blaze_util::Dirname(javac_dir));
+}
+
+// Called from a signal handler!
+static bool GetStartTime(const string& pid, string* start_time) {
+ // TODO: Threw this together somewhat quick. Needs to be checked
+ // for correctness.
+ char filename [PATH_MAX];
+ FILE *f;
+ bool time_set = false;
+ psinfo_t info;
+
+ snprintf(filename, sizeof(filename), "/proc/%s/psinfo", pid.c_str());
+
+ f = fopen(filename, "r");
+ if (f) {
+ if (fread(&info, sizeof(info), 1, f) > 0) {
+ char buffer [128];
+ sprintf (buffer, "%lu", info.pr_start.tv_nsec);
+ *start_time = string(buffer);
+ time_set = true;
+ }
+
+ fclose(f);
+ }
+
+ return time_set;
+}
+
+void WriteSystemSpecificProcessIdentifier(
+ const string& server_dir, pid_t server_pid) {
+ string pid_string = ToString(server_pid);
+
+ string start_time;
+ if (!GetStartTime(pid_string, &start_time)) {
+ BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR)
+ << "Cannot get start time of process " << pid_string.c_str();
+ }
+
+ string start_time_file = blaze_util::JoinPath(server_dir, "server.starttime");
+ if (!blaze_util::WriteFile(start_time, start_time_file)) {
+ BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR)
+ << "Cannot write start time in server dir " << server_dir.c_str();
+ }
+}
+
+// On Linux we use a combination of PID and start time to identify the server
+// process. That is supposed to be unique unless one can start more processes
+// than there are PIDs available within a single jiffy.
+bool VerifyServerProcess(int pid, const string& output_base) {
+ string start_time;
+ if (!GetStartTime(ToString(pid), &start_time)) {
+ // Cannot read PID file from /proc . Process died meantime, all is good. No
+ // stale server is present.
+ return false;
+ }
+
+ string recorded_start_time;
+ bool file_present = blaze_util::ReadFile(
+ blaze_util::JoinPath(output_base, "server/server.starttime"),
+ &recorded_start_time);
+
+ // If start time file got deleted, but PID file didn't, assume that this is an
+ // old Blaze process that doesn't know how to write start time files yet.
+ return !file_present || recorded_start_time == start_time;
+}
+
+// Not supported.
+void ExcludePathFromBackup(const string &path) {
+}
+
+int32_t GetExplicitSystemLimit(const int resource) {
+ return -1;
+}
+
+} // namespace blaze
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java bazel-0.16/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java
--- bazel-0.16-orig/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java 2018-08-10 12:06:01.329811262 +0000
+++ bazel-0.16/src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java 2018-08-10 12:16:22.075161747 +0000
@@ -37,6 +37,8 @@
return "darwin";
case FREEBSD:
return "freebsd";
+ case SOLARIS:
+ return "solaris";
case WINDOWS:
switch (CPU.getCurrent()) {
case X86_64:
@@ -81,6 +83,8 @@
return Pair.of(CPU.getCurrent(), OS.DARWIN);
} else if (input.startsWith("freebsd")) {
return Pair.of(CPU.getCurrent(), OS.FREEBSD);
+ } else if (input.startsWith("solaris")) {
+ return Pair.of(CPU.getCurrent(), OS.SOLARIS);
} else if (input.startsWith("x64_windows")) {
return Pair.of(CPU.getCurrent(), OS.WINDOWS);
}
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE bazel-0.16/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE
--- bazel-0.16-orig/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE 2018-08-10 12:06:01.352287818 +0000
+++ bazel-0.16/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE 2018-08-10 12:16:49.605410853 +0000
@@ -46,6 +46,11 @@
)
bind(
+ name = "jni_md_header-solaris",
+ actual = "@local_jdk//:jni_md_header-solaris",
+)
+
+bind(
name = "java",
actual = "@local_jdk//:java",
)
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt bazel-0.16/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt
--- bazel-0.16-orig/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt 2018-08-10 12:06:01.353676102 +0000
+++ bazel-0.16/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt 2018-08-10 12:17:30.145632711 +0000
@@ -38,7 +38,7 @@
# Find a file in a given search path.
def SearchPath(name):
- search_path = os.getenv('PATH', os.defpath).split(os.pathsep)
+ search_path = os.getenv('PATH', os.defpath + ":/opt/local/bin").split(os.pathsep)
for directory in search_path:
if directory == '': continue
path = os.path.join(directory, name)
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java bazel-0.16/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java
--- bazel-0.16-orig/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java 2018-08-10 12:06:01.407279840 +0000
+++ bazel-0.16/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java 2018-08-10 12:59:25.800515524 +0000
@@ -28,6 +28,7 @@
/** A platform for C++ tool invocations. */
public enum CppPlatform {
LINUX,
+ SOLARIS,
MAC
}
@@ -739,6 +740,59 @@
" expand_if_true: 'libraries_to_link.is_whole_archive'",
" flag: '-Wl,-no-whole-archive'",
" }"),
+ ifSolaris(
+ platform,
+ " flag_group {",
+ " expand_if_true: 'libraries_to_link.is_whole_archive'",
+ " flag: '-Wl,--whole-archive'",
+ " }",
+ " flag_group {",
+ " expand_if_equal: {",
+ " variable: 'libraries_to_link.type'",
+ " value: 'object_file_group'",
+ " }",
+ " iterate_over: 'libraries_to_link.object_files'",
+ " flag: '%{libraries_to_link.object_files}'",
+ " }",
+ " flag_group {",
+ " expand_if_equal: {",
+ " variable: 'libraries_to_link.type'",
+ " value: 'object_file'",
+ " }",
+ " flag: '%{libraries_to_link.name}'",
+ " }",
+ " flag_group {",
+ " expand_if_equal: {",
+ " variable: 'libraries_to_link.type'",
+ " value: 'interface_library'",
+ " }",
+ " flag: '%{libraries_to_link.name}'",
+ " }",
+ " flag_group {",
+ " expand_if_equal: {",
+ " variable: 'libraries_to_link.type'",
+ " value: 'static_library'",
+ " }",
+ " flag: '%{libraries_to_link.name}'",
+ " }",
+ " flag_group {",
+ " expand_if_equal: {",
+ " variable: 'libraries_to_link.type'",
+ " value: 'dynamic_library'",
+ " }",
+ " flag: '-l%{libraries_to_link.name}'",
+ " }",
+ " flag_group {",
+ " expand_if_equal: {",
+ " variable: 'libraries_to_link.type'",
+ " value: 'versioned_dynamic_library'",
+ " }",
+ " flag: '-l:%{libraries_to_link.name}'",
+ " }",
+ " flag_group {",
+ " expand_if_true: 'libraries_to_link.is_whole_archive'",
+ " flag: '-Wl,--no-whole-archive'",
+ " }"),
ifMac(
platform,
" flag_group {",
@@ -892,7 +946,11 @@
" action: 'c++-link-nodeps-dynamic-library'",
" flag_group {",
" expand_if_all_available: 'strip_debug_symbols'",
- " flag: '-Wl,-S'",
+ ifLinux(platform, " flag: '-Wl,-S'"),
+ ifMac(platform, " flag: '-Wl,-S'"),
+ // TODO: Figure out how to only strib debug symbols on Solaris.
+ // 'zstrip-class' is not present on Illumos I think?
+ //ifSolaris(platform, " flag: '-Wl,zstrip-class=debug'"),
" }",
" }",
"}"),
@@ -1178,6 +1236,10 @@
return ifTrue(platform == CppPlatform.LINUX, lines);
}
+ private static String ifSolaris(CppPlatform platform, String... lines) {
+ return ifTrue(platform == CppPlatform.SOLARIS, lines);
+ }
+
private static String ifMac(CppPlatform platform, String... lines) {
return ifTrue(platform == CppPlatform.MAC, lines);
}
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/java/com/google/devtools/build/lib/rules/cpp/CppToolchainInfo.java bazel-0.16/src/main/java/com/google/devtools/build/lib/rules/cpp/CppToolchainInfo.java
--- bazel-0.16-orig/src/main/java/com/google/devtools/build/lib/rules/cpp/CppToolchainInfo.java 2018-08-10 12:06:01.409545890 +0000
+++ bazel-0.16/src/main/java/com/google/devtools/build/lib/rules/cpp/CppToolchainInfo.java 2018-08-10 12:22:16.348356756 +0000
@@ -400,9 +400,18 @@
toolchain = removeLegacyCompileFlagsFeatureFromToolchain(toolchain);
}
+ CppPlatform cppPlatform;
+ if (toolchain.getTargetLibc().equals("macosx")) {
+ cppPlatform = CppPlatform.MAC;
+ } else if (toolchain.getTargetLibc().equals("solaris")) {
+ cppPlatform = CppPlatform.SOLARIS;
+ } else {
+ cppPlatform = CppPlatform.LINUX;
+ }
+
TextFormat.merge(
CppActionConfigs.getCppActionConfigs(
- toolchain.getTargetLibc().equals("macosx") ? CppPlatform.MAC : CppPlatform.LINUX,
+ cppPlatform,
featureNames,
gccToolPath,
linkerToolPath,
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/java/com/google/devtools/build/lib/util/OS.java bazel-0.16/src/main/java/com/google/devtools/build/lib/util/OS.java
--- bazel-0.16-orig/src/main/java/com/google/devtools/build/lib/util/OS.java 2018-08-10 12:06:01.465638044 +0000
+++ bazel-0.16/src/main/java/com/google/devtools/build/lib/util/OS.java 2018-08-10 12:22:46.308683928 +0000
@@ -21,11 +21,12 @@
public enum OS {
DARWIN("osx", "Mac OS X"),
FREEBSD("freebsd", "FreeBSD"),
+ SOLARIS("solaris","SunOS"),
LINUX("linux", "Linux"),
WINDOWS("windows", "Windows"),
UNKNOWN("unknown", "");
- private static final EnumSet<OS> POSIX_COMPATIBLE = EnumSet.of(DARWIN, FREEBSD, LINUX);
+ private static final EnumSet<OS> POSIX_COMPATIBLE = EnumSet.of(DARWIN, FREEBSD, SOLARIS, LINUX);
private final String canonicalName;
private final String detectionName;
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/java/com/google/devtools/build/lib/vfs/OsPathPolicy.java bazel-0.16/src/main/java/com/google/devtools/build/lib/vfs/OsPathPolicy.java
--- bazel-0.16-orig/src/main/java/com/google/devtools/build/lib/vfs/OsPathPolicy.java 2018-08-10 12:06:01.522083834 +0000
+++ bazel-0.16/src/main/java/com/google/devtools/build/lib/vfs/OsPathPolicy.java 2018-08-10 12:24:39.613130654 +0000
@@ -87,6 +87,7 @@
switch (OS.getCurrent()) {
case LINUX:
case FREEBSD:
+ case SOLARIS:
case UNKNOWN:
return UnixOsPathPolicy.INSTANCE;
case DARWIN:
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/native/BUILD bazel-0.16/src/main/native/BUILD
--- bazel-0.16-orig/src/main/native/BUILD 2018-08-10 12:06:01.540046947 +0000
+++ bazel-0.16/src/main/native/BUILD 2018-08-10 12:25:22.413240333 +0000
@@ -4,6 +4,7 @@
"//src/conditions:darwin": ["//tools/jdk:jni_md_header-darwin"],
"//src/conditions:darwin_x86_64": ["//tools/jdk:jni_md_header-darwin"],
"//src/conditions:freebsd": ["//tools/jdk:jni_md_header-freebsd"],
+ "//src/conditions:solaris": ["//tools/jdk:jni_md_header-solaris"],
"//src/conditions:windows": ["//tools/jdk:jni_md_header-windows"],
"//conditions:default": ["//tools/jdk:jni_md_header-linux"],
}),
@@ -32,6 +33,7 @@
"fsevents.cc",
],
"//src/conditions:freebsd": ["unix_jni_freebsd.cc"],
+ "//src/conditions:solaris": ["unix_jni_solaris.cc"],
"//conditions:default": ["unix_jni_linux.cc"],
}),
)
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/native/unix_jni.cc bazel-0.16/src/main/native/unix_jni.cc
--- bazel-0.16-orig/src/main/native/unix_jni.cc 2018-08-10 12:06:01.540401647 +0000
+++ bazel-0.16/src/main/native/unix_jni.cc 2018-08-10 12:27:32.581670474 +0000
@@ -642,6 +642,7 @@
static char GetDirentType(struct dirent *entry,
int dirfd,
bool follow_symlinks) {
+#ifdef _DIRENT_HAVE_D_TYPE
switch (entry->d_type) {
case DT_REG:
return 'f';
@@ -653,16 +654,19 @@
}
FALLTHROUGH_INTENDED;
case DT_UNKNOWN:
+#endif
portable_stat_struct statbuf;
if (portable_fstatat(dirfd, entry->d_name, &statbuf, 0) == 0) {
if (S_ISREG(statbuf.st_mode)) return 'f';
if (S_ISDIR(statbuf.st_mode)) return 'd';
}
+#ifdef _DIRENT_HAVE_D_TYPE
// stat failed or returned something weird; fall through
FALLTHROUGH_INTENDED;
default:
return '?';
}
+#endif
}
/*
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/native/unix_jni.h bazel-0.16/src/main/native/unix_jni.h
--- bazel-0.16-orig/src/main/native/unix_jni.h 2018-08-10 12:06:01.540467040 +0000
+++ bazel-0.16/src/main/native/unix_jni.h 2018-08-10 12:27:50.326058821 +0000
@@ -31,7 +31,7 @@
} \
} while (0)
-#if defined(__APPLE__) || defined(__FreeBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun)
// stat64 is deprecated on OS X/BSD.
typedef struct stat portable_stat_struct;
#define portable_stat ::stat
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/native/unix_jni_solaris.cc bazel-0.16/src/main/native/unix_jni_solaris.cc
--- bazel-0.16-orig/src/main/native/unix_jni_solaris.cc 1970-01-01 00:00:00.000000000 +0000
+++ bazel-0.16/src/main/native/unix_jni_solaris.cc 2018-08-10 15:03:04.204815831 +0000
@@ -0,0 +1,88 @@
+// Copyright 2015 The Bazel Authors. 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/param.h>
+#include <sys/stat.h>
+#include <sys/unistd.h>
+#include <sys/types.h>
+
+#include <string>
+
+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) {
+ // TODO: Implement nano second based timers on Solaris.
+ switch (t) {
+ case STAT_ATIME:
+ return statbuf.st_atim.tv_nsec;
+ case STAT_CTIME:
+ return statbuf.st_ctim.tv_nsec;
+ case STAT_MTIME:
+ return statbuf.st_mtim.tv_nsec;
+ default:
+ CHECK(false);
+ }
+}
+
+ssize_t portable_getxattr(const char *path, const char *name, void *value,
+ size_t size, bool *attr_not_found) {
+ errno = ENOSYS;
+ return -1;
+}
+
+ssize_t portable_lgetxattr(const char *path, const char *name, void *value,
+ size_t size, bool *attr_not_found) {
+ errno = ENOSYS;
+ return -1;
+}
+
+int portable_sysctlbyname(const char *name_chars, long *mibp, size_t *sizep) {
+ errno = ENOSYS;
+ return -1;
+}
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/tools/BUILD bazel-0.16/src/main/tools/BUILD
--- bazel-0.16-orig/src/main/tools/BUILD 2018-08-10 12:06:01.543362149 +0000
+++ bazel-0.16/src/main/tools/BUILD 2018-08-10 12:29:41.197286643 +0000
@@ -56,6 +56,7 @@
"//src/conditions:darwin": ["dummy-sandbox.c"],
"//src/conditions:darwin_x86_64": ["dummy-sandbox.c"],
"//src/conditions:freebsd": ["dummy-sandbox.c"],
+ "//src/conditions:solaris": ["dummy-sandbox.c"],
"//src/conditions:windows": ["dummy-sandbox.c"],
"//conditions:default": [
"linux-sandbox.cc",
@@ -71,6 +72,7 @@
"//src/conditions:darwin": [],
"//src/conditions:darwin_x86_64": [],
"//src/conditions:freebsd": [],
+ "//src/conditions:solaris": [],
"//src/conditions:windows": [],
"//conditions:default": [
":logging",
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/main/tools/jdk.BUILD bazel-0.16/src/main/tools/jdk.BUILD
--- bazel-0.16-orig/src/main/tools/jdk.BUILD 2018-08-10 12:06:01.543609068 +0000
+++ bazel-0.16/src/main/tools/jdk.BUILD 2018-08-10 12:31:28.629472111 +0000
@@ -21,6 +21,11 @@
)
filegroup(
+ name = "jni_md_header-solaris",
+ srcs = ["include/solaris/jni_md.h"],
+)
+
+filegroup(
name = "jni_md_header-windows",
srcs = ["include/win32/jni_md.h"],
)
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/tools/singlejar/diag.h bazel-0.16/src/tools/singlejar/diag.h
--- bazel-0.16-orig/src/tools/singlejar/diag.h 2018-08-10 12:06:01.716655578 +0000
+++ bazel-0.16/src/tools/singlejar/diag.h 2018-08-10 12:32:50.085707561 +0000
@@ -19,7 +19,7 @@
* Various useful diagnostics functions from Linux err.h file, wrapped
* for portability.
*/
-#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__)
+#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) || defined(__sun)
#include <err.h>
#define diag_err(...) err(__VA_ARGS__)
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/tools/singlejar/mapped_file_posix.inc bazel-0.16/src/tools/singlejar/mapped_file_posix.inc
--- bazel-0.16-orig/src/tools/singlejar/mapped_file_posix.inc 2018-08-10 12:06:01.717397082 +0000
+++ bazel-0.16/src/tools/singlejar/mapped_file_posix.inc 2018-08-10 12:34:19.866706675 +0000
@@ -25,8 +25,8 @@
#include "src/tools/singlejar/diag.h"
// The implementation is 64-bit Linux or OSX specific.
-#if !((defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)) && \
- __SIZEOF_POINTER__ == 8)
+#if !((defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
+ defined(__sun)) && __SIZEOF_POINTER__ == 8)
#error This code for 64 bit Unix.
#endif
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/src/tools/singlejar/zip_headers.h bazel-0.16/src/tools/singlejar/zip_headers.h
--- bazel-0.16-orig/src/tools/singlejar/zip_headers.h 2018-08-10 12:06:01.718808774 +0000
+++ bazel-0.16/src/tools/singlejar/zip_headers.h 2018-08-10 12:34:52.828280974 +0000
@@ -25,7 +25,7 @@
#include <cinttypes>
-#if defined(__linux__)
+#if defined(__linux__) || defined(__sun)
#include <endian.h>
#elif defined(__FreeBSD__)
#include <sys/endian.h>
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/third_party/BUILD bazel-0.16/third_party/BUILD
--- bazel-0.16-orig/third_party/BUILD 2018-08-10 12:06:01.743986044 +0000
+++ bazel-0.16/third_party/BUILD 2018-08-10 12:35:32.966413712 +0000
@@ -652,6 +652,11 @@
)
config_setting(
+ name = "solaris",
+ values = {"host_cpu": "solaris"},
+)
+
+config_setting(
name = "s390x",
values = {"host_cpu": "s390x"},
)
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/third_party/grpc/BUILD bazel-0.16/third_party/grpc/BUILD
--- bazel-0.16-orig/third_party/grpc/BUILD 2018-08-10 12:06:01.915165999 +0000
+++ bazel-0.16/third_party/grpc/BUILD 2018-08-10 12:36:08.070611217 +0000
@@ -435,6 +435,15 @@
"-std=gnu99",
"-Wimplicit-function-declaration",
],
+ "//src/conditions:solaris": [
+ # Needed for 'msg_control' in 'msghdr'.
+ "-D_XOPEN_SOURCE=600",
+ # Needed for 'IPV6_V6ONLY' in 'in.h'.
+ "-D__EXTENSIONS__",
+ # Must be c99 otherwise 'feature_tests.h' will complain.
+ "-std=c99",
+ "-Wimplicit-function-declaration",
+ ],
":windows": ["/we4013"],
}),
includes = [
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/third_party/grpc/include/grpc/impl/codegen/port_platform.h bazel-0.16/third_party/grpc/include/grpc/impl/codegen/port_platform.h
--- bazel-0.16-orig/third_party/grpc/include/grpc/impl/codegen/port_platform.h 2018-08-10 12:06:01.923985014 +0000
+++ bazel-0.16/third_party/grpc/include/grpc/impl/codegen/port_platform.h 2018-08-10 13:02:33.800114976 +0000
@@ -249,6 +249,38 @@
#else /* _LP64 */
#define GPR_ARCH_32 1
#endif /* _LP64 */
+#elif defined(__sun)
+#define GPR_PLATFORM_STRING "solaris"
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+#define GPR_SOLARIS 1
+#define GPR_CPU_POSIX 1
+#define GPR_GCC_ATOMIC 1
+#define GPR_GCC_TLS 1
+#define GPR_POSIX_LOG 1
+#define GPR_POSIX_ENV 1
+#define GPR_POSIX_TMPFILE 1
+#define GPR_POSIX_STRING 1
+#define GPR_POSIX_SUBPROCESS 1
+#define GPR_POSIX_SYNC 1
+#define GPR_POSIX_TIME 1
+#define GPR_GETPID_IN_UNISTD_H 1
+#define GPR_SUPPORT_CHANNELS_FROM_FD 1
+#define GPR_HAVE_ARPA_NAMESER 1
+#define GPR_HAVE_IFADDRS 1
+#define GPR_HAVE_IPV6_RECVPKTINFO 1
+#define GPR_HAVE_UNIX_SOCKET 1
+#define GPR_POSIX_FORK 1
+#define GPR_POSIX_NO_SPECIAL_WAKEUP_FD 1
+#define GPR_POSIX_SOCKET 1
+#define GPR_POSIX_SOCKETADDR 1
+#define GPR_POSIX_SOCKETUTILS 1
+#define GPR_POSIX_WAKEUP_FD 1
+#define GPR_TIMER_USE_GENERIC 1
+// Event ports are not implemented so this is our best option.
+#define GPR_POSIX_MULTIPOLL_WITH_POLL 1
+#define GPR_ARCH_64 1
#elif defined(__FreeBSD__)
#define GPR_PLATFORM_STRING "freebsd"
#ifndef _BSD_SOURCE
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/tools/cpp/BUILD bazel-0.16/tools/cpp/BUILD
--- bazel-0.16-orig/tools/cpp/BUILD 2018-08-10 12:06:01.736043965 +0000
+++ bazel-0.16/tools/cpp/BUILD 2018-08-10 12:38:24.438390002 +0000
@@ -93,6 +93,7 @@
"armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a",
"darwin|compiler": ":cc-compiler-darwin",
"freebsd|compiler": ":cc-compiler-freebsd",
+ "solaris|compiler": ":cc-compiler-solaris",
"local|compiler": ":cc-compiler-local",
"x64_windows|compiler": ":cc-compiler-x64_windows",
"x64_windows_msvc|compiler": ":cc-compiler-x64_windows_msvc",
@@ -264,6 +265,20 @@
)
cc_toolchain(
+ name = "cc-compiler-solaris",
+ 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,
+)
+
+cc_toolchain(
name = "cc-compiler-x64_windows",
all_files = ":empty",
compiler_files = ":empty",
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/tools/cpp/BUILD.static.freebsd bazel-0.16/tools/cpp/BUILD.static.freebsd
--- bazel-0.16-orig/tools/cpp/BUILD.static.freebsd 2018-08-10 12:06:01.736157966 +0000
+++ bazel-0.16/tools/cpp/BUILD.static.freebsd 2018-08-10 13:16:40.376264738 +0000
@@ -35,6 +35,7 @@
toolchains = {
"armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a",
"freebsd|compiler": ":cc-compiler-freebsd",
+ "solaris|compiler": ":cc-compiler-solaris",
"ios_x86_64|compiler": ":cc-compiler-ios_x86_64",
},
)
@@ -67,6 +68,34 @@
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
+cc_toolchain(
+ name = "cc-compiler-solaris",
+ 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,
+)
+
+toolchain(
+ name = "cc-toolchain-solaris",
+ exec_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:solaris",
+ ],
+ target_compatible_with = [
+ "@bazel_tools//platforms:x86_64",
+ "@bazel_tools//platforms:solaris",
+ ],
+ toolchain = ":cc-compiler-solaris",
+ toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
+)
+
cc_toolchain(
name = "cc-compiler-armeabi-v7a",
all_files = ":empty",
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/tools/cpp/CROSSTOOL bazel-0.16/tools/cpp/CROSSTOOL
--- bazel-0.16-orig/tools/cpp/CROSSTOOL 2018-08-10 12:06:01.736393683 +0000
+++ bazel-0.16/tools/cpp/CROSSTOOL 2018-08-10 13:05:00.329114781 +0000
@@ -19,6 +19,10 @@
toolchain_identifier: "local_freebsd"
}
default_toolchain {
+ cpu: "solaris"
+ toolchain_identifier: "local_solaris"
+}
+default_toolchain {
cpu: "armeabi-v7a"
toolchain_identifier: "stub_armeabi-v7a"
}
@@ -420,6 +424,186 @@
}
toolchain {
+ 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
+ target_libc: "solaris"
+ target_cpu: "solaris"
+ target_system_name: "local"
+ toolchain_identifier: "local_solaris"
+
+ tool_path { name: "ar" path: "/usr/bin/ar" }
+ tool_path { name: "compat-ld" path: "/usr/bin/ld" }
+ tool_path { name: "cpp" path: "/opt/local/gcc7/bin/cpp" }
+ tool_path { name: "dwp" path: "/usr/bin/dwp" }
+ tool_path { name: "gcc" path: "/opt/local/gcc7/bin/gcc" }
+ cxx_flag: "-std=c++11"
+ linker_flag: "-lstdc++"
+ #linker_flag: "-B/usr/bin/"
+
+ # TODO: These are actually just required by depdencies (sub project) like protobuf (js_embed).
+ # Shouldn't be in the normal tool chain.
+ linker_flag: "-lxnet"
+ linker_flag: "-lsocket"
+ linker_flag: "-lnsl"
+
+ # Make the Solaris linker more talkative about what it's doing.
+ linker_flag: "-Wl,-z,verbose"
+ # Make the Solaris linker behave more strictly.
+ linker_flag: "-Wl,-z,text"
+ # Make the Solaris linker rescan the archive files that are provided to the link-edit.
+ linker_flag: "-Wl,-z,rescan"
+
+ # TODO: Can we do without a 'linker_flag'? Only defaults are in it. However
+ # last time I removed it we ran in to (what should be unrelated) build errors.
+ linker_flag: "-Wl,-z,defs"
+
+ # 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?
+ #
+ # Paths obtained with '/opt/local/gcc7/bin/g++ -E -x c++ - -v < /dev/null'.
+ cxx_builtin_include_directory: "/opt/local/gcc7/include/c++"
+ cxx_builtin_include_directory: "/opt/local/gcc7/include/c++/x86_64-sun-solaris2.11"
+ cxx_builtin_include_directory: "/opt/local/gcc7/include/c++/backward"
+ cxx_builtin_include_directory: "/opt/local/gcc7/lib/gcc/x86_64-sun-solaris2.11/7.2.0/include"
+ cxx_builtin_include_directory: "/opt/local/include"
+ cxx_builtin_include_directory: "/opt/local/gcc7/include"
+ cxx_builtin_include_directory: "/opt/local/gcc7/lib/gcc/x86_64-sun-solaris2.11/7.2.0/include-fixed"
+ cxx_builtin_include_directory: "/usr/include"
+
+ tool_path { name: "gcov" path: "/opt/local/gcc7/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: "/opt/local/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"
+ unfiltered_cxx_flag: "-fno-canonical-system-headers"
+
+ # 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"
+ # TODO: Does the Solaris linker support this?
+ #compiler_flag: "-fstack-protector"
+
+ # Uncomment to make GCC more talkative about what it's doing.
+ #compiler_flag: "-v"
+
+ # 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"
+
+ 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"
+ }
+ linking_mode_flags { mode: DYNAMIC }
+
+ # Needed in order to get 'ar' correctly invoked.
+ feature {
+ name: 'archiver_flags'
+ enabled: true
+
+ flag_set {
+ action: 'c++-link-static-library'
+ action: 'c++-link-alwayslink-static-library'
+ action: 'c++-link-pic-static-library'
+ action: 'c++-link-alwayslink-pic-static-library'
+
+ flag_group {
+ expand_if_all_available: 'output_execpath'
+ flag: '-rcs'
+ flag: '%{output_execpath}'
+ }
+
+ flag_group {
+ flag_group {
+ expand_if_all_available: "libraries_to_link"
+ iterate_over: "libraries_to_link"
+ flag_group {
+ expand_if_equal {
+ variable: "libraries_to_link.type"
+ value: "object_file"
+ }
+ flag: "%{libraries_to_link.name}"
+ }
+ flag_group {
+ expand_if_equal {
+ variable: "libraries_to_link.type"
+ value: "object_file_group"
+ }
+ iterate_over: "libraries_to_link.object_files"
+ flag: "%{libraries_to_link.object_files}"
+ }
+ }
+ }
+ }
+ }
+}
+
+toolchain {
abi_version: "local"
abi_libc_version: "local"
builtin_sysroot: ""
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/tools/cpp/cc_configure.bzl bazel-0.16/tools/cpp/cc_configure.bzl
--- bazel-0.16-orig/tools/cpp/cc_configure.bzl 2018-08-10 12:06:01.736671275 +0000
+++ bazel-0.16/tools/cpp/cc_configure.bzl 2018-08-10 12:46:32.934720231 +0000
@@ -38,7 +38,7 @@
if "BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN" in env and env["BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN"] == "1":
repository_ctx.symlink(Label("@bazel_tools//tools/cpp:CROSSTOOL.empty"), "CROSSTOOL")
repository_ctx.symlink(Label("@bazel_tools//tools/cpp:BUILD.empty"), "BUILD")
- elif cpu_value == "freebsd":
+ elif (cpu_value == "freebsd" or cpu_value == "solaris"):
# This is defaulting to the static crosstool, we should eventually
# autoconfigure this platform too. Theorically, FreeBSD should be
# straightforward to add but we cannot run it in a docker container so
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/tools/cpp/lib_cc_configure.bzl bazel-0.16/tools/cpp/lib_cc_configure.bzl
--- bazel-0.16-orig/tools/cpp/lib_cc_configure.bzl 2018-08-10 12:06:01.737126103 +0000
+++ bazel-0.16/tools/cpp/lib_cc_configure.bzl 2018-08-10 12:47:03.663225943 +0000
@@ -181,6 +181,8 @@
return "darwin"
if os_name.find("freebsd") != -1:
return "freebsd"
+ if os_name.find("sunos") != -1:
+ return "solaris"
if os_name.find("windows") != -1:
return "x64_windows"
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/tools/cpp/solaris_cc_configure.bzl bazel-0.16/tools/cpp/solaris_cc_configure.bzl
--- bazel-0.16-orig/tools/cpp/solaris_cc_configure.bzl 1970-01-01 00:00:00.000000000 +0000
+++ bazel-0.16/tools/cpp/solaris_cc_configure.bzl 2018-08-10 13:05:55.151986855 +0000
@@ -0,0 +1,32 @@
+# pylint: disable=g-bad-file-header
+# Copyright 2016 The Bazel Authors. 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.
+"""Configuring the C++ toolchain on Solaris."""
+
+load(
+ "@bazel_tools//tools/cpp:lib_cc_configure.bzl",
+ "escape_string",
+)
+
+load(
+ "@bazel_tools//tools/cpp:unix_cc_configure.bzl",
+ "get_escaped_cxx_inc_directories",
+ "tpl",
+ "get_env",
+ "find_cc",
+ "configure_unix_toolchain"
+)
+
+def configure_osx_toolchain(repository_ctx, overriden_tools):
+ """Configure C++ toolchain on Solaris."""
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/tools/jdk/BUILD bazel-0.16/tools/jdk/BUILD
--- bazel-0.16-orig/tools/jdk/BUILD 2018-08-10 12:06:01.734772715 +0000
+++ bazel-0.16/tools/jdk/BUILD 2018-08-10 12:47:27.246917019 +0000
@@ -78,6 +78,11 @@
)
alias(
+ name = "jni_md_header-solaris",
+ actual = "@local_jdk//:jni_md_header-solaris",
+)
+
+alias(
name = "java",
actual = "@local_jdk//:java",
)
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/tools/platforms/BUILD bazel-0.16/tools/platforms/BUILD
--- bazel-0.16-orig/tools/platforms/BUILD 2018-08-10 12:06:01.735665494 +0000
+++ bazel-0.16/tools/platforms/BUILD 2018-08-10 12:49:13.173925895 +0000
@@ -68,6 +68,11 @@
)
constraint_value(
+ name = "solaris",
+ constraint_setting = ":os",
+)
+
+constraint_value(
name = "android",
constraint_setting = ":os",
)
@@ -119,6 +124,7 @@
os_constraints = [
":osx",
":freebsd",
+ ":solaris",
":linux",
":windows",
],
@@ -140,6 +146,7 @@
os_constraints = [
":osx",
":freebsd",
+ ":solaris",
":linux",
":windows",
],
diff -Nuar '--exclude=bazel-*' '--exclude=output' bazel-0.16-orig/tools/platforms/platforms.BUILD bazel-0.16/tools/platforms/platforms.BUILD
--- bazel-0.16-orig/tools/platforms/platforms.BUILD 2018-08-10 12:06:01.735721673 +0000
+++ bazel-0.16/tools/platforms/platforms.BUILD 2018-08-10 12:50:05.187032869 +0000
@@ -56,6 +56,11 @@
)
constraint_value(
+ name = "solaris",
+ constraint_setting = ":os",
+)
+
+constraint_value(
name = "android",
constraint_setting = ":os",
)
@@ -107,6 +112,7 @@
os_constraints = [
":osx",
":freebsd",
+ ":solaris",
":linux",
":windows",
],
@@ -128,6 +134,7 @@
os_constraints = [
":osx",
":freebsd",
+ ":solaris",
":linux",
":windows",
],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment