diff --git a/src/etc/mklldeps.py b/src/etc/mklldeps.py index 5b1abdf68a3d6..3b2cef3c9e1cb 100644 --- a/src/etc/mklldeps.py +++ b/src/etc/mklldeps.py @@ -7,6 +7,7 @@ f = open(sys.argv[1], 'wb') components = sys.argv[2].split(' ') +components = [i for i in components if i] # ignore extra whitespaces f.write("""// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at @@ -51,6 +52,10 @@ proc = subprocess.Popen(args, stdout = subprocess.PIPE) out, err = proc.communicate() + if err: + print("failed to run llconfig: args = `{}`".format(args)) + sys.exit(1) + for lib in out.strip().split(' '): lib = lib[2:] # chop of the leading '-l' f.write("#[link(name = \"" + lib + "\", kind = \"static\")]\n") diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 955ba54a404fd..ec651b2c02ae2 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -219,7 +219,11 @@ fn visit_item(e: &Env, i: @ast::item) { @"foo" } }; - cstore::add_used_library(cstore, n.to_owned(), kind); + if n.is_empty() { + e.sess.span_err(m.span, "#[link(name = \"\")] given with empty name"); + } else { + cstore::add_used_library(cstore, n.to_owned(), kind); + } } None => {} } diff --git a/src/test/compile-fail/bad-extern-link-attrs.rs b/src/test/compile-fail/bad-extern-link-attrs.rs index 0616da266021e..ff63d4b739aef 100644 --- a/src/test/compile-fail/bad-extern-link-attrs.rs +++ b/src/test/compile-fail/bad-extern-link-attrs.rs @@ -9,6 +9,7 @@ // except according to those terms. #[link()] //~ ERROR: specified without `name = +#[link(name = "")] //~ ERROR: with empty name #[link(name = "foo")] #[link(name = "foo", kind = "bar")] //~ ERROR: unknown kind extern {}