Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(buck2): allow rustc to use Nix environment when compiling #2266

Merged
merged 1 commit into from
May 31, 2023

Commits on May 31, 2023

  1. fix(buck2): allow rustc to use Nix environment when compiling

    This change enables our project to build using the Nix environment
    running on Linux and macOS platforms.
    
    Background
    ----------
    
    The upstream `rustc_action.py` script which invokes `rustc` filters the
    environment in an effort to maintain a better sandboxed build. When we
    build in a Nix environment (currently used for development and shortly
    in CI), there are several environment variables that cause the correct
    linking behavior under Nix.
    
    The Nix environment provides wrapper scripts for `clang` and `clang++`
    which use these environment variables. The `rustc` program is
    responsible for invoking the linker (by default this tends to be
    `cc`/`clang`) which means these environment variables need to be present
    in the `rustc` process so that its children can inherit them.
    
    The Fix
    -------
    
    While there were many attempts at a solution to this problem, we went
    with a "patch the upstream" approach. In other words, the
    `rustc_action.py` script is what prevents our correct Nix behavior, so
    we slightly augmented it with support for more environment variables.
    This script is provided to us via the upstream
    `facebookincubator/buck2-prelude` Git repository which we currently
    vendor using `git subtree`. This means that our "patch" will be wiped
    out when we re-vendor/update against upstream changes. With this in
    mind, we provide a `third-party/patches/nix_rustc_action.patch` file
    which should allow us to patch over upstream updates similar to upstream
    patching in a packaging system.
    
    Co-authored-by: Nick Gerace <[email protected]>
    Signed-off-by: Fletcher Nichol <[email protected]>
    fnichol and nickgerace committed May 31, 2023
    Configuration menu
    Copy the full SHA
    5866399 View commit details
    Browse the repository at this point in the history