diff options
Diffstat (limited to 'science/py-tensorflow/files/bazel')
-rw-r--r-- | science/py-tensorflow/files/bazel/fix-environ.patch | 32 | ||||
-rw-r--r-- | science/py-tensorflow/files/bazel/fix-pybind11_protobuf.patch | 116 | ||||
-rw-r--r-- | science/py-tensorflow/files/bazel/fix-xnnpack.patch (renamed from science/py-tensorflow/files/bazel/add-default-option.patch) | 31 | ||||
-rw-r--r-- | science/py-tensorflow/files/bazel/fix_cpuinfo.patch | 80 | ||||
-rw-r--r-- | science/py-tensorflow/files/bazel/freebsd_python_fix.patch | 11 | ||||
-rw-r--r-- | science/py-tensorflow/files/bazel/set-c++17.patch | 11 |
6 files changed, 155 insertions, 126 deletions
diff --git a/science/py-tensorflow/files/bazel/fix-environ.patch b/science/py-tensorflow/files/bazel/fix-environ.patch index 2e38ce60543d..d1437f158055 100644 --- a/science/py-tensorflow/files/bazel/fix-environ.patch +++ b/science/py-tensorflow/files/bazel/fix-environ.patch @@ -1,18 +1,18 @@ ---- a/llvm/lib/Support/Unix/Program.inc 2022-09-06 21:14:28.808580000 +0100 -+++ b/llvm/lib/Support/Unix/Program.inc 2022-09-06 21:16:15.007790000 +0100 +--- a/llvm/lib/Support/Unix/Program.inc 2023-04-28 21:51:01.000000000 +0200 ++++ b/llvm/lib/Support/Unix/Program.inc 2024-07-02 11:12:41.645169000 +0200 @@ -54,10 +54,8 @@ #define USE_NSGETENVIRON 0 #endif -#if !USE_NSGETENVIRON +#if USE_NSGETENVIRON - extern char **environ; + extern char **environ; -#else -#include <crt_externs.h> // _NSGetEnviron #endif #endif -@@ -240,14 +238,6 @@ +@@ -238,14 +236,6 @@ } } @@ -27,16 +27,16 @@ constexpr int maxRetries = 8; int retries = 0; pid_t PID; -@@ -308,11 +298,7 @@ +@@ -312,11 +302,7 @@ - // Execute! - std::string PathStr = std::string(Program); -- if (Envp != nullptr) -- execve(PathStr.c_str(), const_cast<char **>(Argv), -- const_cast<char **>(Envp)); -- else -- execv(PathStr.c_str(), const_cast<char **>(Argv)); -+ execv(PathStr.c_str(), const_cast<char **>(Argv)); - // If the execve() failed, we should exit. Follow Unix protocol and - // return 127 if the executable was not found, and 126 otherwise. - // Use _exit rather than exit so that atexit functions and static + // Execute! + std::string PathStr = std::string(Program); +- if (Envp != nullptr) +- execve(PathStr.c_str(), const_cast<char **>(Argv), +- const_cast<char **>(Envp)); +- else +- execv(PathStr.c_str(), const_cast<char **>(Argv)); ++ execv(PathStr.c_str(), const_cast<char **>(Argv)); + // If the execve() failed, we should exit. Follow Unix protocol and + // return 127 if the executable was not found, and 126 otherwise. + // Use _exit rather than exit so that atexit functions and static diff --git a/science/py-tensorflow/files/bazel/fix-pybind11_protobuf.patch b/science/py-tensorflow/files/bazel/fix-pybind11_protobuf.patch new file mode 100644 index 000000000000..80d30bf25333 --- /dev/null +++ b/science/py-tensorflow/files/bazel/fix-pybind11_protobuf.patch @@ -0,0 +1,116 @@ +diff --git a/pybind11_protobuf/BUILD b/pybind11_protobuf/BUILD +index b62eb91..1856ad3 100644 +--- a/pybind11_protobuf/BUILD ++++ b/pybind11_protobuf/BUILD +@@ -61,9 +61,11 @@ pybind_library( + "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/types:optional", +- "@com_google_protobuf//:proto_api", + "@com_google_protobuf//:protobuf", +- ], ++ ] + select({ ++ ":enable_pyproto_api_setting": ["@com_google_protobuf//:proto_api"], ++ "//conditions:default": [], ++ }), + ) + + pybind_library( +diff --git a/pybind11_protobuf/proto_cast_util.cc b/pybind11_protobuf/proto_cast_util.cc +index 52c57c9..771e688 100644 +--- a/pybind11_protobuf/proto_cast_util.cc ++++ b/pybind11_protobuf/proto_cast_util.cc +@@ -14,9 +14,12 @@ + + #include "google/protobuf/descriptor.pb.h" + #include "google/protobuf/descriptor.h" ++#include "google/protobuf/descriptor_database.h" + #include "google/protobuf/dynamic_message.h" + #include "google/protobuf/message.h" ++#if defined(PYBIND11_PROTOBUF_ENABLE_PYPROTO_API) + #include "python/google/protobuf/proto_api.h" ++#endif + #include "absl/container/flat_hash_map.h" + #include "absl/strings/numbers.h" + #include "absl/strings/str_replace.h" +@@ -35,8 +38,12 @@ using ::google::protobuf::FileDescriptor; + using ::google::protobuf::FileDescriptorProto; + using ::google::protobuf::Message; + using ::google::protobuf::MessageFactory; ++#if defined(PYBIND11_PROTOBUF_ENABLE_PYPROTO_API) + using ::google::protobuf::python::PyProto_API; + using ::google::protobuf::python::PyProtoAPICapsuleName; ++#else ++struct PyProto_API; ++#endif + + namespace pybind11_protobuf { + namespace { +@@ -321,6 +328,7 @@ py::object GlobalState::PyMessageInstance(const Descriptor* descriptor) { + module_name + "?"); + } + ++#if defined(PYBIND11_PROTOBUF_ENABLE_PYPROTO_API) + std::pair<py::object, Message*> GlobalState::PyFastCppProtoMessageInstance( + const Descriptor* descriptor) { + assert(descriptor != nullptr); +@@ -361,6 +369,7 @@ std::pair<py::object, Message*> GlobalState::PyFastCppProtoMessageInstance( + } + return {std::move(result), message}; + } ++#endif + + // Create C++ DescriptorPools based on Python DescriptorPools. + // The Python pool will provide message definitions when they are needed. +@@ -500,6 +509,7 @@ class PythonDescriptorPoolWrapper { + private: + bool CopyToFileDescriptorProto(py::handle py_file_descriptor, + FileDescriptorProto* output) { ++#if defined(PYBIND11_PROTOBUF_ENABLE_PYPROTO_API) + if (GlobalState::instance()->py_proto_api()) { + try { + py::object c_proto = py::reinterpret_steal<py::object>( +@@ -518,6 +528,7 @@ class PythonDescriptorPoolWrapper { + PyErr_Print(); + } + } ++#endif + + py::object wire = py_file_descriptor.attr("serialized_pb"); + const char* bytes = PYBIND11_BYTES_AS_STRING(wire.ptr()); +@@ -561,6 +572,9 @@ void ImportProtoDescriptorModule(const Descriptor* descriptor) { + + const Message* PyProtoGetCppMessagePointer(py::handle src) { + assert(PyGILState_Check()); ++#ifndef PYBIND11_PROTOBUF_ENABLE_PYPROTO_API ++ return nullptr; ++#else + if (!GlobalState::instance()->py_proto_api()) return nullptr; + auto* ptr = + GlobalState::instance()->py_proto_api()->GetMessagePointer(src.ptr()); +@@ -571,6 +585,7 @@ const Message* PyProtoGetCppMessagePointer(py::handle src) { + return nullptr; + } + return ptr; ++#endif + } + + absl::optional<std::string> PyProtoDescriptorName(py::handle py_proto) { +@@ -732,6 +747,9 @@ py::handle GenericPyProtoCast(Message* src, py::return_value_policy policy, + + py::handle GenericFastCppProtoCast(Message* src, py::return_value_policy policy, + py::handle parent, bool is_const) { ++#ifndef PYBIND11_PROTOBUF_ENABLE_PYPROTO_API ++ throw std::logic_error("Not implemented"); ++#else + assert(policy != pybind11::return_value_policy::automatic); + assert(policy != pybind11::return_value_policy::automatic_reference); + assert(src != nullptr); +@@ -802,6 +820,7 @@ py::handle GenericFastCppProtoCast(Message* src, py::return_value_policy policy, + std::string message("pybind11_protobuf unhandled return_value_policy::"); + throw py::cast_error(message + ReturnValuePolicyName(policy)); + } ++#endif + } + + py::handle GenericProtoCast(Message* src, py::return_value_policy policy, diff --git a/science/py-tensorflow/files/bazel/add-default-option.patch b/science/py-tensorflow/files/bazel/fix-xnnpack.patch index ce5c250608fb..7a995bbff74d 100644 --- a/science/py-tensorflow/files/bazel/add-default-option.patch +++ b/science/py-tensorflow/files/bazel/fix-xnnpack.patch @@ -1,6 +1,8 @@ ---- a/build_defs.bzl 2022-08-28 12:18:33.375130000 +0100 -+++ b/build_defs.bzl 2022-08-28 12:21:40.701070000 +0100 -@@ -173,7 +173,7 @@ +diff --git a/build_defs.bzl b/build_defs.bzl +index 01b436eb7..ca4abd54d 100644 +--- a/build_defs.bzl ++++ b/build_defs.bzl +@@ -146,7 +146,7 @@ def xnnpack_cc_library( ":emscripten_wasm": wasm_srcs, ":emscripten_wasmsimd": wasmsimd_srcs, ":emscripten_wasmrelaxedsimd": wasmrelaxedsimd_srcs, @@ -9,7 +11,7 @@ }), copts = [ "-Iinclude", -@@ -210,7 +210,7 @@ +@@ -179,7 +179,7 @@ def xnnpack_cc_library( ":emscripten_wasm": wasm_copts, ":emscripten_wasmsimd": wasmsimd_copts, ":emscripten_wasmrelaxedsimd": wasmrelaxedsimd_copts, @@ -18,7 +20,7 @@ }) + select({ ":windows_x86_64_clang": ["/clang:" + opt for opt in gcc_copts], ":windows_x86_64_mingw": gcc_copts, -@@ -233,7 +233,7 @@ +@@ -202,7 +202,7 @@ def xnnpack_cc_library( ":linux_armv7a": ["-lpthread"], ":linux_arm64": ["-lpthread"], ":android": ["-lm"], @@ -27,11 +29,24 @@ }), textual_hdrs = hdrs, visibility = visibility, -@@ -304,6 +304,7 @@ - ":emscripten_wasm": wasm_deps, +@@ -249,6 +249,7 @@ def xnnpack_aggregate_library( ":emscripten_wasmsimd": wasmsimd_deps, ":emscripten_wasmrelaxedsimd": wasmrelaxedsimd_deps, + ":riscv": riscv_deps, + "//conditions:default": x86_deps, }), - ) + defines = defines, + compatible_with = compatible_with, +diff --git a/src/runtime.c b/src/runtime.c +index 0c4649017..29e74a85b 100644 +--- a/src/runtime.c ++++ b/src/runtime.c +@@ -4,7 +4,7 @@ + // LICENSE file in the root directory of this source tree. + #ifndef __MACH__ +-#define _POSIX_C_SOURCE 199309L ++#define _POSIX_C_SOURCE 199506L + #endif + + #include <assert.h> diff --git a/science/py-tensorflow/files/bazel/fix_cpuinfo.patch b/science/py-tensorflow/files/bazel/fix_cpuinfo.patch deleted file mode 100644 index 1041a2319286..000000000000 --- a/science/py-tensorflow/files/bazel/fix_cpuinfo.patch +++ /dev/null @@ -1,80 +0,0 @@ ---- a/src/mach/topology.c 2022-09-01 12:09:36.036365000 +0100 -+++ b/src/mach/topology.c 2022-09-01 12:09:07.146529000 +0100 -@@ -1,5 +1,4 @@ - #include <string.h> --#include <alloca.h> - #include <errno.h> - - #include <sys/types.h> -@@ -8,38 +7,27 @@ - #include <cpuinfo/log.h> - #include <mach/api.h> - --#include <TargetConditionals.h> - -- - struct cpuinfo_mach_topology cpuinfo_mach_detect_topology(void) { - int cores = 1; - size_t sizeof_cores = sizeof(cores); -- if (sysctlbyname("hw.physicalcpu_max", &cores, &sizeof_cores, NULL, 0) != 0) { -- cpuinfo_log_error("sysctlbyname(\"hw.physicalcpu_max\") failed: %s", strerror(errno)); -+ if (sysctlbyname("hw.ncpu", &cores, &sizeof_cores, NULL, 0) != 0) { -+ cpuinfo_log_error("sysctlbyname(\"hw.ncpu\") failed: %s", strerror(errno)); - } else if (cores <= 0) { -- cpuinfo_log_error("sysctlbyname(\"hw.physicalcpu_max\") returned invalid value %d", cores); -+ cpuinfo_log_error("sysctlbyname(\"hw.ncpu\") returned invalid value %d", cores); - cores = 1; - } - - int threads = 1; - size_t sizeof_threads = sizeof(threads); -- if (sysctlbyname("hw.logicalcpu_max", &threads, &sizeof_threads, NULL, 0) != 0) { -- cpuinfo_log_error("sysctlbyname(\"hw.logicalcpu_max\") failed: %s", strerror(errno)); -+ if (sysctlbyname("hw.ncpu", &threads, &sizeof_threads, NULL, 0) != 0) { -+ cpuinfo_log_error("sysctlbyname(\"ncpu\") failed: %s", strerror(errno)); - } else if (threads <= 0) { -- cpuinfo_log_error("sysctlbyname(\"hw.logicalcpu_max\") returned invalid value %d", threads); -+ cpuinfo_log_error("sysctlbyname(\"ncpu\") returned invalid value %d", threads); - threads = cores; - } - - int packages = 1; --#if !TARGET_OS_IPHONE -- size_t sizeof_packages = sizeof(packages); -- if (sysctlbyname("hw.packages", &packages, &sizeof_packages, NULL, 0) != 0) { -- cpuinfo_log_error("sysctlbyname(\"hw.packages\") failed: %s", strerror(errno)); -- } else if (packages <= 0) { -- cpuinfo_log_error("sysctlbyname(\"hw.packages\") returned invalid value %d", packages); -- packages = 1; -- } --#endif - - cpuinfo_log_debug("mach topology: packages = %d, cores = %d, threads = %d", packages, (int) cores, (int) threads); - struct cpuinfo_mach_topology topology = { -@@ -48,26 +36,5 @@ - .threads = (uint32_t) threads - }; - --#if !TARGET_OS_IPHONE -- size_t cacheconfig_size = 0; -- if (sysctlbyname("hw.cacheconfig", NULL, &cacheconfig_size, NULL, 0) != 0) { -- cpuinfo_log_error("sysctlbyname(\"hw.cacheconfig\") failed: %s", strerror(errno)); -- } else { -- uint64_t* cacheconfig = alloca(cacheconfig_size); -- if (sysctlbyname("hw.cacheconfig", cacheconfig, &cacheconfig_size, NULL, 0) != 0) { -- cpuinfo_log_error("sysctlbyname(\"hw.cacheconfig\") failed: %s", strerror(errno)); -- } else { -- size_t cache_configs = cacheconfig_size / sizeof(uint64_t); -- cpuinfo_log_debug("mach hw.cacheconfig count: %zu", cache_configs); -- if (cache_configs > CPUINFO_MACH_MAX_CACHE_LEVELS) { -- cache_configs = CPUINFO_MACH_MAX_CACHE_LEVELS; -- } -- for (size_t i = 0; i < cache_configs; i++) { -- cpuinfo_log_debug("mach hw.cacheconfig[%zu]: %"PRIu64, i, cacheconfig[i]); -- topology.threads_per_cache[i] = cacheconfig[i]; -- } -- } -- } --#endif - return topology; - } diff --git a/science/py-tensorflow/files/bazel/freebsd_python_fix.patch b/science/py-tensorflow/files/bazel/freebsd_python_fix.patch deleted file mode 100644 index e6bcae9950be..000000000000 --- a/science/py-tensorflow/files/bazel/freebsd_python_fix.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/utils/bazel/configure.bzl 2022-08-27 19:11:41.138993000 +0100 -+++ b/utils/bazel/configure.bzl 2022-08-27 19:12:07.525186000 +0100 -@@ -37,7 +37,7 @@ - overlay_path = bazel_path.get_child("llvm-project-overlay") - script_path = bazel_path.get_child("overlay_directories.py") - -- python_bin = repository_ctx.which("python3") -+ python_bin = repository_ctx.which("%%PYTHON%%") - if not python_bin: - # Windows typically just defines "python" as python3. The script itself - # contains a check to ensure python3. diff --git a/science/py-tensorflow/files/bazel/set-c++17.patch b/science/py-tensorflow/files/bazel/set-c++17.patch deleted file mode 100644 index aef1f6c38467..000000000000 --- a/science/py-tensorflow/files/bazel/set-c++17.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/cc/private/toolchain/freebsd_cc_toolchain_config.bzl 2022-08-28 16:31:59.271838000 +0100 -+++ b/cc/private/toolchain/freebsd_cc_toolchain_config.bzl 2022-08-28 16:32:10.096301000 +0100 -@@ -159,7 +159,7 @@ - ), - flag_set( - actions = all_cpp_compile_actions + [ACTION_NAMES.lto_backend], -- flag_groups = [flag_group(flags = ["-std=c++0x"])], -+ flag_groups = [flag_group(flags = ["-std=c++17"])], - ), - ], - ) |