-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Reduce the need for users to write build scripts #14948
Comments
I would draw a distinction between main binary build scripts (e.g. the executable or cdylib) and libraries. I think a build scripts for an executable is far more tolerable than for libraries. They're in direct control of the crate author and don't have any other users. Also a single top-level build script is going to have negligible impact on build times for all but the smallest projects. Which is not to say reducing the need for them is not important too, just that reducing the need for library build scripts will likely have the far bigger impact. |
This is not about trying to remove all build scripts but finding patterns in the community and providing a solution to avoid writing one yourself. In some cases, this will be using an artifact dependency as your build script. This is a general solution that helps libs and bins. And the benefits extend to bins. For smaller projects it democratizes the benefits of build scripts by making it easier to discover what you can do, easier to implement, and with fewer bugs. For larger projects with multiple bins, it makes reuse easier, reduces build times, and makes it easier to audit your own code base. Yes, libs will get more benefits as we prioritize solutions to implement but understanding and tracking the needs of bins takes little away from that but instead gives a better understanding for designing soluations. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Can we add "cfg aliases" to this list (i.e. what is implemented using a build script by the https://docs.rs/cfg_aliases/latest/cfg_aliases/ crate)? Winit is a prominent crate that depends on this Use cases where this is commonly comes up are where there is functionality that works on N of M platforms (e.g. 3 of 6), that you also want to be controllable with a feature flag (users may or may not want the function), and that you want to be disabled on platforms where it doesn't work even when the feature is enabled (as otherwise it becomes burdensome for users to set platform-specific features (where this is even possible)). To give an entirely concrete example. In blitz-shell we use muda for implementing system menus on windows/macos/linux(desktop), but this functionality isn't available and doesn't make sense on android/ios/web. We also wish to make it optional on platforms that do support it. So we need a feature flag AND platform-specific It would be nice if we could define aliases (either in |
@nicoburns I've added |
I feel like the use cases given might have some overlap with global, mutually exclusive features and I wonder if there is a way to fit a higher level construct into that. |
Another use case we have is to record the I mean, there's other ways as well like linking in function to get info, but stamping this in the executable might be useful to external tools as well. Just some thoughts. |
The
As for PE/COFF executables, it looks like the PDB debuginfo file will contain the rustc string. At least https://rust.godbolt.org/z/3zxrKehsK shows the |
Interesting. I ran As for PE/COFF, I expected this was in the
|
Another important use-case I want to mention is FFI (especially with C/C++), which probably broadly fits under the build scripts are encouraged for bindgen, CXX and CXX-Qt. Especially in the case of cc/CXX/CXX-Qt, this means the build script invokes the C/C++ compiler. Here are the timing results of rebuilding CXX-Qt after touching a single file in cxx-qt-gen: In this example, the build scripts take up about 17.34s out of 20.5s (~85%). |
@LeonMatthesKDAB FFI was listed under #14903 in the list. While maybe we can eventually find a stable interface to declare these (though I suspect we won't), sharing more of the implementation of As for problems with an ever-changing out dir, I'm not seeing an existing issue and it might be good to open one for us to explore what could be done. Granted, if we could find a way to have C/C++ be a part of our build graph and know how to handle intermediate files, that would be amazing. However, that is probably even farther in the future and builds on the work of #14903 |
Like RUSTFLAGS, build scripts are an important escape hatch. Like RUSTFLAGS (#12739), we should find replacements for common uses of build scripts so people don't have to reach to this escape hatch so often
Reducing build scripts would
Uses of build scripts
#[cfg(accessible(::path::to::thing))]
rust#64797#[cfg(version(..))]
rust#64796cfg
values available at runtime (e.g. in--bugreport
,--version
, or crash reports, or for tests building examples)cfg_value!
,cfg_values!
,try_cfg_value!
,try_cfg_values!
(see also mutually exclusive features)TARGET
available at runtime (e.g.--version
, building examples in tests)package.rs
) #12552-sys
crates / FFI?The text was updated successfully, but these errors were encountered: