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

Accpet OsStr instead of str for flags #1100

Merged
merged 9 commits into from
Jun 23, 2024
Merged

Accpet OsStr instead of str for flags #1100

merged 9 commits into from
Jun 23, 2024

Conversation

NobodyXu
Copy link
Collaborator

Fixed #1018

It is possible that the environment variable contains non-utf8 charactes

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
… Error>`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
…_modifiers`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Copy link
Contributor

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely a good idea!

Copy link
Member

@ChrisDenton ChrisDenton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this but I have just one query really. Not a blocker though.

src/lib.rs Outdated
Comment on lines 979 to 980
#[deprecated(since = "1.0.100", note = "please use `cpp_link_stdlib_path` instead")]
pub fn cpp_link_stdlib<'a, V: Into<Option<&'a str>>>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we absolutely have to deprecate this rather than, I dunno, doing some special trait shenanigans so it works with str but OsStr also works? Maybe we do but it seems unfortunate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I don't think we can, Into< Option<&str>> prevents this.

Copy link
Member

@thomcc thomcc Jun 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is unfortunate. It's usually not a path, but a literal "c++" or "stdc++" so I don't know that deprecating this is worth it.

Edit: People who really care can just link the c++ stdlib as a normal library.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will revert that

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reverted changes to cpp_{set, link}_stdlib according to review feedback of @thomcc

Copy link
Member

@thomcc thomcc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure about the deprecation.

src/lib.rs Outdated
Comment on lines 979 to 980
#[deprecated(since = "1.0.100", note = "please use `cpp_link_stdlib_path` instead")]
pub fn cpp_link_stdlib<'a, V: Into<Option<&'a str>>>(
Copy link
Member

@thomcc thomcc Jun 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is unfortunate. It's usually not a path, but a literal "c++" or "stdc++" so I don't know that deprecating this is worth it.

Edit: People who really care can just link the c++ stdlib as a normal library.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
NobodyXu and others added 3 commits June 23, 2024 12:03
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
@NobodyXu NobodyXu merged commit a1e291a into main Jun 23, 2024
48 checks passed
@NobodyXu NobodyXu deleted the non-utf-8 branch June 23, 2024 12:51
@sagudev
Copy link

sagudev commented Jun 26, 2024

@NobodyXu
Copy link
Collaborator Author

Oops looks like cargo-semver-check missed this one cc @obi1kenobi

678 |             build.flag(&confdefs_path.to_string_lossy());
    |                   ----  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::AsRef<std::ffi::OsStr>` is not implemented for `std::borrow::Cow<'_, str>`, which is required by `&std::borrow::Cow<'_, str>: std::convert::AsRef<std::ffi::OsStr>`
    |                   |

looks like we would have to revert the change to the interface and add a set of new interface to accept OsStr

@NobodyXu
Copy link
Collaborator Author

@sagudev It is unfortunate that AsRef does not work for Cow<', str>, however looking at the log, it seems that they are converting an OsStr to Cow<', str> to workaround a past limiation of our interface.

maybe the best way forward is to pass the OsStr directly?

@sagudev
Copy link

sagudev commented Jun 26, 2024

Yes, indeed. I just wanted to warn that this is a breaking change, although trivial to fix on our side, there might be more crates affected by this.

@NobodyXu
Copy link
Collaborator Author

Thank you, now that we have released 1.0.100, I'm not sure if we should yank and then revert its interface, that could break people on new releases.

On the other hand, most people are probably using old version and has yet update, so maybe we could still yank and revert?

@thomcc
Copy link
Member

thomcc commented Jun 26, 2024

It's probably worth yanking rather than breaking semver if we have a way to avoid breaking semver.

@thomcc
Copy link
Member

thomcc commented Jun 26, 2024

Eh, At this point we've probably missed the boat for this to be a good candidate for yanking. I may change my mind if more reports of bustage come in though.

@obi1kenobi
Copy link
Member

obi1kenobi commented Jun 26, 2024

Oops looks like cargo-semver-check missed this one cc @obi1kenobi

Yup, it can't currently check anything related to changes in types: https://predr.ag/blog/four-challenges-cargo-semver-checks-has-yet-to-tackle/#surprising-limitation-no-checking-of-types

It's tied to the next point in that blog post: a lack of sustainable project funding. I'd love to build type-aware checks, but that requires being able to pay my rent with cargo-semver-checks and we are nowhere close to that right now 😢 I have many individuals sponsoring me on GitHub, and I love them all for it. But what would really move the needle are recurring $100-$500/month company sponsorships, and I haven't been able to get any of those so far — so rent has been coming out of my savings for many months now.

For any folks negatively affected by this issue, please remember:

  • cargo-semver-checks can be updated to catch it in the future.
  • It's up to you to help make that happen. Please get your employer to sponsor me so I can build it!

Companies, I'd love to put your logo on the cargo-semver-checks README, and I'll tell everyone you're sponsoring me. So dig into your marketing budget and send some love my way!

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

Successfully merging this pull request may close these issues.

Support arbitrary OsStrs as arguments to compiler
6 participants