Skip to content

Commit 7116e76

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 build to work on current rustc stable 1.73+ I had to remove the #![feature(provide_any)] usage. You may need to be on rustc 1.73+ internally to import this successfully 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 7116e76

File tree

6 files changed

+32
-11
lines changed

6 files changed

+32
-11
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/git/git_types/src/lib.rs

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

88
#![feature(error_generic_member_access)]
99
#![feature(iterator_try_reduce)]
10-
#![feature(provide_any)]
1110

1211
pub mod mode;
1312

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

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

88
#![feature(error_generic_member_access)]
9-
#![feature(provide_any)]
109

1110
use std::backtrace::BacktraceStatus;
1211
use std::convert::Infallible;
@@ -21,6 +20,9 @@ use thiserror::Error;
2120
pub mod macro_reexport {
2221
pub use anyhow::anyhow;
2322
}
23+
// The cargo build of anyhow disables its backtrace features when using RUSTC_BOOTSTRAP=1
24+
#[cfg(not(fbcode_build))]
25+
pub static DISABLED: std::backtrace::Backtrace = std::backtrace::Backtrace::disabled();
2426

2527
#[macro_export]
2628
macro_rules! cloneable_error {
@@ -29,9 +31,15 @@ macro_rules! cloneable_error {
2931
pub struct $name(pub ::std::sync::Arc<anyhow::Error>);
3032

3133
impl $name {
34+
#[cfg(fbcode_build)]
3235
pub fn backtrace(&self) -> &::std::backtrace::Backtrace {
3336
self.0.backtrace()
3437
}
38+
39+
#[cfg(not(fbcode_build))]
40+
pub fn backtrace(&self) -> &::std::backtrace::Backtrace {
41+
&$crate::DISABLED
42+
}
3543
}
3644

3745
impl ::std::fmt::Display for $name {
@@ -51,6 +59,7 @@ macro_rules! cloneable_error {
5159
Some(&**self.0)
5260
}
5361

62+
#[cfg(fbcode_build)]
5463
fn provide<'a>(&'a self, demand: &mut ::std::any::Demand<'a>) {
5564
demand.provide_ref::<::std::backtrace::Backtrace>(self.backtrace());
5665
}

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
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
#![feature(error_generic_member_access)]
9-
#![feature(provide_any)]
109
#![feature(trait_alias)]
1110

1211
use std::sync::Arc;

0 commit comments

Comments
 (0)