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 tracked access to environment variables from proc macros #74690

Closed
petrochenkov opened this issue Jul 23, 2020 · 6 comments
Closed
Labels
A-proc-macros Area: Procedural macros C-tracking-issue Category: A tracking issue for an RFC or an unstable feature.

Comments

@petrochenkov
Copy link
Contributor

petrochenkov commented Jul 23, 2020

#74653 introduces proc_macro::tracked_env::var - a new function that is similar to regular env::var called from a proc macro, except that it also adds the accessed variable to depinfo.

This way build system executing the compiler will know that the variable was accessed during compilation, and will be able to rerun the build when the value of that variable changes.

Besides the dependency tracking tracked_env::var differs from env::var from the standard library by requiring UTF-8 arguments.
See some discussion in #71858 for the motivation, non UTF-8 variables were considered unimportant corner cases by the stakeholders, and tracking for them can be introduced later with new depinfo directives like # env-dep-bytes.

@programmerjake
Copy link
Member

This seems really useful, what would it take to stabilize it? Also, this function should be mentioned in the docs for std's environment access functions, since using those from a proc-macro could be considered incorrect.

@petrochenkov
Copy link
Contributor Author

petrochenkov commented Mar 24, 2021

This seems really useful, what would it take to stabilize it?

Some user experience I guess?
Things are usually stabilized if someone is using them and pushing for them, but so far there was silence on this issue.

@programmerjake
Copy link
Member

one alternative that might be more useful is to instead add tracking to std's env functions that's only enabled in proc-macros, that way code wouldn't need to change and you can easily catch nearly all env usage. Idk if that's feasible though...

@petrochenkov
Copy link
Contributor Author

This function need to wired into the compiler to affect depinfo files.
In theory it can be added to std if std gets an analogue of "proc macro bridge" that proc_macro uses to talk with the compiler through a stable ABI, although I seriously doubt that it would be a good idea.

@petrochenkov
Copy link
Contributor Author

In #84029 (comment) @Xanewok has some concerns about the module structure.
It should be somehow harmonized with a similar interface for tracking files (#84029).

@m-ou-se
Copy link
Member

m-ou-se commented Jul 20, 2022

Closing this in favor of this tracking issue, tracking both path and env: #99515

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-proc-macros Area: Procedural macros C-tracking-issue Category: A tracking issue for an RFC or an unstable feature.
Projects
None yet
Development

No branches or pull requests

4 participants