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

Support arbitrary OsStrs as arguments to compiler #1018

Open
TheButlah opened this issue Mar 20, 2024 · 7 comments
Open

Support arbitrary OsStrs as arguments to compiler #1018

TheButlah opened this issue Mar 20, 2024 · 7 comments

Comments

@TheButlah
Copy link

I want to pass -fdebug-prefix-map=PATH1=PATH2 to the compiler. However, to be most portable, these should be &Paths and the overall flag should be an OsString. However, I don't see a way to pass custom os strings to the builder, unless I manually recreate the logic in .compile(output) with a bunch of .to_command()s.

Could there be an easy way to pass arbitrary os strings as arguments?

@NobodyXu
Copy link
Collaborator

We could update cc::Build::flag to take OsStr, I would accept a PR for this

@ChrisDenton
Copy link
Contributor

Note that historically (and speaking in general) UTF-8 strings have been preferred because they tend to be the common denominator between both tools and platforms. E.g. some tools only reliably take UTF-8 values and there can be cross compiling issues when using an unspecified encoding.

Which is not to pour water on the idea, but just to say OsStr can actually be a portability hazard in another way.

@NobodyXu
Copy link
Collaborator

That's a problem indeed, though accepting OsStr also seems to make sense.

E.g. some tools only reliably take UTF-8 values and there can be cross compiling issues when using an unspecified encoding.

May I ask which tools have the problem?

We should look into it and see if cc-rs still support them or if they have improved.

@ChrisDenton
Copy link
Contributor

I don't recall a specific issue with cc-rs off the top of my head but I know of problems with passing things through to WINE on a Linux host or when it's necessary for things to be written to a text file (e.g. json). Git on Windows also deals in bytes (whereas the host is u16s) meaning anything not unicode won't be handled correctly.

@NobodyXu
Copy link
Collaborator

Let me ask in zulip to ask for more opinions on this

@TheButlah
Copy link
Author

any updates?

@NobodyXu
Copy link
Collaborator

Sorry I forgot to post the update here, we concluded the discussion that it's ok to change flag to take impl AsRef<OsStr>.

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

No branches or pull requests

3 participants