Skip to content

Commit 0bf9914

Browse files
committed
fix mononoke build
Makes usage of anyhow::Error::backtrace() conditional on fbcode_build. This is necessary because the cargo build of anyhow disables its backtrace features when using RUSTC_BOOTSTRAP=1 For oss cargo build to work on current rustc stable 1.73+ I hid the #![feature(provide_any)] usage by making it condition on fbcode_build. Test plan: local build with `./build/fbcode_builder/getdeps.py --allow-system-packages build --src-dir=. mononoke` github CI, done by regenerating the mononoke github actions with: `./build/fbcode_builder/getdeps.py --allow-system-packages generate-github-actions --free-up-disk --src-dir=. --output-dir=.github/workflows --job-name="Mononoke " --job-file-prefix=mononoke_ mononoke` Before, broken After, works
1 parent 317ae34 commit 0bf9914

File tree

7 files changed

+36
-12
lines changed

7 files changed

+36
-12
lines changed

.github/workflows/mononoke_linux.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ on:
1010
branches:
1111
- main
1212

13+
permissions:
14+
contents: read # to fetch code (actions/checkout)
15+
1316
jobs:
1417
build:
1518
runs-on: ubuntu-20.04
1619
steps:
17-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v4
1821
- name: Show disk space at start
1922
run: df -h
2023
- name: Free up disk space
@@ -25,10 +28,10 @@ jobs:
2528
run: sudo apt-get update
2629
- name: Install system deps
2730
run: sudo python3 build/fbcode_builder/getdeps.py --allow-system-packages install-system-deps --recursive mononoke
31+
- name: Install packaging system deps
32+
run: sudo python3 build/fbcode_builder/getdeps.py --allow-system-packages install-system-deps --recursive patchelf
2833
- name: Install Rust Stable
2934
uses: dtolnay/rust-toolchain@stable
30-
- name: Fetch lld
31-
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests lld
3235
- name: Fetch ninja
3336
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests ninja
3437
- name: Fetch cmake
@@ -89,8 +92,6 @@ jobs:
8992
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests fb303
9093
- name: Fetch rust-shed
9194
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages fetch --no-tests rust-shed
92-
- name: Build lld
93-
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests lld
9495
- name: Build ninja
9596
run: python3 build/fbcode_builder/getdeps.py --allow-system-packages build --free-up-disk --no-tests ninja
9697
- name: Build cmake

.github/workflows/mononoke_mac.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ on:
1010
branches:
1111
- main
1212

13+
permissions:
14+
contents: read # to fetch code (actions/checkout)
15+
1316
jobs:
1417
build:
1518
runs-on: macOS-latest
1619
steps:
17-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v4
1821
- name: Show disk space at start
1922
run: df -h
2023
- name: Free up disk space

eden/mononoke/commit_rewriting/mononoke_x_repo_sync_job/src/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ async fn check_if_independent_branch_and_return(
523523
.commit_graph()
524524
.ancestors_difference_stream(ctx, branch_tips.clone(), other_branches)
525525
.await?
526-
.map_ok({ move |cs| async move { Ok(cs.load(ctx, blobstore).await?) } })
526+
.map_ok(move |cs| async move { Ok(cs.load(ctx, blobstore).await?) })
527527
.try_buffered(100)
528528
.try_collect::<Vec<_>>()
529529
.await?;

eden/mononoke/git/git_types/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#![feature(error_generic_member_access)]
99
#![feature(iterator_try_reduce)]
10-
#![feature(provide_any)]
10+
#![cfg_attr(fbcode_build, feature(provide_any))]
1111

1212
pub mod mode;
1313

eden/mononoke/megarepo_api/megarepo_error/src/lib.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
#![feature(error_generic_member_access)]
9-
#![feature(provide_any)]
9+
#![cfg_attr(fbcode_build, feature(provide_any))]
1010

1111
use std::backtrace::BacktraceStatus;
1212
use std::convert::Infallible;
@@ -21,6 +21,9 @@ use thiserror::Error;
2121
pub mod macro_reexport {
2222
pub use anyhow::anyhow;
2323
}
24+
// The cargo build of anyhow disables its backtrace features when using RUSTC_BOOTSTRAP=1
25+
#[cfg(not(fbcode_build))]
26+
pub static DISABLED: std::backtrace::Backtrace = std::backtrace::Backtrace::disabled();
2427

2528
#[macro_export]
2629
macro_rules! cloneable_error {
@@ -29,9 +32,15 @@ macro_rules! cloneable_error {
2932
pub struct $name(pub ::std::sync::Arc<anyhow::Error>);
3033

3134
impl $name {
35+
#[cfg(fbcode_build)]
3236
pub fn backtrace(&self) -> &::std::backtrace::Backtrace {
3337
self.0.backtrace()
3438
}
39+
40+
#[cfg(not(fbcode_build))]
41+
pub fn backtrace(&self) -> &::std::backtrace::Backtrace {
42+
&$crate::DISABLED
43+
}
3544
}
3645

3746
impl ::std::fmt::Display for $name {
@@ -51,6 +60,7 @@ macro_rules! cloneable_error {
5160
Some(&**self.0)
5261
}
5362

63+
#[cfg(fbcode_build)]
5464
fn provide<'a>(&'a self, demand: &mut ::std::any::Demand<'a>) {
5565
demand.provide_ref::<::std::backtrace::Backtrace>(self.backtrace());
5666
}

eden/mononoke/mononoke_api/src/errors.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* GNU General Public License version 2.
66
*/
77

8-
use std::any::Demand;
98
use std::backtrace::Backtrace;
109
use std::convert::Infallible;
1110
use std::error::Error as StdError;
@@ -30,10 +29,20 @@ use crate::path::MononokePath;
3029
#[derive(Clone, Debug)]
3130
pub struct InternalError(Arc<Error>);
3231

32+
// The cargo build of anyhow disables its backtrace features when using RUSTC_BOOTSTRAP=1
33+
#[cfg(not(fbcode_build))]
34+
static DISABLED: Backtrace = Backtrace::disabled();
35+
3336
impl InternalError {
37+
#[cfg(fbcode_build)]
3438
pub fn backtrace(&self) -> &Backtrace {
3539
self.0.backtrace()
3640
}
41+
42+
#[cfg(not(fbcode_build))]
43+
pub fn backtrace(&self) -> &Backtrace {
44+
&DISABLED
45+
}
3746
}
3847

3948
impl fmt::Display for InternalError {
@@ -53,7 +62,8 @@ impl StdError for InternalError {
5362
Some(&**self.0)
5463
}
5564

56-
fn provide<'a>(&'a self, demand: &mut Demand<'a>) {
65+
#[cfg(fbcode_build)]
66+
fn provide<'a>(&'a self, demand: &mut ::std::any::Demand<'a>) {
5767
demand.provide_ref::<Backtrace>(self.backtrace());
5868
}
5969
}

eden/mononoke/mononoke_api/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
#![feature(error_generic_member_access)]
9-
#![feature(provide_any)]
9+
#![cfg_attr(fbcode_build, feature(provide_any))]
1010
#![feature(trait_alias)]
1111

1212
use std::sync::Arc;

0 commit comments

Comments
 (0)