]> git.proxmox.com Git - rustc.git/blobdiff - src/vendor/gcc/src/lib.rs
New upstream version 1.20.0+dfsg1
[rustc.git] / src / vendor / gcc / src / lib.rs
index 7d19e135e808e4d4d19b3e468cd8498ab7d84c69..16ab426c0e9543785a5e0cde916ea581c2e0c840 100644 (file)
@@ -92,6 +92,8 @@ pub struct Config {
     cargo_metadata: bool,
     pic: Option<bool>,
     static_crt: Option<bool>,
+    shared_flag: Option<bool>,
+    static_flag: Option<bool>,
 }
 
 /// Configuration used to represent an invocation of a C compiler.
@@ -185,6 +187,8 @@ impl Config {
             objects: Vec::new(),
             flags: Vec::new(),
             files: Vec::new(),
+            shared_flag: None,
+            static_flag: None,
             cpp: false,
             cpp_link_stdlib: None,
             cpp_set_stdlib: None,
@@ -226,6 +230,24 @@ impl Config {
         self
     }
 
+    /// Set the `-shared` flag.
+    ///
+    /// When enabled, the compiler will produce a shared object which can
+    /// then be linked with other objects to form an executable.
+    pub fn shared_flag(&mut self, shared_flag: bool) -> &mut Config {
+        self.shared_flag = Some(shared_flag);
+        self
+    }
+
+    /// Set the `-static` flag.
+    ///
+    /// When enabled on systems that support dynamic linking, this prevents
+    /// linking with the shared libraries.
+    pub fn static_flag(&mut self, static_flag: bool) -> &mut Config {
+        self.static_flag = Some(static_flag);
+        self
+    }
+
     /// Add a file which will be compiled
     pub fn file<P: AsRef<Path>>(&mut self, p: P) -> &mut Config {
         self.files.push(p.as_ref().to_path_buf());
@@ -618,7 +640,7 @@ impl Config {
                     cmd.args.push("-m64".into());
                 }
 
-                if target.contains("musl") {
+                if self.static_flag.is_none() && target.contains("musl") {
                     cmd.args.push("-static".into());
                 }
 
@@ -698,6 +720,13 @@ impl Config {
             self.ios_flags(&mut cmd);
         }
 
+        if self.static_flag.unwrap_or(false) {
+            cmd.args.push("-static".into());
+        }
+        if self.shared_flag.unwrap_or(false) {
+            cmd.args.push("-shared".into());
+        }
+
         if self.cpp {
             match (self.cpp_set_stdlib.as_ref(), cmd.family) {
                 (None, _) => { }
@@ -930,14 +959,14 @@ impl Config {
                         "arm-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
                         "arm-unknown-linux-musleabi" => Some("arm-linux-musleabi"),
                         "arm-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
-                        "arm-unknown-netbsdelf-eabi" => Some("arm--netbsdelf-eabi"),
-                        "armv6-unknown-netbsdelf-eabihf" => Some("armv6--netbsdelf-eabihf"),
+                        "arm-unknown-netbsd-eabi" => Some("arm--netbsdelf-eabi"),
+                        "armv6-unknown-netbsd-eabihf" => Some("armv6--netbsdelf-eabihf"),
                         "armv7-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"),
                         "armv7-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"),
-                        "armv7-unknown-netbsdelf-eabihf" => Some("armv7--netbsdelf-eabihf"),
+                        "armv7-unknown-netbsd-eabihf" => Some("armv7--netbsdelf-eabihf"),
                         "i686-pc-windows-gnu" => Some("i686-w64-mingw32"),
                         "i686-unknown-linux-musl" => Some("musl"),
-                        "i686-unknown-netbsdelf" => Some("i486--netbsdelf"),
+                        "i686-unknown-netbsd" => Some("i486--netbsdelf"),
                         "mips-unknown-linux-gnu" => Some("mips-linux-gnu"),
                         "mipsel-unknown-linux-gnu" => Some("mipsel-linux-gnu"),
                         "mips64-unknown-linux-gnuabi64" => Some("mips64-linux-gnuabi64"),