2019-02-05 07:37:15 -06:00
|
|
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
2015-11-24 16:00:26 -06:00
|
|
|
|
2016-10-03 11:49:39 -05:00
|
|
|
#![feature(box_patterns)]
|
2019-10-10 02:42:06 -05:00
|
|
|
#![feature(core_intrinsics)]
|
2019-07-18 16:24:58 -05:00
|
|
|
#![feature(crate_visibility_modifier)]
|
Keep last redundant linker flag, not first
When a library (L1) is passed to the linker multiple times, this is
sometimes purposeful: there might be several other libraries in the
linker command (L2 and L3) that all depend on L1. You'd end up with a
(simplified) linker command that looks like:
-l2 -l1 -l3 -l1
With the previous behavior, when rustc encountered a redundant library,
it would keep the first instance, and remove the later ones, resulting
in:
-l2 -l1 -l3
This can cause a linker error, because on some platforms (e.g. Linux),
the linker will only include symbols from L1 that are needed *at the
point it's referenced in the command line*. So if L3 depends on
additional symbols from L1, which aren't needed by L2, the linker won't
know to include them, and you'll end up with "undefined symbols" errors.
A better behavior is to keep the *last* instance of the library:
-l2 -l3 -l1
This ensures that all "downstream" libraries have been included in the
linker command before the "upstream" library is referenced.
Fixes rust-lang#47989
2018-12-20 14:46:42 -06:00
|
|
|
#![feature(drain_filter)]
|
2019-04-11 02:22:02 -05:00
|
|
|
#![feature(in_band_lifetimes)]
|
2017-11-23 10:07:18 -06:00
|
|
|
#![feature(libc)]
|
2018-09-26 16:26:46 -05:00
|
|
|
#![feature(nll)]
|
2016-10-03 11:49:39 -05:00
|
|
|
#![feature(proc_macro_internals)]
|
2018-04-21 19:05:02 -05:00
|
|
|
#![feature(proc_macro_quote)]
|
2017-05-08 16:36:44 -05:00
|
|
|
#![feature(rustc_private)]
|
2019-07-18 16:24:58 -05:00
|
|
|
#![feature(slice_patterns)]
|
|
|
|
#![feature(specialization)]
|
2019-10-10 02:42:06 -05:00
|
|
|
#![feature(stmt_expr_attributes)]
|
2015-11-24 16:00:26 -06:00
|
|
|
|
2018-03-02 23:22:19 -06:00
|
|
|
#![recursion_limit="256"]
|
|
|
|
|
2017-11-23 10:07:18 -06:00
|
|
|
extern crate libc;
|
2016-10-03 11:49:39 -05:00
|
|
|
extern crate proc_macro;
|
2015-11-24 16:00:26 -06:00
|
|
|
|
2016-03-28 16:00:01 -05:00
|
|
|
#[macro_use]
|
2015-11-24 16:00:26 -06:00
|
|
|
extern crate rustc;
|
2018-03-02 23:17:06 -06:00
|
|
|
#[macro_use]
|
2016-10-03 11:49:39 -05:00
|
|
|
extern crate rustc_data_structures;
|
2015-11-24 16:00:26 -06:00
|
|
|
|
2019-09-03 20:15:18 -05:00
|
|
|
pub mod error_codes;
|
2015-11-24 16:00:26 -06:00
|
|
|
|
2016-09-08 11:05:50 -05:00
|
|
|
mod encoder;
|
|
|
|
mod decoder;
|
2019-05-23 12:29:01 -05:00
|
|
|
mod dependency_format;
|
2016-10-19 04:56:39 -05:00
|
|
|
mod cstore_impl;
|
2018-02-10 16:28:17 -06:00
|
|
|
mod foreign_modules;
|
2019-05-23 12:29:01 -05:00
|
|
|
mod link_args;
|
|
|
|
mod native_libs;
|
|
|
|
mod schema;
|
|
|
|
mod table;
|
2016-09-08 11:05:50 -05:00
|
|
|
|
2015-11-24 16:00:26 -06:00
|
|
|
pub mod creader;
|
|
|
|
pub mod cstore;
|
2017-11-23 10:07:18 -06:00
|
|
|
pub mod dynamic_lib;
|
2016-10-19 23:31:14 -05:00
|
|
|
pub mod locator;
|
2016-08-29 09:27:04 -05:00
|
|
|
|
2018-10-25 08:11:59 -05:00
|
|
|
pub fn validate_crate_name(
|
|
|
|
sess: Option<&rustc::session::Session>,
|
|
|
|
s: &str,
|
|
|
|
sp: Option<syntax_pos::Span>
|
|
|
|
) {
|
|
|
|
let mut err_count = 0;
|
|
|
|
{
|
|
|
|
let mut say = |s: &str| {
|
|
|
|
match (sp, sess) {
|
|
|
|
(_, None) => bug!("{}", s),
|
|
|
|
(Some(sp), Some(sess)) => sess.span_err(sp, s),
|
|
|
|
(None, Some(sess)) => sess.err(s),
|
|
|
|
}
|
|
|
|
err_count += 1;
|
|
|
|
};
|
|
|
|
if s.is_empty() {
|
|
|
|
say("crate name must not be empty");
|
|
|
|
}
|
|
|
|
for c in s.chars() {
|
|
|
|
if c.is_alphanumeric() { continue }
|
|
|
|
if c == '_' { continue }
|
|
|
|
say(&format!("invalid character `{}` in crate name: `{}`", c, s));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if err_count > 0 {
|
|
|
|
sess.unwrap().abort_if_errors();
|
|
|
|
}
|
|
|
|
}
|