about summary refs log tree commit diff
path: root/src/librustc_back/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustc_back/lib.rs')
-rw-r--r--src/librustc_back/lib.rs54
1 files changed, 32 insertions, 22 deletions
diff --git a/src/librustc_back/lib.rs b/src/librustc_back/lib.rs
index 8bf60b091a7..141c8954a33 100644
--- a/src/librustc_back/lib.rs
+++ b/src/librustc_back/lib.rs
@@ -43,14 +43,29 @@ use std::str::FromStr;
 
 use serialize::json::{Json, ToJson};
 
-macro_rules! linker_flavor {
-    ($(($variant:ident, $string:expr),)+) => {
-        #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash,
-                 RustcEncodable, RustcDecodable)]
-        pub enum LinkerFlavor {
-            $($variant,)+
-        }
+#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash,
+         RustcEncodable, RustcDecodable)]
+pub enum LinkerFlavor {
+    Em,
+    Gcc,
+    Ld,
+    Msvc,
+    Lld(LldFlavor),
+}
+
+#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash,
+         RustcEncodable, RustcDecodable)]
+pub enum LldFlavor {
+    Wasm,
+}
 
+impl ToJson for LinkerFlavor {
+    fn to_json(&self) -> Json {
+        self.desc().to_json()
+    }
+}
+macro_rules! flavor_mappings {
+    ($((($($flavor:tt)*), $string:expr),)*) => (
         impl LinkerFlavor {
             pub const fn one_of() -> &'static str {
                 concat!("one of: ", $($string, " ",)+)
@@ -58,32 +73,27 @@ macro_rules! linker_flavor {
 
             pub fn from_str(s: &str) -> Option<Self> {
                 Some(match s {
-                    $($string => LinkerFlavor::$variant,)+
+                    $($string => $($flavor)*,)+
                     _ => return None,
                 })
             }
 
             pub fn desc(&self) -> &str {
                 match *self {
-                    $(LinkerFlavor::$variant => $string,)+
+                    $($($flavor)* => $string,)+
                 }
             }
         }
-
-        impl ToJson for LinkerFlavor {
-            fn to_json(&self) -> Json {
-                self.desc().to_json()
-            }
-        }
-    }
+    )
 }
 
-linker_flavor! {
-    (Em, "em"),
-    (Binaryen, "binaryen"),
-    (Gcc, "gcc"),
-    (Ld, "ld"),
-    (Msvc, "msvc"),
+
+flavor_mappings! {
+    ((LinkerFlavor::Em), "em"),
+    ((LinkerFlavor::Gcc), "gcc"),
+    ((LinkerFlavor::Ld), "ld"),
+    ((LinkerFlavor::Msvc), "msvc"),
+    ((LinkerFlavor::Lld(LldFlavor::Wasm)), "wasm-ld"),
 }
 
 #[derive(Clone, Copy, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]