Skip to content

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

Closed
@brson

Description

@brson

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-driverArea: rustc_driver that ties everything together into the `rustc` compilerA-frontendArea: Compiler frontend (errors, parsing and HIR)C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions