Skip to content
Open
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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ psutil = "3.2"
quote = "1.0.3"
rand = { version = "0.9", features = ["small_rng"] }
rand_08 = { package = "rand", version = "0.8.4", features = ["small_rng"] }
rand_chacha = "0.3"
rand_distr = "0.4"
rand_chacha = "0.9"
rand_distr = "0.5"
rand_xoshiro = "0.7"
ref-cast = "1.0.0"
regex = "1.5.4"
Expand Down
1 change: 1 addition & 0 deletions app/buck2_build_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dupe = { workspace = true }
gazebo = { workspace = true }
remote_execution = { workspace = true }
rustls = { workspace = true }
setsketch = { workspace = true }
sorted_vector_map = { workspace = true }
starlark = { workspace = true }
starlark_map = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion app/buck2_build_signals_impl/src/enhancement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl CriticalPathProtoEnhancer {
let duration_proto: prost_types::Duration = duration.try_into()?;
self.entries.push(buck2_data::CriticalPathEntry2 {
span_ids: Vec::new(),
duration: Some(duration_proto.clone()),
duration: Some(duration_proto),
user_duration: Some(Duration::ZERO.try_into()?),
queue_duration: None,
total_duration: Some(duration_proto),
Expand Down
2 changes: 1 addition & 1 deletion app/buck2_critical_path/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn make_dag(nodes: usize, rng: &mut impl Rng) -> TestDag {
let edges_count = edges_count.min(candidate_count);

keys.push(format!("k{i}"));
weights.push(rng.gen_range(0..10_000));
weights.push(rng.random_range(0..10_000));
vertices.push(GraphVertex {
edges_idx: edges.len().try_into().unwrap(),
edges_count: edges_count.try_into().unwrap(),
Expand Down
2 changes: 2 additions & 0 deletions app/buck2_external_cells_bundled/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ fn write_include_file(prelude: &Path, mut include_file: impl io::Write) -> io::R

for res in walkdir::WalkDir::new(prelude) {
let entry = res.map_err(|e| e.into_io_error().unwrap())?;
// Watch all files and directories for changes
println!("cargo:rerun-if-changed={}", entry.path().display());
if !entry.file_type().is_file() {
continue;
}
Expand Down
4 changes: 3 additions & 1 deletion prelude/apple/prebuilt_apple_framework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ load(
"cxx_attr_preferred_linkage",
"cxx_platform_supported",
)
load("@prelude//cxx:linker.bzl", "wrap_linker_flags")
load(
"@prelude//cxx:preprocessor.bzl",
"CPreprocessor",
Expand Down Expand Up @@ -122,10 +123,11 @@ def prebuilt_apple_framework_impl(ctx: AnalysisContext) -> [list[Provider], Prom
lib = framework_library_artifact,
)

linker_type = get_cxx_toolchain_info(ctx).linker_info.type
link = LinkInfo(
name = framework_name,
linkables = [linkable],
pre_flags = [cxx_attr_exported_linker_flags(ctx)],
pre_flags = wrap_linker_flags(linker_type, cxx_attr_exported_linker_flags(ctx)),
)
link_info = LinkInfos(default = link)

Expand Down
36 changes: 36 additions & 0 deletions prelude/build_mode/constraints/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
load("@prelude//utils:source_listing.bzl", "source_listing")

oncall("build_infra")

source_listing()

# Build mode constraints for OSS

constraint_setting(
name = "build_mode",
visibility = ["PUBLIC"],
)

constraint_value(
name = "static",
constraint_setting = ":build_mode",
visibility = ["PUBLIC"],
)

constraint_value(
name = "static_pic",
constraint_setting = ":build_mode",
visibility = ["PUBLIC"],
)

constraint_value(
name = "opt",
constraint_setting = ":build_mode",
visibility = ["PUBLIC"],
)

constraint_value(
name = "dev",
constraint_setting = ":build_mode",
visibility = ["PUBLIC"],
)
37 changes: 37 additions & 0 deletions prelude/compiler/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is dual-licensed under either the MIT license found in the
# LICENSE-MIT file in the root directory of this source tree or the Apache
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree. You may select, at your option, one of the
# above-listed licenses.

load("@prelude//utils:source_listing.bzl", "source_listing")

oncall("build_infra")

source_listing()

config_setting(
name = "clang",
constraint_values = [
"prelude//compiler/constraints:clang",
],
visibility = ["PUBLIC"],
)

config_setting(
name = "gcc",
constraint_values = [
"prelude//compiler/constraints:gcc",
],
visibility = ["PUBLIC"],
)

config_setting(
name = "msvc",
constraint_values = [
"prelude//compiler/constraints:msvc",
],
visibility = ["PUBLIC"],
)
36 changes: 36 additions & 0 deletions prelude/compiler/constraints/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is dual-licensed under either the MIT license found in the
# LICENSE-MIT file in the root directory of this source tree or the Apache
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree. You may select, at your option, one of the
# above-listed licenses.

load("@prelude//utils:source_listing.bzl", "source_listing")

oncall("build_infra")

source_listing()

constraint_setting(
name = "compiler",
visibility = ["PUBLIC"],
)

constraint_value(
name = "clang",
constraint_setting = ":compiler",
visibility = ["PUBLIC"],
)

constraint_value(
name = "gcc",
constraint_setting = ":compiler",
visibility = ["PUBLIC"],
)

constraint_value(
name = "msvc",
constraint_setting = ":compiler",
visibility = ["PUBLIC"],
)
21 changes: 21 additions & 0 deletions prelude/cpp/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load("@prelude//utils:source_listing.bzl", "source_listing")

oncall("build_infra")

source_listing()

config_setting(
name = "libc++",
constraint_values = [
"//cpp/constraints:libc++",
],
visibility = ["PUBLIC"],
)

config_setting(
name = "libstdc++",
constraint_values = [
"//cpp/constraints:libstdc++",
],
visibility = ["PUBLIC"],
)
24 changes: 24 additions & 0 deletions prelude/cpp/constraints/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
load("@prelude//utils:source_listing.bzl", "source_listing")

oncall("build_infra")

source_listing()

# Used by open source projects to support `prelude//`

constraint_setting(
name = "stdlib",
visibility = ["PUBLIC"],
)

constraint_value(
name = "libc++",
constraint_setting = ":stdlib",
visibility = ["PUBLIC"],
)

constraint_value(
name = "libstdc++",
constraint_setting = ":stdlib",
visibility = ["PUBLIC"],
)
6 changes: 4 additions & 2 deletions prelude/cxx/cxx_executable.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ load(
"cxx_attr_resources",
"cxx_is_gnu",
)
load(":linker.bzl", "wrap_linker_flags")
load(
":cxx_link_utility.bzl",
"executable_shared_lib_arguments",
Expand Down Expand Up @@ -377,9 +378,10 @@ def cxx_executable(ctx: AnalysisContext, impl_params: CxxRuleConstructorParams,
)

# Gather link inputs.
cxx_toolchain_info = get_cxx_toolchain_info(ctx)
own_link_flags = (
get_cxx_toolchain_info(ctx).linker_info.binary_linker_flags +
cxx_attr_linker_flags(ctx) +
cxx_toolchain_info.linker_info.binary_linker_flags +
wrap_linker_flags(cxx_toolchain_info.linker_info.type, cxx_attr_linker_flags(ctx)) +
impl_params.extra_link_flags +
impl_params.extra_exported_link_flags
)
Expand Down
16 changes: 11 additions & 5 deletions prelude/cxx/cxx_library_utility.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ load(
"from_named_set",
)
load(":cxx_context.bzl", "get_cxx_platform_info", "get_cxx_toolchain_info")
load(":linker.bzl", "wrap_linker_flags")
load(
":cxx_toolchain_types.bzl",
"LinkerType",
Expand Down Expand Up @@ -65,15 +66,20 @@ def cxx_attr_linker_flags_all(ctx: AnalysisContext) -> LinkerFlags:
if local_linker_script_flags_attr:
flags.extend(local_linker_script_flags_attr)

post_flags = getattr(ctx.attrs, "post_linker_flags", [])
post_flags = list(getattr(ctx.attrs, "post_linker_flags", []))

exported_flags = cxx_attr_exported_linker_flags(ctx)
exported_post_flags = cxx_attr_exported_post_linker_flags(ctx)

# Wrap linker flags with -Wl, prefix for linker types that use a compiler
# driver (gnu, darwin). This ensures flags like --as-needed, --push-state,
# etc. are properly passed through to the linker.
linker_type = get_cxx_toolchain_info(ctx).linker_info.type
return LinkerFlags(
flags = flags,
post_flags = post_flags,
exported_flags = exported_flags,
exported_post_flags = exported_post_flags,
flags = wrap_linker_flags(linker_type, flags),
post_flags = wrap_linker_flags(linker_type, post_flags),
exported_flags = wrap_linker_flags(linker_type, exported_flags),
exported_post_flags = wrap_linker_flags(linker_type, exported_post_flags),
)

def cxx_attr_exported_linker_flags(ctx: AnalysisContext) -> list[typing.Any]:
Expand Down
22 changes: 22 additions & 0 deletions prelude/cxx/linker.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,28 @@ def get_link_whole_args(linker_type: LinkerType, inputs: list[Artifact]) -> list

return args

def wrap_linker_flags(linker_type: LinkerType, flags: list[typing.Any]) -> list[typing.Any]:
"""
Wrap linker flags with -Wl, prefix for linker types that use a compiler
driver (e.g., clang++, g++) as the linker.

When using a compiler driver as the linker, linker-specific flags must be
prefixed with -Wl, to be passed through to the actual linker. This function
handles that wrapping automatically for gnu and darwin linker types.

Flags already prefixed with -Wl, are left unchanged.
"""
if linker_type not in (LinkerType("gnu"), LinkerType("darwin")):
return flags

result = []
for flag in flags:
if type(flag) == "string" and flag.startswith("-Wl,"):
result.append(flag)
else:
result.append(cmd_args(flag, format = "-Wl,{}"))
return result

def get_objects_as_library_args(linker_type: LinkerType, objects: list[Artifact]) -> list[typing.Any]:
"""
Return linker args used to link the given objects as a library.
Expand Down
13 changes: 13 additions & 0 deletions prelude/distro/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("@prelude//utils:source_listing.bzl", "source_listing")

oncall("build_infra")

source_listing()

config_setting(
name = "conda",
constraint_values = [
"//distro/constraints:conda",
],
visibility = ["PUBLIC"],
)
18 changes: 18 additions & 0 deletions prelude/distro/constraints/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@prelude//utils:source_listing.bzl", "source_listing")

oncall("build_infra")

source_listing()

# Used by open source projects to support `prelude//`

constraint_setting(
name = "distro",
visibility = ["PUBLIC"],
)

constraint_value(
name = "conda",
constraint_setting = ":distro",
visibility = ["PUBLIC"],
)
4 changes: 4 additions & 0 deletions prelude/platforms/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ prelude = native

execution_platform(
name = "default",
abi_configuration = host_configuration.abi,
compiler_configuration = host_configuration.compiler,
cpu_configuration = host_configuration.cpu,
cpp_stdlib_configuration = host_configuration.cpp_stdlib,
distro_configuration = host_configuration.distro,
os_configuration = host_configuration.os,
use_windows_path_separators = host_info().os.is_windows,
visibility = ["PUBLIC"],
Expand Down
Loading
Loading