Skip to content

Add Build::build_for_host #1861

Description

@tgross35

Some C libraries need you to build and run small C programs on the host as part of a prepare step. It would be nice if you could use cc for this, but the problem is a lot of build setups seem to use unsuffixed CC for the target's cross compiler - so setting .target(&env::var("HOST").unwrap()) means you'll get the wrong compiler.

Proposal:

impl Build {
    fn build_for_host(host: bool) -> &mut Build;
}

If true, all other functions would ignore CC and TARGET_CC. There could be more checks as well like panicking if you try to set .target(...), though that doesn't seem necessary.

Basically I'd like this test to emit my-cc-only-for-aarch64 then cc, rather than my-cc-only-for-aarch64 both times https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=addf8301e9aa9181539c10fb17ff0804.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions