Should build.rs
be compiled like plugins?
#5436
Labels
A-build-scripts
Area: build.rs scripts
C-enhancement
Category: enhancement
S-needs-design
Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Currently,
build.rs
scripts (and build-dependencies) are built with the same restrictions as compiler plugins (panic
andlto
cannot be set, maybe other issues?). I don't think this is quite correct because build scripts are not used the same way proc-macro/plugins are.This is caused by several parts of the code that check
for_host()
but don't differentiate for build scripts (but some places do!).One consequence of the current implementation is that a dependency that is shared between regular dependencies and build-dependencies will be built without
panic
set. I'm not sure if there is much of a problem with this because dependencies built withunwind
seem to be fine? (I'd like to better understand the difference, since the assembly output looks almost identical.) Another oddity is that withcargo test
orcargo bench
, these shared dependencies will be built twice, but with the exact same settings.Repro:
I think to fix it so that
build.rs
includes panic, it is a relatively simple change to avoid walking theRunCustomBuild
unit inbuild_used_in_plugin_map
.Alternatively, to keep the current behavior and fix the shared dependencies, we should be clearing the
panic
flag inget_profile
(instead ofbuild_base_args
), though I'm uncertain what other issues there might be.In general, it seems to be dangerous to use
for_host()
if the code is really wanting to know if something is a plugin.The text was updated successfully, but these errors were encountered: