diff options
-rw-r--r-- | gcc/rust/lang.opt | 4 | ||||
-rw-r--r-- | gcc/rust/rust-session-manager.cc | 19 | ||||
-rw-r--r-- | gcc/rust/rust-session-manager.h | 3 |
3 files changed, 26 insertions, 0 deletions
diff --git a/gcc/rust/lang.opt b/gcc/rust/lang.opt index e05dd72870a..537b93fa545 100644 --- a/gcc/rust/lang.opt +++ b/gcc/rust/lang.opt @@ -62,6 +62,10 @@ frust-crate= Rust Joined RejectNegative -frust-crate=<name> Set the crate name for the compilation +frust-extern= +Rust RejectNegative Joined +-frust-extern= Specify where an external library is located + 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 e537b413d16..5d1326e5aca 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -190,6 +190,11 @@ Session::handle_option ( } break; + case OPT_frust_extern_: { + std::string input (arg); + ret = handle_extern_option (input); + } + break; case OPT_frust_crate_: // set the crate name if (arg != nullptr) @@ -250,6 +255,20 @@ Session::handle_option ( } bool +Session::handle_extern_option (std::string &input) +{ + auto pos = input.find ('='); + if (std::string::npos == pos) + return false; + + std::string libname = input.substr (0, pos); + std::string path = input.substr (pos + 1); + + extern_crates.insert ({libname, path}); + return true; +} + +bool Session::handle_cfg_option (std::string &input) { std::string key; diff --git a/gcc/rust/rust-session-manager.h b/gcc/rust/rust-session-manager.h index 5636a29590c..85d4d43e1b9 100644 --- a/gcc/rust/rust-session-manager.h +++ b/gcc/rust/rust-session-manager.h @@ -288,6 +288,7 @@ struct Session /* This should really be in a per-crate storage area but it is wiped with * every file so eh. */ std::string injected_crate_name; + std::map<std::string, std::string> extern_crates; /* extra files get included during late stages of compilation (e.g. macro * expansion) */ @@ -366,6 +367,8 @@ private: // handle cfg_option bool handle_cfg_option (std::string &data); + + bool handle_extern_option (std::string &data); }; } // namespace Rust |