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

Build cli:buck2 #31

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions buck2_server/src/jemalloc_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use cli_proto::StatusResponse;

#[cfg(all(unix, not(fbcode_build)))]
#[cfg(all(unix, not(fbcode_build), not(buck_oss_build)))]
pub fn jemalloc_stats(response: &mut StatusResponse) {
use jemalloc_ctl::epoch;
use jemalloc_ctl::stats;
Expand All @@ -29,7 +29,7 @@ pub fn jemalloc_stats(response: &mut StatusResponse) {
set(&mut response.bytes_retained, stats::retained::read());
}

#[cfg(not(all(unix, not(fbcode_build))))]
#[cfg(not(all(unix, not(fbcode_build), not(buck_oss_build))))]
pub fn jemalloc_stats(_response: &mut StatusResponse) {}

#[cfg(test)]
Expand Down
4 changes: 2 additions & 2 deletions cli/bin/buck2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use tracing_subscriber::EnvFilter;
// fbcode likes to set its own allocator in fbcode.default_allocator
// So when we set our own allocator, buck build buck2 or buck2 build buck2 often breaks.
// Making jemalloc the default only when we do a cargo build.
#[cfg_attr(all(unix, not(fbcode_build)), global_allocator)]
#[cfg(all(unix, not(fbcode_build)))]
#[cfg_attr(all(unix, not(fbcode_build), not(buck_oss_build)), global_allocator)]
#[cfg(all(unix, not(fbcode_build), not(buck_oss_build)))]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

fn init_logging(_fb: FacebookInit) -> anyhow::Result<()> {
Expand Down
33 changes: 29 additions & 4 deletions shim/shims.bzl
Original file line number Diff line number Diff line change
@@ -1,21 +1,44 @@
# @lint-ignore FBCODEBZLADDLOADS

def rust_library(os_deps = None, test_deps = None, test_env = None, named_deps = None, deps = [], visibility = ["PUBLIC"], **kwargs):
def rust_library(
rustc_flags = [],
deps = [],
named_deps = None,
os_deps = None,
test_deps = None,
test_env = None,
visibility = ["PUBLIC"],
**kwargs):
_unused = (test_deps, test_env, named_deps) # @unused
deps = _fix_deps(deps)
if os_deps:
deps += _select_os_deps(_fix_dict_deps(os_deps))
native.rust_library(
rustc_flags = rustc_flags + [_CFG_BUCK_OSS_BUILD],
deps = deps,
visibility = visibility,
**kwargs
)

def rust_binary(unittests = None, deps = [], **kwargs):
def rust_binary(
rustc_flags = [],
deps = [],
unittests = None,
**kwargs):
_unused = unittests # @unused
native.rust_binary(deps = filter(None, map(_fix_dep, deps)), **kwargs)
deps = _fix_deps(deps)
native.rust_binary(
rustc_flags = rustc_flags + [_CFG_BUCK_OSS_BUILD],
deps = deps,
**kwargs)

def rust_protobuf_library(name, srcs, build_script, spec, build_env = None, deps = None):
def rust_protobuf_library(
name,
srcs,
build_script,
spec,
build_env = None,
deps = None):
deps = _fix_deps(deps) if deps else None
if build_env:
build_env = {
Expand Down Expand Up @@ -76,6 +99,8 @@ def rust_protobuf_library(name, srcs, build_script, spec, build_env = None, deps
visibility = ["PUBLIC"],
)

_CFG_BUCK_OSS_BUILD = "--cfg=buck_oss_build"

def _select_os_deps(xss: [(
"string",
["string"],
Expand Down
5 changes: 3 additions & 2 deletions shim/third-party/cxx/vendor/openssl-linux/BUCK_OSS
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ prebuilt_cxx_library(
name = "openssl",
exported_headers = glob(["include/**/*.h"]),
header_dirs = ["include"],
deps = [":ssl"],
visibility = ["PUBLIC"],
)

prebuilt_cxx_library(
name = "ssl",
static_lib = "lib/x86_64-linux-gnu/libssl.a",
visibility = ["PUBLIC"],
deps = [":crypto"],
)

prebuilt_cxx_library(
name = "crypto",
exported_post_linker_flags = ["-lc"],
static_lib = "lib/x86_64-linux-gnu/libcrypto.a",
visibility = ["PUBLIC"],
)
4 changes: 4 additions & 0 deletions shim/third-party/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ bytes = "1.0"
chrono = "=0.4.19" # Avoid a dependency iana-time-zone, which requires a fixup
clap = { version = "3.1.18", features = ["derive", "env"] }
clap-4 = { package = "clap", version = "4.0.7", features = ["derive", "env"] }
constant_time_eq = "0.2.4"
convert_case = "0.4.0"
criterion = { version = "0.3.4", features = ["async", "async_tokio", "html_reports"] }
crossbeam-channel = "0.5"
Expand Down Expand Up @@ -69,12 +70,14 @@ glob = "0.3.0"
globset = "0.4.7"
hashbrown = { version = "0.12.3", features = ["raw"] }
hex = "0.4.3"
hostname = "0.3.1"
http = "0.2"
httparse = "1.7.1"
humantime = "2.0.1"
indent_write = "2.2.0"
indexmap = { version = "1.9.1", features = ["serde-1"] }
indoc = "1.0.3"
inferno = "0.11.11"
internment = "0.4.0"
inventory = "0.1.10"
itertools = "0.10.3"
Expand Down Expand Up @@ -160,6 +163,7 @@ trybuild = "1.0.56"
twox-hash = "1.6.1"
uuid = { version = "0.8", features = ["v4"] }
walkdir = "2.3.2"
which = "4.3.0"
winapi = { version = "0.3", features = ["everything"] }
xattr = "0.2.2"
zip = "0.5"
Expand Down
2 changes: 0 additions & 2 deletions shim/third-party/rust/fixups/openssl-sys/fixups.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ buildscript = []
buildscript = []
extra_deps = [
"buck//third-party/cxx/vendor/openssl-linux:openssl",
"buck//third-party/cxx/vendor/openssl-linux:ssl",
"buck//third-party/cxx/vendor/openssl-linux:crypto",
]

[platform_fixup.'cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))']
Expand Down
2 changes: 0 additions & 2 deletions shim/third-party/rust/fixups/openssl/fixups.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ buildscript = []
buildscript = []
extra_deps = [
"buck//third-party/cxx/vendor/openssl-linux:openssl",
"buck//third-party/cxx/vendor/openssl-linux:ssl",
"buck//third-party/cxx/vendor/openssl-linux:crypto",
]

[platform_fixup.'cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))']
Expand Down
56 changes: 56 additions & 0 deletions shim/third-party/rust/fixups/zstd-sys/fixups.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[[buildscript]]
[buildscript.cxx_library]
name = "zstd"
srcs = [
"zstd/lib/common/debug.c",
"zstd/lib/common/entropy_common.c",
"zstd/lib/common/error_private.c",
"zstd/lib/common/fse_decompress.c",
"zstd/lib/common/pool.c",
"zstd/lib/common/threading.c",
#"zstd/lib/common/xxhash.c",
"zstd/lib/common/zstd_common.c",
"zstd/lib/compress/**/*.c",
"zstd/lib/decompress/**/*.c",
"zstd/lib/decompress/huf_decompress_amd64.S",
"zstd/lib/dictBuilder/**/*.c",
"zstd/lib/legacy/**/*.c",
]
headers = [
"zdict.h",
"zstd.h",
"zstd/lib/common/bitstream.h",
"zstd/lib/common/compiler.h",
"zstd/lib/common/cpu.h",
"zstd/lib/common/debug.h",
"zstd/lib/common/error_private.h",
"zstd/lib/common/fse.h",
"zstd/lib/common/huf.h",
"zstd/lib/common/mem.h",
"zstd/lib/common/pool.h",
"zstd/lib/common/portability_macros.h",
"zstd/lib/common/threading.h",
#"zstd/lib/common/xxhash.h",
"zstd/lib/common/zstd_deps.h",
"zstd/lib/common/zstd_internal.h",
"zstd/lib/common/zstd_trace.h",
"zstd/lib/compress/**/*.h",
"zstd/lib/decompress/**/*.h",
"zstd/lib/deprecated/zbuff.h",
"zstd/lib/dictBuilder/cover.h",
"zstd/lib/dictBuilder/divsufsort.h",
"zstd/lib/legacy/**/*.h",
"zstd/lib/zdict.h",
"zstd/lib/zstd_errors.h",
"zstd/lib/zstd.h",
]
compiler_flags = [
"-O3",
"-DZSTD_LIB_DEPRECATED=0",
"-fvisibility=hidden",
"-DXXH_PRIVATE_API=",
"-DZSTDLIB_VISIBILITY=",
"-DZDICTLIB_VISIBILITY=",
"-DZSTDERRORLIB_VISIBILITY=",
"-DZSTD_LEGACY_SUPPORT=1"
]