Skip to content

Commit

Permalink
FreeBSD compatibility (tensorflow#7073)
Browse files Browse the repository at this point in the history
* Adding FreeBSD compatibility (non-breaking changes)

* Adding FreeBSD compatibility (BREAKING changes)
 - FreeBSD has libdl integrated into libc so -ldl is not available

* Adding FreeBSD compatibility (BREAKING changes)
 - FreeBSD has libdl integrated into libc so -ldl is not available

* - Define FreeBSD config
- Clear -ldl linkopts for FreeBSD only

* Clear -ldl linkopts for FreeBSD only

* Changing to local condition just as previously done with darwin

* Removing one indentation for syntax validation

* Removing one indentation here too

* - Changing new config name to lowercase
- Fixing buildifier warning
  • Loading branch information
blodan authored and Vijay Vasudevan committed Feb 15, 2017
1 parent f621cf2 commit e75c0fc
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 16 deletions.
6 changes: 6 additions & 0 deletions tensorflow/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ config_setting(
visibility = ["//visibility:public"],
)

config_setting(
name = "freebsd",
values = {"cpu": "freebsd"},
visibility = ["//visibility:public"],
)

package_group(
name = "internal",
packages = ["//tensorflow/..."],
Expand Down
21 changes: 16 additions & 5 deletions tensorflow/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,10 @@ cc_library(
],
copts = tf_copts(),
defines = tf_additional_lib_defines(),
linkopts = ["-ldl"],
linkopts = select({
"//tensorflow:freebsd": [],
"//conditions:default": ["-ldl"],
}),
deps = tf_additional_lib_deps() + [
":lib_hash_crc32c_accelerate_internal",
":lib_proto_parsing",
Expand All @@ -1223,7 +1226,10 @@ cc_library(
],
hdrs = ["lib/gif/gif_io.h"],
copts = tf_copts(),
linkopts = ["-ldl"],
linkopts = select({
"//tensorflow:freebsd": [],
"//conditions:default": ["-ldl"],
}),
deps = [
":lib",
"//tensorflow/core/platform/default/build_config:gif",
Expand All @@ -1242,7 +1248,10 @@ cc_library(
"lib/jpeg/jpeg_mem.h",
],
copts = tf_copts(),
linkopts = ["-ldl"],
linkopts = select({
"//tensorflow:freebsd": [],
"//conditions:default": ["-ldl"],
}),
deps = [
":lib",
"//tensorflow/core/platform/default/build_config:jpeg",
Expand Down Expand Up @@ -1320,8 +1329,10 @@ tf_cuda_library(
"util/tensor_slice_util.h",
],
copts = tf_copts(),
linkopts = [
"-ldl",
linkopts = select({
"//tensorflow:freebsd": [],
"//conditions:default": ["-ldl"],
}) + [
"-lm",
],
deps = [
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/core/platform/posix/error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ error::Code ErrnoToCode(int err_number) {
case ENETUNREACH: // Network unreachable
case ENOLCK: // No locks available
case ENOLINK: // Link has been severed
#if !(defined(__APPLE__) || defined(_WIN32))
#if !(defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32))
case ENONET: // Machine is not on the network
#endif
code = error::UNAVAILABLE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ limitations under the License.
#include <string.h>
#include <sys/ioctl.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>

#include "tensorflow/core/lib/strings/stringprintf.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ limitations under the License.
#ifndef TENSORFLOW_PLATFORM_PROFILEUTILS_ANDROID_ARMV7A_CPU_UTILS_HELPER_H__
#define TENSORFLOW_PLATFORM_PROFILEUTILS_ANDROID_ARMV7A_CPU_UTILS_HELPER_H__

#include <sys/types.h>

#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/platform/profile_utils/i_cpu_utils_helper.h"
#include "tensorflow/core/platform/types.h"
Expand Down
14 changes: 8 additions & 6 deletions tensorflow/stream_executor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ cc_library(
"lib/gtl/*.h",
"platform/**/*.h",
]),
linkopts = [
"-ldl",
],
linkopts = select({
"//tensorflow:freebsd": [],
"//conditions:default": ["-ldl"],
}),
visibility = ["//visibility:public"],
deps = [
"//tensorflow/core:lib",
Expand All @@ -45,9 +46,10 @@ cc_library(
exclude = ["cuda/cuda_platform_id.cc"],
),
),
linkopts = [
"-ldl",
],
linkopts = select({
"//tensorflow:freebsd": [],
"//conditions:default": ["-ldl"],
}),
visibility = ["//visibility:public"],
deps = [
":stream_executor",
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/stream_executor/rng.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bool RngSupport::CheckSeed(const uint8 *seed, uint64 seed_bytes) {
return true;
}

#if defined(__APPLE__)
#if defined(__APPLE__) || defined(__FreeBSD__)
const int RngSupport::kMinSeedBytes;
const int RngSupport::kMaxSeedBytes;
#endif
Expand Down
12 changes: 10 additions & 2 deletions third_party/gpus/cuda/BUILD.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ config_setting(
visibility = ["//visibility:public"],
)

config_setting(
name = "freebsd",
values = {"cpu": "freebsd"},
visibility = ["//visibility:public"],
)

cc_library(
name = "cuda_headers",
hdrs = glob([
Expand All @@ -49,8 +55,10 @@ cc_library(
name = "cudart_static",
srcs = ["lib/%{cudart_static_lib}"],
includes = ["include/"],
linkopts = [
"-ldl",
linkopts = select({
":freebsd": [],
"//conditions:default": ["-ldl"],
}) + [
"-lpthread",
%{cudart_static_linkopt}
],
Expand Down
2 changes: 1 addition & 1 deletion third_party/gpus/cuda_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def _lib_name(lib, cpu_value, version="", static=False):
Returns:
The platform-specific name of the library.
"""
if cpu_value == "Linux":
if cpu_value in ("Linux", "FreeBSD"):
if static:
return "lib%s.a" % lib
else:
Expand Down

0 comments on commit e75c0fc

Please sign in to comment.