diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 794b72fd7c663..200abe9ecdadf 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,7 +2,7 @@ "name": "Sapling", "build": { "context": "..", - "dockerfile": "../.github/workflows/sapling-cli-ubuntu-22.04.Dockerfile" + "dockerfile": "../.github/workflows/manylinux_2_34.Dockerfile" }, "updateContentCommand": "ln -sf /workspaces/sapling/eden/scm/sl /usr/local/bin/sl", "customizations": { diff --git a/CMakeLists.txt b/CMakeLists.txt index a6a4c34c7e3e3..f1c1948e0fcb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,7 +99,7 @@ else() endif() if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) message(STATUS "setting C++ standard to C++${CMAKE_CXX_STANDARD}") endif() diff --git a/common/network/Hostname.h b/common/network/Hostname.h new file mode 100644 index 0000000000000..d76ddbebff2cf --- /dev/null +++ b/common/network/Hostname.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2004-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +#pragma once + +namespace facebook { +namespace network { + +constexpr std::string_view DOMAIN_SUFFIX = ".facebook.com"; + +inline std::string getLocalHost(bool stripFbDomain) { + std::array buf{}; + + if (::gethostname(buf.data(), buf.size()) != 0) { + throw std::system_error(errno, std::generic_category(), "gethostname failed"); + } + + std::string hostname(buf.data()); + + if (stripFbDomain && + hostname.size() >= DOMAIN_SUFFIX.size() && + hostname.compare(hostname.size() - DOMAIN_SUFFIX.size(), + DOMAIN_SUFFIX.size(), + DOMAIN_SUFFIX) == 0) + { + hostname.resize(hostname.size() - DOMAIN_SUFFIX.size()); + } + + return hostname; +} + +} // namespace network +} // namespace facebook diff --git a/eden/fs/CMakeLists.txt b/eden/fs/CMakeLists.txt index 0065033347f82..0e0ffa2c40854 100644 --- a/eden/fs/CMakeLists.txt +++ b/eden/fs/CMakeLists.txt @@ -65,6 +65,7 @@ add_subdirectory(notifications) add_subdirectory(prjfs) add_subdirectory(py) add_subdirectory(rocksdb) +add_subdirectory(rust/redirect_ffi) add_subdirectory(service) add_subdirectory(sqlite) add_subdirectory(store) diff --git a/eden/fs/cli_rs/edenfs-client/BUCK b/eden/fs/cli_rs/edenfs-client/BUCK index 6e3976bff4f10..83e6455bbb9ec 100644 --- a/eden/fs/cli_rs/edenfs-client/BUCK +++ b/eden/fs/cli_rs/edenfs-client/BUCK @@ -5,9 +5,6 @@ oncall("scm_client_infra") rust_library( name = "edenfs-client", srcs = glob(["src/**/*.rs"]), - named_deps = { - "hg_util": "//eden/scm/lib/util:util", - }, os_deps = [ ( "windows", diff --git a/eden/fs/cli_rs/edenfs-client/Cargo.toml b/eden/fs/cli_rs/edenfs-client/Cargo.toml index eec86be9ada0d..6c51ae642f825 100644 --- a/eden/fs/cli_rs/edenfs-client/Cargo.toml +++ b/eden/fs/cli_rs/edenfs-client/Cargo.toml @@ -21,7 +21,6 @@ fbinit = { version = "0.2.0", git = "https://github.com/facebookexperimental/rus futures = { version = "0.3.31", features = ["async-await", "compat"] } futures_stats = { version = "0.1.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "main" } hex = { version = "0.4.3", features = ["alloc"] } -hg_util = { package = "sapling-util", version = "0.1.0", path = "../../../scm/lib/util" } lazy_static = "1.5" libc = "0.2.139" parking_lot = { version = "0.12.1", features = ["send_guard"] } @@ -32,6 +31,7 @@ sapling-atomicfile = { version = "0.1.0", path = "../../../scm/lib/atomicfile" } sapling-config-remote-loader = { version = "0.1.0", path = "../../../scm/lib/config/remote-loader" } sapling-http-client = { version = "0.1.0", path = "../../../scm/lib/http-client" } sapling-thrift-types = { version = "0.1.0", path = "../../../scm/lib/thrift-types" } +sapling-util = { version = "0.1.0", path = "../../../scm/lib/util" } serde = { version = "1.0.219", features = ["derive", "rc"] } serde_json = { version = "1.0.140", features = ["alloc", "float_roundtrip", "raw_value", "unbounded_depth"] } shlex = "1.3" diff --git a/eden/fs/cli_rs/edenfs-client/src/instance.rs b/eden/fs/cli_rs/edenfs-client/src/instance.rs index 81163b1a5f379..c4907376a04e4 100644 --- a/eden/fs/cli_rs/edenfs-client/src/instance.rs +++ b/eden/fs/cli_rs/edenfs-client/src/instance.rs @@ -106,9 +106,9 @@ use edenfs_utils::get_executable; #[cfg(windows)] use edenfs_utils::strip_unc_prefix; use fbinit::expect_init; -use hg_util::lock::PathLock; use tracing::Level; use tracing::event; +use util::lock::PathLock; use crate::client::EdenFsClient; use crate::use_case::UseCase; diff --git a/eden/fs/cli_rs/edenfs-client/src/redirect.rs b/eden/fs/cli_rs/edenfs-client/src/redirect.rs index 5ced316626e6c..1293c04f5827a 100644 --- a/eden/fs/cli_rs/edenfs-client/src/redirect.rs +++ b/eden/fs/cli_rs/edenfs-client/src/redirect.rs @@ -28,7 +28,6 @@ use edenfs_telemetry::EDEN_EVENTS_SCUBA; use edenfs_telemetry::send; use edenfs_utils::metadata::MetadataExt; use edenfs_utils::remove_symlink; -use hg_util::path::absolute; #[cfg(target_os = "windows")] use mkscratch::zzencode; use pathdiff::diff_paths; @@ -38,6 +37,7 @@ use serde::Deserialize; use serde::Deserializer; use serde::Serialize; use toml::value::Value; +use util::path::absolute; use crate::checkout::CheckoutConfig; use crate::checkout::EdenFsCheckout; diff --git a/eden/fs/cli_rs/edenfs-client/src/utils.rs b/eden/fs/cli_rs/edenfs-client/src/utils.rs index a764794ed5e5c..0d14546ff39c6 100644 --- a/eden/fs/cli_rs/edenfs-client/src/utils.rs +++ b/eden/fs/cli_rs/edenfs-client/src/utils.rs @@ -13,7 +13,7 @@ use anyhow::Context; use anyhow::Result; use anyhow::anyhow; use anyhow::bail; -use hg_util::path::expand_path; +use util::path::expand_path; use crate::instance::DEFAULT_CONFIG_DIR; use crate::instance::DEFAULT_ETC_EDEN_DIR; diff --git a/eden/fs/inodes/CMakeLists.txt b/eden/fs/inodes/CMakeLists.txt index bb4e4cc22e7cb..9ed59fecfc39e 100644 --- a/eden/fs/inodes/CMakeLists.txt +++ b/eden/fs/inodes/CMakeLists.txt @@ -20,16 +20,17 @@ list( REMOVE_ITEM INODES_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/RequestContext.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/InodeNumber.cpp ${CMAKE_CURRENT_SOURCE_DIR}/InodeMetadata.cpp ${CMAKE_CURRENT_SOURCE_DIR}/InodeTimestamps.cpp ) add_library( eden_inodes_inodenumber STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/InodeNumber.cpp + InodeNumber.h ) +set_target_properties(eden_inodes_inodenumber PROPERTIES LINKER_LANGUAGE CXX) + target_link_libraries( eden_inodes_inodenumber PUBLIC @@ -79,6 +80,7 @@ else() PUBLIC eden_fuse eden_fscatalog + eden_fscatalog_dev eden_lmdb_catalog eden_overlay_checker ) @@ -116,6 +118,7 @@ target_link_libraries( add_subdirectory(overlay) add_subdirectory(fscatalog) +add_subdirectory(fscatalog_dev) add_subdirectory(memcatalog) add_subdirectory(sqlitecatalog) add_subdirectory(lmdbcatalog) diff --git a/eden/fs/inodes/fscatalog_dev/CMakeLists.txt b/eden/fs/inodes/fscatalog_dev/CMakeLists.txt new file mode 100644 index 0000000000000..794dbbc5f29da --- /dev/null +++ b/eden/fs/inodes/fscatalog_dev/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2. + +if (NOT WIN32) + file(GLOB OVERLAY_SRCS "*.cpp") + list( + REMOVE_ITEM OVERLAY_SRCS + "${CMAKE_CURRENT_SOURCE_DIR}/eden_fsck.cpp" + ) + add_library( + eden_fscatalog_dev STATIC + ${OVERLAY_SRCS} + ) + target_link_libraries( + eden_fscatalog_dev + PUBLIC + eden_overlay_thrift_cpp + eden_fuse + eden_utils + ) +endif() diff --git a/eden/fs/inodes/sqlitecatalog/test/CMakeLists.txt b/eden/fs/inodes/sqlitecatalog/test/CMakeLists.txt index 2a09466572954..1417c80432b4f 100644 --- a/eden/fs/inodes/sqlitecatalog/test/CMakeLists.txt +++ b/eden/fs/inodes/sqlitecatalog/test/CMakeLists.txt @@ -18,6 +18,7 @@ target_link_libraries( eden_model eden_sqlite eden_utils + edenfs_ffi Folly::folly ${LIBGMOCK_LIBRARIES} ) diff --git a/eden/fs/privhelper/CMakeLists.txt b/eden/fs/privhelper/CMakeLists.txt index 7363021ff6649..da5e5dffbc290 100644 --- a/eden/fs/privhelper/CMakeLists.txt +++ b/eden/fs/privhelper/CMakeLists.txt @@ -3,7 +3,7 @@ # This software may be used and distributed according to the terms of the # GNU General Public License version 2. -file(GLOB PRIVHELPER_SRCS "*.cpp") +file(GLOB PRIVHELPER_SRCS "*.cpp" "priority/*.cpp") add_library( eden_fuse_privhelper STATIC diff --git a/eden/fs/rust/redirect_ffi/CMakeLists.txt b/eden/fs/rust/redirect_ffi/CMakeLists.txt new file mode 100644 index 0000000000000..11a8d85ee1064 --- /dev/null +++ b/eden/fs/rust/redirect_ffi/CMakeLists.txt @@ -0,0 +1,57 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2. + +# Due to some tools changing '-' to '_' when building, +# this library/crate is named using an '_' so that it can link successfully. +rust_static_library(rust_redirect_ffi CRATE redirect_ffi USE_CXX_INCLUDE) + +install_rust_static_library( + rust_redirect_ffi + INSTALL_DIR lib +) + +rust_cxx_bridge( + redirect_ffi + "src/lib.rs" + LIBS + fmt::fmt + Folly::folly +) + +file(GLOB C_API_SRCS "src/*.cpp") +file(GLOB C_API_HDRS "include/*.h") +target_sources( + redirect_ffi + PRIVATE + "${C_API_SRCS}" +) + +set_target_properties( + redirect_ffi + PROPERTIES + PUBLIC_HEADER + "${C_API_HDRS}" +) + +target_include_directories( + redirect_ffi + PUBLIC + $ + $ +) +target_link_libraries( + redirect_ffi + PUBLIC + rust_redirect_ffi + Folly::folly + edencommon::edencommon_utils + fmt::fmt +) + +install( + TARGETS redirect_ffi + LIBRARY DESTINATION lib + PUBLIC_HEADER DESTINATION eden/scm/lib/redirect_ffi/include +) diff --git a/eden/fs/rust/redirect_ffi/Cargo.toml b/eden/fs/rust/redirect_ffi/Cargo.toml index 58c2b291187e6..007fbc616304c 100644 --- a/eden/fs/rust/redirect_ffi/Cargo.toml +++ b/eden/fs/rust/redirect_ffi/Cargo.toml @@ -1,14 +1,21 @@ # @generated by autocargo from //eden/fs/rust/redirect_ffi:redirect-ffi [package] -name = "redirect-ffi" +name = "redirect_ffi" version = "0.1.0" authors = ["Facebook Source Control Team "] edition = "2024" license = "GPLv2+" +[lib] +name = "redirect_ffi" +crate-type = ["lib", "staticlib"] + [dependencies] anyhow = "1.0.98" cxx = "1.0.119" edenfs-client = { version = "0.1.0", path = "../../cli_rs/edenfs-client" } tokio = { version = "1.47.1", features = ["full", "test-util", "tracing"] } + +[build-dependencies] +cxx-build = "1.0.119" diff --git a/eden/fs/rust/redirect_ffi/build.rs b/eden/fs/rust/redirect_ffi/build.rs deleted file mode 100644 index 2a623ae7d1ed6..0000000000000 --- a/eden/fs/rust/redirect_ffi/build.rs +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This software may be used and distributed according to the terms of the - * GNU General Public License version 2. - */ - -fn main() { - cxx_build::bridge("src/lib.rs"); - println!("cargo:rerun-if-changed=src/lib.rs"); -} diff --git a/eden/fs/service/CMakeLists.txt b/eden/fs/service/CMakeLists.txt index 7f41ea2305370..8c97afda8c5a4 100644 --- a/eden/fs/service/CMakeLists.txt +++ b/eden/fs/service/CMakeLists.txt @@ -12,7 +12,7 @@ add_fbthrift_library( EdenService DEPENDS eden_config_thrift - fb303::fb303_thrift + fb303::fb303_core ) add_fbthrift_library( streamingeden_thrift @@ -33,13 +33,14 @@ file(GLOB SERVICE_SRCS "*.cpp") # eden/fs/thrift/ subdirectory, perhaps along with eden.thrift too. list( REMOVE_ITEM SERVICE_SRCS - ${CMAKE_CURRENT_SOURCE_DIR}/PrettyPrinters.cpp ${CMAKE_CURRENT_SOURCE_DIR}/PrivHelperMain.cpp ) + add_library( eden_service_thrift_util STATIC - PrettyPrinters.cpp + PrettyPrinters.h ) +set_target_properties(eden_service_thrift_util PROPERTIES LINKER_LANGUAGE CXX) target_link_libraries( eden_service_thrift_util PUBLIC @@ -57,6 +58,11 @@ add_library( eden_service STATIC ${SERVICE_SRCS} ) +target_link_options( + eden_service + PUBLIC + -Wl,--allow-multiple-definition +) target_link_libraries( eden_service PUBLIC @@ -71,6 +77,7 @@ target_link_libraries( eden_store eden_takeover eden_telemetry + redirect_ffi ${EDEN_STORE_IMPLEMENTATIONS} ${YARPL_LIBRARIES} Folly::folly diff --git a/eden/fs/service/EdenServer.cpp b/eden/fs/service/EdenServer.cpp index b5443f87c8f00..45c1ccce9e657 100644 --- a/eden/fs/service/EdenServer.cpp +++ b/eden/fs/service/EdenServer.cpp @@ -50,6 +50,7 @@ #include +#include "common/network/Hostname.h" #include "eden/common/telemetry/RequestMetricsScope.h" #include "eden/common/telemetry/SessionInfo.h" #include "eden/common/telemetry/StructuredLoggerFactory.h" @@ -112,7 +113,6 @@ #ifdef EDEN_HAVE_SERVER_OBSERVER #include "common/fb303/cpp/ThreadPoolExecutorCounters.h" // @manual -#include "common/network/Hostname.h" #include "eden/fs/service/facebook/ServerObserver.h" // @manual #endif diff --git a/eden/scm/lib/backingstore/CMakeLists.txt b/eden/scm/lib/backingstore/CMakeLists.txt index 62bde26384d4a..e6751cbb7a18e 100644 --- a/eden/scm/lib/backingstore/CMakeLists.txt +++ b/eden/scm/lib/backingstore/CMakeLists.txt @@ -51,6 +51,7 @@ target_link_libraries( backingstore PUBLIC edencommon::edencommon_os + eden_config rust_backingstore fmt::fmt Folly::folly diff --git a/eden/scm/lib/backingstore/Cargo.toml b/eden/scm/lib/backingstore/Cargo.toml index 828459498893d..e162c8c07f2a4 100644 --- a/eden/scm/lib/backingstore/Cargo.toml +++ b/eden/scm/lib/backingstore/Cargo.toml @@ -1,7 +1,7 @@ # @generated by autocargo from //eden/scm/lib/backingstore:backingstore [package] -name = "sapling-backingstore" +name = "backingstore" version = "0.1.0" authors = ["Meta Source Control Team "] edition = "2024" @@ -45,4 +45,6 @@ tracing-subscriber = { version = "0.3.20", features = ["chrono", "env-filter", " rand_chacha = "0.3" [features] +cas = [] fb = ["sapling-configloader/fb"] +scuba = [] diff --git a/eden/scm/lib/backingstore/benches/Cargo.toml b/eden/scm/lib/backingstore/benches/Cargo.toml index f956315e06d0b..327bb94a3e7b5 100644 --- a/eden/scm/lib/backingstore/benches/Cargo.toml +++ b/eden/scm/lib/backingstore/benches/Cargo.toml @@ -7,7 +7,7 @@ edition = "2024" [dependencies] fbinit = { version = "0.2.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "main" } -sapling-backingstore = { version = "0.1.0", path = ".." } +backingstore = { version = "0.1.0", path = ".." } sapling-configloader = { version = "0.1.0", path = "../../config/loader" } sapling-identity = { version = "0.1.0", path = "../../identity" } sapling-minibench = { version = "0.1.0", path = "../../minibench" } diff --git a/eden/scm/lib/edenfs_ffi/Cargo.toml b/eden/scm/lib/edenfs_ffi/Cargo.toml index 2f1afd92c915a..f76f13adec0b6 100644 --- a/eden/scm/lib/edenfs_ffi/Cargo.toml +++ b/eden/scm/lib/edenfs_ffi/Cargo.toml @@ -1,7 +1,7 @@ # @generated by autocargo from //eden/scm/lib/edenfs_ffi:edenfs_ffi [package] -name = "sapling-edenfs_ffi" +name = "edenfs_ffi" version = "0.1.0" authors = ["Meta Source Control Team "] edition = "2024"