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

Create a mechanism to merge config files into the crate compilation environment #612

Closed
brson opened this issue Jul 1, 2011 · 8 comments
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-driver Area: rustc_driver that ties everything together into the `rustc` compiler A-frontend Area: Compiler frontend (errors, parsing and HIR) C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@brson
Copy link
Contributor

brson commented Jul 1, 2011

We need some mechanism to provide configuration information to the compiler via a file that, e.g. is produced by the build system. The intent is - at least partially - to remove the need for the long, arcane command lines that plague C compilers.

I would like to, at minimum, be able to merge arbitrary attributes into the list of the crate's attributes. This would provide enough flexibility to provide various types of unforeseen hints to the compiler. So you could have a rustc.attrs file that looks like:

// Provide additional link information
#[link(prerelease)];
// Bulid for the Osbourne 1
#[cfg(platform = "osbourne")];
// Disable warnings about global warming 
#[nowarn(number = "588")];

How this is actually merged into the compilation environment I do not know. Graydon has suggested a --cfg-file= command line option (maybe --attr-file?). We could also have an #include extension that goes in the .rc file, in which case the included file might contain arbitrary content, though that would behave significantly different from current extensions. We could also just have a convention: if theres a [crate].attrs file in some location it gets merged in.

Needs discussion.

@brson
Copy link
Contributor Author

brson commented Jul 2, 2011

Instead of an #include syntax extension we could have an include attribute that's interpreted by the crate evaluator, like #[include(file = "rustc.attrs")];

@brson
Copy link
Contributor Author

brson commented Mar 28, 2012

I hit the situation the other day where I couldn't get rustc to find my native library without modifying the source code, and it was super annoying, so I may do this for 0.3

@brson
Copy link
Contributor Author

brson commented May 3, 2013

Nominating feature complete. We never followed up on this idea and in the meantime rustc has grown a lot of command line options and crate attributes.

@emberian
Copy link
Member

This would be quite useful. Also isn't backwards compatible.

@graydon
Copy link
Contributor

graydon commented Aug 1, 2013

accepted for feature-complete milestone

@catamorphism
Copy link
Contributor

Not 1.0

@steveklabnik
Copy link
Member

Is this still valid? I'd imagine this is basically "Cargo," right?

@thestinger
Copy link
Contributor

@steveklabnik: Yeah, this is exactly what Cargo is for.

keeperofdakeys pushed a commit to keeperofdakeys/rust that referenced this issue Dec 12, 2017
marysaka pushed a commit to sunriseos/rust that referenced this issue Oct 20, 2019
pdietl pushed a commit to pdietl/rust that referenced this issue Apr 23, 2020
Document that literals with any suffixes are valid as tokens
ZuseZ4 pushed a commit to EnzymeAD/rust that referenced this issue Mar 7, 2023
celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
We no longer plan to use these hooks so I am deleting them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-driver Area: rustc_driver that ties everything together into the `rustc` compiler A-frontend Area: Compiler frontend (errors, parsing and HIR) C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

6 participants