From 5a5cc84db6c62e27c33d733c2a6138f51804d41b Mon Sep 17 00:00:00 2001 From: Max Lepikhin Date: Sun, 25 Oct 2026 17:31:47 -0600 Subject: [PATCH 1/4] edencommon: avoid unavailable pipe2 on macOS --- build/fbcode_builder/manifests/edencommon | 1 + .../patches/edencommon_pipe_darwin.patch | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 build/fbcode_builder/patches/edencommon_pipe_darwin.patch diff --git a/build/fbcode_builder/manifests/edencommon b/build/fbcode_builder/manifests/edencommon index d21bc13fcc691..c2806e2ba1d5e 100644 --- a/build/fbcode_builder/manifests/edencommon +++ b/build/fbcode_builder/manifests/edencommon @@ -9,6 +9,7 @@ repo_url = https://github.com/facebookexperimental/edencommon.git [build] builder = cmake +patchfile = edencommon_pipe_darwin.patch [dependencies] boost diff --git a/build/fbcode_builder/patches/edencommon_pipe_darwin.patch b/build/fbcode_builder/patches/edencommon_pipe_darwin.patch new file mode 100644 index 0000000000000..f06af5c6db70b --- /dev/null +++ b/build/fbcode_builder/patches/edencommon_pipe_darwin.patch @@ -0,0 +1,22 @@ +diff --git a/eden/common/utils/Pipe.cpp b/eden/common/utils/Pipe.cpp +index 1724dbd1..67e188b2 100644 +--- a/eden/common/utils/Pipe.cpp ++++ b/eden/common/utils/Pipe.cpp +@@ -43,7 +43,7 @@ Pipe::Pipe(bool nonBlocking) { + #else + int fds[2]; + int res; +-#if FOLLY_HAVE_PIPE2 ++#if FOLLY_HAVE_PIPE2 && !defined(__APPLE__) + res = pipe2(fds, (nonBlocking ? O_NONBLOCK : 0) | O_CLOEXEC); + #else + res = pipe(fds); +@@ -58,7 +58,7 @@ Pipe::Pipe(bool nonBlocking) { + read = FileDescriptor(fds[0], FileDescriptor::FDType::Pipe); + write = FileDescriptor(fds[1], FileDescriptor::FDType::Pipe); + +-#if !FOLLY_HAVE_PIPE2 ++#if !FOLLY_HAVE_PIPE2 || defined(__APPLE__) + read.setCloExec(); + write.setCloExec(); + if (nonBlocking) { From 4188da7a1a76a5536e9575852a3e1a1fe7c545a9 Mon Sep 17 00:00:00 2001 From: Max Lepikhin Date: Sun, 25 Oct 2026 17:31:50 -0600 Subject: [PATCH 2/4] eden: correct managed macOS dependency recipes --- build/fbcode_builder/manifests/cpptoml | 3 +++ build/fbcode_builder/manifests/eden | 6 ++---- .../patches/glog_default_visibility.patch | 11 +++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/build/fbcode_builder/manifests/cpptoml b/build/fbcode_builder/manifests/cpptoml index c4d6d8d9c5656..15f4206269173 100644 --- a/build/fbcode_builder/manifests/cpptoml +++ b/build/fbcode_builder/manifests/cpptoml @@ -14,3 +14,6 @@ subdir = cpptoml-0.1.2 [cmake.defines.os=freebsd] ENABLE_LIBCXX=NO + +[cmake.defines.os=darwin] +ENABLE_LIBCXX=NO diff --git a/build/fbcode_builder/manifests/eden b/build/fbcode_builder/manifests/eden index 0a00e9f9b1e0c..5fcbab612b07e 100644 --- a/build/fbcode_builder/manifests/eden +++ b/build/fbcode_builder/manifests/eden @@ -37,15 +37,13 @@ rust-shed [dependencies.fbsource=on] rust -[dependencies.os=darwin] -osxfuse - [dependencies.not(os=windows)] # TODO: teach getdeps to compile curl on Windows. # Enabling curl on Windows requires us to find a way to compile libcurl with # msvc. libcurl -# Added so that OSS doesn't see system "python" which is python 2 on darwin and some linux + +# Avoid finding a system "python" that may still be Python 2. python [dependencies.test=on] diff --git a/build/fbcode_builder/patches/glog_default_visibility.patch b/build/fbcode_builder/patches/glog_default_visibility.patch index 5ef0d6a8bf488..73e42c721217a 100644 --- a/build/fbcode_builder/patches/glog_default_visibility.patch +++ b/build/fbcode_builder/patches/glog_default_visibility.patch @@ -9,3 +9,14 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -set (CMAKE_VISIBILITY_INLINES_HIDDEN ON) set (CMAKE_DEBUG_POSTFIX d) +diff --git a/src/logging.cc b/src/logging.cc +--- a/src/logging.cc ++++ b/src/logging.cc +@@ -35,6 +35,7 @@ + #include + #include + #include ++#include + #ifdef HAVE_UNISTD_H + # include // For _exit. + #endif From 75bb210cf339f3f118c5e07c60f9c82c11cfb01a Mon Sep 17 00:00:00 2001 From: Max Lepikhin Date: Sun, 25 Oct 2026 17:33:19 -0600 Subject: [PATCH 3/4] getdeps: package Folly and Thrift Python runtimes on macOS --- CMake/EdenConfigChecks.cmake | 10 +- .../CMake/FBThriftPythonLibrary.cmake | 24 +- build/fbcode_builder/manifests/fb303 | 3 + .../fbcode_builder/manifests/fbthrift-python | 26 +- build/fbcode_builder/manifests/folly-python | 29 ++- .../patches/fbthrift_python_darwin.patch | 223 ++++++++++++++++++ .../patches/folly_python_darwin.patch | 13 + 7 files changed, 301 insertions(+), 27 deletions(-) create mode 100644 build/fbcode_builder/patches/fbthrift_python_darwin.patch create mode 100644 build/fbcode_builder/patches/folly_python_darwin.patch diff --git a/CMake/EdenConfigChecks.cmake b/CMake/EdenConfigChecks.cmake index 0cdaaadad5137..9e8dcc22ec436 100644 --- a/CMake/EdenConfigChecks.cmake +++ b/CMake/EdenConfigChecks.cmake @@ -42,8 +42,8 @@ fb_find_or_fetch(FBThrift) include_directories(${FBTHRIFT_INCLUDE_DIR}) # The Python CLI uses fb303's thrift-python modules, which, like thrift-python, -# getdeps only builds on Linux. -if (CMAKE_SYSTEM_NAME STREQUAL "Linux") +# getdeps builds on Linux and macOS. +if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR APPLE) set(FB303_THRIFT_PYTHON ON) endif() fb_find_or_fetch(fb303) @@ -145,9 +145,9 @@ if (NOT BLAKE3_FOUND) endif() include_directories(${BLAKE3_INCLUDE_DIR}) -# The Python CLI uses thrift-python, which getdeps only builds on Linux, and -# the thrift-python modules that fb303 builds with FB303_THRIFT_PYTHON. -if (ENABLE_THRIFT_PYTHON AND CMAKE_SYSTEM_NAME STREQUAL "Linux") +# The Python CLI uses thrift-python and the thrift-python modules that fb303 +# builds with FB303_THRIFT_PYTHON. getdeps provides them on Linux and macOS. +if (ENABLE_THRIFT_PYTHON AND (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR APPLE)) include(FBThriftPythonLibrary) if (ENABLE_THRIFT_PYTHON STREQUAL "AUTO") fb_find_thrift_python_runtime(QUIET) diff --git a/build/fbcode_builder/CMake/FBThriftPythonLibrary.cmake b/build/fbcode_builder/CMake/FBThriftPythonLibrary.cmake index 16ca6e153e495..7ddd9ff95b82a 100644 --- a/build/fbcode_builder/CMake/FBThriftPythonLibrary.cmake +++ b/build/fbcode_builder/CMake/FBThriftPythonLibrary.cmake @@ -67,7 +67,7 @@ macro(fb_find_thrift_python_runtime) if( NOT _FB_THRIFT_PYTHON_RUNTIME_FOUND OR NOT EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift/python" OR - NOT EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs" OR + (NOT APPLE AND NOT EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs") OR NOT EXISTS "${FOLLY_PYTHON_SITE_PACKAGES}/folly" ) # Ensure Python3 is found so we can use ${Python3_EXECUTABLE} @@ -121,7 +121,7 @@ macro(fb_find_thrift_python_runtime) "fbthrift-python was found at ${THRIFT_PYTHON_SITE_PACKAGES}, but " "its thrift/python runtime package is missing.") unset(THRIFT_PYTHON_SITE_PACKAGES) - elseif(NOT EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs") + elseif(NOT APPLE AND NOT EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs") message(WARNING "fbthrift-python was found at ${THRIFT_PYTHON_SITE_PACKAGES}, but " "thrift.libs is missing. Install an auditwheel-repaired " @@ -370,7 +370,7 @@ function(add_fb_thrift_python_executable TARGET) if( THRIFT_PYTHON_SITE_PACKAGES AND EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift/python" AND - EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs" + (APPLE OR EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs") ) # The bundled thrift/ hides the wheel's namespace package, so link all of # its subpackages: thrift.python imports thrift.py3, for example. @@ -390,17 +390,23 @@ function(add_fb_thrift_python_executable TARGET) ) endif() endforeach() + set(thrift_libs_link_commands) + if(EXISTS "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs") + list(APPEND thrift_libs_link_commands + COMMAND ${CMAKE_COMMAND} + "-DFB_REMOVE_PATH=${target_dir}/thrift.libs" + -P "${_FB_THRIFT_PYTHON_REMOVE_PATH_SCRIPT}" + COMMAND ${CMAKE_COMMAND} -E create_symlink + "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs" + "${target_dir}/thrift.libs" + ) + endif() add_custom_command( TARGET ${TARGET}.GEN_PY_EXE POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${target_dir}/thrift" COMMAND ${CMAKE_COMMAND} -E touch "${target_dir}/thrift/__init__.py" ${link_commands} - COMMAND ${CMAKE_COMMAND} - "-DFB_REMOVE_PATH=${target_dir}/thrift.libs" - -P "${_FB_THRIFT_PYTHON_REMOVE_PATH_SCRIPT}" - COMMAND ${CMAKE_COMMAND} -E create_symlink - "${THRIFT_PYTHON_SITE_PACKAGES}/thrift.libs" - "${target_dir}/thrift.libs" + ${thrift_libs_link_commands} COMMENT "Symlinking thrift-python and its native dependencies into ${TARGET}" ) else() diff --git a/build/fbcode_builder/manifests/fb303 b/build/fbcode_builder/manifests/fb303 index 95f2ee47bca86..66008c868c909 100644 --- a/build/fbcode_builder/manifests/fb303 +++ b/build/fbcode_builder/manifests/fb303 @@ -31,6 +31,9 @@ BUILD_TESTS=OFF [cmake.defines.os=linux] FB303_THRIFT_PYTHON=ON +[cmake.defines.os=darwin] +FB303_THRIFT_PYTHON=ON + [shipit.pathmap] fbcode/fb303/github = . fbcode/fb303/public_autocargo = fb303 diff --git a/build/fbcode_builder/manifests/fbthrift-python b/build/fbcode_builder/manifests/fbthrift-python index 3245c726036bc..955bf83c89d37 100644 --- a/build/fbcode_builder/manifests/fbthrift-python +++ b/build/fbcode_builder/manifests/fbthrift-python @@ -16,8 +16,12 @@ fbthrift = thrift/lib/rust [build] builder = cmake job_weight_mib = 3072 +patchfile = fbthrift_python_darwin.patch -[build.not(os=linux)] +[build.os=darwin] +builder = cmake + +[build.os=windows] builder = nop [cmake.defines] @@ -34,25 +38,35 @@ THRIFT_TESTS=OFF [cmake.defines.os=linux] THRIFT_PYTHON=ON +[cmake.defines.os=darwin] +THRIFT_PYTHON=ON + [dependencies] benchmark -fizz-python -fmt-python folly-python googletest libsodium -wangle-python -zstd-python -mvfst-python xxhash # Thrift also depends on openssl but since the latter requires a platform- # specific configuration we rely on the folly manifest to provide this # dependency to avoid duplication. [dependencies.os=linux] +fizz-python +fmt-python +wangle-python +zstd-python +mvfst-python libaio-python libevent-python +[dependencies.os=darwin] +fizz +fmt +wangle +zstd +mvfst + [shipit.pathmap] xplat/thrift/public_tld = . xplat/thrift = thrift diff --git a/build/fbcode_builder/manifests/folly-python b/build/fbcode_builder/manifests/folly-python index 0da2df690fa02..94eb9948c3efe 100644 --- a/build/fbcode_builder/manifests/folly-python +++ b/build/fbcode_builder/manifests/folly-python @@ -10,8 +10,12 @@ repo_url = https://github.com/facebook/folly.git [build] builder = cmake job_weight_mib = 1024 +patchfile = folly_python_darwin.patch -[build.not(os=linux)] +[build.os=darwin] +builder = cmake + +[build.os=windows] builder = nop [dependencies] @@ -20,15 +24,9 @@ gflags # copy of glog. glog = shared_libs googletest -boost-python -libdwarf-python -libevent-python libsodium fast_float -fmt-python -lz4-python snappy -zstd-python # no openssl or zlib in the linux case, why? # these are usually installed on the system # and are the easiest system deps to pull in. @@ -41,6 +39,12 @@ zstd-python # to build our own. [dependencies.os=darwin] openssl +boost +libdwarf +libevent +fmt +lz4 +zstd # Windows has neither openssl nor zlib, so we get # to provide both @@ -49,6 +53,12 @@ openssl zlib [dependencies.os=linux] +boost-python +libdwarf-python +libevent-python +fmt-python +lz4-python +zstd-python libaio-python libiberty-python libunwind @@ -70,6 +80,11 @@ fbcode/folly = folly PYTHON_EXTENSIONS=ON BUILD_SHARED_LIBS=ON +[cmake.defines.os=darwin] +PYTHON_EXTENSIONS=ON +BUILD_SHARED_LIBS=ON +CMAKE_CXX_FLAGS=-DGLOG_USE_GLOG_EXPORT + [cmake.defines.not(os=windows)] BOOST_LINK_STATIC=ON diff --git a/build/fbcode_builder/patches/fbthrift_python_darwin.patch b/build/fbcode_builder/patches/fbthrift_python_darwin.patch new file mode 100644 index 0000000000000..5f85ce5e02437 --- /dev/null +++ b/build/fbcode_builder/patches/fbthrift_python_darwin.patch @@ -0,0 +1,223 @@ +diff --git a/thrift/lib/python/CMakeLists.txt b/thrift/lib/python/CMakeLists.txt +index 45796d5b65..6ef64ff190 100644 +--- a/thrift/lib/python/CMakeLists.txt ++++ b/thrift/lib/python/CMakeLists.txt +@@ -103,7 +103,9 @@ set(LIBEVENT_STATIC_LINK TRUE) + find_package(Libevent REQUIRED CONFIG) + + # Libiberty: Provides cplus_demangle_v3_callback for folly stack traces +-find_package(Libiberty REQUIRED) ++if (NOT APPLE) ++ find_package(Libiberty REQUIRED) ++endif () + + # gflags warning: + # This section adds explicit dependencies that --whole-archive bypasses. +@@ -312,7 +340,11 @@ endif () + # Set default LDFLAGS for setup.py to fix undefined symbol issues + # --no-as-needed ensures libfolly.so is in NEEDED list even if linker + # thinks it's not needed +-set(DEFAULT_SETUP_LDFLAGS "-Wl,--no-as-needed") ++if (APPLE) ++ set(DEFAULT_SETUP_LDFLAGS "") ++else () ++ set(DEFAULT_SETUP_LDFLAGS "-Wl,--no-as-needed") ++endif () + + # Allow users to override via environment variable (e.g., for custom RPATH) + if (DEFINED ENV{LDFLAGS}) +@@ -565,8 +597,18 @@ target_compile_definitions(thrift_python_cpp + PRIVATE THRIFT_NO_HTTP_CLIENT_CHANNEL) + # Workaround for https://github.com/cython/cython/issues/5973 + target_compile_definitions(thrift_python_cpp PRIVATE __PYX_ENUM_CLASS_DECL=) +-target_include_directories(thrift_python_cpp PRIVATE "${_cybld}" +- ${Python3_INCLUDE_DIRS}) ++if (APPLE) ++ # The wheel staging root contains folly/executor.h, which shadows ++ # Folly's Executor.h on case-insensitive filesystems. ++ file(MAKE_DIRECTORY "${_cybld}/cpp_include") ++ if (NOT EXISTS "${_cybld}/cpp_include/thrift") ++ file(CREATE_LINK "${_cybld}/thrift" "${_cybld}/cpp_include/thrift" SYMBOLIC) ++ endif () ++ target_include_directories(thrift_python_cpp PRIVATE "${_cybld}/cpp_include") ++else () ++ target_include_directories(thrift_python_cpp PRIVATE "${_cybld}") ++endif () ++target_include_directories(thrift_python_cpp PRIVATE ${Python3_INCLUDE_DIRS}) + # Link strategy: + # - STATIC libs (thrift + deps): embed with --whole-archive to consolidate + # into single .so +@@ -576,11 +618,17 @@ target_include_directories(thrift_python_cpp PRIVATE "${_cybld}" + # TJSONProtocol.cpp) + # libevent/libiberty: needed for undefined symbols, + # --allow-multiple-definition handles duplicates ++if (APPLE) ++ set(_whole_archive_prefix "") ++ set(_whole_archive_suffix "") ++else () ++ set(_whole_archive_prefix "-Wl,--whole-archive" "-Wl,--allow-multiple-definition") ++ set(_whole_archive_suffix "-Wl,--no-whole-archive") ++endif () + target_link_libraries( + thrift_python_cpp + PUBLIC # Static libs - embed all symbols +- "-Wl,--whole-archive" +- "-Wl,--allow-multiple-definition" ++ ${_whole_archive_prefix} + thriftcpp2 + rpcmetadata + thrift_annotation +@@ -594,12 +642,17 @@ target_link_libraries( + libevent::core + libevent::extra + ${LIBIBERTY_LIBRARIES} +- "-Wl,--no-whole-archive" ++ ${_whole_archive_suffix} + # Shared libs - runtime deps (see manifests/folly, manifests/fmt) + Folly::folly + Folly::folly_python_cpp + fmt::fmt + glog::glog) ++if (APPLE) ++ target_link_libraries(thrift_python_cpp PRIVATE Python3::Python) ++ target_link_options(thrift_python_cpp PRIVATE ++ "LINKER:-force_load,$") ++endif () + install(TARGETS thrift_python_cpp EXPORT thrift) + install(TARGETS thrift_python_cpp DESTINATION ${py_install_dir}) + +@@ -721,6 +774,7 @@ add_custom_command( + # Run auditwheel repair to make the wheel self-contained + # This bundles .so dependencies and rewrites RPATH to $ORIGIN + # LD_LIBRARY_PATH tells auditwheel where to find the libraries to bundle ++if (NOT APPLE) + add_custom_command( + TARGET thrift_python_and_py3_bindings + COMMAND ${CMAKE_COMMAND} -E make_directory "${_cybld}/dist_self_contained" +@@ -729,6 +783,12 @@ add_custom_command( + ${Python3_EXECUTABLE} -m auditwheel repair --wheel-dir + "${_cybld}/dist_self_contained" "${_cybld}/dist/*.whl" + WORKING_DIRECTORY ${_cybld}) ++else () ++ add_custom_command( ++ TARGET thrift_python_and_py3_bindings ++ COMMAND ${CMAKE_COMMAND} -E copy_directory ++ "${_cybld}/dist" "${_cybld}/dist_self_contained") ++endif () + + # Install the self-contained wheel to the install prefix + # for users to pip install +diff --git a/thrift/lib/setup.py b/thrift/lib/setup.py +index dcf05b5524..c46c0dee31 100644 +--- a/thrift/lib/setup.py ++++ b/thrift/lib/setup.py +@@ -18,6 +18,7 @@ + # created as tree of links to the real source files. + + import os ++import shutil + import sys + + import Cython +@@ -107,13 +108,25 @@ if "--api-only" in sys.argv: + language_level=3, + ) + # Compile streaming modules to generate *_api.h headers ++ # APFS may be case-insensitive: sink.cpp must not shadow Sink.cpp. ++ if sys.platform == "darwin": ++ os.makedirs("generated_api", exist_ok=True) ++ sink_options = Options.CompilationOptions( ++ compilation_options, output_file="generated_api/sink.cpp" ++ ) ++ else: ++ sink_options = compilation_options + Cython.Compiler.Main.compile( + "thrift/python/streaming/sink.pyx", +- options=compilation_options, ++ options=sink_options, + full_module_name="thrift.python.streaming.sink", + cplus=True, + language_level=3, + ) ++ if sys.platform == "darwin": ++ shutil.copyfile( ++ "generated_api/sink_api.h", "thrift/python/streaming/sink_api.h" ++ ) + Cython.Compiler.Main.compile( + "thrift/python/streaming/bidistream.pyx", + options=compilation_options, +@@ -140,7 +153,7 @@ if "--api-only" in sys.argv: + + else: + python_lib_idx = sys.argv.index("--libpython") +- python_lib = sys.argv[python_lib_idx + 1][len("lib") : -len(".so")] ++ python_lib = os.path.splitext(sys.argv[python_lib_idx + 1])[0][len("lib") :] + del sys.argv[python_lib_idx : python_lib_idx + 2] + + # Library search paths from CMakeLists (passed via LIBRARY_DIRS env var) +@@ -163,6 +176,9 @@ else: + "sodium", + "unwind", + ] ++ if sys.platform == "darwin": ++ dynamic_libs = [lib for lib in dynamic_libs if lib not in ("aio", "unwind")] ++ dynamic_libs.append("fmt") + + extra_link_args = [] + +@@ -177,18 +192,42 @@ else: + # Use $ORIGIN so auditwheel can properly bundle libraries into the wheel. + # $ORIGIN/.libs is where auditwheel places bundled shared libraries. + # We also add $ORIGIN for libraries in the same directory as the extension. +- extra_link_args.append("-Wl,-rpath,$ORIGIN/.libs") +- extra_link_args.append("-Wl,-rpath,$ORIGIN") ++ origin = "@loader_path" if sys.platform == "darwin" else "$ORIGIN" ++ extra_link_args.append(f"-Wl,-rpath,{origin}/.libs") ++ extra_link_args.append(f"-Wl,-rpath,{origin}") ++ ++ cpp_include_dirs = include_dirs ++ if sys.platform == "darwin": ++ # Prefer Folly's C++ Executor.h to the staged Cython executor.h. ++ folly_cpp_include = next( ++ ( ++ path ++ for path in include_dirs ++ if os.path.isdir(os.path.join(path, "folly")) ++ and "Executor.h" in os.listdir(os.path.join(path, "folly")) ++ ), ++ None, ++ ) ++ if folly_cpp_include: ++ cpp_include_dirs = [folly_cpp_include] + include_dirs + + common_options = { + "language": "c++", +- "include_dirs": include_dirs, ++ "include_dirs": cpp_include_dirs, + "library_dirs": lib_search_paths, # Tell linker where to find dynamic libraries + "libraries": dynamic_libs + [python_lib], +- "extra_compile_args": ["-std=c++20", "-fcoroutines"], ++ "extra_compile_args": ["-std=c++20", "-fcoroutines"] ++ + (["-DGLOG_USE_GLOG_EXPORT"] if sys.platform == "darwin" else []), + "extra_link_args": extra_link_args, + } + ++ sink_cpp_source = "thrift/python/streaming/Sink.cpp" ++ if sys.platform == "darwin": ++ # Cython's build directory also contains generated sink.cpp. ++ sink_cpp_source = "thrift/python/streaming/SinkNative.cpp" ++ if not os.path.exists(sink_cpp_source): ++ os.symlink("Sink.cpp", sink_cpp_source) ++ + exts = [ + # thrift.python extension modules + Extension( +@@ -338,7 +377,7 @@ else: + "thrift.python.streaming.sink", + sources=[ + "thrift/python/streaming/sink.pyx", +- "thrift/python/streaming/Sink.cpp", ++ sink_cpp_source, + ], + **common_options, + ), diff --git a/build/fbcode_builder/patches/folly_python_darwin.patch b/build/fbcode_builder/patches/folly_python_darwin.patch new file mode 100644 index 0000000000000..b6118940d7609 --- /dev/null +++ b/build/fbcode_builder/patches/folly_python_darwin.patch @@ -0,0 +1,13 @@ +diff --git a/folly/python/CMakeLists.txt b/folly/python/CMakeLists.txt +--- a/folly/python/CMakeLists.txt ++++ b/folly/python/CMakeLists.txt +@@ -137,6 +137,9 @@ + add_dependencies(folly_python_cpp folly create_post_binding_symlink) + set_property(TARGET folly_python_cpp PROPERTY VERSION ${PACKAGE_VERSION}) + target_compile_definitions(folly_python_cpp PRIVATE BOOST_NO_AUTO_PTR) ++if(APPLE) ++ target_include_directories(folly_python_cpp BEFORE PRIVATE "${CMAKE_SOURCE_DIR}") ++endif() + target_include_directories(folly_python_cpp PRIVATE "${_cybld}") + target_link_libraries(folly_python_cpp PUBLIC folly) + apply_folly_compile_options_to_target(folly_python_cpp) From 6b273e986b0f16ed170b97e898936bf073a65e19 Mon Sep 17 00:00:00 2001 From: Max Lepikhin Date: Fri, 30 Oct 2026 12:12:09 -0600 Subject: [PATCH 4/4] edenfs: finish the macOS CMake build --- .../CMake/RustStaticLibrary.cmake | 31 ++++++++++++++----- eden/fs/CMakeLists.txt | 18 +++++++++++ eden/fs/fuse/FuseDirList.h | 1 + eden/fs/rust/edenfs-staticlib/BUCK | 14 +++++++++ eden/fs/rust/edenfs-staticlib/Cargo.toml | 3 ++ eden/fs/service/CMakeLists.txt | 5 +++ eden/scm/lib/backingstore/CMakeLists.txt | 14 +++++++-- eden/scm/lib/edenfs_ffi/CMakeLists.txt | 1 + 8 files changed, 77 insertions(+), 10 deletions(-) diff --git a/build/fbcode_builder/CMake/RustStaticLibrary.cmake b/build/fbcode_builder/CMake/RustStaticLibrary.cmake index 83a562c6c9e9a..3bd63b8d7f0be 100644 --- a/build/fbcode_builder/CMake/RustStaticLibrary.cmake +++ b/build/fbcode_builder/CMake/RustStaticLibrary.cmake @@ -395,7 +395,8 @@ endfunction() # `${TARGET}` CMake library target. # # ```cmake -# rust_cxx_bridge( [CRATE ] [LIBS ]) +# rust_cxx_bridge( [CRATE ] +# [CARGO_DIRECTORY ] [LIBS ]) # ``` # # Parameters: @@ -406,11 +407,14 @@ endfunction() # - CRATE_NAME: # Name of the crate. This parameter is optional. If unspecified, it will # fallback to `${TARGET}`. +# - CARGO_DIRECTORY: +# Directory where Cargo resolves the cxx dependency. Defaults to the current +# source directory. # - LIBS [ ...]: # A list of libraries that this library depends on. # function(rust_cxx_bridge TARGET CXX_BRIDGE_FILE) - fb_cmake_parse_args(ARG "" "CRATE" "LIBS" "${ARGN}") + fb_cmake_parse_args(ARG "" "CRATE;CARGO_DIRECTORY" "LIBS" "${ARGN}") if(DEFINED ARG_CRATE) set(crate_name "${ARG_CRATE}") @@ -418,7 +422,9 @@ function(rust_cxx_bridge TARGET CXX_BRIDGE_FILE) set(crate_name "${TARGET}") endif() - _rust_cxxbridge(cxxbridge cxxbridge_target) + _rust_cxxbridge( + cxxbridge cxxbridge_target "${ARG_CARGO_DIRECTORY}" + ) add_library(${crate_name} STATIC) target_include_directories( @@ -482,7 +488,7 @@ endfunction() # source directory depends on. # # ```cmake -# rust_cxx_header( [LIBS ]) +# rust_cxx_header( [CARGO_DIRECTORY ] [LIBS ]) # ``` # # Parameters: @@ -490,14 +496,19 @@ endfunction() # Name of the interface library target to create, which puts the header on # the include path. An internal custom target, `${TARGET}.header`, generates # it. +# - CARGO_DIRECTORY: +# Directory where Cargo resolves the cxx dependency. Defaults to the current +# source directory. # - LIBS [ ...]: # A list of libraries that this library depends on, such as the Rust static # library that contains the cxx runtime. # function(rust_cxx_header TARGET) - fb_cmake_parse_args(ARG "" "" "LIBS" "${ARGN}") + fb_cmake_parse_args(ARG "" "CARGO_DIRECTORY" "LIBS" "${ARGN}") - _rust_cxxbridge(cxxbridge cxxbridge_target) + _rust_cxxbridge( + cxxbridge cxxbridge_target "${ARG_CARGO_DIRECTORY}" + ) add_custom_target( ${TARGET}.header DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/rust/cxx.h" @@ -513,17 +524,21 @@ endfunction() # commands running it depend on, which runs `cargo install cxxbridge-cmd` when # no installed cxxbridge has that version. Also adds the rule that generates # `rust/cxx.h` in the current binary directory. -function(_rust_cxxbridge CXXBRIDGE_VAR DEPENDS_VAR) +function(_rust_cxxbridge CXXBRIDGE_VAR DEPENDS_VAR CARGO_DIRECTORY) if(USE_CARGO_VENDOR) set(extra_cargo_env "CARGO_HOME=${RUST_CARGO_HOME}") endif() + if(NOT CARGO_DIRECTORY) + set(CARGO_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + endif() + execute_process( COMMAND "${CMAKE_COMMAND}" -E env ${extra_cargo_env} "${CARGO_COMMAND}" tree -i cxx --depth=0 - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + WORKING_DIRECTORY "${CARGO_DIRECTORY}" RESULT_VARIABLE cxx_version_result OUTPUT_VARIABLE cxx_version_output ) diff --git a/eden/fs/CMakeLists.txt b/eden/fs/CMakeLists.txt index 2a6975c272414..a2bcc30ac91c4 100644 --- a/eden/fs/CMakeLists.txt +++ b/eden/fs/CMakeLists.txt @@ -22,6 +22,24 @@ target_link_libraries( Folly::folly ) +if(APPLE) + set_target_properties( + edenfs + PROPERTIES + LINK_LIBRARY_OVERRIDE_backingstore WHOLE_ARCHIVE + LINK_LIBRARY_OVERRIDE_backtrace_ffi WHOLE_ARCHIVE + LINK_LIBRARY_OVERRIDE_edenfs_ffi WHOLE_ARCHIVE + LINK_LIBRARY_OVERRIDE_manifold_ffi WHOLE_ARCHIVE + LINK_LIBRARY_OVERRIDE_redirect_ffi WHOLE_ARCHIVE + ) + target_link_libraries( + edenfs + "-framework IOKit" + "-framework OpenDirectory" + "-framework SystemConfiguration" + ) +endif() + if(NOT WIN32) add_executable( edenfs_privhelper diff --git a/eden/fs/fuse/FuseDirList.h b/eden/fs/fuse/FuseDirList.h index c32bec5f91d1d..4716bd6734b7b 100644 --- a/eden/fs/fuse/FuseDirList.h +++ b/eden/fs/fuse/FuseDirList.h @@ -9,6 +9,7 @@ #include #include #include +#include #include "eden/common/utils/DirType.h" namespace facebook::eden { diff --git a/eden/fs/rust/edenfs-staticlib/BUCK b/eden/fs/rust/edenfs-staticlib/BUCK index 7dc1294c65fb7..db35022c06c9d 100644 --- a/eden/fs/rust/edenfs-staticlib/BUCK +++ b/eden/fs/rust/edenfs-staticlib/BUCK @@ -15,10 +15,24 @@ rust_library( # wezterm-dynamic that this workspace patches in. "extra_buck_dependencies": { "dependencies": ["fbsource//third-party/rust:wezterm-dynamic"], + "target": { + "'cfg(target_os = \"macos\")'": { + "dependencies": ["fbsource//third-party/rust:blake3"], + }, + }, }, "features": { "fb": ["sapling-backingstore/fb"], }, + "dependencies_override": { + "target": { + "'cfg(target_os = \"macos\")'": { + "dependencies": { + "blake3": {"features": ["pure"]}, + }, + }, + }, + }, }, }, # redirect-ffi's thrift client doesn't build for Windows with Buck. diff --git a/eden/fs/rust/edenfs-staticlib/Cargo.toml b/eden/fs/rust/edenfs-staticlib/Cargo.toml index 666d5c3c5c2b1..7858bbebaa233 100644 --- a/eden/fs/rust/edenfs-staticlib/Cargo.toml +++ b/eden/fs/rust/edenfs-staticlib/Cargo.toml @@ -18,5 +18,8 @@ sapling-backingstore = { version = "0.1.0", path = "../../../scm/lib/backingstor sapling-edenfs_ffi = { version = "0.1.0", path = "../../../scm/lib/edenfs_ffi" } wezterm-dynamic = { git = "https://github.com/wezterm/wezterm.git", rev = "05343b387085842b434d267f91b6b0ec157e4331", features = ["std"] } +[target.'cfg(target_os = "macos")'.dependencies] +blake3 = { version = "=1.8.6", features = ["pure"] } + [features] fb = ["sapling-backingstore/fb"] diff --git a/eden/fs/service/CMakeLists.txt b/eden/fs/service/CMakeLists.txt index 02712a6da27a8..5700a7d01cbfd 100644 --- a/eden/fs/service/CMakeLists.txt +++ b/eden/fs/service/CMakeLists.txt @@ -13,6 +13,11 @@ add_fbthrift_library( eden_config_thrift fb303::fb303_thrift ) +target_link_libraries( + eden_service_thrift_cpp + PUBLIC + edencommon::edencommon_utils +) if (EDEN_HAVE_THRIFT_PYTHON) add_fbthrift_python_library( diff --git a/eden/scm/lib/backingstore/CMakeLists.txt b/eden/scm/lib/backingstore/CMakeLists.txt index ddb1e0512506f..2e3c0ec7081a5 100644 --- a/eden/scm/lib/backingstore/CMakeLists.txt +++ b/eden/scm/lib/backingstore/CMakeLists.txt @@ -6,13 +6,19 @@ rust_cxx_bridge( backingstore "src/ffi.rs" + CARGO_DIRECTORY "${CMAKE_SOURCE_DIR}/eden/fs/rust/edenfs-staticlib" LIBS fmt::fmt Folly::folly ) # Open-source builds declare folly::IOBuf in a second bridge, see src/oss.rs. -rust_cxx_bridge(backingstore_iobuf "src/oss.rs" LIBS Folly::folly) +rust_cxx_bridge( + backingstore_iobuf + "src/oss.rs" + CARGO_DIRECTORY "${CMAKE_SOURCE_DIR}/eden/fs/rust/edenfs-staticlib" + LIBS Folly::folly +) file(GLOB C_API_SRCS "src/*.cpp") file(GLOB C_API_HDRS "include/*.h") @@ -46,7 +52,11 @@ target_link_libraries( Folly::folly ) -rust_cxx_header(rust_cxx LIBS rust_edenfs_staticlib) +rust_cxx_header( + rust_cxx + CARGO_DIRECTORY "${CMAKE_SOURCE_DIR}/eden/fs/rust/edenfs-staticlib" + LIBS rust_edenfs_staticlib +) # curl used in the Rust crate has its own copy of curl compiled and it uses # Crypt32 and Secur32 on Windows. We need to declare the link dependencies here diff --git a/eden/scm/lib/edenfs_ffi/CMakeLists.txt b/eden/scm/lib/edenfs_ffi/CMakeLists.txt index 89b8e21af60fd..f9fce5f6f0463 100644 --- a/eden/scm/lib/edenfs_ffi/CMakeLists.txt +++ b/eden/scm/lib/edenfs_ffi/CMakeLists.txt @@ -6,6 +6,7 @@ rust_cxx_bridge( edenfs_ffi "src/lib.rs" + CARGO_DIRECTORY "${CMAKE_SOURCE_DIR}/eden/fs/rust/edenfs-staticlib" LIBS fmt::fmt Folly::folly