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

Various build fixes for FreeBSD #28689

Merged
merged 6 commits into from Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions tensorflow/BUILD
Expand Up @@ -497,6 +497,10 @@ tf_cc_shared_object(
linkopts = select({
"//tensorflow:macos": [],
"//tensorflow:windows": [],
"//tensorflow:freebsd": [
"-Wl,--version-script,$(location //tensorflow:tf_framework_version_script.lds)",
"-lexecinfo"
],
"//conditions:default": [
"-Wl,--version-script,$(location //tensorflow:tf_framework_version_script.lds)",
],
Expand Down
4 changes: 4 additions & 0 deletions tensorflow/compiler/xla/BUILD
Expand Up @@ -165,6 +165,10 @@ cc_library(
"statusor.h",
],
visibility = ["//visibility:public"],
linkopts = select({
"@org_tensorflow//tensorflow:freebsd": ["-lexecinfo"],
"//conditions:default": []
}),
deps = [
":status",
"//tensorflow/stream_executor/lib",
Expand Down
Expand Up @@ -16,6 +16,7 @@ limitations under the License.
#include "tensorflow/contrib/ignite/kernels/client/ignite_plain_client.h"

#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/socket.h>
#include <unistd.h>
Expand Down
2 changes: 2 additions & 0 deletions tensorflow/core/platform/cloud/gcs_dns_cache.cc
Expand Up @@ -16,6 +16,8 @@ limitations under the License.
#include "tensorflow/core/platform/cloud/gcs_dns_cache.h"
#ifndef _WIN32
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <netdb.h>
#else
#include <Windows.h>
Expand Down
14 changes: 10 additions & 4 deletions tensorflow/core/platform/posix/env.cc
Expand Up @@ -25,6 +25,10 @@ limitations under the License.
#include <time.h>
#include <unistd.h>

#ifdef __FreeBSD__
#include <pthread_np.h>
#endif

#include <thread>
#include <vector>

Expand Down Expand Up @@ -110,10 +114,7 @@ class PosixEnv : public Env {
pthread_threadid_np(nullptr, &tid64);
return static_cast<int32>(tid64);
#elif defined(__FreeBSD__)
// Has to be casted to long first, else this error appears:
// static_cast from 'pthread_t' (aka 'pthread *') to 'int32' (aka 'int')
// is not allowed
return static_cast<int32>(static_cast<int64>(pthread_self()));
return pthread_getthreadid_np();
#else
return static_cast<int32>(pthread_self());
#endif
Expand All @@ -133,7 +134,12 @@ class PosixEnv : public Env {
return false;
#else
char buf[100];
#ifdef __FreeBSD__
int res = 0;
pthread_get_name_np(pthread_self(), buf, static_cast<size_t>(100));
#else
int res = pthread_getname_np(pthread_self(), buf, static_cast<size_t>(100));
#endif
if (res != 0) {
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions tensorflow/lite/kernels/internal/BUILD
Expand Up @@ -605,6 +605,9 @@ cc_library(
":darwin_x86_64": [
":neon_tensor_utils",
],
":freebsd": [
":neon_tensor_utils",
],
"//conditions:default": [
":portable_tensor_utils",
],
Expand Down
3 changes: 3 additions & 0 deletions third_party/aws/BUILD.bazel
Expand Up @@ -27,6 +27,9 @@ cc_library(
"@org_tensorflow//tensorflow:raspberry_pi_armeabi": glob([
"aws-cpp-sdk-core/source/platform/linux-shared/*.cpp",
]),
"@org_tensorflow//tensorflow:freebsd": glob([
"aws-cpp-sdk-core/source/platform/linux-shared/*.cpp",
]),
"//conditions:default": [],
}) + glob([
"aws-cpp-sdk-core/include/**/*.h",
Expand Down
2 changes: 1 addition & 1 deletion third_party/gpus/rocm_configure.bzl
Expand Up @@ -301,7 +301,7 @@ def _lib_name(lib, cpu_value, version = "", static = False):
Returns:
The platform-specific name of the library.
"""
if cpu_value in ("Linux"):
if cpu_value in ("Linux", "FreeBSD"):
if static:
return "lib%s.a" % lib
else:
Expand Down
14 changes: 14 additions & 0 deletions third_party/llvm/llvm.bzl
Expand Up @@ -247,6 +247,12 @@ linux_cmake_vars = {
"HAVE_FUTIMENS": 1,
}

# CMake variables specific to the FreeBSD platform
freebsd_cmake_vars = {
"HAVE_MALLOC_H": 1,
"HAVE_LINK_H": 1,
}

# CMake variables specific to the Darwin (Mac OS X) platform.
darwin_cmake_vars = {
"HAVE_MALLOC_MALLOC_H": 1,
Expand Down Expand Up @@ -314,6 +320,13 @@ llvm_all_cmake_vars = select({
win32_cmake_vars,
),
),
"@org_tensorflow//tensorflow:freebsd": cmake_var_string(
_dict_add(
cmake_vars,
llvm_target_cmake_vars("X86", "x86_64-unknown-freebsd"),
posix_cmake_vars
),
),
"//conditions:default": cmake_var_string(
_dict_add(
cmake_vars,
Expand All @@ -326,6 +339,7 @@ llvm_all_cmake_vars = select({

llvm_linkopts = select({
"@org_tensorflow//tensorflow:windows": [],
"@org_tensorflow//tensorflow:freebsd": ["-ldl", "-lm", "-lpthread", "-lexecinfo"],
"//conditions:default": ["-ldl", "-lm", "-lpthread"],
})

Expand Down