fix(oss-build): allow nightly features on stable via RUSTC_BOOTSTRAP - #1365
fix(oss-build): allow nightly features on stable via RUSTC_BOOTSTRAP#1365vegerot wants to merge 1 commit into
Conversation
make oss failed on stable Rust 1.97.1 with:
error[E0554]: #![feature] may not be used on stable
--> smallvec-1.15.2/src/lib.rs:95: specialization
and 8 crates using #![feature(once_cell_try)]
Buck builds use a nightly toolchain internally and handle this,
but cargo oss builds use stable rustc by default.
Cargo.toml files are @generated by autocargo from BUCK files,
so we should not hand-edit them to remove the features.
Setting RUSTC_BOOTSTRAP=1 in build.py's cargo_env allows stable
cargo/rustc to accept these nightly features without requiring
users to install a nightly toolchain or override.
Fixes: cd eden/scm && make -j oss
There was a problem hiding this comment.
Pull request overview
This PR adjusts Sapling’s OSS cargo build environment so stable Rust can compile dependencies that use nightly-only #![feature] gates, avoiding requiring a nightly toolchain for make oss.
Changes:
- Set
RUSTC_BOOTSTRAP=1(if not already set) incargo_env()to allow compiling crates that require nightly features during OSS cargo builds.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This pull request has been imported. If you are a Meta employee, you can view this in D113135919. (Because this pull request was imported automatically, there will not be any future comments.) |
…n in Ghostty
Summary:
When running under Ghostty (and cmux which uses libghostty) outside of tmux,
eden/scm's internal pager and interactive commit UI did not register any
Shift-modified key.
Root cause:
- `termwiz` `UnixTerminal::set_raw_mode()` enables `modifyOtherKeys=2` (`ESC[>4;2m`).
- Ghostty's `key_encode.zig` correctly implements this: `Shift+G` is sent as
`ESC[27;2;71~` (where 71 is uppercase G) and `Shift+@` as `ESC[27;2;64~`.
- `termwiz` `InputParser` decodes these as `Char('G')+SHIFT` and `Char('@')+SHIFT`.
Two separate code paths were affected:
1. **streampager** (Rust, used by `sl log` etc.):
The keymap stores `'G'` as `(NONE, Char('G'))`. The lookup used exact
modifier match, so `(SHIFT, Char('G'))` never matched — `G` was silently dropped.
2. **curses_compat** (Python, used by `sl commit --interactive` / crecord):
`curses_compat.py:getch()` only handled `Modifiers.NONE` and `Modifiers.CTRL`.
When `SHIFT` was set, it fell through to `return -1`, silently dropping the key
so `A` (toggle all), `G`, `J`, `H`, `F` etc. did not work.
Additionally, the CTRL check used `Modifiers.CTRL or Modifiers.RIGHT_CTRL` (Python
`or` always evaluates to `Modifiers.CTRL`); fixed to use bitwise `|` with `&`.
tmux masks this because `send-keys -l` sends plain `0x47` (`G+NONE`). Raw hex
injection via tmux reproduces the bug:
```
tmux send-keys -H '1b5b32373b323b37317e' # ESC[27;2;71~ Shift+G
```
Old `sl` stays at top, new `sl` goes to bottom.
Fix:
Strip the SHIFT modifier and retry the lookup:
1. **streampager**: In `Screen::dispatch_key` and `Prompt::dispatch_key`, build a
candidate list that includes the original key plus a SHIFT-stripped variant, then
try each against the keymap/prompt match. `modifyOtherKeys=2` already sends the
shifted character (uppercase), so stripping SHIFT is sufficient.
2. **curses_compat**: In `getch()`, add a `modifiers & SHIFT` branch that returns
`ord(ch.upper())`. Also fix the CTRL modifier check from `or` to bitwise `|`.
Test Plan:
- `make oss` - builds (but requires facebook#1365)
- tmux test:
```bash
tmux new -d -s t; tmux send-keys -t t './out/sl log -l 5000 --pager=always'
# Check plain G goes to bottom, g to top.
tmux send-keys -t t -H '1b5b32373b323b37317e' # Shift+G Ghostty modifyOtherKeys
# => now goes to bottom (was stuck at top)
tmux send-keys -t t -l '/' ; send -H '1b5b32373b323b36347e' # Shift+@ in prompt
# => now shows Search: @ (was empty)
```
Verified old `/usr/local/bin/sl` fails, new `out/sl` passes.
- `cargo test -p sapling-streampager` still 5 passed.
- `python tests/run-tests.py tests/test-commit-interactive-curses.t` passes.
- Manual in Ghostty.app outside tmux: `G` jumps to bottom, `/` `@` search works,
capital letters searchable (previously broken). `sl commit --interactive` `A`
toggles all files (previously broken).
Fixes facebook#1363
Co-authored-by: Opencode <opencode@anomalyco.dev>
…n in Ghostty
Summary:
When running under Ghostty (and cmux which uses libghostty) outside of tmux,
eden/scm's internal pager and interactive commit UI did not register any
Shift-modified key.
Root cause:
- `termwiz` `UnixTerminal::set_raw_mode()` enables `modifyOtherKeys=2` (`ESC[>4;2m`).
- Ghostty's `key_encode.zig` correctly implements this: `Shift+G` is sent as
`ESC[27;2;71~` (where 71 is uppercase G) and `Shift+@` as `ESC[27;2;64~`.
- `termwiz` `InputParser` decodes these as `Char('G')+SHIFT` and `Char('@')+SHIFT`.
Two separate code paths were affected:
1. **streampager** (Rust, used by `sl log` etc.):
The keymap stores `'G'` as `(NONE, Char('G'))`. The lookup used exact
modifier match, so `(SHIFT, Char('G'))` never matched — `G` was silently dropped.
2. **curses_compat** (Python, used by `sl commit --interactive` / crecord):
`curses_compat.py:getch()` only handled `Modifiers.NONE` and `Modifiers.CTRL`.
When `SHIFT` was set, it fell through to `return -1`, silently dropping the key
so `A` (toggle all), `G`, `J`, `H`, `F` etc. did not work.
Additionally, the CTRL check used `Modifiers.CTRL or Modifiers.RIGHT_CTRL` (Python
`or` always evaluates to `Modifiers.CTRL`); fixed to use bitwise `|` with `&`.
tmux masks this because `send-keys -l` sends plain `0x47` (`G+NONE`). Raw hex
injection via tmux reproduces the bug:
```
tmux send-keys -H '1b5b32373b323b37317e' # ESC[27;2;71~ Shift+G
```
Old `sl` stays at top, new `sl` goes to bottom.
Fix:
Strip the SHIFT modifier and retry the lookup:
1. **streampager**: In `Screen::dispatch_key` and `Prompt::dispatch_key`, build a
candidate list that includes the original key plus a SHIFT-stripped variant, then
try each against the keymap/prompt match. `modifyOtherKeys=2` already sends the
shifted character (uppercase), so stripping SHIFT is sufficient.
2. **curses_compat**: In `getch()`, add a `modifiers & SHIFT` branch that returns
`ord(ch.upper())`. Also fix the CTRL modifier check from `or` to bitwise `|`.
Test Plan:
- `make oss` - builds (but requires facebook#1365)
- tmux test:
```bash
tmux new -d -s t; tmux send-keys -t t './out/sl log -l 5000 --pager=always'
# Check plain G goes to bottom, g to top.
tmux send-keys -t t -H '1b5b32373b323b37317e' # Shift+G Ghostty modifyOtherKeys
# => now goes to bottom (was stuck at top)
tmux send-keys -t t -l '/' ; send -H '1b5b32373b323b36347e' # Shift+@ in prompt
# => now shows Search: @ (was empty)
```
Verified old `/usr/local/bin/sl` fails, new `out/sl` passes.
- `cargo test -p sapling-streampager` still 5 passed.
- `python tests/run-tests.py tests/test-commit-interactive-curses.t` passes.
- Manual in Ghostty.app outside tmux: `G` jumps to bottom, `/` `@` search works,
capital letters searchable (previously broken). `sl commit --interactive` `A`
toggles all files (previously broken).
Fixes facebook#1363
Co-authored-by: Opencode <opencode@anomalyco.dev>
|
According to https://doc.rust-lang.org/beta/unstable-book/compiler-environment-variables/RUSTC_BOOTSTRAP.html
Part of the codebase is published on crates.io. While this env var solves the Sapling binary build, it will force downstream users of the Sapling libraries to use nightly, which is undesirable. I've sent diffs internally to avoid the nightly features. |
|
@quark-zju thanks! I'll close this PR when the other fix lands 🙂 |
make oss failed on stable Rust 1.97.1 with:
error[E0554]: #![feature] may not be used on stable
--> smallvec-1.15.2/src/lib.rs:95: specialization
and 8 crates using #![feature(once_cell_try)]
Buck builds use a nightly toolchain internally and handle this,
but cargo oss builds use stable rustc by default.
Cargo.toml files are @generated by autocargo from BUCK files,
so we should not hand-edit them to remove the features.
Setting RUSTC_BOOTSTRAP=1 in build.py's cargo_env allows stable
cargo/rustc to accept these nightly features without requiring
users to install a nightly toolchain or override.
Fixes: cd eden/scm && make -j oss