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

Tracking Issue for host-config #9452

Open
jameshilliard opened this issue May 3, 2021 · 3 comments
Open

Tracking Issue for host-config #9452

jameshilliard opened this issue May 3, 2021 · 3 comments
Labels
C-tracking-issue Category: A tracking issue for something unstable. S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. S-waiting-on-feedback Status: An implemented feature is waiting on community feedback for bugs or design concerns. Z-host-config Nightly: host-config

Comments

@jameshilliard
Copy link
Contributor

jameshilliard commented May 3, 2021

Summary

Original issue: #3349
Implementation: #9322
Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#host-config
Issues: Z-host-config Nightly: host-config

The host key in a config file can be used pass flags to host build targets such as build scripts that must run on the host system instead of the target system when cross compiling. It supports both generic and host arch specific tables. Matching host arch tables take precedence over generic host tables.

@jameshilliard jameshilliard added the C-tracking-issue Category: A tracking issue for something unstable. label May 3, 2021
@Nemo157
Copy link
Member

Nemo157 commented Dec 14, 2021

I'm attempting to use this to fix rust-lang/docs.rs#1580 by setting the configured rustc-args for all the target and host builds, using this command I expected to see the --cfg procmacro2_semver_exempt make it through to the build_script_build rustc invocation, but it doesn't appear to, am I misunderstanding this feature or is something going wrong here?

cargo rustdoc -vv \
--target x86_64-unknown-linux-gnu \
--config 'build.rustflags=["--cfg", "procmacro2_semver_exempt"]' \
--config 'host.rustflags=["--cfg", "procmacro2_semver_exempt"]' \
-Zhost-config -Ztarget-applies-to-host -Zunstable-options \
-- --cfg procmacro2_semver_exempt --cfg doc_cfg

@Nemo157
Copy link
Member

Nemo157 commented Dec 14, 2021

It looks like rustflags are still being explicitly excluded from all build-scripts, it seems like this feature should change this to read from the host.rustflags (and target specific subtables):

if requested_kinds != [CompileKind::Host] && kind.is_host() {
// This is probably a build script or plugin and we're
// compiling with --target. In this scenario there are
// no rustflags we can apply.
return Ok(Vec::new());
}

@ehuss ehuss added the Z-host-config Nightly: host-config label Jan 17, 2022
@ehuss ehuss added S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. S-waiting-on-feedback Status: An implemented feature is waiting on community feedback for bugs or design concerns. labels Apr 25, 2023
@epage epage moved this to Unstable, baking in Cargo Roadmap Sep 5, 2023
@rib
Copy link

rib commented Apr 4, 2024

I'm currently unsure if the unstable host-config implementation is expected to Just Work with cargo clippy but I'm finding that I need to use -Zhost-config, which works with cargo build but doesn't seem to work with cargo clippy currently.

In this project we have certain crates that are considered "modules" which may either be cross compiled as wasm32-unknown-unknown modules and loaded at runtime, or else with --cfg=native_modules they may be compiled natively and directly linked into the runtime.

This --cfg=native_modules option affects multiple crates that form part of a runtime and it also needs to affect our proc macros which generate an FFI interface for our modules.

We can't practically use cargo features for this, while native linking is mutually exclusive with wasm linking and although we can define a precedence for cfg() guards in rust code, we also need to be able to resolve the mutual exclusion when deciding dependencies too.

It's also notable that this project's runtime runs on PC and mobile and in particular we want this native_module linking on iOS where we can't avoid using --target.

It would be good to understand if it's just a short-term limitation of the host-config implementation that it's not handled consistently by cargo clippy (not sure about other cargo subcommands besides build currently) or would it make sense to open some other issue to discuss having cargo clippy also support this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue for something unstable. S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. S-waiting-on-feedback Status: An implemented feature is waiting on community feedback for bugs or design concerns. Z-host-config Nightly: host-config
Projects
Status: Unstable, baking
Development

No branches or pull requests

4 participants