Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Steps towards getting Bazel compiling on Darwin #5

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,33 @@ darwin)
DYNAMIC_EXT="dylib"
REALTIME_LDFLAGS=""
MD5SUM="md5"
JAVA_HOME="${JAVA_HOME:-$(/usr/libexec/java_home)}"
;;
linux)
ARCHIVE_CFLAGS=""
ARCHIVE_LDFLAGS=""
DYNAMIC_EXT="so"
REALTIME_LDFLAGS="-lrt"
MD5SUM="md5sum"
JAVA_HOME="${JAVA_HOME:-$(readlink -f $(which javac) | sed "s_/bin/javac__")}"
;;
esac

# TODO: CC target architecture needs to match JAVA_HOME.
JAVAC="${JAVA_HOME}/bin/javac"

# Compile .proto files using protoc
PROTO_FILES=(
src/main/protobuf/build.proto
src/main/protobuf/extra_actions.proto
src/main/protobuf/testing_api.proto
)

# TODO: CC target architecture needs to match JAVA_HOME.

# JAVA_HOME must point to a Java 7 installation.
JAVA_HOME=${JAVA_HOME:-$(readlink -f $(which javac) | sed "s_/bin/javac__")}
JAVAC="${JAVA_HOME}/bin/javac"
# To get protoc for darwin:
# grab and untar https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.bz2
# ./configure CC=clang CXX=clang++ CXXFLAGS='-std=c++11 -stdlib=libc++ -O3 -g' LDFLAGS='-stdlib=libc++' LIBS="-lc++ -lc++abi"
# make
# sudo make install
PROTOC=${PROTOC:-protoc}
CC=${CC:-g++}

Expand Down
8 changes: 1 addition & 7 deletions src/main/cpp/blaze.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,6 @@ static vector<string> GetArgumentArray() {
string heap_crash_path = globals->options.output_base;
result.push_back("-XX:HeapDumpPath=" + heap_crash_path);

// Override conservative defaults which allow GC thrashing to last for too
// long.
result.push_back("-XX:GCTimeLimit=85"); // Default is 98%.
result.push_back("-XX:GCHeapFreeLimit=10"); // Default is 2%.
result.push_back("-XX:+CMSUseGCOverheadLimit"); // Include CMS overhead.

result.push_back("-Xverify:none");

// Add JVM arguments particular to building blaze64 and particular JVM
Expand All @@ -263,7 +257,7 @@ static vector<string> GetArgumentArray() {
"_embedded_binaries");
bool first = true;
for (const auto& it : globals->extracted_binaries) {
if (blaze_util::ends_with(it, ".so")) {
if (blaze::IsSharedLibrary(it)) {
if (!first) {
java_library_path += ":";
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/cpp/blaze_util_darwin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "blaze_exit_code.h"
#include "blaze_util.h"
#include "blaze_util_platform.h"
#include "util/strings.h"

namespace blaze {

Expand Down Expand Up @@ -74,4 +75,8 @@ string GetProcessCWD(int pid) {
return string(info.pvi_cdir.vip_path);
}

bool IsSharedLibrary(std::string filename) {
return blaze_util::ends_with(filename, ".dylib");
}

} // namespace blaze.
5 changes: 5 additions & 0 deletions src/main/cpp/blaze_util_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "blaze_exit_code.h"
#include "blaze_util_platform.h"
#include "blaze_util.h"
#include "util/strings.h"

namespace blaze {

Expand Down Expand Up @@ -118,4 +119,8 @@ string GetProcessCWD(int pid) {
return string(server_cwd);
}

bool IsSharedLibrary(std::string filename) {
return blaze_util::ends_with(filename, ".so");
}

} // namespace blaze
2 changes: 2 additions & 0 deletions src/main/cpp/blaze_util_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ void SetScheduling(bool batch_cpu_scheduling, int io_nice_level);
// Returns the cwd for a process.
std::string GetProcessCWD(int pid);

bool IsSharedLibrary(std::string filename);

} // namespace blaze

#endif // DEVTOOLS_BLAZE_MAIN_BLAZE_UTIL_PLATFORM_H_