An option to pass rustc arbitrary arguments from the build script

Hello, I would like to ask the more knowledgeable people in this community why can't Cargo accept arbitrary arguments to rustc on build scripts' behalf?

Currently, it is explictly stated in the code (cargo/custom_build.rs at c8c6e339967617bca15195748b0a72a2a73e486d · rust-lang/cargo · GitHub) that only -L and -l flags are allowed for the rustc-flags build script output option, but no explanation given as to why is that the case. Also, if there is no objections from others on this topic, I would like to work on making other options available to be passed on as well.

An example of how this might benefit the user is the linker and link-flavor codegen options, which, in some rare cases, might need to be specified according to the target for which the user is compiling the code to.

I don't know about cargo in this case, but for these kinds of things, being restrictive and opening up as needed is generally a better policy because otherwise all kinds of things are possible that need to be supported because of backwards compatibility reasons.

Relevant history:

2 Likes

This topic was automatically closed 540 days after the last reply. New replies are no longer allowed.