From 470c65bce0f32ae54399ee9c6ed2e81edc801188 Mon Sep 17 00:00:00 2001 From: Ben Rogers Date: Wed, 7 Jan 2026 16:37:30 -0500 Subject: [PATCH 01/10] fix(oss/prelude): wrap linker flags with -Wl, prefix for compiler driver linker types --- prelude/apple/prebuilt_apple_framework.bzl | 4 +++- prelude/cxx/cxx_executable.bzl | 6 ++++-- prelude/cxx/cxx_library_utility.bzl | 16 +++++++++++----- prelude/cxx/linker.bzl | 22 ++++++++++++++++++++++ 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/prelude/apple/prebuilt_apple_framework.bzl b/prelude/apple/prebuilt_apple_framework.bzl index 3d199ad2f5025..f89215b94f6ae 100644 --- a/prelude/apple/prebuilt_apple_framework.bzl +++ b/prelude/apple/prebuilt_apple_framework.bzl @@ -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", @@ -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) diff --git a/prelude/cxx/cxx_executable.bzl b/prelude/cxx/cxx_executable.bzl index b905aea167290..8468cd67b22f4 100644 --- a/prelude/cxx/cxx_executable.bzl +++ b/prelude/cxx/cxx_executable.bzl @@ -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", @@ -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 ) diff --git a/prelude/cxx/cxx_library_utility.bzl b/prelude/cxx/cxx_library_utility.bzl index 279da767f93a6..85befc29dc334 100644 --- a/prelude/cxx/cxx_library_utility.bzl +++ b/prelude/cxx/cxx_library_utility.bzl @@ -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", @@ -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]: diff --git a/prelude/cxx/linker.bzl b/prelude/cxx/linker.bzl index f6eb8166cf89f..9c4ea94277499 100644 --- a/prelude/cxx/linker.bzl +++ b/prelude/cxx/linker.bzl @@ -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. From 08638878ae28c997dc21afb2213b23cdeb3109a4 Mon Sep 17 00:00:00 2001 From: Ben Rogers Date: Wed, 7 Jan 2026 16:39:52 -0500 Subject: [PATCH 02/10] fix(oss/prelude): constraints for build_mode, distro, cpp stdlib, and libgcc --- prelude/build_mode/constraints/BUCK | 36 +++++++++++++++++++++ prelude/cpp/BUCK | 21 ++++++++++++ prelude/cpp/constraints/BUCK | 24 ++++++++++++++ prelude/distro/BUCK | 13 ++++++++ prelude/distro/constraints/BUCK | 18 +++++++++++ prelude/platforms/BUCK | 2 ++ prelude/platforms/defs.bzl | 25 ++++++++++++++ prelude/third-party/libgcc/BUCK | 13 ++++++++ prelude/third-party/libgcc/constraints/BUCK | 18 +++++++++++ 9 files changed, 170 insertions(+) create mode 100644 prelude/build_mode/constraints/BUCK create mode 100644 prelude/cpp/BUCK create mode 100644 prelude/cpp/constraints/BUCK create mode 100644 prelude/distro/BUCK create mode 100644 prelude/distro/constraints/BUCK create mode 100644 prelude/third-party/libgcc/BUCK create mode 100644 prelude/third-party/libgcc/constraints/BUCK diff --git a/prelude/build_mode/constraints/BUCK b/prelude/build_mode/constraints/BUCK new file mode 100644 index 0000000000000..35054ccc1b84b --- /dev/null +++ b/prelude/build_mode/constraints/BUCK @@ -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"], +) diff --git a/prelude/cpp/BUCK b/prelude/cpp/BUCK new file mode 100644 index 0000000000000..6c39e69f311b4 --- /dev/null +++ b/prelude/cpp/BUCK @@ -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"], +) diff --git a/prelude/cpp/constraints/BUCK b/prelude/cpp/constraints/BUCK new file mode 100644 index 0000000000000..85c49693204aa --- /dev/null +++ b/prelude/cpp/constraints/BUCK @@ -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"], +) diff --git a/prelude/distro/BUCK b/prelude/distro/BUCK new file mode 100644 index 0000000000000..cb21eed5490ff --- /dev/null +++ b/prelude/distro/BUCK @@ -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"], +) diff --git a/prelude/distro/constraints/BUCK b/prelude/distro/constraints/BUCK new file mode 100644 index 0000000000000..391db1ec99da4 --- /dev/null +++ b/prelude/distro/constraints/BUCK @@ -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"], +) diff --git a/prelude/platforms/BUCK b/prelude/platforms/BUCK index f0c38c459bac7..b51bd4739560a 100644 --- a/prelude/platforms/BUCK +++ b/prelude/platforms/BUCK @@ -12,6 +12,8 @@ prelude = native execution_platform( name = "default", 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"], diff --git a/prelude/platforms/defs.bzl b/prelude/platforms/defs.bzl index c19f6686bb5b1..e81851400bc59 100644 --- a/prelude/platforms/defs.bzl +++ b/prelude/platforms/defs.bzl @@ -10,6 +10,10 @@ def _execution_platform_impl(ctx: AnalysisContext) -> list[Provider]: constraints = dict() constraints.update(ctx.attrs.cpu_configuration[ConfigurationInfo].constraints) constraints.update(ctx.attrs.os_configuration[ConfigurationInfo].constraints) + if ctx.attrs.cpp_stdlib_configuration: + constraints.update(ctx.attrs.cpp_stdlib_configuration[ConfigurationInfo].constraints) + if ctx.attrs.distro_configuration: + constraints.update(ctx.attrs.distro_configuration[ConfigurationInfo].constraints) cfg = ConfigurationInfo(constraints = constraints, values = {}) name = ctx.label.raw_target() @@ -34,6 +38,8 @@ execution_platform = rule( impl = _execution_platform_impl, attrs = { "cpu_configuration": attrs.dep(providers = [ConfigurationInfo]), + "cpp_stdlib_configuration": attrs.option(attrs.dep(providers = [ConfigurationInfo]), default = None), + "distro_configuration": attrs.option(attrs.dep(providers = [ConfigurationInfo]), default = None), "os_configuration": attrs.dep(providers = [ConfigurationInfo]), "use_windows_path_separators": attrs.bool(), }, @@ -61,7 +67,26 @@ def _host_os_configuration() -> str: else: return "prelude//os:linux" +def _host_cpp_stdlib_configuration() -> str: + os = host_info().os + # macOS defaults to libc++ + if os.is_macos: + return "prelude//cpp:libc++" + # For other platforms, default to libstdc++ + # (Windows and Linux both default to libstdc++ - on Windows this represents + # the general C++ stdlib concept, on Linux it's typically the actual libstdc++) + else: + return "prelude//cpp:libstdc++" + +def _host_distro_configuration() -> str | None: + # Check if running in a conda environment + if read_root_config("env", "CONDA_PREFIX"): + return "prelude//distro:conda" + return None + host_configuration = struct( cpu = _host_cpu_configuration(), os = _host_os_configuration(), + cpp_stdlib = _host_cpp_stdlib_configuration(), + distro = _host_distro_configuration(), ) diff --git a/prelude/third-party/libgcc/BUCK b/prelude/third-party/libgcc/BUCK new file mode 100644 index 0000000000000..edc58c3f6e86f --- /dev/null +++ b/prelude/third-party/libgcc/BUCK @@ -0,0 +1,13 @@ +load("@prelude//utils:source_listing.bzl", "source_listing") + +oncall("build_infra") + +source_listing() + +config_setting( + name = "11.x", + constraint_values = [ + "//third-party/libgcc/constraints:11.x", + ], + visibility = ["PUBLIC"], +) diff --git a/prelude/third-party/libgcc/constraints/BUCK b/prelude/third-party/libgcc/constraints/BUCK new file mode 100644 index 0000000000000..fee0e123942e3 --- /dev/null +++ b/prelude/third-party/libgcc/constraints/BUCK @@ -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 = "libgcc", + visibility = ["PUBLIC"], +) + +constraint_value( + name = "11.x", + constraint_setting = ":libgcc", + visibility = ["PUBLIC"], +) From 85167d84569ae39c4ba98861f917abbdb0f8d813 Mon Sep 17 00:00:00 2001 From: Ben Rogers Date: Wed, 7 Jan 2026 16:41:07 -0500 Subject: [PATCH 03/10] fix(oss/prelude): constraints for abi and compiler --- prelude/compiler/BUCK | 37 +++++++++++++++++++++++++++++++ prelude/compiler/constraints/BUCK | 36 ++++++++++++++++++++++++++++++ prelude/platforms/BUCK | 2 ++ prelude/platforms/defs.bzl | 24 ++++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 prelude/compiler/BUCK create mode 100644 prelude/compiler/constraints/BUCK diff --git a/prelude/compiler/BUCK b/prelude/compiler/BUCK new file mode 100644 index 0000000000000..965cbf87760b2 --- /dev/null +++ b/prelude/compiler/BUCK @@ -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"], +) diff --git a/prelude/compiler/constraints/BUCK b/prelude/compiler/constraints/BUCK new file mode 100644 index 0000000000000..dc2f3c20059e4 --- /dev/null +++ b/prelude/compiler/constraints/BUCK @@ -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"], +) diff --git a/prelude/platforms/BUCK b/prelude/platforms/BUCK index b51bd4739560a..2b3ccb6a40881 100644 --- a/prelude/platforms/BUCK +++ b/prelude/platforms/BUCK @@ -11,6 +11,8 @@ 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, diff --git a/prelude/platforms/defs.bzl b/prelude/platforms/defs.bzl index e81851400bc59..48dbaab031a89 100644 --- a/prelude/platforms/defs.bzl +++ b/prelude/platforms/defs.bzl @@ -14,6 +14,10 @@ def _execution_platform_impl(ctx: AnalysisContext) -> list[Provider]: constraints.update(ctx.attrs.cpp_stdlib_configuration[ConfigurationInfo].constraints) if ctx.attrs.distro_configuration: constraints.update(ctx.attrs.distro_configuration[ConfigurationInfo].constraints) + if ctx.attrs.compiler_configuration: + constraints.update(ctx.attrs.compiler_configuration[ConfigurationInfo].constraints) + if ctx.attrs.abi_configuration: + constraints.update(ctx.attrs.abi_configuration[ConfigurationInfo].constraints) cfg = ConfigurationInfo(constraints = constraints, values = {}) name = ctx.label.raw_target() @@ -37,6 +41,8 @@ def _execution_platform_impl(ctx: AnalysisContext) -> list[Provider]: execution_platform = rule( impl = _execution_platform_impl, attrs = { + "abi_configuration": attrs.option(attrs.dep(providers = [ConfigurationInfo]), default = None), + "compiler_configuration": attrs.option(attrs.dep(providers = [ConfigurationInfo]), default = None), "cpu_configuration": attrs.dep(providers = [ConfigurationInfo]), "cpp_stdlib_configuration": attrs.option(attrs.dep(providers = [ConfigurationInfo]), default = None), "distro_configuration": attrs.option(attrs.dep(providers = [ConfigurationInfo]), default = None), @@ -84,7 +90,25 @@ def _host_distro_configuration() -> str | None: return "prelude//distro:conda" return None +def _host_compiler_configuration() -> str: + os = host_info().os + if os.is_windows: + return "prelude//compiler:msvc" + else: + # macOS and Linux default to clang + return "prelude//compiler:clang" + +def _host_abi_configuration() -> str: + os = host_info().os + if os.is_windows: + return "prelude//abi:msvc" + else: + # macOS and Linux default to gnu ABI + return "prelude//abi:gnu" + host_configuration = struct( + abi = _host_abi_configuration(), + compiler = _host_compiler_configuration(), cpu = _host_cpu_configuration(), os = _host_os_configuration(), cpp_stdlib = _host_cpp_stdlib_configuration(), From e50ca5c4f020a87490d924250675ce47613f0b1d Mon Sep 17 00:00:00 2001 From: Ben Rogers Date: Wed, 7 Jan 2026 16:41:39 -0500 Subject: [PATCH 04/10] fix(oss/prelude): Use libc++ for clang targets on both macos and linux --- prelude/platforms/defs.bzl | 9 ++++----- prelude/toolchains/cxx.bzl | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/prelude/platforms/defs.bzl b/prelude/platforms/defs.bzl index 48dbaab031a89..195fadabf5c9d 100644 --- a/prelude/platforms/defs.bzl +++ b/prelude/platforms/defs.bzl @@ -75,13 +75,12 @@ def _host_os_configuration() -> str: def _host_cpp_stdlib_configuration() -> str: os = host_info().os - # macOS defaults to libc++ - if os.is_macos: + + if os.is_macos or os.is_linux: + # macOS and Linux default to libc++ (works better with clang) return "prelude//cpp:libc++" - # For other platforms, default to libstdc++ - # (Windows and Linux both default to libstdc++ - on Windows this represents - # the general C++ stdlib concept, on Linux it's typically the actual libstdc++) else: + # Windows defaults to libstdc++ (represents the general C++ stdlib concept) return "prelude//cpp:libstdc++" def _host_distro_configuration() -> str | None: diff --git a/prelude/toolchains/cxx.bzl b/prelude/toolchains/cxx.bzl index ec8e45c41e7a7..74f6d814b74b0 100644 --- a/prelude/toolchains/cxx.bzl +++ b/prelude/toolchains/cxx.bzl @@ -95,7 +95,19 @@ def _cxx_tools_info_toolchain_impl(ctx: AnalysisContext): def _cxx_toolchain_from_cxx_tools_info(ctx: AnalysisContext, cxx_tools_info: CxxToolsInfo, target_name = "x86_64"): os = ctx.attrs._target_os_type[OsLookup].os archiver_supports_argfiles = os != Os("macos") - additional_linker_flags = ["-fuse-ld=lld"] if os == Os("linux") and cxx_tools_info.linker != "g++" and cxx_tools_info.cxx_compiler != "g++" else [] + + # Determine stdlib-specific flags for clang + stdlib_compiler_flags = [] + stdlib_linker_flags = [] + is_clang = cxx_tools_info.compiler_type == "clang" + if is_clang and (os == Os("linux") or os == Os("macos")): + stdlib_compiler_flags = ["-stdlib=libc++"] + stdlib_linker_flags = ["-stdlib=libc++"] + + additional_linker_flags = [] + if os == Os("linux") and cxx_tools_info.linker != "g++" and cxx_tools_info.cxx_compiler != "g++": + additional_linker_flags.append("-fuse-ld=lld") + additional_linker_flags.extend(stdlib_linker_flags) if os == Os("windows"): linker_type = LinkerType("windows") @@ -187,7 +199,7 @@ def _cxx_toolchain_from_cxx_tools_info(ctx: AnalysisContext, cxx_tools_info: Cxx cxx_compiler_info = CxxCompilerInfo( compiler = _run_info(cxx_tools_info.cxx_compiler), preprocessor_flags = [], - compiler_flags = ctx.attrs.cxx_flags, + compiler_flags = stdlib_compiler_flags + ctx.attrs.cxx_flags, compiler_type = cxx_tools_info.compiler_type, supports_two_phase_compilation = supports_two_phase_compilation, supports_content_based_paths = ctx.attrs.supports_content_based_paths, @@ -195,7 +207,7 @@ def _cxx_toolchain_from_cxx_tools_info(ctx: AnalysisContext, cxx_tools_info: Cxx c_compiler_info = CCompilerInfo( compiler = _run_info(cxx_tools_info.compiler), preprocessor_flags = [], - compiler_flags = ctx.attrs.c_flags, + compiler_flags = stdlib_compiler_flags + ctx.attrs.c_flags, compiler_type = cxx_tools_info.compiler_type, supports_content_based_paths = ctx.attrs.supports_content_based_paths, ), From 3a432269e0895391ea9c076d936ca20dafef162d Mon Sep 17 00:00:00 2001 From: Ben Rogers Date: Mon, 8 Dec 2025 22:18:48 -0500 Subject: [PATCH 05/10] fix: cargo rerun-if-changed to detect new prelude files --- app/buck2_external_cells_bundled/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/buck2_external_cells_bundled/build.rs b/app/buck2_external_cells_bundled/build.rs index 7320b245a3890..faf7e6d55e80a 100644 --- a/app/buck2_external_cells_bundled/build.rs +++ b/app/buck2_external_cells_bundled/build.rs @@ -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; } From 9865b1683239861cebb7cabe40e61e0b6d656140 Mon Sep 17 00:00:00 2001 From: Ben Rogers Date: Mon, 8 Dec 2025 22:18:48 -0500 Subject: [PATCH 06/10] fix: using `clone` on type `Duration` which implements the `Copy` trait --- app/buck2_build_signals_impl/src/enhancement.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/buck2_build_signals_impl/src/enhancement.rs b/app/buck2_build_signals_impl/src/enhancement.rs index 77e643eea098d..fabea8ba9abb0 100644 --- a/app/buck2_build_signals_impl/src/enhancement.rs +++ b/app/buck2_build_signals_impl/src/enhancement.rs @@ -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), From b0eb420c10d98d2d95ad16fb9a6d857b181b9e13 Mon Sep 17 00:00:00 2001 From: Ben Rogers Date: Mon, 8 Dec 2025 22:18:48 -0500 Subject: [PATCH 07/10] fix(oss): Update rand revision in Cargo.toml to match internal --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c4387f8053a7b..07a84e062308b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" From 99b4dcc0409923030f171b9d95e66860f328ece3 Mon Sep 17 00:00:00 2001 From: Ben Rogers Date: Mon, 8 Dec 2025 22:18:48 -0500 Subject: [PATCH 08/10] fix(oss): range.gen_range() is deprecated --- app/buck2_critical_path/src/test_utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/buck2_critical_path/src/test_utils.rs b/app/buck2_critical_path/src/test_utils.rs index e8601b5b86d97..08f4b70e1cafb 100644 --- a/app/buck2_critical_path/src/test_utils.rs +++ b/app/buck2_critical_path/src/test_utils.rs @@ -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(), From 78e423468a0f842e0f21daf9a47e84813e3938b1 Mon Sep 17 00:00:00 2001 From: Ben Rogers Date: Mon, 8 Dec 2025 22:18:48 -0500 Subject: [PATCH 09/10] fix(oss): buck2_build_api requires setsketch --- app/buck2_build_api/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/buck2_build_api/Cargo.toml b/app/buck2_build_api/Cargo.toml index 2276da035b708..0272bb8280d9a 100644 --- a/app/buck2_build_api/Cargo.toml +++ b/app/buck2_build_api/Cargo.toml @@ -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 } From 0d466176fb1fad1e48a2fa688665d2a5cc06752c Mon Sep 17 00:00:00 2001 From: Ben Rogers Date: Mon, 8 Dec 2025 22:18:48 -0500 Subject: [PATCH 10/10] hack: bump time limit to make non-deterministic test less flaky --- dice/dice/src/impls/worker/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dice/dice/src/impls/worker/tests.rs b/dice/dice/src/impls/worker/tests.rs index bb27cfea3bcd1..fd9fc898327eb 100644 --- a/dice/dice/src/impls/worker/tests.rs +++ b/dice/dice/src/impls/worker/tests.rs @@ -1371,7 +1371,7 @@ async fn _run_cancellation_caching_test( // Ensure that the time it took to run the test is expected match cancel_type { CancelType::Sync | CancelType::ASync => { - let limit = (FIRST_COMPUTE_MS as f64) * 0.05 + (CANCELLATION_WAIT_MS as f64) * 1.05; + let limit = (FIRST_COMPUTE_MS as f64) * 0.05 + (CANCELLATION_WAIT_MS as f64) * 2.0; assert!(elapsed_ms < limit as u64); } CancelType::NotCancelled => {