diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-11-02 11:55:44 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-02 11:55:44 +0000 |
commit | 09af9b16b436606fa8ced0aa6cc111555bdc3da7 (patch) | |
tree | 5dd119f0db443a687f5a535f9846622055943aff /gcc | |
parent | 9b46e479089b53d9d40d34fa792429951d4e3a42 (diff) | |
parent | 2fc460a64496c7cea1b37882a5ac3f6e8a149568 (diff) | |
download | gcc-09af9b16b436606fa8ced0aa6cc111555bdc3da7.zip gcc-09af9b16b436606fa8ced0aa6cc111555bdc3da7.tar.gz gcc-09af9b16b436606fa8ced0aa6cc111555bdc3da7.tar.bz2 |
Merge #788
788: gccrs: add the `-frust-crate=` option to set the crate name r=philberty a=mathstuf
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Fixes: #627
Co-authored-by: Ben Boeckel <mathstuf@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/lang.opt | 4 | ||||
-rw-r--r-- | gcc/rust/rust-session-manager.cc | 14 | ||||
-rw-r--r-- | gcc/rust/rust-session-manager.h | 8 |
3 files changed, 23 insertions, 3 deletions
diff --git a/gcc/rust/lang.opt b/gcc/rust/lang.opt index 53aa1f4..d0c8286 100644 --- a/gcc/rust/lang.opt +++ b/gcc/rust/lang.opt @@ -34,6 +34,10 @@ L Rust Joined Separate ; Not documented +frust-crate= +Rust Joined RejectNegative +-frust-crate=<name> Set the crate name for the compilation + frust-debug Rust Var(flag_rust_debug) Dump various Rust front end internals. diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index 71688bd..b844e3b 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -70,8 +70,6 @@ const char *kHIRDumpFile = "gccrs.hir.dump"; const char *kHIRTypeResolutionDumpFile = "gccrs.type-resolution.dump"; const char *kTargetOptionsDumpFile = "gccrs.target-options.dump"; -// FIME in the imports/visibility milestone - this needs to be command line -// option const std::string kDefaultCrateName = "TestCrate"; // Implicitly enable a target_feature (and recursively enable dependencies). @@ -330,6 +328,9 @@ Session::init () // setup backend to GCC GIMPLE backend = rust_get_backend (); + // set the default crate name + options.set_crate_name (kDefaultCrateName); + // the constant folder uses gcc ConstFold::Context::init (backend); } @@ -359,6 +360,13 @@ Session::handle_option ( case OPT_L: // TODO: add library link path or something break; + case OPT_frust_crate_: + // set the crate name + if (arg != nullptr) + ret = options.set_crate_name (arg); + else + ret = false; + break; case OPT_frust_dump_: // enable dump and return whether this was successful if (arg != nullptr) @@ -451,7 +459,7 @@ void Session::parse_files (int num_files, const char **files) { auto mappings = Analysis::Mappings::get (); - CrateNum crate_num = mappings->setup_crate_mappings (kDefaultCrateName); + CrateNum crate_num = mappings->setup_crate_mappings (options.crate_name); mappings->set_current_crate (crate_num); for (int i = 0; i < num_files; i++) diff --git a/gcc/rust/rust-session-manager.h b/gcc/rust/rust-session-manager.h index 5c72143..24d4aa1 100644 --- a/gcc/rust/rust-session-manager.h +++ b/gcc/rust/rust-session-manager.h @@ -180,6 +180,7 @@ struct CompileOptions * whatever data related to target arch, features, os, family, env, endian, * pointer width, vendor */ TargetOptions target_data; + std::string crate_name; bool enable_test = false; bool debug_assertions = false; bool proc_macro = false; @@ -203,6 +204,13 @@ struct CompileOptions enable_dump_option (DumpOption::HIR_DUMP); enable_dump_option (DumpOption::TYPE_RESOLUTION_DUMP); } + + bool set_crate_name (std::string name) + { + // TODO: validate the crate name? + crate_name = std::move (name); + return true; + } }; /* Defines a compiler session. This is for a single compiler invocation, so |