diff options
author | Klaus Aehlig <aehlig@google.com> | 2017-06-09 13:34:34 -0400 |
---|---|---|
committer | John Cater <jcater@google.com> | 2017-06-09 14:07:33 -0400 |
commit | 9f8d81e01143e9beffcb3df103a9e76b1e4021ef (patch) | |
tree | 6aa670edab75ac7d2f3ab846a8972b30071f9edb /src | |
parent | ff147c43b87fe8e707ad945040fc36225afabd79 (diff) |
Make singlejar aware of FreeBSD
The C implementation of singlejar verifies that it is built for a
supported system; currently those are 64-bit linux and apple systems.
However, the code is portable enough that it can easily be adapted to
run on 64-bit FreeBSD systems as well. In fact, only the path of a
single header file is different, and we need to link with -lm.
Fixes #3096.
Change-Id: Id69542ad940f1161aceb55eb8f5dabda2f486747
PiperOrigin-RevId: 158533955
Diffstat (limited to 'src')
-rw-r--r-- | src/BUILD | 5 | ||||
-rw-r--r-- | src/test/shell/bazel/BUILD | 3 | ||||
-rw-r--r-- | src/tools/singlejar/BUILD | 4 | ||||
-rw-r--r-- | src/tools/singlejar/diag.h | 2 | ||||
-rw-r--r-- | src/tools/singlejar/mapped_file.h | 3 | ||||
-rw-r--r-- | src/tools/singlejar/zip_headers.h | 2 |
6 files changed, 9 insertions, 10 deletions
@@ -163,11 +163,6 @@ filegroup( "//third_party/ijar:zipper", ], }) + select({ - # TODO(bazel-team): Once https://github.com/bazelbuild/bazel/issues/3096 - # is resolved, use cc implementation of singlejar on freebsd - ":freebsd": [ - "//src/java_tools/singlejar:SingleJar_deploy.jar", - ], # TODO(bazel-team): Once https://github.com/bazelbuild/bazel/issues/2241 # is resolved, use cc implementation of singlejar on windows ":windows": [ diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD index 30a19efa2f..efd5232354 100644 --- a/src/test/shell/bazel/BUILD +++ b/src/test/shell/bazel/BUILD @@ -45,9 +45,6 @@ filegroup( "@local_jdk//:extdir", "@local_jdk//:jdk", ] + select({ - # TODO(bazel-team): Once https://github.com/bazelbuild/bazel/issues/3096 - # is resolved, use cc implementation of singlejar on freebsd - "//src:freebsd": ["//src/java_tools/singlejar:SingleJar_deploy.jar"], # TODO(bazel-team): Once https://github.com/bazelbuild/bazel/issues/2241 # is resolved, use cc implementation of singlejar on windows "//src:windows": ["//src/java_tools/singlejar:SingleJar_deploy.jar"], diff --git a/src/tools/singlejar/BUILD b/src/tools/singlejar/BUILD index f94086ea62..7ca5ffa8ff 100644 --- a/src/tools/singlejar/BUILD +++ b/src/tools/singlejar/BUILD @@ -22,6 +22,10 @@ cc_binary( srcs = [ "singlejar_main.cc", ], + linkopts = select({ + "//src:freebsd": ["-lm"], + "//conditions:default": [], + }), linkstatic = 1, deps = [ "options", diff --git a/src/tools/singlejar/diag.h b/src/tools/singlejar/diag.h index 8f61b66cfd..5dd4a7fb10 100644 --- a/src/tools/singlejar/diag.h +++ b/src/tools/singlejar/diag.h @@ -19,7 +19,7 @@ * Various useful diagnostics functions from Linux err.h file, wrapped * for portability. */ -#if defined(__APPLE__) || defined(__linux__) +#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) #include <err.h> #define diag_err(...) err(__VA_ARGS__) #define diag_errx(...) errx(__VA_ARGS__) diff --git a/src/tools/singlejar/mapped_file.h b/src/tools/singlejar/mapped_file.h index e90d6fe0b2..b6c5e346fe 100644 --- a/src/tools/singlejar/mapped_file.h +++ b/src/tools/singlejar/mapped_file.h @@ -35,7 +35,8 @@ * * The implementation is 64-bit Linux or OSX specific. */ -#if !((defined(__linux__) || defined(__APPLE__)) && __SIZEOF_POINTER__ == 8) +#if !((defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)) && \ + __SIZEOF_POINTER__ == 8) #error This code for 64 bit Unix. #endif diff --git a/src/tools/singlejar/zip_headers.h b/src/tools/singlejar/zip_headers.h index 7d8c3018e7..9c97691c14 100644 --- a/src/tools/singlejar/zip_headers.h +++ b/src/tools/singlejar/zip_headers.h @@ -26,6 +26,8 @@ #if defined(__linux__) #include <endian.h> +#elif defined(__FreeBSD__) +#include <sys/endian.h> #elif defined(__APPLE__) // Hopefully OSX will keep running solely on little endian CPUs, so: #define le16toh(x) (x) |