gccrs: Add compatible version option
Introduces a new option to specify a target Rust compatibility version for gccrs.
To address discrepancies between gccrs’s default target Rust version (1.49) and newer requirements, a new command-line option frust-compat-version has been added. This allows users to specify a target Rust compatibility version, enabling gccrs to account for backward-incompatible language or library changes between Rust versions. This is particularly useful for compiling older codebases, like libcore for Rust Linux, without needing to explicitly enable post-1.49 features.
In Details
The gccrs session management is enhanced with a compat_version option in CompileOptions. This option, handled by Session::handle_option, allows for dynamic adjustment of compiler behavior based on target Rust versions. For example, Session::should_support_offset_of now uses this compat version to determine feature availability, superseding the older frust-assume-builtin-offset-of flag. This aims to improve compatibility with evolving Rust language features and standard library changes.
- compatibility version
- A setting that tells the compiler to adhere to the language rules and standard library features of a specific past version of the language, ensuring that older codebases can still be compiled successfully.
- standard library
- A collection of modules and functions provided by the Rust language that offer common functionality, such as collections, I/O, and string manipulation.
libcoreis a minimal subset of the standard library used in embedded environments. - feature gate
- A mechanism in Rust that allows experimental or unstable language features to be enabled or disabled, often via compiler flags or attributes. This helps manage language evolution.