zama-ai / tfhe-rs

TFHE-rs: A Pure Rust implementation of the TFHE Scheme for Boolean and Integer Arithmetics Over Encrypted Data.
Other
826 stars 126 forks source link

Handle multivalued `target_family` #1320

Closed madsmtm closed 6 days ago

madsmtm commented 1 week ago

target_family / CARGO_CFG_TARGET_FAMILY is documented to be multi-valued.

This was found by a crater run in https://github.com/rust-lang/rust/pull/124355#issuecomment-2091278128. The concrete-csprng crate may fail to compile in the future if Rust decides to add further target families.

The commit history since v0.4.0 shows only cosmetic changes, so I've bumped the version to v0.4.1 to make it easier for you to release this as a patch version.

Check-list:

cla-bot[bot] commented 1 week ago

Thank you for your pull request. We require contributors to sign our Contributor License Agreement / Terms and Conditions, and we don't seem to have the users @madsmtm on file. In order for us to review and merge your code, please sign:

If you already signed one of this document, just wait to be added to the bot config.

IceTDrinker commented 1 week ago

Hello, thanks a lot for the report of the crater run, as you can see there is a CLA for outside contributors, in any case we’ll look to get this fixed as I believe the current use of the build.rs is an antipattern in concrete-csprng

madsmtm commented 1 week ago

I've signed the CLA, but not sure if that's enough. I don't care about attribution or anything for this PR, feel free to license these changes under whatever license you prefer, now or in the future. And you may freely rebase my name away from appearing in any commits if that's easier for your automated systems.

IceTDrinker commented 1 week ago

@madsmtm let us know if you are willing to sign the CLA or if we should fix this ourselves given your report

IceTDrinker commented 1 week ago

Ah let me check on our end then !

aquint-zama commented 1 week ago

@cla-bot check

cla-bot[bot] commented 1 week ago

The cla-bot has been summoned, and re-checked this pull request!

IceTDrinker commented 1 week ago

@madsmtm thanks a lot for fixing this, very much appreciated 🙏

I see there is a formatting issue, could you run make fmt and push the corrected commit here amending the first one ?

one note however reading the docs on the topic really does not make it clear (in my opinion) that it can be multi valued, and no such multi valued example is provided (I'm guessing because it can't happen today).

Perhaps a "in the future CARGO_CFG_TARGET_FAMILY may contain several target families in a comma separated list e.g. CARGO_CFG_TARGET_FAMILY=unix,some_other_family and build.rs scripts are expected to properly parse those" or having a sort of build utils available from cargo that parses those env variables automatically and that can be loaded by the person writing the build.rs script would be useful as the proper behavior would always be enforced (or at least more easily enforced if build.rs writers just use the provided utils).

Let me know if there is a location where we can give this feedback to perhaps update some documentation

Cheers

IceTDrinker commented 1 week ago

if you prefer we do the fix to avoid back and forth @madsmtm let us know, we'll add a co-authored tag on the commit as you were the one to bring this to our attention, proper attribution is the least we can do !

madsmtm commented 6 days ago

I see there is a formatting issue

Ah, sorry about this, I was somewhat lazy, and did this PR without fully setting up my editor :/. Have fixed it now, and actually tested that it works.

one note however reading the docs on the topic really does not make it clear (in my opinion) that it can be multi valued, and no such multi valued example is provided (I'm guessing because it can't happen today).

It says:

Any number of target_family key-value pairs can be set.

But I agree that having no example of this is confusing, I've opened https://github.com/rust-lang/cargo/pull/14165 and https://github.com/rust-lang/reference/pull/1518 to resolve this.

having a sort of build utils available from cargo

There is some recent work on this in https://github.com/rust-lang/cargo/issues/12432.

IceTDrinker commented 6 days ago

I see there is a formatting issue

Ah, sorry about this, I was somewhat lazy, and did this PR without fully setting up my editor :/. Have fixed it now, and actually tested that it works.

one note however reading the docs on the topic really does not make it clear (in my opinion) that it can be multi valued, and no such multi valued example is provided (I'm guessing because it can't happen today).

It says:

Any number of target_family key-value pairs can be set.

But I agree that having no example of this is confusing, I've opened rust-lang/cargo#14165 and rust-lang/reference#1518 to resolve this.

having a sort of build utils available from cargo

There is some recent work on this in rust-lang/cargo#12432.

Thanks for the links, as for the docs, it says multiple pairs but I don’t see comma separated list as pairs 😅

in any cas thanks, merged and 0.4.1 is live wont’ hamper future crater runs