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

Target OS Arch + Feature Flag Regression #3011

Open
ericmcbride opened this issue Nov 19, 2024 · 4 comments
Open

Target OS Arch + Feature Flag Regression #3011

ericmcbride opened this issue Nov 19, 2024 · 4 comments

Comments

@ericmcbride
Copy link
Contributor

We have updated to rules rust 0.54.1 and we are noticing a weird regression with the reqwest library. They added a default feature configuration default = ["default-tls", "charset", "http2", "macos-system-configuration"] for a mac-os specific crate. It takes the following flags

#[cfg(all(target_os = "macos", feature = "macos-system-configuration"))]
use system_configuration::{
    core_foundation::{
        base::CFType,
        dictionary::CFDictionary,
        number::CFNumber,
        string::{CFString, CFStringRef},
    },
    dynamic_store::SCDynamicStoreBuilder,
    sys::schema_definitions::kSCPropNetProxiesHTTPEnable,
    sys::schema_definitions::kSCPropNetProxiesHTTPPort,
    sys::schema_definitions::kSCPropNetProxiesHTTPProxy,
    sys::schema_definitions::kSCPropNetProxiesHTTPSEnable,
    sys::schema_definitions::kSCPropNetProxiesHTTPSPort,
    sys::schema_definitions::kSCPropNetProxiesHTTPSProxy,
};

For some reason on linux x86 and linux-arm64 it s hitting the target_os flag in bazel and it is not doing so with with rules_rust 0.48.0 or with cargo. Any idea why this is happening?

Ive tried using the crate.annotation

 crate.annotation(
    crate = "reqwest",
    version = "0.11.27",
    crate_features = ["default-tls", "charset", "http2"],
    override_target_lib = "@crates_index//:reqwest",
)

But i am getting cyclic deps

    //some-dir:some-bin (cfa282587e9f280b666b5f4aefa7298159ebe1fa690f0b8ef9d34ffeb511b0d4)
    //some-dir:some-bin (cfc81706202ca4f76d7de0ad3ec7512f6faaa459aafda827541c47861f45e386)
    //some-dir:some-bin (cfc81706202ca4f76d7de0ad3ec7512f6faaa459aafda827541c47861f45e386)
    //another-dir:another-bin (cfc81706202ca4f76d7de0ad3ec7512f6faaa459aafda827541c47861f45e386)
.-> @@rules_rust~~crate~crates_index__reqwest-0.11.27//:reqwest (cfc81706202ca4f76d7de0ad3ec7512f6faaa459aafda827541c47861f45e386)
|   @@rules_rust~~crate~crates_index//:reqwest (cfc81706202ca4f76d7de0ad3ec7512f6faaa459aafda827541c47861f45e386)
`-- @@rules_rust~~crate~crates_index__reqwest-0.11.27//:reqwest (cfc81706202ca4f76d7de0ad3ec7512f6faaa459aafda827541c47861f45e386)

Any idea why this could happen? This is stopping us from updating rust.

@jgsogo
Copy link
Contributor

jgsogo commented Nov 20, 2024

I may have another occurrence of this same issue with rules_rust/0.54.1 (not 100% sure, but it might be worth sharing my scenario here).

In my case it is related to this optional dependency of tauri-plugin-v2.03:

[target."cfg(target_os = \"macos\")".dependencies]
plist = { version = "1", optional = true }

It fails (use of undeclared crate or module plist) when my MODULE.bazel looks like the following:

crate.from_cargo(
    name = "crates_libraries",
    cargo_lockfile = "//:Cargo.lock",
    manifests = [
        "//:Cargo.toml",
        ...
    ],
    supported_platform_triples = [
        # "aarch64-apple-darwin",
        "aarch64-unknown-linux-gnu",
        "x86_64-apple-darwin",
    ],
)

However, it builds successfully when I add the aarch64 platform:

    supported_platform_triples = [
        "aarch64-apple-darwin",
        "aarch64-unknown-linux-gnu",
        "x86_64-apple-darwin",
    ],

I'm using MacOS x86_64.

Note.- I've tried rules_rust/0.53.0 and it also fails.

@ericmcbride
Copy link
Contributor Author

Sadly this didnt work. Its still trying to build. Im gonna try a crate.select based off platform for features. Not sure what changed that broke this.

@ericmcbride
Copy link
Contributor Author

Update: Cannot get it to work. Seems like the appropriate cfg(target_os = "macos") aren't working correctly. Not sure if reqwest is the only one. I will add a sample example. Reqwest is a large library and it would suck to see this break all of rules rust

@ericmcbride
Copy link
Contributor Author

Any Update / Advice here?

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

No branches or pull requests

3 participants