about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-01-08 00:10:15 +0000
committerbors <bors@rust-lang.org>2017-01-08 00:10:15 +0000
commit47c8d9fdcf2e6502cf4ca7d7f059fdc1a2810afa (patch)
tree8c15d3347e4f8aee0b8ca8c87e81824a5b21555a /src
parent089682611f055ca6315e2229e5ed29be3d2b41c8 (diff)
parenta8fa2cff2835ceac6308415d1397b59805ea70dc (diff)
downloadrust-47c8d9fdcf2e6502cf4ca7d7f059fdc1a2810afa.tar.gz
rust-47c8d9fdcf2e6502cf4ca7d7f059fdc1a2810afa.zip
Auto merge of #38798 - jsgf:fix-rpath, r=nikomatsakis
rustc: use -Xlinker when specifying an rpath with ',' in it

The `-Wl` option splits its parameters on commas, so if rustc specifies
`-Wl,-rpath,<path>` when `<path>` contains commas, the path gets split up
and the linker gets a partial path and spurious extra parameters.

Gcc/clang support the more verbose `-Xlinker` option to pass options to the linker directly, so use it for comma-containing paths.

Fixes issue #38795.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_trans/back/rpath.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/librustc_trans/back/rpath.rs b/src/librustc_trans/back/rpath.rs
index ccaa0d4e1b1..9c982be3fa0 100644
--- a/src/librustc_trans/back/rpath.rs
+++ b/src/librustc_trans/back/rpath.rs
@@ -51,7 +51,13 @@ pub fn get_rpath_flags(config: &mut RPathConfig) -> Vec<String> {
 fn rpaths_to_flags(rpaths: &[String]) -> Vec<String> {
     let mut ret = Vec::new();
     for rpath in rpaths {
-        ret.push(format!("-Wl,-rpath,{}", &(*rpath)));
+        if rpath.contains(',') {
+            ret.push("-Wl,-rpath".into());
+            ret.push("-Xlinker".into());
+            ret.push(rpath.clone());
+        } else {
+            ret.push(format!("-Wl,-rpath,{}", &(*rpath)));
+        }
     }
     return ret;
 }
@@ -258,4 +264,19 @@ mod tests {
             assert_eq!(res, "$ORIGIN/../lib");
         }
     }
+
+    #[test]
+    fn test_xlinker() {
+        let args = rpaths_to_flags(&[
+            "a/normal/path".to_string(),
+            "a,comma,path".to_string()
+        ]);
+
+        assert_eq!(args, vec![
+            "-Wl,-rpath,a/normal/path".to_string(),
+            "-Wl,-rpath".to_string(),
+            "-Xlinker".to_string(),
+            "a,comma,path".to_string()
+        ]);
+    }
 }