From fad1648e0f8299a8b108f85c2b1055eb37bdab9e Mon Sep 17 00:00:00 2001 From: Lymia Aluysia Date: Fri, 9 Mar 2018 23:56:40 -0600 Subject: Initial implementation of RFC 2151, Raw Identifiers --- src/libsyntax/ast.rs | 2 +- src/libsyntax/attr.rs | 13 +++-- src/libsyntax/diagnostics/plugin.rs | 10 ++-- src/libsyntax/ext/base.rs | 5 +- src/libsyntax/ext/quote.rs | 11 ++-- src/libsyntax/ext/tt/macro_parser.rs | 19 +++--- src/libsyntax/ext/tt/macro_rules.rs | 6 +- src/libsyntax/ext/tt/quoted.rs | 2 +- src/libsyntax/ext/tt/transcribe.rs | 2 +- src/libsyntax/fold.rs | 5 +- src/libsyntax/parse/lexer/mod.rs | 69 ++++++++++++++-------- src/libsyntax/parse/mod.rs | 20 ++++--- src/libsyntax/parse/parser.rs | 29 ++++++---- src/libsyntax/parse/token.rs | 108 +++++++++++++++++++++++++---------- src/libsyntax/print/pprust.rs | 40 +++++++------ src/libsyntax/tokenstream.rs | 2 +- 16 files changed, 215 insertions(+), 128 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 1f16b728cd2..a3af6b247ee 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -112,7 +112,7 @@ impl Path { // or starts with something like `self`/`super`/`$crate`/etc. pub fn make_root(&self) -> Option { if let Some(ident) = self.segments.get(0).map(|seg| seg.identifier) { - if ::parse::token::Ident(ident).is_path_segment_keyword() && + if ::parse::token::is_path_segment_keyword(ident) && ident.name != keywords::Crate.name() { return None; } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index f2cdcda98da..5954b9eb274 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -1106,7 +1106,8 @@ impl IntType { impl MetaItem { fn tokens(&self) -> TokenStream { - let ident = TokenTree::Token(self.span, Token::Ident(Ident::with_empty_ctxt(self.name))); + let ident = TokenTree::Token(self.span, + Token::from_ast_ident(Ident::with_empty_ctxt(self.name))); TokenStream::concat(vec![ident.into(), self.node.tokens(self.span)]) } @@ -1114,9 +1115,9 @@ impl MetaItem { where I: Iterator, { let (span, name) = match tokens.next() { - Some(TokenTree::Token(span, Token::Ident(ident))) => (span, ident.name), + Some(TokenTree::Token(span, Token::Ident(ident, _))) => (span, ident.name), Some(TokenTree::Token(_, Token::Interpolated(ref nt))) => match nt.0 { - token::Nonterminal::NtIdent(ident) => (ident.span, ident.node.name), + token::Nonterminal::NtIdent(ident, _) => (ident.span, ident.node.name), token::Nonterminal::NtMeta(ref meta) => return Some(meta.clone()), _ => return None, }, @@ -1269,14 +1270,14 @@ impl LitKind { "true" } else { "false" - }))), + })), false), } } fn from_token(token: Token) -> Option { match token { - Token::Ident(ident) if ident.name == "true" => Some(LitKind::Bool(true)), - Token::Ident(ident) if ident.name == "false" => Some(LitKind::Bool(false)), + Token::Ident(ident, false) if ident.name == "true" => Some(LitKind::Bool(true)), + Token::Ident(ident, false) if ident.name == "false" => Some(LitKind::Bool(false)), Token::Interpolated(ref nt) => match nt.0 { token::NtExpr(ref v) => match v.node { ExprKind::Lit(ref lit) => Some(lit.node.clone()), diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index 2c91844da96..c7e453c9e10 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -44,7 +44,7 @@ pub fn expand_diagnostic_used<'cx>(ecx: &'cx mut ExtCtxt, token_tree: &[TokenTree]) -> Box { let code = match (token_tree.len(), token_tree.get(0)) { - (1, Some(&TokenTree::Token(_, token::Ident(code)))) => code, + (1, Some(&TokenTree::Token(_, token::Ident(code, false)))) => code, _ => unreachable!() }; @@ -82,10 +82,10 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt, token_tree.get(1), token_tree.get(2) ) { - (1, Some(&TokenTree::Token(_, token::Ident(ref code))), None, None) => { + (1, Some(&TokenTree::Token(_, token::Ident(ref code, false))), None, None) => { (code, None) }, - (3, Some(&TokenTree::Token(_, token::Ident(ref code))), + (3, Some(&TokenTree::Token(_, token::Ident(ref code, false))), Some(&TokenTree::Token(_, token::Comma)), Some(&TokenTree::Token(_, token::Literal(token::StrRaw(description, _), None)))) => { (code, Some(description)) @@ -150,9 +150,9 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt, let (crate_name, name) = match (&token_tree[0], &token_tree[2]) { ( // Crate name. - &TokenTree::Token(_, token::Ident(ref crate_name)), + &TokenTree::Token(_, token::Ident(ref crate_name, false)), // DIAGNOSTICS ident. - &TokenTree::Token(_, token::Ident(ref name)) + &TokenTree::Token(_, token::Ident(ref name, false)) ) => (*&crate_name, name), _ => unreachable!() }; diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 23c42972912..c3ae0fd2ca8 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -229,8 +229,9 @@ impl TTMacroExpander for F impl Folder for AvoidInterpolatedIdents { fn fold_tt(&mut self, tt: tokenstream::TokenTree) -> tokenstream::TokenTree { if let tokenstream::TokenTree::Token(_, token::Interpolated(ref nt)) = tt { - if let token::NtIdent(ident) = nt.0 { - return tokenstream::TokenTree::Token(ident.span, token::Ident(ident.node)); + if let token::NtIdent(ident, is_raw) = nt.0 { + return tokenstream::TokenTree::Token(ident.span, + token::Ident(ident.node, is_raw)); } } fold::noop_fold_tt(tt, self) diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 6844532e7b3..090b9a35446 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -75,7 +75,7 @@ pub mod rt { impl ToTokens for ast::Ident { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - vec![TokenTree::Token(DUMMY_SP, token::Ident(*self))] + vec![TokenTree::Token(DUMMY_SP, Token::from_ast_ident(*self))] } } @@ -238,7 +238,8 @@ pub mod rt { if i > 0 { inner.push(TokenTree::Token(self.span, token::Colon).into()); } - inner.push(TokenTree::Token(self.span, token::Ident(segment.identifier)).into()); + inner.push(TokenTree::Token(self.span, + token::Ident(segment.identifier, false)).into()); } inner.push(self.tokens.clone()); @@ -658,10 +659,10 @@ fn expr_mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P { token::Literal(token::ByteStr(i), suf) => return mk_lit!("ByteStr", suf, i), token::Literal(token::ByteStrRaw(i, n), suf) => return mk_lit!("ByteStrRaw", suf, i, n), - token::Ident(ident) => { + token::Ident(ident, is_raw) => { return cx.expr_call(sp, mk_token_path(cx, sp, "Ident"), - vec![mk_ident(cx, sp, ident)]); + vec![mk_ident(cx, sp, ident), cx.expr_bool(sp, is_raw)]); } token::Lifetime(ident) => { @@ -720,7 +721,7 @@ fn expr_mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P { fn statements_mk_tt(cx: &ExtCtxt, tt: &TokenTree, quoted: bool) -> Vec { match *tt { - TokenTree::Token(sp, token::Ident(ident)) if quoted => { + TokenTree::Token(sp, token::Ident(ident, _)) if quoted => { // tt.extend($ident.to_tokens(ext_cx)) let e_to_toks = diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 667653b5f7f..714b7ca981d 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -365,7 +365,7 @@ pub fn parse_failure_msg(tok: Token) -> String { /// Perform a token equality check, ignoring syntax context (that is, an unhygienic comparison) fn token_name_eq(t1: &Token, t2: &Token) -> bool { if let (Some(id1), Some(id2)) = (t1.ident(), t2.ident()) { - id1.name == id2.name + id1.name == id2.name && t1.is_raw_ident() == t2.is_raw_ident() } else if let (&token::Lifetime(id1), &token::Lifetime(id2)) = (t1, t2) { id1.name == id2.name } else { @@ -711,9 +711,10 @@ pub fn parse( /// The token is an identifier, but not `_`. /// We prohibit passing `_` to macros expecting `ident` for now. -fn get_macro_ident(token: &Token) -> Option { +fn get_macro_ident(token: &Token) -> Option<(Ident, bool)> { match *token { - token::Ident(ident) if ident.name != keywords::Underscore.name() => Some(ident), + token::Ident(ident, is_raw) if ident.name != keywords::Underscore.name() => + Some((ident, is_raw)), _ => None, } } @@ -737,7 +738,7 @@ fn may_begin_with(name: &str, token: &Token) -> bool { "ident" => get_macro_ident(token).is_some(), "vis" => match *token { // The follow-set of :vis + "priv" keyword + interpolated - Token::Comma | Token::Ident(_) | Token::Interpolated(_) => true, + Token::Comma | Token::Ident(..) | Token::Interpolated(_) => true, _ => token.can_begin_type(), }, "block" => match *token { @@ -746,7 +747,7 @@ fn may_begin_with(name: &str, token: &Token) -> bool { token::NtItem(_) | token::NtPat(_) | token::NtTy(_) - | token::NtIdent(_) + | token::NtIdent(..) | token::NtMeta(_) | token::NtPath(_) | token::NtVis(_) => false, // none of these may start with '{'. @@ -755,7 +756,7 @@ fn may_begin_with(name: &str, token: &Token) -> bool { _ => false, }, "path" | "meta" => match *token { - Token::ModSep | Token::Ident(_) => true, + Token::ModSep | Token::Ident(..) => true, Token::Interpolated(ref nt) => match nt.0 { token::NtPath(_) | token::NtMeta(_) => true, _ => may_be_ident(&nt.0), @@ -763,7 +764,7 @@ fn may_begin_with(name: &str, token: &Token) -> bool { _ => false, }, "pat" => match *token { - Token::Ident(_) | // box, ref, mut, and other identifiers (can stricten) + Token::Ident(..) | // box, ref, mut, and other identifiers (can stricten) Token::OpenDelim(token::Paren) | // tuple pattern Token::OpenDelim(token::Bracket) | // slice pattern Token::BinOp(token::And) | // reference @@ -823,9 +824,9 @@ fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal { "expr" => token::NtExpr(panictry!(p.parse_expr())), "ty" => token::NtTy(panictry!(p.parse_ty())), // this could be handled like a token, since it is one - "ident" => if let Some(ident) = get_macro_ident(&p.token) { + "ident" => if let Some((ident, is_raw)) = get_macro_ident(&p.token) { p.bump(); - token::NtIdent(respan(p.prev_span, ident)) + token::NtIdent(respan(p.prev_span, ident), is_raw) } else { let token_str = pprust::token_to_string(&p.token); p.fatal(&format!("expected ident, found {}", &token_str)).emit(); diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index a4b2c3990f5..10e5926eb9e 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -831,7 +831,7 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> Result match *tok { TokenTree::Token(_, ref tok) => match *tok { FatArrow | Comma | Eq | BinOp(token::Or) => Ok(true), - Ident(i) if i.name == "if" || i.name == "in" => Ok(true), + Ident(i, false) if i.name == "if" || i.name == "in" => Ok(true), _ => Ok(false) }, _ => Ok(false), @@ -840,7 +840,7 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> Result match *tok { OpenDelim(token::DelimToken::Brace) | OpenDelim(token::DelimToken::Bracket) | Comma | FatArrow | Colon | Eq | Gt | Semi | BinOp(token::Or) => Ok(true), - Ident(i) if i.name == "as" || i.name == "where" => Ok(true), + Ident(i, false) if i.name == "as" || i.name == "where" => Ok(true), _ => Ok(false) }, TokenTree::MetaVarDecl(_, _, frag) if frag.name == "block" => Ok(true), @@ -860,7 +860,7 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> Result match *tok { Comma => Ok(true), - Ident(i) if i.name != "priv" => Ok(true), + Ident(i, is_raw) if is_raw || i.name != "priv" => Ok(true), ref tok => Ok(tok.can_begin_type()) }, TokenTree::MetaVarDecl(_, _, frag) if frag.name == "ident" diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index 122bb9ba024..11eb9b940ae 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -296,7 +296,7 @@ where name: keywords::DollarCrate.name(), ..ident }; - TokenTree::Token(span, token::Ident(ident)) + TokenTree::Token(span, token::Ident(ident, false)) } else { TokenTree::MetaVar(span, ident) } diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 7883c4bbc16..0f5855a3225 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -169,7 +169,7 @@ pub fn transcribe(cx: &ExtCtxt, Ident { ctxt: ident.ctxt.apply_mark(cx.current_expansion.mark), ..ident }; sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark)); result.push(TokenTree::Token(sp, token::Dollar).into()); - result.push(TokenTree::Token(sp, token::Ident(ident)).into()); + result.push(TokenTree::Token(sp, token::Ident(ident, false)).into()); } } quoted::TokenTree::Delimited(mut span, delimited) => { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 46e6027b094..05a3150c139 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -578,7 +578,7 @@ pub fn noop_fold_tts(tts: TokenStream, fld: &mut T) -> TokenStream { // apply ident folder if it's an ident, apply other folds to interpolated nodes pub fn noop_fold_token(t: token::Token, fld: &mut T) -> token::Token { match t { - token::Ident(id) => token::Ident(fld.fold_ident(id)), + token::Ident(id, is_raw) => token::Ident(fld.fold_ident(id), is_raw), token::Lifetime(id) => token::Lifetime(fld.fold_ident(id)), token::Interpolated(nt) => { let nt = match Lrc::try_unwrap(nt) { @@ -630,7 +630,8 @@ pub fn noop_fold_interpolated(nt: token::Nonterminal, fld: &mut T) token::NtPat(pat) => token::NtPat(fld.fold_pat(pat)), token::NtExpr(expr) => token::NtExpr(fld.fold_expr(expr)), token::NtTy(ty) => token::NtTy(fld.fold_ty(ty)), - token::NtIdent(id) => token::NtIdent(Spanned::{node: fld.fold_ident(id.node), ..id}), + token::NtIdent(id, is_raw) => + token::NtIdent(Spanned::{node: fld.fold_ident(id.node), ..id}, is_raw), token::NtMeta(meta) => token::NtMeta(fld.fold_meta_item(meta)), token::NtPath(path) => token::NtPath(fld.fold_path(path)), token::NtTT(tt) => token::NtTT(fld.fold_tt(tt)), diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 0e20eb49d39..0596fb44abe 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -14,7 +14,7 @@ use codemap::{CodeMap, FilePathMapping}; use errors::{FatalError, DiagnosticBuilder}; use parse::{token, ParseSess}; use str::char_at; -use symbol::Symbol; +use symbol::{Symbol, keywords}; use std_unicode::property::Pattern_White_Space; use std::borrow::Cow; @@ -1115,26 +1115,49 @@ impl<'a> StringReader<'a> { /// token, and updates the interner fn next_token_inner(&mut self) -> Result { let c = self.ch; - if ident_start(c) && - match (c.unwrap(), self.nextch(), self.nextnextch()) { - // Note: r as in r" or r#" is part of a raw string literal, - // b as in b' is part of a byte literal. - // They are not identifiers, and are handled further down. - ('r', Some('"'), _) | - ('r', Some('#'), _) | - ('b', Some('"'), _) | - ('b', Some('\''), _) | - ('b', Some('r'), Some('"')) | - ('b', Some('r'), Some('#')) => false, - _ => true, - } { - let start = self.pos; - while ident_continue(self.ch) { - self.bump(); - } - // FIXME: perform NFKC normalization here. (Issue #2253) - return Ok(self.with_str_from(start, |string| token::Ident(self.mk_ident(string)))); + if ident_start(c) { + let (is_ident_start, is_raw_ident) = + match (c.unwrap(), self.nextch(), self.nextnextch()) { + // r# followed by an identifier starter is a raw identifier. + // This is an exception to the r# case below. + ('r', Some('#'), x) if ident_start(x) => (true, true), + // r as in r" or r#" is part of a raw string literal. + // b as in b' is part of a byte literal. + // They are not identifiers, and are handled further down. + ('r', Some('"'), _) | + ('r', Some('#'), _) | + ('b', Some('"'), _) | + ('b', Some('\''), _) | + ('b', Some('r'), Some('"')) | + ('b', Some('r'), Some('#')) => (false, false), + _ => (true, false), + }; + if is_ident_start { + let raw_start = self.pos; + if is_raw_ident { + // Consume the 'r#' characters. + self.bump(); + self.bump(); + } + + let start = self.pos; + while ident_continue(self.ch) { + self.bump(); + } + + return Ok(self.with_str_from(start, |string| { + // FIXME: perform NFKC normalization here. (Issue #2253) + let ident = self.mk_ident(string); + if is_raw_ident && (token::is_path_segment_keyword(ident) || + ident.name == keywords::Underscore.name()) { + self.fatal_span_(raw_start, self.pos, + &format!("`r#{}` is not currently supported.", ident.name) + ).raise(); + } + token::Ident(ident, is_raw_ident) + })); + } } if is_dec_digit(c) { @@ -1801,7 +1824,7 @@ mod tests { assert_eq!(string_reader.next_token().tok, token::Whitespace); let tok1 = string_reader.next_token(); let tok2 = TokenAndSpan { - tok: token::Ident(id), + tok: token::Ident(id, false), sp: Span::new(BytePos(21), BytePos(23), NO_EXPANSION), }; assert_eq!(tok1, tok2); @@ -1811,7 +1834,7 @@ mod tests { // read another token: let tok3 = string_reader.next_token(); let tok4 = TokenAndSpan { - tok: token::Ident(Ident::from_str("main")), + tok: mk_ident("main"), sp: Span::new(BytePos(24), BytePos(28), NO_EXPANSION), }; assert_eq!(tok3, tok4); @@ -1830,7 +1853,7 @@ mod tests { // make the identifier by looking up the string in the interner fn mk_ident(id: &str) -> token::Token { - token::Ident(Ident::from_str(id)) + token::Token::from_ast_ident(Ident::from_str(id)) } #[test] diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index f7e5d40b524..4acfdab53c0 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -741,9 +741,9 @@ mod tests { match (tts.len(), tts.get(0), tts.get(1), tts.get(2), tts.get(3)) { ( 4, - Some(&TokenTree::Token(_, token::Ident(name_macro_rules))), + Some(&TokenTree::Token(_, token::Ident(name_macro_rules, false))), Some(&TokenTree::Token(_, token::Not)), - Some(&TokenTree::Token(_, token::Ident(name_zip))), + Some(&TokenTree::Token(_, token::Ident(name_zip, false))), Some(&TokenTree::Delimited(_, ref macro_delimed)), ) if name_macro_rules.name == "macro_rules" @@ -762,7 +762,7 @@ mod tests { ( 2, Some(&TokenTree::Token(_, token::Dollar)), - Some(&TokenTree::Token(_, token::Ident(ident))), + Some(&TokenTree::Token(_, token::Ident(ident, false))), ) if first_delimed.delim == token::Paren && ident.name == "a" => {}, _ => panic!("value 3: {:?}", *first_delimed), @@ -772,7 +772,7 @@ mod tests { ( 2, Some(&TokenTree::Token(_, token::Dollar)), - Some(&TokenTree::Token(_, token::Ident(ident))), + Some(&TokenTree::Token(_, token::Ident(ident, false))), ) if second_delimed.delim == token::Paren && ident.name == "a" => {}, @@ -793,17 +793,18 @@ mod tests { let tts = string_to_stream("fn a (b : i32) { b; }".to_string()); let expected = TokenStream::concat(vec![ - TokenTree::Token(sp(0, 2), token::Ident(Ident::from_str("fn"))).into(), - TokenTree::Token(sp(3, 4), token::Ident(Ident::from_str("a"))).into(), + TokenTree::Token(sp(0, 2), token::Ident(Ident::from_str("fn"), false)).into(), + TokenTree::Token(sp(3, 4), token::Ident(Ident::from_str("a"), false)).into(), TokenTree::Delimited( sp(5, 14), tokenstream::Delimited { delim: token::DelimToken::Paren, tts: TokenStream::concat(vec![ - TokenTree::Token(sp(6, 7), token::Ident(Ident::from_str("b"))).into(), + TokenTree::Token(sp(6, 7), + token::Ident(Ident::from_str("b"), false)).into(), TokenTree::Token(sp(8, 9), token::Colon).into(), TokenTree::Token(sp(10, 13), - token::Ident(Ident::from_str("i32"))).into(), + token::Ident(Ident::from_str("i32"), false)).into(), ]).into(), }).into(), TokenTree::Delimited( @@ -811,7 +812,8 @@ mod tests { tokenstream::Delimited { delim: token::DelimToken::Brace, tts: TokenStream::concat(vec![ - TokenTree::Token(sp(17, 18), token::Ident(Ident::from_str("b"))).into(), + TokenTree::Token(sp(17, 18), + token::Ident(Ident::from_str("b"), false)).into(), TokenTree::Token(sp(18, 19), token::Semi).into(), ]).into(), }).into() diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index cb5010a638d..4c1575cf589 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -358,7 +358,7 @@ impl TokenCursor { let body = TokenTree::Delimited(sp, Delimited { delim: token::Bracket, - tts: [TokenTree::Token(sp, token::Ident(ast::Ident::from_str("doc"))), + tts: [TokenTree::Token(sp, token::Ident(ast::Ident::from_str("doc"), false)), TokenTree::Token(sp, token::Eq), TokenTree::Token(sp, token::Literal( token::StrRaw(Symbol::intern(&stripped), num_of_hashes), None))] @@ -784,7 +784,7 @@ impl<'a> Parser<'a> { fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { match self.token { - token::Ident(i) => { + token::Ident(i, _) => { if self.token.is_reserved_ident() { let mut err = self.expected_ident_found(); if recover { @@ -1925,7 +1925,7 @@ impl<'a> Parser<'a> { pub fn parse_path_segment_ident(&mut self) -> PResult<'a, ast::Ident> { match self.token { - token::Ident(sid) if self.token.is_path_segment_keyword() => { + token::Ident(sid, _) if self.token.is_path_segment_keyword() => { self.bump(); Ok(sid) } @@ -2740,11 +2740,14 @@ impl<'a> Parser<'a> { } pub fn process_potential_macro_variable(&mut self) { - let ident = match self.token { + let (ident, is_raw) = match self.token { token::Dollar if self.span.ctxt() != syntax_pos::hygiene::SyntaxContext::empty() && self.look_ahead(1, |t| t.is_ident()) => { self.bump(); - let name = match self.token { token::Ident(ident) => ident, _ => unreachable!() }; + let name = match self.token { + token::Ident(ident, _) => ident, + _ => unreachable!() + }; let mut err = self.fatal(&format!("unknown macro variable `{}`", name)); err.span_label(self.span, "unknown macro variable"); err.emit(); @@ -2753,13 +2756,13 @@ impl<'a> Parser<'a> { token::Interpolated(ref nt) => { self.meta_var_span = Some(self.span); match nt.0 { - token::NtIdent(ident) => ident, + token::NtIdent(ident, is_raw) => (ident, is_raw), _ => return, } } _ => return, }; - self.token = token::Ident(ident.node); + self.token = token::Ident(ident.node, is_raw); self.span = ident.span; } @@ -4245,7 +4248,7 @@ impl<'a> Parser<'a> { -> PResult<'a, Option>> { let token_lo = self.span; let (ident, def) = match self.token { - token::Ident(ident) if ident.name == keywords::Macro.name() => { + token::Ident(ident, false) if ident.name == keywords::Macro.name() => { self.bump(); let ident = self.parse_ident()?; let tokens = if self.check(&token::OpenDelim(token::Brace)) { @@ -4273,7 +4276,7 @@ impl<'a> Parser<'a> { (ident, ast::MacroDef { tokens: tokens.into(), legacy: false }) } - token::Ident(ident) if ident.name == "macro_rules" && + token::Ident(ident, _) if ident.name == "macro_rules" && self.look_ahead(1, |t| *t == token::Not) => { let prev_span = self.prev_span; self.complain_if_pub_macro(&vis.node, prev_span); @@ -5078,7 +5081,9 @@ impl<'a> Parser<'a> { fn parse_self_arg(&mut self) -> PResult<'a, Option> { let expect_ident = |this: &mut Self| match this.token { // Preserve hygienic context. - token::Ident(ident) => { let sp = this.span; this.bump(); codemap::respan(sp, ident) } + token::Ident(ident, _) => { + let sp = this.span; this.bump(); codemap::respan(sp, ident) + } _ => unreachable!() }; let isolated_self = |this: &mut Self, n| { @@ -5375,7 +5380,7 @@ impl<'a> Parser<'a> { VisibilityKind::Inherited => Ok(()), _ => { let is_macro_rules: bool = match self.token { - token::Ident(sid) => sid.name == Symbol::intern("macro_rules"), + token::Ident(sid, _) => sid.name == Symbol::intern("macro_rules"), _ => false, }; if is_macro_rules { @@ -7016,7 +7021,7 @@ impl<'a> Parser<'a> { fn parse_rename(&mut self) -> PResult<'a, Option> { if self.eat_keyword(keywords::As) { match self.token { - token::Ident(ident) if ident.name == keywords::Underscore.name() => { + token::Ident(ident, false) if ident.name == keywords::Underscore.name() => { self.bump(); // `_` Ok(Some(Ident { name: ident.name.gensymed(), ..ident })) } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 4ada9e20f2c..6406651bcba 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -91,8 +91,8 @@ impl Lit { } } -fn ident_can_begin_expr(ident: ast::Ident) -> bool { - let ident_token: Token = Ident(ident); +fn ident_can_begin_expr(ident: ast::Ident, is_raw: bool) -> bool { + let ident_token: Token = Ident(ident, is_raw); !ident_token.is_reserved_ident() || ident_token.is_path_segment_keyword() || @@ -116,8 +116,8 @@ fn ident_can_begin_expr(ident: ast::Ident) -> bool { ].contains(&ident.name) } -fn ident_can_begin_type(ident: ast::Ident) -> bool { - let ident_token: Token = Ident(ident); +fn ident_can_begin_type(ident: ast::Ident, is_raw: bool) -> bool { + let ident_token: Token = Ident(ident, is_raw); !ident_token.is_reserved_ident() || ident_token.is_path_segment_keyword() || @@ -132,6 +132,37 @@ fn ident_can_begin_type(ident: ast::Ident) -> bool { ].contains(&ident.name) } +pub fn is_path_segment_keyword(id: ast::Ident) -> bool { + id.name == keywords::Super.name() || + id.name == keywords::SelfValue.name() || + id.name == keywords::SelfType.name() || + id.name == keywords::Extern.name() || + id.name == keywords::Crate.name() || + id.name == keywords::CrateRoot.name() || + id.name == keywords::DollarCrate.name() +} + +// Returns true for reserved identifiers used internally for elided lifetimes, +// unnamed method parameters, crate root module, error recovery etc. +pub fn is_special_ident(id: ast::Ident) -> bool { + id.name <= keywords::Underscore.name() +} + +/// Returns `true` if the token is a keyword used in the language. +pub fn is_used_keyword(id: ast::Ident) -> bool { + id.name >= keywords::As.name() && id.name <= keywords::While.name() +} + +/// Returns `true` if the token is a keyword reserved for possible future use. +pub fn is_unused_keyword(id: ast::Ident) -> bool { + id.name >= keywords::Abstract.name() && id.name <= keywords::Yield.name() +} + +/// Returns `true` if the token is either a special identifier or a keyword. +pub fn is_reserved_ident(id: ast::Ident) -> bool { + is_special_ident(id) || is_used_keyword(id) || is_unused_keyword(id) +} + #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Debug)] pub enum Token { /* Expression-operator symbols. */ @@ -175,7 +206,7 @@ pub enum Token { Literal(Lit, Option), /* Name components */ - Ident(ast::Ident), + Ident(ast::Ident, /* is_raw */ bool), Lifetime(ast::Ident), // The `LazyTokenStream` is a pure function of the `Nonterminal`, @@ -203,6 +234,11 @@ impl Token { Token::Interpolated(Lrc::new((nt, LazyTokenStream::new()))) } + /// Recovers a `Token` from an `ast::Ident`. This creates a raw identifier if necessary. + pub fn from_ast_ident(ident: ast::Ident) -> Token { + Ident(ident, is_reserved_ident(ident)) + } + /// Returns `true` if the token starts with '>'. pub fn is_like_gt(&self) -> bool { match *self { @@ -214,7 +250,8 @@ impl Token { /// Returns `true` if the token can appear at the start of an expression. pub fn can_begin_expr(&self) -> bool { match *self { - Ident(ident) => ident_can_begin_expr(ident), // value name or keyword + Ident(ident, is_raw) => + ident_can_begin_expr(ident, is_raw), // value name or keyword OpenDelim(..) | // tuple, array or block Literal(..) | // literal Not | // operator not @@ -239,7 +276,8 @@ impl Token { /// Returns `true` if the token can appear at the start of a type. pub fn can_begin_type(&self) -> bool { match *self { - Ident(ident) => ident_can_begin_type(ident), // type name or keyword + Ident(ident, is_raw) => + ident_can_begin_type(ident, is_raw), // type name or keyword OpenDelim(Paren) | // tuple OpenDelim(Bracket) | // array Not | // never @@ -272,17 +310,32 @@ impl Token { } } - pub fn ident(&self) -> Option { + fn ident_common(&self, allow_raw: bool) -> Option { match *self { - Ident(ident) => Some(ident), + Ident(ident, is_raw) if !is_raw || allow_raw => Some(ident), Interpolated(ref nt) => match nt.0 { - NtIdent(ident) => Some(ident.node), + NtIdent(ident, is_raw) if !is_raw || allow_raw => Some(ident.node), _ => None, }, _ => None, } } + pub fn nonraw_ident(&self) -> Option { + self.ident_common(false) + } + + pub fn is_raw_ident(&self) -> bool { + match *self { + Ident(_, true) => true, + _ => false, + } + } + + pub fn ident(&self) -> Option { + self.ident_common(true) + } + /// Returns `true` if the token is an identifier. pub fn is_ident(&self) -> bool { self.ident().is_some() @@ -351,18 +404,12 @@ impl Token { /// Returns `true` if the token is a given keyword, `kw`. pub fn is_keyword(&self, kw: keywords::Keyword) -> bool { - self.ident().map(|ident| ident.name == kw.name()).unwrap_or(false) + self.nonraw_ident().map(|ident| ident.name == kw.name()).unwrap_or(false) } pub fn is_path_segment_keyword(&self) -> bool { - match self.ident() { - Some(id) => id.name == keywords::Super.name() || - id.name == keywords::SelfValue.name() || - id.name == keywords::SelfType.name() || - id.name == keywords::Extern.name() || - id.name == keywords::Crate.name() || - id.name == keywords::CrateRoot.name() || - id.name == keywords::DollarCrate.name(), + match self.nonraw_ident() { + Some(id) => is_path_segment_keyword(id), None => false, } } @@ -370,24 +417,24 @@ impl Token { // Returns true for reserved identifiers used internally for elided lifetimes, // unnamed method parameters, crate root module, error recovery etc. pub fn is_special_ident(&self) -> bool { - match self.ident() { - Some(id) => id.name <= keywords::Underscore.name(), + match self.nonraw_ident() { + Some(id) => is_special_ident(id), _ => false, } } /// Returns `true` if the token is a keyword used in the language. pub fn is_used_keyword(&self) -> bool { - match self.ident() { - Some(id) => id.name >= keywords::As.name() && id.name <= keywords::While.name(), + match self.nonraw_ident() { + Some(id) => is_used_keyword(id), _ => false, } } /// Returns `true` if the token is a keyword reserved for possible future use. pub fn is_unused_keyword(&self) -> bool { - match self.ident() { - Some(id) => id.name >= keywords::Abstract.name() && id.name <= keywords::Yield.name(), + match self.nonraw_ident() { + Some(id) => is_unused_keyword(id), _ => false, } } @@ -460,7 +507,10 @@ impl Token { /// Returns `true` if the token is either a special identifier or a keyword. pub fn is_reserved_ident(&self) -> bool { - self.is_special_ident() || self.is_used_keyword() || self.is_unused_keyword() + match self.nonraw_ident() { + Some(id) => is_reserved_ident(id), + _ => false, + } } pub fn interpolated_to_tokenstream(&self, sess: &ParseSess, span: Span) @@ -496,8 +546,8 @@ impl Token { Nonterminal::NtImplItem(ref item) => { tokens = prepend_attrs(sess, &item.attrs, item.tokens.as_ref(), span); } - Nonterminal::NtIdent(ident) => { - let token = Token::Ident(ident.node); + Nonterminal::NtIdent(ident, is_raw) => { + let token = Token::Ident(ident.node, is_raw); tokens = Some(TokenTree::Token(ident.span, token).into()); } Nonterminal::NtLifetime(lifetime) => { @@ -529,7 +579,7 @@ pub enum Nonterminal { NtPat(P), NtExpr(P), NtTy(P), - NtIdent(ast::SpannedIdent), + NtIdent(ast::SpannedIdent, /* is_raw */ bool), /// Stuff inside brackets for attributes NtMeta(ast::MetaItem), NtPath(ast::Path), diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 7adb2848f8d..50577a26abf 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -250,7 +250,8 @@ pub fn token_to_string(tok: &Token) -> String { } /* Name components */ - token::Ident(s) => s.to_string(), + token::Ident(s, false) => s.to_string(), + token::Ident(s, true) => format!("r#{}", s), token::Lifetime(s) => s.to_string(), /* Other */ @@ -261,24 +262,25 @@ pub fn token_to_string(tok: &Token) -> String { token::Shebang(s) => format!("/* shebang: {}*/", s), token::Interpolated(ref nt) => match nt.0 { - token::NtExpr(ref e) => expr_to_string(e), - token::NtMeta(ref e) => meta_item_to_string(e), - token::NtTy(ref e) => ty_to_string(e), - token::NtPath(ref e) => path_to_string(e), - token::NtItem(ref e) => item_to_string(e), - token::NtBlock(ref e) => block_to_string(e), - token::NtStmt(ref e) => stmt_to_string(e), - token::NtPat(ref e) => pat_to_string(e), - token::NtIdent(ref e) => ident_to_string(e.node), - token::NtTT(ref tree) => tt_to_string(tree.clone()), - token::NtArm(ref e) => arm_to_string(e), - token::NtImplItem(ref e) => impl_item_to_string(e), - token::NtTraitItem(ref e) => trait_item_to_string(e), - token::NtGenerics(ref e) => generic_params_to_string(&e.params), - token::NtWhereClause(ref e) => where_clause_to_string(e), - token::NtArg(ref e) => arg_to_string(e), - token::NtVis(ref e) => vis_to_string(e), - token::NtLifetime(ref e) => lifetime_to_string(e), + token::NtExpr(ref e) => expr_to_string(e), + token::NtMeta(ref e) => meta_item_to_string(e), + token::NtTy(ref e) => ty_to_string(e), + token::NtPath(ref e) => path_to_string(e), + token::NtItem(ref e) => item_to_string(e), + token::NtBlock(ref e) => block_to_string(e), + token::NtStmt(ref e) => stmt_to_string(e), + token::NtPat(ref e) => pat_to_string(e), + token::NtIdent(ref e, false) => ident_to_string(e.node), + token::NtIdent(ref e, true) => format!("r#{}", ident_to_string(e.node)), + token::NtTT(ref tree) => tt_to_string(tree.clone()), + token::NtArm(ref e) => arm_to_string(e), + token::NtImplItem(ref e) => impl_item_to_string(e), + token::NtTraitItem(ref e) => trait_item_to_string(e), + token::NtGenerics(ref e) => generic_params_to_string(&e.params), + token::NtWhereClause(ref e) => where_clause_to_string(e), + token::NtArg(ref e) => arg_to_string(e), + token::NtVis(ref e) => vis_to_string(e), + token::NtLifetime(ref e) => lifetime_to_string(e), } } } diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index 1219e909e12..3a7a1b9a669 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -684,7 +684,7 @@ mod tests { with_globals(|| { let test0: TokenStream = Vec::::new().into_iter().collect(); let test1: TokenStream = - TokenTree::Token(sp(0, 1), Token::Ident(Ident::from_str("a"))).into(); + TokenTree::Token(sp(0, 1), Token::Ident(Ident::from_str("a"), false)).into(); let test2 = string_to_ts("foo(bar::baz)"); assert_eq!(test0.is_empty(), true); -- cgit 1.4.1-3-g733a5 From 7d5c29b9eae5857c040bf6f1b2d729596c8af3ae Mon Sep 17 00:00:00 2001 From: Lymia Aluysia Date: Wed, 14 Mar 2018 02:00:41 -0500 Subject: Feature gate raw identifiers. --- src/libsyntax/feature_gate.rs | 14 ++++++++++++++ src/libsyntax/parse/lexer/mod.rs | 1 + src/libsyntax/parse/mod.rs | 4 ++++ src/libsyntax/parse/parser.rs | 5 ++++- src/test/run-pass/rfc-2151-raw-identifiers/attr.rs | 2 ++ src/test/run-pass/rfc-2151-raw-identifiers/basic.rs | 2 ++ src/test/run-pass/rfc-2151-raw-identifiers/items.rs | 2 ++ src/test/run-pass/rfc-2151-raw-identifiers/macros.rs | 1 + src/test/ui/feature-gate-raw-identifiers.rs | 14 ++++++++++++++ src/test/ui/feature-gate-raw-identifiers.stderr | 11 +++++++++++ src/test/ui/raw-literal-keywords.rs | 1 + src/test/ui/raw-literal-keywords.stderr | 6 +++--- src/test/ui/raw-literal-self.rs | 2 ++ src/test/ui/raw-literal-self.stderr | 2 +- 14 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 src/test/ui/feature-gate-raw-identifiers.rs create mode 100644 src/test/ui/feature-gate-raw-identifiers.stderr (limited to 'src/libsyntax') diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index fa600cd6860..153e42c8214 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -452,6 +452,9 @@ declare_features! ( // `use path as _;` and `extern crate c as _;` (active, underscore_imports, "1.26.0", Some(48216), None), + + // Raw identifiers allowing keyword names to be used + (active, raw_identifiers, "1.26.0", Some(48589), None), ); declare_features! ( @@ -1932,6 +1935,17 @@ pub fn check_crate(krate: &ast::Crate, parse_sess: sess, plugin_attributes, }; + + if !features.raw_identifiers { + for &span in sess.raw_identifier_spans.borrow().iter() { + if !span.allows_unstable() { + gate_feature!(&ctx, raw_identifiers, span, + "raw identifiers are experimental and subject to change" + ); + } + } + } + let visitor = &mut PostExpansionVisitor { context: &ctx }; visitor.whole_crate_feature_gates(krate); visit::walk_crate(visitor, krate); diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 0596fb44abe..8e746ea69e7 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1796,6 +1796,7 @@ mod tests { included_mod_stack: RefCell::new(Vec::new()), code_map: cm, missing_fragment_specifiers: RefCell::new(HashSet::new()), + raw_identifier_spans: RefCell::new(Vec::new()), registered_diagnostics: Lock::new(ErrorMap::new()), non_modrs_mods: RefCell::new(vec![]), } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 4acfdab53c0..03ac1e8b5a9 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -48,6 +48,9 @@ pub struct ParseSess { pub unstable_features: UnstableFeatures, pub config: CrateConfig, pub missing_fragment_specifiers: RefCell>, + /// Places where raw identifiers were used. This is used for feature gating + /// raw identifiers + pub raw_identifier_spans: RefCell>, /// The registered diagnostics codes pub registered_diagnostics: Lock, // Spans where a `mod foo;` statement was included in a non-mod.rs file. @@ -74,6 +77,7 @@ impl ParseSess { unstable_features: UnstableFeatures::from_environment(), config: HashSet::new(), missing_fragment_specifiers: RefCell::new(HashSet::new()), + raw_identifier_spans: RefCell::new(Vec::new()), registered_diagnostics: Lock::new(ErrorMap::new()), included_mod_stack: RefCell::new(vec![]), code_map, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4c1575cf589..c2ee78e9e9d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -784,7 +784,7 @@ impl<'a> Parser<'a> { fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { match self.token { - token::Ident(i, _) => { + token::Ident(i, is_raw) => { if self.token.is_reserved_ident() { let mut err = self.expected_ident_found(); if recover { @@ -793,6 +793,9 @@ impl<'a> Parser<'a> { return Err(err); } } + if is_raw { + self.sess.raw_identifier_spans.borrow_mut().push(self.span); + } self.bump(); Ok(i) } diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs b/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs index 2ef9fba2076..6cea75cf1d1 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(raw_identifiers)] + use std::mem; #[r#repr(r#C, r#packed)] diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs b/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs index eefce3981be..5d495c4e9e5 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(raw_identifiers)] + fn r#fn(r#match: u32) -> u32 { r#match } diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/items.rs b/src/test/run-pass/rfc-2151-raw-identifiers/items.rs index 4306ffe2042..256bd263d38 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/items.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/items.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(raw_identifiers)] + #[derive(Debug, PartialEq, Eq)] struct IntWrapper(u32); diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs b/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs index 9e89b79266c..4bd16ded52f 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs @@ -9,6 +9,7 @@ // except according to those terms. #![feature(decl_macro)] +#![feature(raw_identifiers)] r#macro_rules! r#struct { ($r#struct:expr) => { $r#struct } diff --git a/src/test/ui/feature-gate-raw-identifiers.rs b/src/test/ui/feature-gate-raw-identifiers.rs new file mode 100644 index 00000000000..38024feb432 --- /dev/null +++ b/src/test/ui/feature-gate-raw-identifiers.rs @@ -0,0 +1,14 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let r#foo = 3; //~ ERROR raw identifiers are experimental and subject to change + println!("{}", foo); +} diff --git a/src/test/ui/feature-gate-raw-identifiers.stderr b/src/test/ui/feature-gate-raw-identifiers.stderr new file mode 100644 index 00000000000..02eff7247c4 --- /dev/null +++ b/src/test/ui/feature-gate-raw-identifiers.stderr @@ -0,0 +1,11 @@ +error[E0658]: raw identifiers are experimental and subject to change (see issue #48589) + --> $DIR/feature-gate-raw-identifiers.rs:12:9 + | +LL | let r#foo = 3; //~ ERROR raw identifiers are experimental and subject to change + | ^^^^^ + | + = help: add #![feature(raw_identifiers)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/raw-literal-keywords.rs b/src/test/ui/raw-literal-keywords.rs index 8b3747dbe15..9b28aa0b151 100644 --- a/src/test/ui/raw-literal-keywords.rs +++ b/src/test/ui/raw-literal-keywords.rs @@ -11,6 +11,7 @@ // compile-flags: -Z parse-only #![feature(dyn_trait)] +#![feature(raw_identifiers)] fn test_if() { r#if true { } //~ ERROR found `true` diff --git a/src/test/ui/raw-literal-keywords.stderr b/src/test/ui/raw-literal-keywords.stderr index 022f80ae8a4..3758568323c 100644 --- a/src/test/ui/raw-literal-keywords.stderr +++ b/src/test/ui/raw-literal-keywords.stderr @@ -1,17 +1,17 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `true` - --> $DIR/raw-literal-keywords.rs:16:10 + --> $DIR/raw-literal-keywords.rs:17:10 | LL | r#if true { } //~ ERROR found `true` | ^^^^ expected one of 8 possible tokens here error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` - --> $DIR/raw-literal-keywords.rs:20:14 + --> $DIR/raw-literal-keywords.rs:21:14 | LL | r#struct Test; //~ ERROR found `Test` | ^^^^ expected one of 8 possible tokens here error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` - --> $DIR/raw-literal-keywords.rs:24:13 + --> $DIR/raw-literal-keywords.rs:25:13 | LL | r#union Test; //~ ERROR found `Test` | ^^^^ expected one of 8 possible tokens here diff --git a/src/test/ui/raw-literal-self.rs b/src/test/ui/raw-literal-self.rs index 17496d767b6..f88d6cf9a67 100644 --- a/src/test/ui/raw-literal-self.rs +++ b/src/test/ui/raw-literal-self.rs @@ -10,6 +10,8 @@ // compile-flags: -Z parse-only +#![feature(raw_identifiers)] + fn self_test(r#self: u32) { //~^ ERROR `r#self` is not currently supported. } diff --git a/src/test/ui/raw-literal-self.stderr b/src/test/ui/raw-literal-self.stderr index f4b75937247..e3345847aa8 100644 --- a/src/test/ui/raw-literal-self.stderr +++ b/src/test/ui/raw-literal-self.stderr @@ -1,5 +1,5 @@ error: `r#self` is not currently supported. - --> $DIR/raw-literal-self.rs:13:14 + --> $DIR/raw-literal-self.rs:15:14 | LL | fn self_test(r#self: u32) { | ^^^^^^ -- cgit 1.4.1-3-g733a5 From d2e7953d1325b1a1fe1cef526dbe8d23fa3e00a1 Mon Sep 17 00:00:00 2001 From: Lymia Aluysia Date: Sun, 18 Mar 2018 11:21:38 -0500 Subject: Move raw_identifiers check to the lexer. --- src/libsyntax/parse/lexer/mod.rs | 4 ++++ src/libsyntax/parse/parser.rs | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 8e746ea69e7..068929c8948 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1155,6 +1155,10 @@ impl<'a> StringReader<'a> { &format!("`r#{}` is not currently supported.", ident.name) ).raise(); } + if is_raw_ident { + let span = self.mk_sp(raw_start, self.pos); + self.sess.raw_identifier_spans.borrow_mut().push(span); + } token::Ident(ident, is_raw_ident) })); } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c2ee78e9e9d..4c1575cf589 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -784,7 +784,7 @@ impl<'a> Parser<'a> { fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { match self.token { - token::Ident(i, is_raw) => { + token::Ident(i, _) => { if self.token.is_reserved_ident() { let mut err = self.expected_ident_found(); if recover { @@ -793,9 +793,6 @@ impl<'a> Parser<'a> { return Err(err); } } - if is_raw { - self.sess.raw_identifier_spans.borrow_mut().push(self.span); - } self.bump(); Ok(i) } -- cgit 1.4.1-3-g733a5 From 5c3d6320deb20f78d83d12fb3a319b9dd6b15290 Mon Sep 17 00:00:00 2001 From: Lymia Aluysia Date: Sun, 18 Mar 2018 12:16:02 -0500 Subject: Return a is_raw parameter from Token::ident rather than having separate methods. --- src/libsyntax/ext/tt/macro_parser.rs | 4 ++-- src/libsyntax/ext/tt/quoted.rs | 4 ++-- src/libsyntax/parse/token.rs | 45 ++++++++++++------------------------ 3 files changed, 19 insertions(+), 34 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 714b7ca981d..8cb331c65da 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -364,8 +364,8 @@ pub fn parse_failure_msg(tok: Token) -> String { /// Perform a token equality check, ignoring syntax context (that is, an unhygienic comparison) fn token_name_eq(t1: &Token, t2: &Token) -> bool { - if let (Some(id1), Some(id2)) = (t1.ident(), t2.ident()) { - id1.name == id2.name && t1.is_raw_ident() == t2.is_raw_ident() + if let (Some((id1, is_raw1)), Some((id2, is_raw2))) = (t1.ident(), t2.ident()) { + id1.name == id2.name && is_raw1 == is_raw2 } else if let (&token::Lifetime(id1), &token::Lifetime(id2)) = (t1, t2) { id1.name == id2.name } else { diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index 11eb9b940ae..f324edeb117 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -200,7 +200,7 @@ pub fn parse( let span = match trees.next() { Some(tokenstream::TokenTree::Token(span, token::Colon)) => match trees.next() { Some(tokenstream::TokenTree::Token(end_sp, ref tok)) => match tok.ident() { - Some(kind) => { + Some((kind, _)) => { let span = end_sp.with_lo(start_sp.lo()); result.push(TokenTree::MetaVarDecl(span, ident, kind)); continue; @@ -289,7 +289,7 @@ where // `tree` is followed by an `ident`. This could be `$meta_var` or the `$crate` special // metavariable that names the crate of the invokation. Some(tokenstream::TokenTree::Token(ident_span, ref token)) if token.is_ident() => { - let ident = token.ident().unwrap(); + let (ident, _) = token.ident().unwrap(); let span = ident_span.with_lo(span.lo()); if ident.name == keywords::Crate.name() { let ident = ast::Ident { diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 6406651bcba..4e7a282adc5 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -310,32 +310,17 @@ impl Token { } } - fn ident_common(&self, allow_raw: bool) -> Option { + pub fn ident(&self) -> Option<(ast::Ident, bool)> { match *self { - Ident(ident, is_raw) if !is_raw || allow_raw => Some(ident), + Ident(ident, is_raw) => Some((ident, is_raw)), Interpolated(ref nt) => match nt.0 { - NtIdent(ident, is_raw) if !is_raw || allow_raw => Some(ident.node), + NtIdent(ident, is_raw) => Some((ident.node, is_raw)), _ => None, }, _ => None, } } - pub fn nonraw_ident(&self) -> Option { - self.ident_common(false) - } - - pub fn is_raw_ident(&self) -> bool { - match *self { - Ident(_, true) => true, - _ => false, - } - } - - pub fn ident(&self) -> Option { - self.ident_common(true) - } - /// Returns `true` if the token is an identifier. pub fn is_ident(&self) -> bool { self.ident().is_some() @@ -404,37 +389,37 @@ impl Token { /// Returns `true` if the token is a given keyword, `kw`. pub fn is_keyword(&self, kw: keywords::Keyword) -> bool { - self.nonraw_ident().map(|ident| ident.name == kw.name()).unwrap_or(false) + self.ident().map(|(ident, is_raw)| ident.name == kw.name() && !is_raw).unwrap_or(false) } pub fn is_path_segment_keyword(&self) -> bool { - match self.nonraw_ident() { - Some(id) => is_path_segment_keyword(id), - None => false, + match self.ident() { + Some((id, false)) => is_path_segment_keyword(id), + _ => false, } } // Returns true for reserved identifiers used internally for elided lifetimes, // unnamed method parameters, crate root module, error recovery etc. pub fn is_special_ident(&self) -> bool { - match self.nonraw_ident() { - Some(id) => is_special_ident(id), + match self.ident() { + Some((id, false)) => is_special_ident(id), _ => false, } } /// Returns `true` if the token is a keyword used in the language. pub fn is_used_keyword(&self) -> bool { - match self.nonraw_ident() { - Some(id) => is_used_keyword(id), + match self.ident() { + Some((id, false)) => is_used_keyword(id), _ => false, } } /// Returns `true` if the token is a keyword reserved for possible future use. pub fn is_unused_keyword(&self) -> bool { - match self.nonraw_ident() { - Some(id) => is_unused_keyword(id), + match self.ident() { + Some((id, false)) => is_unused_keyword(id), _ => false, } } @@ -507,8 +492,8 @@ impl Token { /// Returns `true` if the token is either a special identifier or a keyword. pub fn is_reserved_ident(&self) -> bool { - match self.nonraw_ident() { - Some(id) => is_reserved_ident(id), + match self.ident() { + Some((id, false)) => is_reserved_ident(id), _ => false, } } -- cgit 1.4.1-3-g733a5 From ce84a41936e367dfeb7d348564f2337819395ca6 Mon Sep 17 00:00:00 2001 From: Lymia Aluysia Date: Sun, 18 Mar 2018 13:27:56 -0500 Subject: Allow raw identifiers in diagnostic macros. --- src/libsyntax/diagnostics/plugin.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index c7e453c9e10..aecf32ab6af 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -44,7 +44,7 @@ pub fn expand_diagnostic_used<'cx>(ecx: &'cx mut ExtCtxt, token_tree: &[TokenTree]) -> Box { let code = match (token_tree.len(), token_tree.get(0)) { - (1, Some(&TokenTree::Token(_, token::Ident(code, false)))) => code, + (1, Some(&TokenTree::Token(_, token::Ident(code, _)))) => code, _ => unreachable!() }; @@ -82,10 +82,10 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt, token_tree.get(1), token_tree.get(2) ) { - (1, Some(&TokenTree::Token(_, token::Ident(ref code, false))), None, None) => { + (1, Some(&TokenTree::Token(_, token::Ident(ref code, _))), None, None) => { (code, None) }, - (3, Some(&TokenTree::Token(_, token::Ident(ref code, false))), + (3, Some(&TokenTree::Token(_, token::Ident(ref code, _))), Some(&TokenTree::Token(_, token::Comma)), Some(&TokenTree::Token(_, token::Literal(token::StrRaw(description, _), None)))) => { (code, Some(description)) @@ -150,9 +150,9 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt, let (crate_name, name) = match (&token_tree[0], &token_tree[2]) { ( // Crate name. - &TokenTree::Token(_, token::Ident(ref crate_name, false)), + &TokenTree::Token(_, token::Ident(ref crate_name, _)), // DIAGNOSTICS ident. - &TokenTree::Token(_, token::Ident(ref name, false)) + &TokenTree::Token(_, token::Ident(ref name, _)) ) => (*&crate_name, name), _ => unreachable!() }; -- cgit 1.4.1-3-g733a5 From 3c8d55549728ec117fb6e3de93ce3d96fb6622d4 Mon Sep 17 00:00:00 2001 From: Kurtis Nusbaum Date: Wed, 14 Mar 2018 20:30:06 -0700 Subject: rename epoch to edition --- src/librustc/lint/context.rs | 12 ++-- src/librustc/lint/mod.rs | 20 +++---- src/librustc/session/config.rs | 24 ++++---- src/librustc/session/mod.rs | 10 ++-- src/librustc_driver/driver.rs | 2 +- src/librustc_lint/lib.rs | 34 +++++------ src/librustc_typeck/check/method/probe.rs | 2 +- src/libsyntax/config.rs | 6 +- src/libsyntax/edition.rs | 69 ++++++++++++++++++++++ src/libsyntax/epoch.rs | 69 ---------------------- src/libsyntax/feature_gate.rs | 20 +++---- src/libsyntax/lib.rs | 2 +- .../edition-raw-pointer-method-2015.rs | 23 ++++++++ .../edition-raw-pointer-method-2018.rs | 22 +++++++ .../compile-fail/epoch-raw-pointer-method-2015.rs | 23 -------- .../compile-fail/epoch-raw-pointer-method-2018.rs | 22 ------- src/test/run-pass/dyn-trait.rs | 2 +- src/test/run-pass/epoch-gate-feature.rs | 2 +- .../inference-variable-behind-raw-pointer.stderr | 2 +- 19 files changed, 183 insertions(+), 183 deletions(-) create mode 100644 src/libsyntax/edition.rs delete mode 100644 src/libsyntax/epoch.rs create mode 100644 src/test/compile-fail/edition-raw-pointer-method-2015.rs create mode 100644 src/test/compile-fail/edition-raw-pointer-method-2018.rs delete mode 100644 src/test/compile-fail/epoch-raw-pointer-method-2015.rs delete mode 100644 src/test/compile-fail/epoch-raw-pointer-method-2018.rs (limited to 'src/libsyntax') diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 4fa6594df16..936aa71f16c 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -41,7 +41,7 @@ use util::nodemap::FxHashMap; use std::default::Default as StdDefault; use std::cell::{Ref, RefCell}; use syntax::ast; -use syntax::epoch; +use syntax::edition; use syntax_pos::{MultiSpan, Span}; use errors::DiagnosticBuilder; use hir; @@ -103,9 +103,9 @@ pub struct FutureIncompatibleInfo { pub id: LintId, /// e.g., a URL for an issue/PR/RFC or error code pub reference: &'static str, - /// If this is an epoch fixing lint, the epoch in which + /// If this is an edition fixing lint, the edition in which /// this lint becomes obsolete - pub epoch: Option, + pub edition: Option, } /// The target of the `by_name` map, which accounts for renaming/deprecation. @@ -201,11 +201,11 @@ impl LintStore { sess: Option<&Session>, lints: Vec) { - for epoch in epoch::ALL_EPOCHS { - let lints = lints.iter().filter(|f| f.epoch == Some(*epoch)).map(|f| f.id) + for edition in edition::ALL_EPOCHS { + let lints = lints.iter().filter(|f| f.edition == Some(*edition)).map(|f| f.id) .collect::>(); if !lints.is_empty() { - self.register_group(sess, false, epoch.lint_name(), lints) + self.register_group(sess, false, edition.lint_name(), lints) } } diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 7c103dc2721..cd038d067a1 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -42,7 +42,7 @@ use session::{Session, DiagnosticMessageId}; use std::hash; use syntax::ast; use syntax::codemap::MultiSpan; -use syntax::epoch::Epoch; +use syntax::edition::Edition; use syntax::symbol::Symbol; use syntax::visit as ast_visit; use syntax_pos::Span; @@ -77,8 +77,8 @@ pub struct Lint { /// e.g. "imports that are never used" pub desc: &'static str, - /// Deny lint after this epoch - pub epoch_deny: Option, + /// Deny lint after this edition + pub edition_deny: Option, } impl Lint { @@ -88,8 +88,8 @@ impl Lint { } pub fn default_level(&self, session: &Session) -> Level { - if let Some(epoch_deny) = self.epoch_deny { - if session.epoch() >= epoch_deny { + if let Some(edition_deny) = self.edition_deny { + if session.edition() >= edition_deny { return Level::Deny } } @@ -100,12 +100,12 @@ impl Lint { /// Declare a static item of type `&'static Lint`. #[macro_export] macro_rules! declare_lint { - ($vis: vis $NAME: ident, $Level: ident, $desc: expr, $epoch: expr) => ( + ($vis: vis $NAME: ident, $Level: ident, $desc: expr, $edition: expr) => ( $vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint { name: stringify!($NAME), default_level: $crate::lint::$Level, desc: $desc, - epoch_deny: Some($epoch) + edition_deny: Some($edition) }; ); ($vis: vis $NAME: ident, $Level: ident, $desc: expr) => ( @@ -113,7 +113,7 @@ macro_rules! declare_lint { name: stringify!($NAME), default_level: $crate::lint::$Level, desc: $desc, - epoch_deny: None, + edition_deny: None, }; ); } @@ -499,8 +499,8 @@ pub fn struct_lint_level<'a>(sess: &'a Session, // Check for future incompatibility lints and issue a stronger warning. let lints = sess.lint_store.borrow(); if let Some(future_incompatible) = lints.future_incompatible(LintId::of(lint)) { - let future = if let Some(epoch) = future_incompatible.epoch { - format!("the {} epoch", epoch) + let future = if let Some(edition) = future_incompatible.edition { + format!("the {} edition", edition) } else { "a future release".to_owned() }; diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 0d91074e946..4ba634f8b25 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -28,7 +28,7 @@ use middle::cstore; use syntax::ast::{self, IntTy, UintTy}; use syntax::codemap::{FileName, FilePathMapping}; -use syntax::epoch::Epoch; +use syntax::edition::Edition; use syntax::parse::token; use syntax::parse; use syntax::symbol::Symbol; @@ -771,7 +771,7 @@ macro_rules! options { Some("`string` or `string=string`"); pub const parse_lto: Option<&'static str> = Some("one of `thin`, `fat`, or omitted"); - pub const parse_epoch: Option<&'static str> = + pub const parse_edition: Option<&'static str> = Some("one of: `2015`, `2018`"); } @@ -780,7 +780,7 @@ macro_rules! options { use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto}; use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel}; use std::path::PathBuf; - use syntax::epoch::Epoch; + use syntax::edition::Edition; $( pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool { @@ -983,11 +983,11 @@ macro_rules! options { true } - fn parse_epoch(slot: &mut Epoch, v: Option<&str>) -> bool { + fn parse_edition(slot: &mut Edition, v: Option<&str>) -> bool { match v { Some(s) => { - let epoch = s.parse(); - if let Ok(parsed) = epoch { + let edition = s.parse(); + if let Ok(parsed) = edition { *slot = parsed; true } else { @@ -1280,10 +1280,10 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, `everybody_loops` (all function bodies replaced with `loop {}`), `hir` (the HIR), `hir,identified`, or `hir,typed` (HIR with types for each node)."), - epoch: Epoch = (Epoch::Epoch2015, parse_epoch, [TRACKED], - "The epoch to build Rust with. Newer epochs may include features - that require breaking changes. The default epoch is 2015 (the first - epoch). Crates compiled with different epochs can be linked together."), + edition: Edition = (Edition::Edition2015, parse_edition, [TRACKED], + "The edition to build Rust with. Newer editions may include features + that require breaking changes. The default edition is 2015 (the first + edition). Crates compiled with different editions can be linked together."), run_dsymutil: Option = (None, parse_opt_bool, [TRACKED], "run `dsymutil` and delete intermediate object files"), ui_testing: bool = (false, parse_bool, [UNTRACKED], @@ -2258,7 +2258,7 @@ mod dep_tracking { use std::hash::Hash; use std::path::PathBuf; use std::collections::hash_map::DefaultHasher; - use super::{CrateType, DebugInfoLevel, Epoch, ErrorOutputType, Lto, OptLevel, OutputTypes, + use super::{CrateType, DebugInfoLevel, Edition, ErrorOutputType, Lto, OptLevel, OutputTypes, Passes, Sanitizer}; use syntax::feature_gate::UnstableFeatures; use rustc_back::{PanicStrategy, RelroLevel}; @@ -2320,7 +2320,7 @@ mod dep_tracking { impl_dep_tracking_hash_via_hash!(cstore::NativeLibraryKind); impl_dep_tracking_hash_via_hash!(Sanitizer); impl_dep_tracking_hash_via_hash!(Option); - impl_dep_tracking_hash_via_hash!(Epoch); + impl_dep_tracking_hash_via_hash!(Edition); impl_dep_tracking_hash_for_sortable_vec_of!(String); impl_dep_tracking_hash_for_sortable_vec_of!(PathBuf); diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 3f52ecfc099..556255e06ed 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -31,7 +31,7 @@ use rustc_data_structures::sync::{Lrc, Lock}; use syntax::ast::NodeId; use errors::{self, DiagnosticBuilder, DiagnosticId}; use errors::emitter::{Emitter, EmitterWriter}; -use syntax::epoch::Epoch; +use syntax::edition::Edition; use syntax::json::JsonEmitter; use syntax::feature_gate; use syntax::symbol::Symbol; @@ -976,13 +976,13 @@ impl Session { self.opts.debugging_opts.teach && !self.parse_sess.span_diagnostic.code_emitted(code) } - /// Are we allowed to use features from the Rust 2018 epoch? + /// Are we allowed to use features from the Rust 2018 edition? pub fn rust_2018(&self) -> bool { - self.opts.debugging_opts.epoch >= Epoch::Epoch2018 + self.opts.debugging_opts.edition >= Edition::Edition2018 } - pub fn epoch(&self) -> Epoch { - self.opts.debugging_opts.epoch + pub fn edition(&self) -> Edition { + self.opts.debugging_opts.edition } } diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index f2fe6542db1..a3115544f30 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -648,7 +648,7 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(sess: &'a Session, { let (mut krate, features) = syntax::config::features(krate, &sess.parse_sess, sess.opts.test, - sess.opts.debugging_opts.epoch); + sess.opts.debugging_opts.edition); // these need to be set "early" so that expansion sees `quote` if enabled. sess.init_features(features); diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index ce896bfb701..59d2d3e8fdc 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -48,7 +48,7 @@ use rustc::session; use rustc::util; use session::Session; -use syntax::epoch::Epoch; +use syntax::edition::Edition; use lint::LintId; use lint::FutureIncompatibleInfo; @@ -197,82 +197,82 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { FutureIncompatibleInfo { id: LintId::of(PRIVATE_IN_PUBLIC), reference: "issue #34537 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(PUB_USE_OF_PRIVATE_EXTERN_CRATE), reference: "issue #34537 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(PATTERNS_IN_FNS_WITHOUT_BODY), reference: "issue #35203 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(SAFE_EXTERN_STATICS), reference: "issue #36247 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(INVALID_TYPE_PARAM_DEFAULT), reference: "issue #36887 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(LEGACY_DIRECTORY_OWNERSHIP), reference: "issue #37872 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(LEGACY_IMPORTS), reference: "issue #38260 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(LEGACY_CONSTRUCTOR_VISIBILITY), reference: "issue #39207 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(MISSING_FRAGMENT_SPECIFIER), reference: "issue #40107 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(ILLEGAL_FLOATING_POINT_LITERAL_PATTERN), reference: "issue #41620 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(ANONYMOUS_PARAMETERS), reference: "issue #41686 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES), reference: "issue #42238 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(LATE_BOUND_LIFETIME_ARGUMENTS), reference: "issue #42868 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(SAFE_PACKED_BORROWS), reference: "issue #46043 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(INCOHERENT_FUNDAMENTAL_IMPLS), reference: "issue #46205 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(TYVAR_BEHIND_RAW_POINTER), reference: "issue #46906 ", - epoch: Some(Epoch::Epoch2018), + edition: Some(Edition::Edition2018), } ]); diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 4d344eb2799..c7921d2bd45 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -326,7 +326,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if reached_raw_pointer && !self.tcx.features().arbitrary_self_types { // this case used to be allowed by the compiler, - // so we do a future-compat lint here for the 2015 epoch + // so we do a future-compat lint here for the 2015 edition // (see https://github.com/rust-lang/rust/issues/46906) if self.tcx.sess.rust_2018() { span_err!(self.tcx.sess, span, E0908, diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 6013c20daf2..56b1306e5b3 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -13,7 +13,7 @@ use feature_gate::{feature_err, EXPLAIN_STMT_ATTR_SYNTAX, Features, get_features use {fold, attr}; use ast; use codemap::Spanned; -use epoch::Epoch; +use edition::Edition; use parse::{token, ParseSess}; use ptr::P; @@ -27,7 +27,7 @@ pub struct StripUnconfigured<'a> { } // `cfg_attr`-process the crate's attributes and compute the crate's features. -pub fn features(mut krate: ast::Crate, sess: &ParseSess, should_test: bool, epoch: Epoch) +pub fn features(mut krate: ast::Crate, sess: &ParseSess, should_test: bool, edition: Edition) -> (ast::Crate, Features) { let features; { @@ -47,7 +47,7 @@ pub fn features(mut krate: ast::Crate, sess: &ParseSess, should_test: bool, epoc return (krate, Features::new()); } - features = get_features(&sess.span_diagnostic, &krate.attrs, epoch); + features = get_features(&sess.span_diagnostic, &krate.attrs, edition); // Avoid reconfiguring malformed `cfg_attr`s if err_count == sess.span_diagnostic.err_count() { diff --git a/src/libsyntax/edition.rs b/src/libsyntax/edition.rs new file mode 100644 index 00000000000..12ac6410ce1 --- /dev/null +++ b/src/libsyntax/edition.rs @@ -0,0 +1,69 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt; +use std::str::FromStr; + +/// The edition of the compiler (RFC 2052) +#[derive(Clone, Copy, Hash, PartialOrd, Ord, Eq, PartialEq, Debug)] +#[non_exhaustive] +pub enum Edition { + // editions must be kept in order, newest to oldest + + /// The 2015 edition + Edition2015, + /// The 2018 edition + Edition2018, + + // when adding new editions, be sure to update: + // + // - the list in the `parse_edition` static in librustc::session::config + // - add a `rust_####()` function to the session + // - update the enum in Cargo's sources as well + // + // When -Zedition becomes --edition, there will + // also be a check for the edition being nightly-only + // somewhere. That will need to be updated + // whenever we're stabilizing/introducing a new edition + // as well as changing the default Cargo template. +} + +// must be in order from oldest to newest +pub const ALL_EPOCHS: &[Edition] = &[Edition::Edition2015, Edition::Edition2018]; + +impl fmt::Display for Edition { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let s = match *self { + Edition::Edition2015 => "2015", + Edition::Edition2018 => "2018", + }; + write!(f, "{}", s) + } +} + +impl Edition { + pub fn lint_name(&self) -> &'static str { + match *self { + Edition::Edition2015 => "edition_2015", + Edition::Edition2018 => "edition_2018", + } + } +} + +impl FromStr for Edition { + type Err = (); + fn from_str(s: &str) -> Result { + match s { + "2015" => Ok(Edition::Edition2015), + "2018" => Ok(Edition::Edition2018), + _ => Err(()) + } + } +} diff --git a/src/libsyntax/epoch.rs b/src/libsyntax/epoch.rs deleted file mode 100644 index 32cbc79c550..00000000000 --- a/src/libsyntax/epoch.rs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::fmt; -use std::str::FromStr; - -/// The epoch of the compiler (RFC 2052) -#[derive(Clone, Copy, Hash, PartialOrd, Ord, Eq, PartialEq, Debug)] -#[non_exhaustive] -pub enum Epoch { - // epochs must be kept in order, newest to oldest - - /// The 2015 epoch - Epoch2015, - /// The 2018 epoch - Epoch2018, - - // when adding new epochs, be sure to update: - // - // - the list in the `parse_epoch` static in librustc::session::config - // - add a `rust_####()` function to the session - // - update the enum in Cargo's sources as well - // - // When -Zepoch becomes --epoch, there will - // also be a check for the epoch being nightly-only - // somewhere. That will need to be updated - // whenever we're stabilizing/introducing a new epoch - // as well as changing the default Cargo template. -} - -// must be in order from oldest to newest -pub const ALL_EPOCHS: &[Epoch] = &[Epoch::Epoch2015, Epoch::Epoch2018]; - -impl fmt::Display for Epoch { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let s = match *self { - Epoch::Epoch2015 => "2015", - Epoch::Epoch2018 => "2018", - }; - write!(f, "{}", s) - } -} - -impl Epoch { - pub fn lint_name(&self) -> &'static str { - match *self { - Epoch::Epoch2015 => "epoch_2015", - Epoch::Epoch2018 => "epoch_2018", - } - } -} - -impl FromStr for Epoch { - type Err = (); - fn from_str(s: &str) -> Result { - match s { - "2015" => Ok(Epoch::Epoch2015), - "2018" => Ok(Epoch::Epoch2018), - _ => Err(()) - } - } -} diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 915396d29fe..8feb8d6a402 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -28,7 +28,7 @@ use self::AttributeGate::*; use abi::Abi; use ast::{self, NodeId, PatKind, RangeEnd}; use attr; -use epoch::Epoch; +use edition::Edition; use codemap::Spanned; use syntax_pos::{Span, DUMMY_SP}; use errors::{DiagnosticBuilder, Handler, FatalError}; @@ -55,13 +55,13 @@ macro_rules! set { } macro_rules! declare_features { - ($((active, $feature: ident, $ver: expr, $issue: expr, $epoch: expr),)+) => { + ($((active, $feature: ident, $ver: expr, $issue: expr, $edition: expr),)+) => { /// Represents active features that are currently being implemented or /// currently being considered for addition/removal. const ACTIVE_FEATURES: &'static [(&'static str, &'static str, Option, - Option, fn(&mut Features, Span))] = - &[$((stringify!($feature), $ver, $issue, $epoch, set!($feature))),+]; + Option, fn(&mut Features, Span))] = + &[$((stringify!($feature), $ver, $issue, $edition, set!($feature))),+]; /// A set of features to be used by later passes. #[derive(Clone)] @@ -402,7 +402,7 @@ declare_features! ( (active, match_default_bindings, "1.22.0", Some(42640), None), // Trait object syntax with `dyn` prefix - (active, dyn_trait, "1.22.0", Some(44662), Some(Epoch::Epoch2018)), + (active, dyn_trait, "1.22.0", Some(44662), Some(Edition::Edition2018)), // `crate` as visibility modifier, synonymous to `pub(crate)` (active, crate_visibility_modifier, "1.23.0", Some(45388), None), @@ -1800,16 +1800,16 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute], - epoch: Epoch) -> Features { + edition: Edition) -> Features { let mut features = Features::new(); let mut feature_checker = FeatureChecker::default(); - for &(.., f_epoch, set) in ACTIVE_FEATURES.iter() { - if let Some(f_epoch) = f_epoch { - if epoch >= f_epoch { + for &(.., f_edition, set) in ACTIVE_FEATURES.iter() { + if let Some(f_edition) = f_edition { + if edition >= f_edition { // FIXME(Manishearth) there is currently no way to set - // lang features by epoch + // lang features by edition set(&mut features, DUMMY_SP); } } diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 5f58b3bc3a0..74f1ee373ec 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -145,7 +145,7 @@ pub mod codemap; #[macro_use] pub mod config; pub mod entry; -pub mod epoch; +pub mod edition; pub mod feature_gate; pub mod fold; pub mod parse; diff --git a/src/test/compile-fail/edition-raw-pointer-method-2015.rs b/src/test/compile-fail/edition-raw-pointer-method-2015.rs new file mode 100644 index 00000000000..fdc9b4f704c --- /dev/null +++ b/src/test/compile-fail/edition-raw-pointer-method-2015.rs @@ -0,0 +1,23 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength +// compile-flags: -Zedition=2015 -Zunstable-options + +// tests that editions work with the tyvar warning-turned-error + +#[deny(warnings)] +fn main() { + let x = 0; + let y = &x as *const _; + let _ = y.is_null(); + //~^ error: type annotations needed [tyvar_behind_raw_pointer] + //~^^ warning: this was previously accepted +} diff --git a/src/test/compile-fail/edition-raw-pointer-method-2018.rs b/src/test/compile-fail/edition-raw-pointer-method-2018.rs new file mode 100644 index 00000000000..58b34591029 --- /dev/null +++ b/src/test/compile-fail/edition-raw-pointer-method-2018.rs @@ -0,0 +1,22 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength +// compile-flags: -Zedition=2018 -Zunstable-options + +// tests that editions work with the tyvar warning-turned-error + +#[deny(warnings)] +fn main() { + let x = 0; + let y = &x as *const _; + let _ = y.is_null(); + //~^ error: the type of this value must be known to call a method on a raw pointer on it [E0908] +} diff --git a/src/test/compile-fail/epoch-raw-pointer-method-2015.rs b/src/test/compile-fail/epoch-raw-pointer-method-2015.rs deleted file mode 100644 index 6aa83a38b7e..00000000000 --- a/src/test/compile-fail/epoch-raw-pointer-method-2015.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength -// compile-flags: -Zepoch=2015 -Zunstable-options - -// tests that epochs work with the tyvar warning-turned-error - -#[deny(warnings)] -fn main() { - let x = 0; - let y = &x as *const _; - let _ = y.is_null(); - //~^ error: type annotations needed [tyvar_behind_raw_pointer] - //~^^ warning: this was previously accepted -} diff --git a/src/test/compile-fail/epoch-raw-pointer-method-2018.rs b/src/test/compile-fail/epoch-raw-pointer-method-2018.rs deleted file mode 100644 index c4815de2306..00000000000 --- a/src/test/compile-fail/epoch-raw-pointer-method-2018.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength -// compile-flags: -Zepoch=2018 -Zunstable-options - -// tests that epochs work with the tyvar warning-turned-error - -#[deny(warnings)] -fn main() { - let x = 0; - let y = &x as *const _; - let _ = y.is_null(); - //~^ error: the type of this value must be known to call a method on a raw pointer on it [E0908] -} diff --git a/src/test/run-pass/dyn-trait.rs b/src/test/run-pass/dyn-trait.rs index fdec6a26ac9..399823ec92d 100644 --- a/src/test/run-pass/dyn-trait.rs +++ b/src/test/run-pass/dyn-trait.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-pretty `dyn ::foo` parses differently in the current epoch +// ignore-pretty `dyn ::foo` parses differently in the current edition #![feature(dyn_trait)] diff --git a/src/test/run-pass/epoch-gate-feature.rs b/src/test/run-pass/epoch-gate-feature.rs index 37d092c06e0..f3d8f216e11 100644 --- a/src/test/run-pass/epoch-gate-feature.rs +++ b/src/test/run-pass/epoch-gate-feature.rs @@ -11,7 +11,7 @@ // Checks if the correct registers are being used to pass arguments // when the sysv64 ABI is specified. -// compile-flags: -Zepoch=2018 +// compile-flags: -Zedition=2018 pub trait Foo {} diff --git a/src/test/ui/inference-variable-behind-raw-pointer.stderr b/src/test/ui/inference-variable-behind-raw-pointer.stderr index eb40151615d..fe6dc0b0748 100644 --- a/src/test/ui/inference-variable-behind-raw-pointer.stderr +++ b/src/test/ui/inference-variable-behind-raw-pointer.stderr @@ -5,6 +5,6 @@ LL | if data.is_null() {} | ^^^^^^^ | = note: #[warn(tyvar_behind_raw_pointer)] on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 epoch! + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! = note: for more information, see issue #46906 -- cgit 1.4.1-3-g733a5 From 11f14060a4da7776c5f56e7dc53cc9545e4ab25f Mon Sep 17 00:00:00 2001 From: Kurtis Nusbaum Date: Wed, 14 Mar 2018 20:56:13 -0700 Subject: change all appropriate EPOCH to EDITION --- src/librustc/lint/context.rs | 2 +- src/libsyntax/edition.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libsyntax') diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 936aa71f16c..3c833251f72 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -201,7 +201,7 @@ impl LintStore { sess: Option<&Session>, lints: Vec) { - for edition in edition::ALL_EPOCHS { + for edition in edition::ALL_EDITIONS { let lints = lints.iter().filter(|f| f.edition == Some(*edition)).map(|f| f.id) .collect::>(); if !lints.is_empty() { diff --git a/src/libsyntax/edition.rs b/src/libsyntax/edition.rs index 12ac6410ce1..61246d4493c 100644 --- a/src/libsyntax/edition.rs +++ b/src/libsyntax/edition.rs @@ -36,7 +36,7 @@ pub enum Edition { } // must be in order from oldest to newest -pub const ALL_EPOCHS: &[Edition] = &[Edition::Edition2015, Edition::Edition2018]; +pub const ALL_EDITIONS: &[Edition] = &[Edition::Edition2015, Edition::Edition2018]; impl fmt::Display for Edition { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { -- cgit 1.4.1-3-g733a5 From bfb94ac5f43ac7fb0736185421f6135fe7043a2e Mon Sep 17 00:00:00 2001 From: Lymia Aluysia Date: Thu, 22 Mar 2018 10:34:51 -0500 Subject: Clean up raw identifier handling when recovering tokens from AST. --- src/libsyntax/ext/quote.rs | 5 +++-- src/libsyntax/ext/tt/transcribe.rs | 2 +- src/libsyntax/parse/token.rs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 090b9a35446..540a03ff032 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -238,8 +238,9 @@ pub mod rt { if i > 0 { inner.push(TokenTree::Token(self.span, token::Colon).into()); } - inner.push(TokenTree::Token(self.span, - token::Ident(segment.identifier, false)).into()); + inner.push(TokenTree::Token( + self.span, token::Token::from_ast_ident(segment.identifier) + ).into()); } inner.push(self.tokens.clone()); diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 0f5855a3225..3f01d5ec6dd 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -169,7 +169,7 @@ pub fn transcribe(cx: &ExtCtxt, Ident { ctxt: ident.ctxt.apply_mark(cx.current_expansion.mark), ..ident }; sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark)); result.push(TokenTree::Token(sp, token::Dollar).into()); - result.push(TokenTree::Token(sp, token::Ident(ident, false)).into()); + result.push(TokenTree::Token(sp, token::Token::from_ast_ident(ident)).into()); } } quoted::TokenTree::Delimited(mut span, delimited) => { diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 4e7a282adc5..7798a7a77ee 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -236,7 +236,7 @@ impl Token { /// Recovers a `Token` from an `ast::Ident`. This creates a raw identifier if necessary. pub fn from_ast_ident(ident: ast::Ident) -> Token { - Ident(ident, is_reserved_ident(ident)) + Ident(ident, is_reserved_ident(ident) && !is_path_segment_keyword(ident)) } /// Returns `true` if the token starts with '>'. -- cgit 1.4.1-3-g733a5 From 57f9c4d6d9ba7d48b9f64193dd037a54e11ef7b4 Mon Sep 17 00:00:00 2001 From: Lymia Aluysia Date: Thu, 22 Mar 2018 10:35:49 -0500 Subject: Clarify description of raw_identifiers feature flag. --- src/libsyntax/feature_gate.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 153e42c8214..c64e0f514de 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -453,7 +453,7 @@ declare_features! ( // `use path as _;` and `extern crate c as _;` (active, underscore_imports, "1.26.0", Some(48216), None), - // Raw identifiers allowing keyword names to be used + // Allows keywords to be escaped for use as identifiers (active, raw_identifiers, "1.26.0", Some(48589), None), ); -- cgit 1.4.1-3-g733a5 From 7df6f4161cdc13a19216b5f1087081f490f06cdb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 9 Mar 2018 09:26:15 -0800 Subject: rustc: Add a `#[wasm_custom_section]` attribute This commit is an implementation of adding custom sections to wasm artifacts in rustc. The intention here is to expose the ability of the wasm binary format to contain custom sections with arbitrary user-defined data. Currently neither our version of LLVM nor LLD supports this so the implementation is currently custom to rustc itself. The implementation here is to attach a `#[wasm_custom_section = "foo"]` attribute to any `const` which has a type like `[u8; N]`. Other types of constants aren't supported yet but may be added one day! This should hopefully be enough to get off the ground with *some* custom section support. The current semantics are that any constant tagged with `#[wasm_custom_section]` section will be *appended* to the corresponding section in the final output wasm artifact (and this affects dependencies linked in as well, not just the final crate). This means that whatever is interpreting the contents must be able to interpret binary-concatenated sections (or each constant needs to be in its own custom section). To test this change the existing `run-make` test suite was moved to a `run-make-fulldeps` folder and a new `run-make` test suite was added which applies to all targets by default. This test suite currently only has one test which only runs for the wasm target (using a node.js script to use `WebAssembly` in JS to parse the wasm output). --- src/bootstrap/builder.rs | 1 + src/bootstrap/compile.rs | 2 +- src/bootstrap/test.rs | 19 +- src/librustc/dep_graph/dep_node.rs | 2 + src/librustc/hir/check_attr.rs | 13 + src/librustc/middle/dead.rs | 5 + src/librustc/ty/maps/config.rs | 6 + src/librustc/ty/maps/mod.rs | 2 + src/librustc/ty/maps/plumbing.rs | 1 + src/librustc_metadata/cstore_impl.rs | 2 + src/librustc_metadata/decoder.rs | 10 + src/librustc_metadata/encoder.rs | 12 + src/librustc_metadata/schema.rs | 1 + src/librustc_trans/attributes.rs | 32 +- src/librustc_trans/back/link.rs | 6 + src/librustc_trans/back/wasm.rs | 44 ++ src/librustc_trans/base.rs | 66 +++ src/librustc_trans/lib.rs | 3 + src/librustc_typeck/check/mod.rs | 23 +- src/libsyntax/feature_gate.rs | 8 + .../run-make-fulldeps/a-b-a-linker-guard/Makefile | 12 + src/test/run-make-fulldeps/a-b-a-linker-guard/a.rs | 18 + src/test/run-make-fulldeps/a-b-a-linker-guard/b.rs | 17 + .../run-make-fulldeps/alloc-extern-crates/Makefile | 5 + .../alloc-extern-crates/fakealloc.rs | 33 ++ .../allow-non-lint-warnings-cmdline/Makefile | 11 + .../allow-non-lint-warnings-cmdline/foo.rs | 15 + .../allow-warnings-cmdline-stability/Makefile | 15 + .../allow-warnings-cmdline-stability/bar.rs | 15 + .../allow-warnings-cmdline-stability/foo.rs | 15 + .../archive-duplicate-names/Makefile | 11 + .../archive-duplicate-names/bar.c | 11 + .../archive-duplicate-names/bar.rs | 15 + .../archive-duplicate-names/foo.c | 11 + .../archive-duplicate-names/foo.rs | 24 ++ .../run-make-fulldeps/atomic-lock-free/Makefile | 46 ++ .../atomic-lock-free/atomic_lock_free.rs | 66 +++ src/test/run-make-fulldeps/bare-outfile/Makefile | 6 + src/test/run-make-fulldeps/bare-outfile/foo.rs | 12 + .../run-make-fulldeps/c-dynamic-dylib/Makefile | 14 + src/test/run-make-fulldeps/c-dynamic-dylib/bar.rs | 15 + src/test/run-make-fulldeps/c-dynamic-dylib/cfoo.c | 5 + src/test/run-make-fulldeps/c-dynamic-dylib/foo.rs | 20 + src/test/run-make-fulldeps/c-dynamic-rlib/Makefile | 17 + src/test/run-make-fulldeps/c-dynamic-rlib/bar.rs | 15 + src/test/run-make-fulldeps/c-dynamic-rlib/cfoo.c | 6 + src/test/run-make-fulldeps/c-dynamic-rlib/foo.rs | 20 + .../c-link-to-rust-dylib/Makefile | 17 + .../run-make-fulldeps/c-link-to-rust-dylib/bar.c | 7 + .../run-make-fulldeps/c-link-to-rust-dylib/foo.rs | 14 + .../c-link-to-rust-staticlib/Makefile | 16 + .../c-link-to-rust-staticlib/bar.c | 7 + .../c-link-to-rust-staticlib/foo.rs | 14 + src/test/run-make-fulldeps/c-static-dylib/Makefile | 9 + src/test/run-make-fulldeps/c-static-dylib/bar.rs | 15 + src/test/run-make-fulldeps/c-static-dylib/cfoo.c | 2 + src/test/run-make-fulldeps/c-static-dylib/foo.rs | 20 + src/test/run-make-fulldeps/c-static-rlib/Makefile | 8 + src/test/run-make-fulldeps/c-static-rlib/bar.rs | 15 + src/test/run-make-fulldeps/c-static-rlib/cfoo.c | 2 + src/test/run-make-fulldeps/c-static-rlib/foo.rs | 20 + .../cat-and-grep-sanity-check/Makefile | 46 ++ .../cdylib-fewer-symbols/Makefile | 15 + .../run-make-fulldeps/cdylib-fewer-symbols/foo.rs | 16 + src/test/run-make-fulldeps/cdylib/Makefile | 19 + src/test/run-make-fulldeps/cdylib/bar.rs | 15 + src/test/run-make-fulldeps/cdylib/foo.c | 20 + src/test/run-make-fulldeps/cdylib/foo.rs | 23 + .../codegen-options-parsing/Makefile | 31 ++ .../codegen-options-parsing/dummy.rs | 11 + src/test/run-make-fulldeps/compile-stdin/Makefile | 5 + .../compiler-lookup-paths-2/Makefile | 8 + .../run-make-fulldeps/compiler-lookup-paths-2/a.rs | 11 + .../run-make-fulldeps/compiler-lookup-paths-2/b.rs | 12 + .../run-make-fulldeps/compiler-lookup-paths-2/c.rs | 13 + .../compiler-lookup-paths/Makefile | 38 ++ .../run-make-fulldeps/compiler-lookup-paths/a.rs | 11 + .../run-make-fulldeps/compiler-lookup-paths/b.rs | 12 + .../run-make-fulldeps/compiler-lookup-paths/c.rs | 12 + .../run-make-fulldeps/compiler-lookup-paths/d.rs | 14 + .../run-make-fulldeps/compiler-lookup-paths/e.rs | 12 + .../run-make-fulldeps/compiler-lookup-paths/e2.rs | 14 + .../run-make-fulldeps/compiler-lookup-paths/f.rs | 12 + .../compiler-lookup-paths/native.c | 9 + .../compiler-rt-works-on-mingw/Makefile | 17 + .../compiler-rt-works-on-mingw/foo.cpp | 5 + .../compiler-rt-works-on-mingw/foo.rs | 16 + .../run-make-fulldeps/crate-data-smoke/Makefile | 10 + .../run-make-fulldeps/crate-data-smoke/crate.rs | 17 + src/test/run-make-fulldeps/crate-data-smoke/lib.rs | 12 + .../run-make-fulldeps/crate-data-smoke/rlib.rs | 12 + .../run-make-fulldeps/crate-name-priority/Makefile | 11 + .../run-make-fulldeps/crate-name-priority/foo.rs | 11 + .../run-make-fulldeps/crate-name-priority/foo1.rs | 13 + .../run-make-fulldeps/debug-assertions/Makefile | 25 ++ .../run-make-fulldeps/debug-assertions/debug.rs | 43 ++ .../dep-info-doesnt-run-much/Makefile | 4 + .../dep-info-doesnt-run-much/foo.rs | 15 + .../run-make-fulldeps/dep-info-spaces/Makefile | 28 ++ .../run-make-fulldeps/dep-info-spaces/Makefile.foo | 7 + src/test/run-make-fulldeps/dep-info-spaces/bar.rs | 11 + .../run-make-fulldeps/dep-info-spaces/foo foo.rs | 11 + src/test/run-make-fulldeps/dep-info-spaces/lib.rs | 14 + src/test/run-make-fulldeps/dep-info/Makefile | 34 ++ src/test/run-make-fulldeps/dep-info/Makefile.foo | 7 + src/test/run-make-fulldeps/dep-info/bar.rs | 11 + src/test/run-make-fulldeps/dep-info/foo.rs | 11 + src/test/run-make-fulldeps/dep-info/lib.rs | 14 + src/test/run-make-fulldeps/dep-info/lib2.rs | 13 + .../duplicate-output-flavors/Makefile | 5 + .../duplicate-output-flavors/foo.rs | 11 + src/test/run-make-fulldeps/dylib-chain/Makefile | 12 + src/test/run-make-fulldeps/dylib-chain/m1.rs | 12 + src/test/run-make-fulldeps/dylib-chain/m2.rs | 14 + src/test/run-make-fulldeps/dylib-chain/m3.rs | 14 + src/test/run-make-fulldeps/dylib-chain/m4.rs | 13 + src/test/run-make-fulldeps/emit/Makefile | 21 + src/test/run-make-fulldeps/emit/test-24876.rs | 19 + src/test/run-make-fulldeps/emit/test-26235.rs | 56 +++ .../error-found-staticlib-instead-crate/Makefile | 5 + .../error-found-staticlib-instead-crate/bar.rs | 15 + .../error-found-staticlib-instead-crate/foo.rs | 11 + .../error-writing-dependencies/Makefile | 8 + .../error-writing-dependencies/foo.rs | 11 + .../extern-diff-internal-name/Makefile | 5 + .../extern-diff-internal-name/lib.rs | 12 + .../extern-diff-internal-name/test.rs | 15 + .../extern-flag-disambiguates/Makefile | 25 ++ .../extern-flag-disambiguates/a.rs | 16 + .../extern-flag-disambiguates/b.rs | 19 + .../extern-flag-disambiguates/c.rs | 19 + .../extern-flag-disambiguates/d.rs | 21 + .../run-make-fulldeps/extern-flag-fun/Makefile | 17 + .../run-make-fulldeps/extern-flag-fun/bar-alt.rs | 11 + src/test/run-make-fulldeps/extern-flag-fun/bar.rs | 9 + src/test/run-make-fulldeps/extern-flag-fun/foo.rs | 13 + .../run-make-fulldeps/extern-fn-generic/Makefile | 6 + .../run-make-fulldeps/extern-fn-generic/test.c | 17 + .../run-make-fulldeps/extern-fn-generic/test.rs | 32 ++ .../extern-fn-generic/testcrate.rs | 24 ++ .../run-make-fulldeps/extern-fn-mangle/Makefile | 5 + src/test/run-make-fulldeps/extern-fn-mangle/test.c | 9 + .../run-make-fulldeps/extern-fn-mangle/test.rs | 25 ++ .../run-make-fulldeps/extern-fn-reachable/Makefile | 9 + .../run-make-fulldeps/extern-fn-reachable/dylib.rs | 24 ++ .../run-make-fulldeps/extern-fn-reachable/main.rs | 28 ++ .../extern-fn-struct-passing-abi/Makefile | 5 + .../extern-fn-struct-passing-abi/test.c | 324 ++++++++++++++ .../extern-fn-struct-passing-abi/test.rs | 144 +++++++ .../extern-fn-with-extern-types/Makefile | 5 + .../extern-fn-with-extern-types/ctest.c | 17 + .../extern-fn-with-extern-types/test.rs | 27 ++ .../extern-fn-with-packed-struct/Makefile | 5 + .../extern-fn-with-packed-struct/test.c | 27 ++ .../extern-fn-with-packed-struct/test.rs | 30 ++ .../extern-fn-with-union/Makefile | 6 + .../run-make-fulldeps/extern-fn-with-union/ctest.c | 11 + .../run-make-fulldeps/extern-fn-with-union/test.rs | 33 ++ .../extern-fn-with-union/testcrate.rs | 21 + .../extern-multiple-copies/Makefile | 8 + .../extern-multiple-copies/bar.rs | 16 + .../extern-multiple-copies/foo1.rs | 11 + .../extern-multiple-copies/foo2.rs | 11 + .../extern-multiple-copies2/Makefile | 10 + .../extern-multiple-copies2/bar.rs | 18 + .../extern-multiple-copies2/foo1.rs | 17 + .../extern-multiple-copies2/foo2.rs | 18 + .../extern-overrides-distribution/Makefile | 5 + .../extern-overrides-distribution/libc.rs | 13 + .../extern-overrides-distribution/main.rs | 15 + .../extra-filename-with-temp-outputs/Makefile | 6 + .../extra-filename-with-temp-outputs/foo.rs | 11 + src/test/run-make-fulldeps/fpic/Makefile | 13 + src/test/run-make-fulldeps/fpic/hello.rs | 11 + src/test/run-make-fulldeps/hir-tree/Makefile | 8 + src/test/run-make-fulldeps/hir-tree/input.rs | 13 + .../hotplug_codegen_backend/Makefile | 9 + .../hotplug_codegen_backend/some_crate.rs | 13 + .../hotplug_codegen_backend/the_backend.rs | 82 ++++ .../run-make-fulldeps/include_bytes_deps/Makefile | 20 + .../run-make-fulldeps/include_bytes_deps/input.bin | 1 + .../run-make-fulldeps/include_bytes_deps/input.md | 1 + .../run-make-fulldeps/include_bytes_deps/input.txt | 1 + .../run-make-fulldeps/include_bytes_deps/main.rs | 22 + .../inline-always-many-cgu/Makefile | 8 + .../inline-always-many-cgu/foo.rs | 25 ++ .../interdependent-c-libraries/Makefile | 14 + .../interdependent-c-libraries/bar.c | 4 + .../interdependent-c-libraries/bar.rs | 22 + .../interdependent-c-libraries/foo.c | 2 + .../interdependent-c-libraries/foo.rs | 20 + .../interdependent-c-libraries/main.rs | 16 + .../intrinsic-unreachable/Makefile | 15 + .../intrinsic-unreachable/exit-ret.rs | 25 ++ .../intrinsic-unreachable/exit-unreachable.rs | 27 ++ .../run-make-fulldeps/invalid-library/Makefile | 6 + src/test/run-make-fulldeps/invalid-library/foo.rs | 13 + .../run-make-fulldeps/invalid-staticlib/Makefile | 5 + src/test/run-make-fulldeps/issue-11908/Makefile | 21 + src/test/run-make-fulldeps/issue-11908/bar.rs | 13 + src/test/run-make-fulldeps/issue-11908/foo.rs | 11 + src/test/run-make-fulldeps/issue-14500/Makefile | 17 + src/test/run-make-fulldeps/issue-14500/bar.rs | 11 + src/test/run-make-fulldeps/issue-14500/foo.c | 17 + src/test/run-make-fulldeps/issue-14500/foo.rs | 15 + src/test/run-make-fulldeps/issue-14698/Makefile | 4 + src/test/run-make-fulldeps/issue-14698/foo.rs | 11 + src/test/run-make-fulldeps/issue-15460/Makefile | 6 + src/test/run-make-fulldeps/issue-15460/bar.rs | 14 + src/test/run-make-fulldeps/issue-15460/foo.c | 6 + src/test/run-make-fulldeps/issue-15460/foo.rs | 16 + src/test/run-make-fulldeps/issue-18943/Makefile | 7 + src/test/run-make-fulldeps/issue-18943/foo.rs | 16 + src/test/run-make-fulldeps/issue-19371/Makefile | 9 + src/test/run-make-fulldeps/issue-19371/foo.rs | 88 ++++ src/test/run-make-fulldeps/issue-20626/Makefile | 8 + src/test/run-make-fulldeps/issue-20626/foo.rs | 23 + src/test/run-make-fulldeps/issue-22131/Makefile | 7 + src/test/run-make-fulldeps/issue-22131/foo.rs | 15 + src/test/run-make-fulldeps/issue-24445/Makefile | 12 + src/test/run-make-fulldeps/issue-24445/foo.c | 16 + src/test/run-make-fulldeps/issue-24445/foo.rs | 25 ++ src/test/run-make-fulldeps/issue-25581/Makefile | 5 + src/test/run-make-fulldeps/issue-25581/test.c | 16 + src/test/run-make-fulldeps/issue-25581/test.rs | 32 ++ src/test/run-make-fulldeps/issue-26006/Makefile | 18 + .../run-make-fulldeps/issue-26006/in/libc/lib.rs | 12 + .../run-make-fulldeps/issue-26006/in/time/lib.rs | 13 + src/test/run-make-fulldeps/issue-26092/Makefile | 4 + src/test/run-make-fulldeps/issue-26092/blank.rs | 11 + src/test/run-make-fulldeps/issue-28595/Makefile | 6 + src/test/run-make-fulldeps/issue-28595/a.c | 11 + src/test/run-make-fulldeps/issue-28595/a.rs | 16 + src/test/run-make-fulldeps/issue-28595/b.c | 16 + src/test/run-make-fulldeps/issue-28595/b.rs | 21 + src/test/run-make-fulldeps/issue-28766/Makefile | 5 + src/test/run-make-fulldeps/issue-28766/foo.rs | 18 + src/test/run-make-fulldeps/issue-28766/main.rs | 17 + src/test/run-make-fulldeps/issue-30063/Makefile | 35 ++ src/test/run-make-fulldeps/issue-30063/foo.rs | 11 + src/test/run-make-fulldeps/issue-33329/Makefile | 5 + src/test/run-make-fulldeps/issue-33329/main.rs | 11 + src/test/run-make-fulldeps/issue-35164/Makefile | 4 + src/test/run-make-fulldeps/issue-35164/main.rs | 15 + .../run-make-fulldeps/issue-35164/submodule/mod.rs | 13 + src/test/run-make-fulldeps/issue-37839/Makefile | 12 + src/test/run-make-fulldeps/issue-37839/a.rs | 12 + src/test/run-make-fulldeps/issue-37839/b.rs | 12 + src/test/run-make-fulldeps/issue-37839/c.rs | 12 + src/test/run-make-fulldeps/issue-37893/Makefile | 10 + src/test/run-make-fulldeps/issue-37893/a.rs | 12 + src/test/run-make-fulldeps/issue-37893/b.rs | 12 + src/test/run-make-fulldeps/issue-37893/c.rs | 13 + src/test/run-make-fulldeps/issue-38237/Makefile | 11 + src/test/run-make-fulldeps/issue-38237/bar.rs | 14 + src/test/run-make-fulldeps/issue-38237/baz.rs | 18 + src/test/run-make-fulldeps/issue-38237/foo.rs | 19 + src/test/run-make-fulldeps/issue-40535/Makefile | 13 + src/test/run-make-fulldeps/issue-40535/bar.rs | 13 + src/test/run-make-fulldeps/issue-40535/baz.rs | 11 + src/test/run-make-fulldeps/issue-40535/foo.rs | 14 + src/test/run-make-fulldeps/issue-46239/Makefile | 5 + src/test/run-make-fulldeps/issue-46239/main.rs | 18 + src/test/run-make-fulldeps/issue-7349/Makefile | 11 + src/test/run-make-fulldeps/issue-7349/foo.rs | 32 ++ .../run-make-fulldeps/issues-41478-43796/Makefile | 8 + src/test/run-make-fulldeps/issues-41478-43796/a.rs | 19 + src/test/run-make-fulldeps/libs-and-bins/Makefile | 6 + src/test/run-make-fulldeps/libs-and-bins/foo.rs | 14 + .../libs-through-symlinks/Makefile | 14 + .../run-make-fulldeps/libs-through-symlinks/bar.rs | 13 + .../run-make-fulldeps/libs-through-symlinks/foo.rs | 12 + src/test/run-make-fulldeps/libtest-json/Makefile | 14 + src/test/run-make-fulldeps/libtest-json/f.rs | 32 ++ .../run-make-fulldeps/libtest-json/output.json | 10 + .../libtest-json/validate_json.py | 18 + src/test/run-make-fulldeps/link-arg/Makefile | 5 + src/test/run-make-fulldeps/link-arg/empty.rs | 11 + src/test/run-make-fulldeps/link-cfg/Makefile | 22 + .../link-cfg/dep-with-staticlib.rs | 18 + src/test/run-make-fulldeps/link-cfg/dep.rs | 18 + src/test/run-make-fulldeps/link-cfg/no-deps.rs | 30 ++ src/test/run-make-fulldeps/link-cfg/return1.c | 16 + src/test/run-make-fulldeps/link-cfg/return2.c | 16 + src/test/run-make-fulldeps/link-cfg/return3.c | 16 + src/test/run-make-fulldeps/link-cfg/with-deps.rs | 24 ++ .../link-cfg/with-staticlib-deps.rs | 24 ++ .../run-make-fulldeps/link-path-order/Makefile | 18 + .../run-make-fulldeps/link-path-order/correct.c | 2 + src/test/run-make-fulldeps/link-path-order/main.rs | 28 ++ src/test/run-make-fulldeps/link-path-order/wrong.c | 2 + .../linkage-attr-on-static/Makefile | 5 + .../linkage-attr-on-static/bar.rs | 26 ++ .../run-make-fulldeps/linkage-attr-on-static/foo.c | 8 + .../linker-output-non-utf8/Makefile | 32 ++ .../linker-output-non-utf8/exec.rs | 16 + .../linker-output-non-utf8/library.rs | 20 + src/test/run-make-fulldeps/llvm-pass/Makefile | 28 ++ .../llvm-pass/llvm-function-pass.so.cc | 61 +++ .../llvm-pass/llvm-module-pass.so.cc | 60 +++ src/test/run-make-fulldeps/llvm-pass/main.rs | 14 + src/test/run-make-fulldeps/llvm-pass/plugin.rs | 28 ++ .../long-linker-command-lines-cmd-exe/Makefile | 6 + .../long-linker-command-lines-cmd-exe/foo.bat | 1 + .../long-linker-command-lines-cmd-exe/foo.rs | 111 +++++ .../long-linker-command-lines/Makefile | 5 + .../long-linker-command-lines/foo.rs | 101 +++++ .../run-make-fulldeps/longjmp-across-rust/Makefile | 5 + .../run-make-fulldeps/longjmp-across-rust/foo.c | 28 ++ .../run-make-fulldeps/longjmp-across-rust/main.rs | 40 ++ src/test/run-make-fulldeps/ls-metadata/Makefile | 7 + src/test/run-make-fulldeps/ls-metadata/foo.rs | 11 + .../lto-no-link-whole-rlib/Makefile | 18 + .../run-make-fulldeps/lto-no-link-whole-rlib/bar.c | 13 + .../run-make-fulldeps/lto-no-link-whole-rlib/foo.c | 13 + .../lto-no-link-whole-rlib/lib1.rs | 20 + .../lto-no-link-whole-rlib/lib2.rs | 23 + .../lto-no-link-whole-rlib/main.rs | 17 + .../run-make-fulldeps/lto-readonly-lib/Makefile | 12 + src/test/run-make-fulldeps/lto-readonly-lib/lib.rs | 11 + .../run-make-fulldeps/lto-readonly-lib/main.rs | 13 + src/test/run-make-fulldeps/lto-smoke-c/Makefile | 11 + src/test/run-make-fulldeps/lto-smoke-c/bar.c | 7 + src/test/run-make-fulldeps/lto-smoke-c/foo.rs | 14 + src/test/run-make-fulldeps/lto-smoke/Makefile | 6 + src/test/run-make-fulldeps/lto-smoke/lib.rs | 11 + src/test/run-make-fulldeps/lto-smoke/main.rs | 13 + .../run-make-fulldeps/manual-crate-name/Makefile | 5 + .../run-make-fulldeps/manual-crate-name/bar.rs | 11 + src/test/run-make-fulldeps/manual-link/Makefile | 6 + src/test/run-make-fulldeps/manual-link/bar.c | 2 + src/test/run-make-fulldeps/manual-link/foo.c | 2 + src/test/run-make-fulldeps/manual-link/foo.rs | 19 + src/test/run-make-fulldeps/manual-link/main.rs | 15 + .../many-crates-but-no-match/Makefile | 36 ++ .../many-crates-but-no-match/crateA1.rs | 14 + .../many-crates-but-no-match/crateA2.rs | 14 + .../many-crates-but-no-match/crateA3.rs | 14 + .../many-crates-but-no-match/crateB.rs | 11 + .../many-crates-but-no-match/crateC.rs | 13 + .../metadata-flag-frobs-symbols/Makefile | 10 + .../metadata-flag-frobs-symbols/bar.rs | 18 + .../metadata-flag-frobs-symbols/foo.rs | 16 + .../run-make-fulldeps/min-global-align/Makefile | 22 + .../min-global-align/min_global_align.rs | 38 ++ .../mismatching-target-triples/Makefile | 11 + .../mismatching-target-triples/bar.rs | 13 + .../mismatching-target-triples/foo.rs | 13 + .../missing-crate-dependency/Makefile | 9 + .../missing-crate-dependency/crateA.rs | 12 + .../missing-crate-dependency/crateB.rs | 11 + .../missing-crate-dependency/crateC.rs | 13 + src/test/run-make-fulldeps/mixing-deps/Makefile | 7 + src/test/run-make-fulldeps/mixing-deps/both.rs | 14 + src/test/run-make-fulldeps/mixing-deps/dylib.rs | 16 + src/test/run-make-fulldeps/mixing-deps/prog.rs | 19 + src/test/run-make-fulldeps/mixing-formats/Makefile | 74 ++++ src/test/run-make-fulldeps/mixing-formats/bar1.rs | 11 + src/test/run-make-fulldeps/mixing-formats/bar2.rs | 11 + src/test/run-make-fulldeps/mixing-formats/baz.rs | 13 + src/test/run-make-fulldeps/mixing-formats/baz2.rs | 14 + src/test/run-make-fulldeps/mixing-formats/foo.rs | 9 + src/test/run-make-fulldeps/mixing-libs/Makefile | 9 + src/test/run-make-fulldeps/mixing-libs/dylib.rs | 14 + src/test/run-make-fulldeps/mixing-libs/prog.rs | 17 + src/test/run-make-fulldeps/mixing-libs/rlib.rs | 12 + .../run-make-fulldeps/msvc-opt-minsize/Makefile | 5 + src/test/run-make-fulldeps/msvc-opt-minsize/foo.rs | 29 ++ src/test/run-make-fulldeps/multiple-emits/Makefile | 7 + src/test/run-make-fulldeps/multiple-emits/foo.rs | 11 + .../run-make-fulldeps/no-builtins-lto/Makefile | 9 + src/test/run-make-fulldeps/no-builtins-lto/main.rs | 13 + .../no-builtins-lto/no_builtins.rs | 12 + .../run-make-fulldeps/no-duplicate-libs/Makefile | 10 + src/test/run-make-fulldeps/no-duplicate-libs/bar.c | 15 + src/test/run-make-fulldeps/no-duplicate-libs/foo.c | 11 + .../run-make-fulldeps/no-duplicate-libs/main.rs | 20 + .../run-make-fulldeps/no-integrated-as/Makefile | 7 + .../run-make-fulldeps/no-integrated-as/hello.rs | 13 + .../no-intermediate-extras/Makefile | 7 + .../no-intermediate-extras/foo.rs | 9 + .../obey-crate-type-flag/Makefile | 13 + .../run-make-fulldeps/obey-crate-type-flag/test.rs | 12 + .../Makefile | 7 + .../foo.rs | 11 + .../output-filename-overwrites-input/Makefile | 13 + .../output-filename-overwrites-input/bar.rs | 11 + .../output-filename-overwrites-input/foo.rs | 11 + .../output-type-permutations/Makefile | 146 +++++++ .../output-type-permutations/foo.rs | 13 + .../run-make-fulldeps/output-with-hyphens/Makefile | 6 + .../output-with-hyphens/foo-bar.rs | 14 + src/test/run-make-fulldeps/prefer-dylib/Makefile | 8 + src/test/run-make-fulldeps/prefer-dylib/bar.rs | 11 + src/test/run-make-fulldeps/prefer-dylib/foo.rs | 15 + src/test/run-make-fulldeps/prefer-rlib/Makefile | 8 + src/test/run-make-fulldeps/prefer-rlib/bar.rs | 11 + src/test/run-make-fulldeps/prefer-rlib/foo.rs | 15 + .../pretty-expanded-hygiene/Makefile | 21 + .../pretty-expanded-hygiene/input.pp.rs | 19 + .../pretty-expanded-hygiene/input.rs | 24 ++ .../run-make-fulldeps/pretty-expanded/Makefile | 5 + .../run-make-fulldeps/pretty-expanded/input.rs | 22 + .../pretty-print-path-suffix/Makefile | 9 + .../pretty-print-path-suffix/foo.pp | 15 + .../pretty-print-path-suffix/foo_method.pp | 17 + .../pretty-print-path-suffix/input.rs | 28 ++ .../pretty-print-path-suffix/nest_foo.pp | 14 + .../pretty-print-to-file/Makefile | 5 + .../pretty-print-to-file/input.pp | 13 + .../pretty-print-to-file/input.rs | 15 + src/test/run-make-fulldeps/print-cfg/Makefile | 16 + .../run-make-fulldeps/print-target-list/Makefile | 15 + src/test/run-make-fulldeps/profile/Makefile | 9 + src/test/run-make-fulldeps/profile/test.rs | 11 + .../run-make-fulldeps/prune-link-args/Makefile | 11 + .../run-make-fulldeps/prune-link-args/empty.rs | 11 + .../run-make-fulldeps/relocation-model/Makefile | 19 + src/test/run-make-fulldeps/relocation-model/foo.rs | 11 + src/test/run-make-fulldeps/relro-levels/Makefile | 21 + src/test/run-make-fulldeps/relro-levels/hello.rs | 13 + .../run-make-fulldeps/reproducible-build/Makefile | 74 ++++ .../run-make-fulldeps/reproducible-build/linker.rs | 54 +++ .../reproducible-build/reproducible-build-aux.rs | 38 ++ .../reproducible-build/reproducible-build.rs | 126 ++++++ src/test/run-make-fulldeps/rlib-chain/Makefile | 10 + src/test/run-make-fulldeps/rlib-chain/m1.rs | 12 + src/test/run-make-fulldeps/rlib-chain/m2.rs | 14 + src/test/run-make-fulldeps/rlib-chain/m3.rs | 14 + src/test/run-make-fulldeps/rlib-chain/m4.rs | 13 + .../rustc-macro-dep-files/Makefile | 12 + .../run-make-fulldeps/rustc-macro-dep-files/bar.rs | 19 + .../run-make-fulldeps/rustc-macro-dep-files/foo.rs | 22 + .../run-make-fulldeps/rustdoc-error-lines/Makefile | 8 + .../run-make-fulldeps/rustdoc-error-lines/input.rs | 21 + .../run-make-fulldeps/rustdoc-output-path/Makefile | 4 + .../run-make-fulldeps/rustdoc-output-path/foo.rs | 11 + .../run-make-fulldeps/sanitizer-address/Makefile | 29 ++ .../sanitizer-address/overflow.rs | 14 + .../sanitizer-cdylib-link/Makefile | 22 + .../sanitizer-cdylib-link/library.rs | 15 + .../sanitizer-cdylib-link/program.rs | 17 + .../sanitizer-dylib-link/Makefile | 22 + .../sanitizer-dylib-link/library.rs | 15 + .../sanitizer-dylib-link/program.rs | 17 + .../sanitizer-invalid-cratetype/Makefile | 18 + .../sanitizer-invalid-cratetype/hello.rs | 13 + .../sanitizer-invalid-target/Makefile | 5 + .../sanitizer-invalid-target/hello.rs | 13 + src/test/run-make-fulldeps/sanitizer-leak/Makefile | 16 + src/test/run-make-fulldeps/sanitizer-leak/leak.rs | 16 + .../run-make-fulldeps/sanitizer-memory/Makefile | 10 + .../run-make-fulldeps/sanitizer-memory/uninit.rs | 16 + .../sanitizer-staticlib-link/Makefile | 18 + .../sanitizer-staticlib-link/library.rs | 15 + .../sanitizer-staticlib-link/program.c | 8 + .../run-make-fulldeps/save-analysis-fail/Makefile | 6 + .../save-analysis-fail/SameDir.rs | 15 + .../save-analysis-fail/SameDir3.rs | 13 + .../save-analysis-fail/SubDir/mod.rs | 37 ++ .../run-make-fulldeps/save-analysis-fail/foo.rs | 468 +++++++++++++++++++++ .../run-make-fulldeps/save-analysis-fail/krate2.rs | 18 + src/test/run-make-fulldeps/save-analysis/Makefile | 6 + .../run-make-fulldeps/save-analysis/SameDir.rs | 15 + .../run-make-fulldeps/save-analysis/SameDir3.rs | 13 + .../run-make-fulldeps/save-analysis/SubDir/mod.rs | 37 ++ .../run-make-fulldeps/save-analysis/extra-docs.md | 1 + src/test/run-make-fulldeps/save-analysis/foo.rs | 467 ++++++++++++++++++++ src/test/run-make-fulldeps/save-analysis/krate2.rs | 18 + .../run-make-fulldeps/sepcomp-cci-copies/Makefile | 12 + .../sepcomp-cci-copies/cci_lib.rs | 16 + .../run-make-fulldeps/sepcomp-cci-copies/foo.rs | 35 ++ .../run-make-fulldeps/sepcomp-inlining/Makefile | 15 + src/test/run-make-fulldeps/sepcomp-inlining/foo.rs | 40 ++ .../run-make-fulldeps/sepcomp-separate/Makefile | 9 + src/test/run-make-fulldeps/sepcomp-separate/foo.rs | 33 ++ src/test/run-make-fulldeps/simd-ffi/Makefile | 47 +++ src/test/run-make-fulldeps/simd-ffi/simd.rs | 83 ++++ src/test/run-make-fulldeps/simple-dylib/Makefile | 5 + src/test/run-make-fulldeps/simple-dylib/bar.rs | 11 + src/test/run-make-fulldeps/simple-dylib/foo.rs | 15 + src/test/run-make-fulldeps/simple-rlib/Makefile | 5 + src/test/run-make-fulldeps/simple-rlib/bar.rs | 11 + src/test/run-make-fulldeps/simple-rlib/foo.rs | 15 + .../run-make-fulldeps/stable-symbol-names/Makefile | 40 ++ .../stable-symbol-names/stable-symbol-names1.rs | 41 ++ .../stable-symbol-names/stable-symbol-names2.rs | 28 ++ .../static-dylib-by-default/Makefile | 16 + .../static-dylib-by-default/bar.rs | 18 + .../static-dylib-by-default/foo.rs | 14 + .../static-dylib-by-default/main.c | 16 + .../run-make-fulldeps/static-nobundle/Makefile | 21 + src/test/run-make-fulldeps/static-nobundle/aaa.c | 11 + src/test/run-make-fulldeps/static-nobundle/bbb.rs | 23 + src/test/run-make-fulldeps/static-nobundle/ccc.rs | 23 + src/test/run-make-fulldeps/static-nobundle/ddd.rs | 17 + .../run-make-fulldeps/static-unwinding/Makefile | 6 + src/test/run-make-fulldeps/static-unwinding/lib.rs | 25 ++ .../run-make-fulldeps/static-unwinding/main.rs | 34 ++ .../run-make-fulldeps/staticlib-blank-lib/Makefile | 6 + .../run-make-fulldeps/staticlib-blank-lib/foo.rs | 16 + src/test/run-make-fulldeps/stdin-non-utf8/Makefile | 6 + src/test/run-make-fulldeps/stdin-non-utf8/non-utf8 | 1 + .../run-make-fulldeps/suspicious-library/Makefile | 7 + .../run-make-fulldeps/suspicious-library/bar.rs | 13 + .../run-make-fulldeps/suspicious-library/foo.rs | 13 + .../run-make-fulldeps/symbol-visibility/Makefile | 60 +++ .../symbol-visibility/a_cdylib.rs | 22 + .../symbol-visibility/a_rust_dylib.rs | 20 + .../symbol-visibility/an_executable.rs | 17 + .../run-make-fulldeps/symbol-visibility/an_rlib.rs | 16 + .../symbols-are-reasonable/Makefile | 13 + .../symbols-are-reasonable/lib.rs | 21 + .../symbols-include-type-name/Makefile | 9 + .../symbols-include-type-name/lib.rs | 24 ++ .../run-make-fulldeps/symlinked-extern/Makefile | 16 + src/test/run-make-fulldeps/symlinked-extern/bar.rs | 16 + src/test/run-make-fulldeps/symlinked-extern/baz.rs | 16 + src/test/run-make-fulldeps/symlinked-extern/foo.rs | 15 + .../run-make-fulldeps/symlinked-libraries/Makefile | 15 + .../run-make-fulldeps/symlinked-libraries/bar.rs | 15 + .../run-make-fulldeps/symlinked-libraries/foo.rs | 13 + src/test/run-make-fulldeps/symlinked-rlib/Makefile | 14 + src/test/run-make-fulldeps/symlinked-rlib/bar.rs | 15 + src/test/run-make-fulldeps/symlinked-rlib/foo.rs | 11 + .../sysroot-crates-are-unstable/Makefile | 2 + .../sysroot-crates-are-unstable/test.py | 71 ++++ .../run-make-fulldeps/target-cpu-native/Makefile | 5 + .../run-make-fulldeps/target-cpu-native/foo.rs | 12 + src/test/run-make-fulldeps/target-specs/Makefile | 9 + src/test/run-make-fulldeps/target-specs/foo.rs | 32 ++ .../target-specs/my-awesome-platform.json | 11 + .../target-specs/my-incomplete-platform.json | 10 + .../target-specs/my-invalid-platform.json | 1 + .../my-x86_64-unknown-linux-gnu-platform.json | 12 + .../target-without-atomics/Makefile | 5 + src/test/run-make-fulldeps/test-harness/Makefile | 8 + .../test-harness/test-ignore-cfg.rs | 19 + src/test/run-make-fulldeps/tools.mk | 134 ++++++ .../run-make-fulldeps/treat-err-as-bug/Makefile | 5 + src/test/run-make-fulldeps/treat-err-as-bug/err.rs | 13 + .../type-mismatch-same-crate-name/Makefile | 19 + .../type-mismatch-same-crate-name/crateA.rs | 26 ++ .../type-mismatch-same-crate-name/crateB.rs | 14 + .../type-mismatch-same-crate-name/crateC.rs | 35 ++ .../use-extern-for-plugins/Makefile | 21 + .../use-extern-for-plugins/bar.rs | 19 + .../use-extern-for-plugins/baz.rs | 18 + .../use-extern-for-plugins/foo.rs | 18 + src/test/run-make-fulldeps/used/Makefile | 11 + src/test/run-make-fulldeps/used/used.rs | 17 + src/test/run-make-fulldeps/version/Makefile | 6 + .../run-make-fulldeps/volatile-intrinsics/Makefile | 9 + .../run-make-fulldeps/volatile-intrinsics/main.rs | 27 ++ .../weird-output-filenames/Makefile | 15 + .../weird-output-filenames/foo.rs | 11 + src/test/run-make-fulldeps/windows-spawn/Makefile | 14 + src/test/run-make-fulldeps/windows-spawn/hello.rs | 13 + src/test/run-make-fulldeps/windows-spawn/spawn.rs | 22 + .../run-make-fulldeps/windows-subsystem/Makefile | 5 + .../run-make-fulldeps/windows-subsystem/console.rs | 14 + .../run-make-fulldeps/windows-subsystem/windows.rs | 13 + src/test/run-make/a-b-a-linker-guard/Makefile | 12 - src/test/run-make/a-b-a-linker-guard/a.rs | 18 - src/test/run-make/a-b-a-linker-guard/b.rs | 17 - src/test/run-make/alloc-extern-crates/Makefile | 5 - src/test/run-make/alloc-extern-crates/fakealloc.rs | 33 -- .../allow-non-lint-warnings-cmdline/Makefile | 11 - .../allow-non-lint-warnings-cmdline/foo.rs | 15 - .../allow-warnings-cmdline-stability/Makefile | 15 - .../allow-warnings-cmdline-stability/bar.rs | 15 - .../allow-warnings-cmdline-stability/foo.rs | 15 - src/test/run-make/archive-duplicate-names/Makefile | 11 - src/test/run-make/archive-duplicate-names/bar.c | 11 - src/test/run-make/archive-duplicate-names/bar.rs | 15 - src/test/run-make/archive-duplicate-names/foo.c | 11 - src/test/run-make/archive-duplicate-names/foo.rs | 24 -- src/test/run-make/atomic-lock-free/Makefile | 46 -- .../run-make/atomic-lock-free/atomic_lock_free.rs | 66 --- src/test/run-make/bare-outfile/Makefile | 6 - src/test/run-make/bare-outfile/foo.rs | 12 - src/test/run-make/c-dynamic-dylib/Makefile | 14 - src/test/run-make/c-dynamic-dylib/bar.rs | 15 - src/test/run-make/c-dynamic-dylib/cfoo.c | 5 - src/test/run-make/c-dynamic-dylib/foo.rs | 20 - src/test/run-make/c-dynamic-rlib/Makefile | 17 - src/test/run-make/c-dynamic-rlib/bar.rs | 15 - src/test/run-make/c-dynamic-rlib/cfoo.c | 6 - src/test/run-make/c-dynamic-rlib/foo.rs | 20 - src/test/run-make/c-link-to-rust-dylib/Makefile | 17 - src/test/run-make/c-link-to-rust-dylib/bar.c | 7 - src/test/run-make/c-link-to-rust-dylib/foo.rs | 14 - .../run-make/c-link-to-rust-staticlib/Makefile | 16 - src/test/run-make/c-link-to-rust-staticlib/bar.c | 7 - src/test/run-make/c-link-to-rust-staticlib/foo.rs | 14 - src/test/run-make/c-static-dylib/Makefile | 9 - src/test/run-make/c-static-dylib/bar.rs | 15 - src/test/run-make/c-static-dylib/cfoo.c | 2 - src/test/run-make/c-static-dylib/foo.rs | 20 - src/test/run-make/c-static-rlib/Makefile | 8 - src/test/run-make/c-static-rlib/bar.rs | 15 - src/test/run-make/c-static-rlib/cfoo.c | 2 - src/test/run-make/c-static-rlib/foo.rs | 20 - .../run-make/cat-and-grep-sanity-check/Makefile | 46 -- src/test/run-make/cdylib-fewer-symbols/Makefile | 15 - src/test/run-make/cdylib-fewer-symbols/foo.rs | 16 - src/test/run-make/cdylib/Makefile | 19 - src/test/run-make/cdylib/bar.rs | 15 - src/test/run-make/cdylib/foo.c | 20 - src/test/run-make/cdylib/foo.rs | 23 - src/test/run-make/codegen-options-parsing/Makefile | 31 -- src/test/run-make/codegen-options-parsing/dummy.rs | 11 - src/test/run-make/compile-stdin/Makefile | 5 - src/test/run-make/compiler-lookup-paths-2/Makefile | 8 - src/test/run-make/compiler-lookup-paths-2/a.rs | 11 - src/test/run-make/compiler-lookup-paths-2/b.rs | 12 - src/test/run-make/compiler-lookup-paths-2/c.rs | 13 - src/test/run-make/compiler-lookup-paths/Makefile | 38 -- src/test/run-make/compiler-lookup-paths/a.rs | 11 - src/test/run-make/compiler-lookup-paths/b.rs | 12 - src/test/run-make/compiler-lookup-paths/c.rs | 12 - src/test/run-make/compiler-lookup-paths/d.rs | 14 - src/test/run-make/compiler-lookup-paths/e.rs | 12 - src/test/run-make/compiler-lookup-paths/e2.rs | 14 - src/test/run-make/compiler-lookup-paths/f.rs | 12 - src/test/run-make/compiler-lookup-paths/native.c | 9 - .../run-make/compiler-rt-works-on-mingw/Makefile | 17 - .../run-make/compiler-rt-works-on-mingw/foo.cpp | 5 - .../run-make/compiler-rt-works-on-mingw/foo.rs | 16 - src/test/run-make/crate-data-smoke/Makefile | 10 - src/test/run-make/crate-data-smoke/crate.rs | 17 - src/test/run-make/crate-data-smoke/lib.rs | 12 - src/test/run-make/crate-data-smoke/rlib.rs | 12 - src/test/run-make/crate-name-priority/Makefile | 11 - src/test/run-make/crate-name-priority/foo.rs | 11 - src/test/run-make/crate-name-priority/foo1.rs | 13 - src/test/run-make/debug-assertions/Makefile | 25 -- src/test/run-make/debug-assertions/debug.rs | 43 -- .../run-make/dep-info-doesnt-run-much/Makefile | 4 - src/test/run-make/dep-info-doesnt-run-much/foo.rs | 15 - src/test/run-make/dep-info-spaces/Makefile | 28 -- src/test/run-make/dep-info-spaces/Makefile.foo | 7 - src/test/run-make/dep-info-spaces/bar.rs | 11 - src/test/run-make/dep-info-spaces/foo foo.rs | 11 - src/test/run-make/dep-info-spaces/lib.rs | 14 - src/test/run-make/dep-info/Makefile | 34 -- src/test/run-make/dep-info/Makefile.foo | 7 - src/test/run-make/dep-info/bar.rs | 11 - src/test/run-make/dep-info/foo.rs | 11 - src/test/run-make/dep-info/lib.rs | 14 - src/test/run-make/dep-info/lib2.rs | 13 - .../run-make/duplicate-output-flavors/Makefile | 5 - src/test/run-make/duplicate-output-flavors/foo.rs | 11 - src/test/run-make/dylib-chain/Makefile | 12 - src/test/run-make/dylib-chain/m1.rs | 12 - src/test/run-make/dylib-chain/m2.rs | 14 - src/test/run-make/dylib-chain/m3.rs | 14 - src/test/run-make/dylib-chain/m4.rs | 13 - src/test/run-make/emit/Makefile | 21 - src/test/run-make/emit/test-24876.rs | 19 - src/test/run-make/emit/test-26235.rs | 56 --- .../error-found-staticlib-instead-crate/Makefile | 5 - .../error-found-staticlib-instead-crate/bar.rs | 15 - .../error-found-staticlib-instead-crate/foo.rs | 11 - .../run-make/error-writing-dependencies/Makefile | 8 - .../run-make/error-writing-dependencies/foo.rs | 11 - .../run-make/extern-diff-internal-name/Makefile | 5 - src/test/run-make/extern-diff-internal-name/lib.rs | 12 - .../run-make/extern-diff-internal-name/test.rs | 15 - .../run-make/extern-flag-disambiguates/Makefile | 25 -- src/test/run-make/extern-flag-disambiguates/a.rs | 16 - src/test/run-make/extern-flag-disambiguates/b.rs | 19 - src/test/run-make/extern-flag-disambiguates/c.rs | 19 - src/test/run-make/extern-flag-disambiguates/d.rs | 21 - src/test/run-make/extern-flag-fun/Makefile | 17 - src/test/run-make/extern-flag-fun/bar-alt.rs | 11 - src/test/run-make/extern-flag-fun/bar.rs | 9 - src/test/run-make/extern-flag-fun/foo.rs | 13 - src/test/run-make/extern-fn-generic/Makefile | 6 - src/test/run-make/extern-fn-generic/test.c | 17 - src/test/run-make/extern-fn-generic/test.rs | 32 -- src/test/run-make/extern-fn-generic/testcrate.rs | 24 -- src/test/run-make/extern-fn-mangle/Makefile | 5 - src/test/run-make/extern-fn-mangle/test.c | 9 - src/test/run-make/extern-fn-mangle/test.rs | 25 -- src/test/run-make/extern-fn-reachable/Makefile | 9 - src/test/run-make/extern-fn-reachable/dylib.rs | 24 -- src/test/run-make/extern-fn-reachable/main.rs | 28 -- .../run-make/extern-fn-struct-passing-abi/Makefile | 5 - .../run-make/extern-fn-struct-passing-abi/test.c | 324 -------------- .../run-make/extern-fn-struct-passing-abi/test.rs | 144 ------- .../run-make/extern-fn-with-extern-types/Makefile | 5 - .../run-make/extern-fn-with-extern-types/ctest.c | 17 - .../run-make/extern-fn-with-extern-types/test.rs | 27 -- .../run-make/extern-fn-with-packed-struct/Makefile | 5 - .../run-make/extern-fn-with-packed-struct/test.c | 27 -- .../run-make/extern-fn-with-packed-struct/test.rs | 30 -- src/test/run-make/extern-fn-with-union/Makefile | 6 - src/test/run-make/extern-fn-with-union/ctest.c | 11 - src/test/run-make/extern-fn-with-union/test.rs | 33 -- .../run-make/extern-fn-with-union/testcrate.rs | 21 - src/test/run-make/extern-multiple-copies/Makefile | 8 - src/test/run-make/extern-multiple-copies/bar.rs | 16 - src/test/run-make/extern-multiple-copies/foo1.rs | 11 - src/test/run-make/extern-multiple-copies/foo2.rs | 11 - src/test/run-make/extern-multiple-copies2/Makefile | 10 - src/test/run-make/extern-multiple-copies2/bar.rs | 18 - src/test/run-make/extern-multiple-copies2/foo1.rs | 17 - src/test/run-make/extern-multiple-copies2/foo2.rs | 18 - .../extern-overrides-distribution/Makefile | 5 - .../run-make/extern-overrides-distribution/libc.rs | 13 - .../run-make/extern-overrides-distribution/main.rs | 15 - .../extra-filename-with-temp-outputs/Makefile | 6 - .../extra-filename-with-temp-outputs/foo.rs | 11 - src/test/run-make/fpic/Makefile | 13 - src/test/run-make/fpic/hello.rs | 11 - src/test/run-make/hir-tree/Makefile | 8 - src/test/run-make/hir-tree/input.rs | 13 - src/test/run-make/hotplug_codegen_backend/Makefile | 9 - .../run-make/hotplug_codegen_backend/some_crate.rs | 13 - .../hotplug_codegen_backend/the_backend.rs | 82 ---- src/test/run-make/include_bytes_deps/Makefile | 20 - src/test/run-make/include_bytes_deps/input.bin | 1 - src/test/run-make/include_bytes_deps/input.md | 1 - src/test/run-make/include_bytes_deps/input.txt | 1 - src/test/run-make/include_bytes_deps/main.rs | 22 - src/test/run-make/inline-always-many-cgu/Makefile | 8 - src/test/run-make/inline-always-many-cgu/foo.rs | 25 -- .../run-make/interdependent-c-libraries/Makefile | 14 - src/test/run-make/interdependent-c-libraries/bar.c | 4 - .../run-make/interdependent-c-libraries/bar.rs | 22 - src/test/run-make/interdependent-c-libraries/foo.c | 2 - .../run-make/interdependent-c-libraries/foo.rs | 20 - .../run-make/interdependent-c-libraries/main.rs | 16 - src/test/run-make/intrinsic-unreachable/Makefile | 15 - .../run-make/intrinsic-unreachable/exit-ret.rs | 25 -- .../intrinsic-unreachable/exit-unreachable.rs | 27 -- src/test/run-make/invalid-library/Makefile | 6 - src/test/run-make/invalid-library/foo.rs | 13 - src/test/run-make/invalid-staticlib/Makefile | 5 - src/test/run-make/issue-11908/Makefile | 21 - src/test/run-make/issue-11908/bar.rs | 13 - src/test/run-make/issue-11908/foo.rs | 11 - src/test/run-make/issue-14500/Makefile | 17 - src/test/run-make/issue-14500/bar.rs | 11 - src/test/run-make/issue-14500/foo.c | 17 - src/test/run-make/issue-14500/foo.rs | 15 - src/test/run-make/issue-14698/Makefile | 4 - src/test/run-make/issue-14698/foo.rs | 11 - src/test/run-make/issue-15460/Makefile | 6 - src/test/run-make/issue-15460/bar.rs | 14 - src/test/run-make/issue-15460/foo.c | 6 - src/test/run-make/issue-15460/foo.rs | 16 - src/test/run-make/issue-18943/Makefile | 7 - src/test/run-make/issue-18943/foo.rs | 16 - src/test/run-make/issue-19371/Makefile | 9 - src/test/run-make/issue-19371/foo.rs | 88 ---- src/test/run-make/issue-20626/Makefile | 8 - src/test/run-make/issue-20626/foo.rs | 23 - src/test/run-make/issue-22131/Makefile | 7 - src/test/run-make/issue-22131/foo.rs | 15 - src/test/run-make/issue-24445/Makefile | 12 - src/test/run-make/issue-24445/foo.c | 16 - src/test/run-make/issue-24445/foo.rs | 25 -- src/test/run-make/issue-25581/Makefile | 5 - src/test/run-make/issue-25581/test.c | 16 - src/test/run-make/issue-25581/test.rs | 32 -- src/test/run-make/issue-26006/Makefile | 18 - src/test/run-make/issue-26006/in/libc/lib.rs | 12 - src/test/run-make/issue-26006/in/time/lib.rs | 13 - src/test/run-make/issue-26092/Makefile | 4 - src/test/run-make/issue-26092/blank.rs | 11 - src/test/run-make/issue-28595/Makefile | 6 - src/test/run-make/issue-28595/a.c | 11 - src/test/run-make/issue-28595/a.rs | 16 - src/test/run-make/issue-28595/b.c | 16 - src/test/run-make/issue-28595/b.rs | 21 - src/test/run-make/issue-28766/Makefile | 5 - src/test/run-make/issue-28766/foo.rs | 18 - src/test/run-make/issue-28766/main.rs | 17 - src/test/run-make/issue-30063/Makefile | 35 -- src/test/run-make/issue-30063/foo.rs | 11 - src/test/run-make/issue-33329/Makefile | 5 - src/test/run-make/issue-33329/main.rs | 11 - src/test/run-make/issue-35164/Makefile | 4 - src/test/run-make/issue-35164/main.rs | 15 - src/test/run-make/issue-35164/submodule/mod.rs | 13 - src/test/run-make/issue-37839/Makefile | 12 - src/test/run-make/issue-37839/a.rs | 12 - src/test/run-make/issue-37839/b.rs | 12 - src/test/run-make/issue-37839/c.rs | 12 - src/test/run-make/issue-37893/Makefile | 10 - src/test/run-make/issue-37893/a.rs | 12 - src/test/run-make/issue-37893/b.rs | 12 - src/test/run-make/issue-37893/c.rs | 13 - src/test/run-make/issue-38237/Makefile | 11 - src/test/run-make/issue-38237/bar.rs | 14 - src/test/run-make/issue-38237/baz.rs | 18 - src/test/run-make/issue-38237/foo.rs | 19 - src/test/run-make/issue-40535/Makefile | 13 - src/test/run-make/issue-40535/bar.rs | 13 - src/test/run-make/issue-40535/baz.rs | 11 - src/test/run-make/issue-40535/foo.rs | 14 - src/test/run-make/issue-46239/Makefile | 5 - src/test/run-make/issue-46239/main.rs | 18 - src/test/run-make/issue-7349/Makefile | 11 - src/test/run-make/issue-7349/foo.rs | 32 -- src/test/run-make/issues-41478-43796/Makefile | 8 - src/test/run-make/issues-41478-43796/a.rs | 19 - src/test/run-make/libs-and-bins/Makefile | 6 - src/test/run-make/libs-and-bins/foo.rs | 14 - src/test/run-make/libs-through-symlinks/Makefile | 14 - src/test/run-make/libs-through-symlinks/bar.rs | 13 - src/test/run-make/libs-through-symlinks/foo.rs | 12 - src/test/run-make/libtest-json/Makefile | 14 - src/test/run-make/libtest-json/f.rs | 32 -- src/test/run-make/libtest-json/output.json | 10 - src/test/run-make/libtest-json/validate_json.py | 18 - src/test/run-make/link-arg/Makefile | 5 - src/test/run-make/link-arg/empty.rs | 11 - src/test/run-make/link-cfg/Makefile | 22 - src/test/run-make/link-cfg/dep-with-staticlib.rs | 18 - src/test/run-make/link-cfg/dep.rs | 18 - src/test/run-make/link-cfg/no-deps.rs | 30 -- src/test/run-make/link-cfg/return1.c | 16 - src/test/run-make/link-cfg/return2.c | 16 - src/test/run-make/link-cfg/return3.c | 16 - src/test/run-make/link-cfg/with-deps.rs | 24 -- src/test/run-make/link-cfg/with-staticlib-deps.rs | 24 -- src/test/run-make/link-path-order/Makefile | 18 - src/test/run-make/link-path-order/correct.c | 2 - src/test/run-make/link-path-order/main.rs | 28 -- src/test/run-make/link-path-order/wrong.c | 2 - src/test/run-make/linkage-attr-on-static/Makefile | 5 - src/test/run-make/linkage-attr-on-static/bar.rs | 26 -- src/test/run-make/linkage-attr-on-static/foo.c | 8 - src/test/run-make/linker-output-non-utf8/Makefile | 32 -- src/test/run-make/linker-output-non-utf8/exec.rs | 16 - .../run-make/linker-output-non-utf8/library.rs | 20 - src/test/run-make/llvm-pass/Makefile | 28 -- .../run-make/llvm-pass/llvm-function-pass.so.cc | 61 --- src/test/run-make/llvm-pass/llvm-module-pass.so.cc | 60 --- src/test/run-make/llvm-pass/main.rs | 14 - src/test/run-make/llvm-pass/plugin.rs | 28 -- .../long-linker-command-lines-cmd-exe/Makefile | 6 - .../long-linker-command-lines-cmd-exe/foo.bat | 1 - .../long-linker-command-lines-cmd-exe/foo.rs | 111 ----- .../run-make/long-linker-command-lines/Makefile | 5 - src/test/run-make/long-linker-command-lines/foo.rs | 101 ----- src/test/run-make/longjmp-across-rust/Makefile | 5 - src/test/run-make/longjmp-across-rust/foo.c | 28 -- src/test/run-make/longjmp-across-rust/main.rs | 40 -- src/test/run-make/ls-metadata/Makefile | 7 - src/test/run-make/ls-metadata/foo.rs | 11 - src/test/run-make/lto-no-link-whole-rlib/Makefile | 18 - src/test/run-make/lto-no-link-whole-rlib/bar.c | 13 - src/test/run-make/lto-no-link-whole-rlib/foo.c | 13 - src/test/run-make/lto-no-link-whole-rlib/lib1.rs | 20 - src/test/run-make/lto-no-link-whole-rlib/lib2.rs | 23 - src/test/run-make/lto-no-link-whole-rlib/main.rs | 17 - src/test/run-make/lto-readonly-lib/Makefile | 12 - src/test/run-make/lto-readonly-lib/lib.rs | 11 - src/test/run-make/lto-readonly-lib/main.rs | 13 - src/test/run-make/lto-smoke-c/Makefile | 11 - src/test/run-make/lto-smoke-c/bar.c | 7 - src/test/run-make/lto-smoke-c/foo.rs | 14 - src/test/run-make/lto-smoke/Makefile | 6 - src/test/run-make/lto-smoke/lib.rs | 11 - src/test/run-make/lto-smoke/main.rs | 13 - src/test/run-make/manual-crate-name/Makefile | 5 - src/test/run-make/manual-crate-name/bar.rs | 11 - src/test/run-make/manual-link/Makefile | 6 - src/test/run-make/manual-link/bar.c | 2 - src/test/run-make/manual-link/foo.c | 2 - src/test/run-make/manual-link/foo.rs | 19 - src/test/run-make/manual-link/main.rs | 15 - .../run-make/many-crates-but-no-match/Makefile | 36 -- .../run-make/many-crates-but-no-match/crateA1.rs | 14 - .../run-make/many-crates-but-no-match/crateA2.rs | 14 - .../run-make/many-crates-but-no-match/crateA3.rs | 14 - .../run-make/many-crates-but-no-match/crateB.rs | 11 - .../run-make/many-crates-but-no-match/crateC.rs | 13 - .../run-make/metadata-flag-frobs-symbols/Makefile | 10 - .../run-make/metadata-flag-frobs-symbols/bar.rs | 18 - .../run-make/metadata-flag-frobs-symbols/foo.rs | 16 - src/test/run-make/min-global-align/Makefile | 22 - .../run-make/min-global-align/min_global_align.rs | 38 -- .../run-make/mismatching-target-triples/Makefile | 11 - .../run-make/mismatching-target-triples/bar.rs | 13 - .../run-make/mismatching-target-triples/foo.rs | 13 - .../run-make/missing-crate-dependency/Makefile | 9 - .../run-make/missing-crate-dependency/crateA.rs | 12 - .../run-make/missing-crate-dependency/crateB.rs | 11 - .../run-make/missing-crate-dependency/crateC.rs | 13 - src/test/run-make/mixing-deps/Makefile | 7 - src/test/run-make/mixing-deps/both.rs | 14 - src/test/run-make/mixing-deps/dylib.rs | 16 - src/test/run-make/mixing-deps/prog.rs | 19 - src/test/run-make/mixing-formats/Makefile | 74 ---- src/test/run-make/mixing-formats/bar1.rs | 11 - src/test/run-make/mixing-formats/bar2.rs | 11 - src/test/run-make/mixing-formats/baz.rs | 13 - src/test/run-make/mixing-formats/baz2.rs | 14 - src/test/run-make/mixing-formats/foo.rs | 9 - src/test/run-make/mixing-libs/Makefile | 9 - src/test/run-make/mixing-libs/dylib.rs | 14 - src/test/run-make/mixing-libs/prog.rs | 17 - src/test/run-make/mixing-libs/rlib.rs | 12 - src/test/run-make/msvc-opt-minsize/Makefile | 5 - src/test/run-make/msvc-opt-minsize/foo.rs | 29 -- src/test/run-make/multiple-emits/Makefile | 7 - src/test/run-make/multiple-emits/foo.rs | 11 - src/test/run-make/no-builtins-lto/Makefile | 9 - src/test/run-make/no-builtins-lto/main.rs | 13 - src/test/run-make/no-builtins-lto/no_builtins.rs | 12 - src/test/run-make/no-duplicate-libs/Makefile | 10 - src/test/run-make/no-duplicate-libs/bar.c | 15 - src/test/run-make/no-duplicate-libs/foo.c | 11 - src/test/run-make/no-duplicate-libs/main.rs | 20 - src/test/run-make/no-integrated-as/Makefile | 7 - src/test/run-make/no-integrated-as/hello.rs | 13 - src/test/run-make/no-intermediate-extras/Makefile | 7 - src/test/run-make/no-intermediate-extras/foo.rs | 9 - src/test/run-make/obey-crate-type-flag/Makefile | 13 - src/test/run-make/obey-crate-type-flag/test.rs | 12 - .../Makefile | 7 - .../foo.rs | 11 - .../output-filename-overwrites-input/Makefile | 13 - .../output-filename-overwrites-input/bar.rs | 11 - .../output-filename-overwrites-input/foo.rs | 11 - .../run-make/output-type-permutations/Makefile | 146 ------- src/test/run-make/output-type-permutations/foo.rs | 13 - src/test/run-make/output-with-hyphens/Makefile | 6 - src/test/run-make/output-with-hyphens/foo-bar.rs | 14 - src/test/run-make/prefer-dylib/Makefile | 8 - src/test/run-make/prefer-dylib/bar.rs | 11 - src/test/run-make/prefer-dylib/foo.rs | 15 - src/test/run-make/prefer-rlib/Makefile | 8 - src/test/run-make/prefer-rlib/bar.rs | 11 - src/test/run-make/prefer-rlib/foo.rs | 15 - src/test/run-make/pretty-expanded-hygiene/Makefile | 21 - .../run-make/pretty-expanded-hygiene/input.pp.rs | 19 - src/test/run-make/pretty-expanded-hygiene/input.rs | 24 -- src/test/run-make/pretty-expanded/Makefile | 5 - src/test/run-make/pretty-expanded/input.rs | 22 - .../run-make/pretty-print-path-suffix/Makefile | 9 - src/test/run-make/pretty-print-path-suffix/foo.pp | 15 - .../pretty-print-path-suffix/foo_method.pp | 17 - .../run-make/pretty-print-path-suffix/input.rs | 28 -- .../run-make/pretty-print-path-suffix/nest_foo.pp | 14 - src/test/run-make/pretty-print-to-file/Makefile | 5 - src/test/run-make/pretty-print-to-file/input.pp | 13 - src/test/run-make/pretty-print-to-file/input.rs | 15 - src/test/run-make/print-cfg/Makefile | 16 - src/test/run-make/print-target-list/Makefile | 15 - src/test/run-make/profile/Makefile | 9 - src/test/run-make/profile/test.rs | 11 - src/test/run-make/prune-link-args/Makefile | 11 - src/test/run-make/prune-link-args/empty.rs | 11 - src/test/run-make/relocation-model/Makefile | 19 - src/test/run-make/relocation-model/foo.rs | 11 - src/test/run-make/relro-levels/Makefile | 21 - src/test/run-make/relro-levels/hello.rs | 13 - src/test/run-make/reproducible-build/Makefile | 74 ---- src/test/run-make/reproducible-build/linker.rs | 54 --- .../reproducible-build/reproducible-build-aux.rs | 38 -- .../reproducible-build/reproducible-build.rs | 126 ------ src/test/run-make/rlib-chain/Makefile | 10 - src/test/run-make/rlib-chain/m1.rs | 12 - src/test/run-make/rlib-chain/m2.rs | 14 - src/test/run-make/rlib-chain/m3.rs | 14 - src/test/run-make/rlib-chain/m4.rs | 13 - src/test/run-make/rustc-macro-dep-files/Makefile | 12 - src/test/run-make/rustc-macro-dep-files/bar.rs | 19 - src/test/run-make/rustc-macro-dep-files/foo.rs | 22 - src/test/run-make/rustdoc-error-lines/Makefile | 8 - src/test/run-make/rustdoc-error-lines/input.rs | 21 - src/test/run-make/rustdoc-output-path/Makefile | 4 - src/test/run-make/rustdoc-output-path/foo.rs | 11 - src/test/run-make/sanitizer-address/Makefile | 29 -- src/test/run-make/sanitizer-address/overflow.rs | 14 - src/test/run-make/sanitizer-cdylib-link/Makefile | 22 - src/test/run-make/sanitizer-cdylib-link/library.rs | 15 - src/test/run-make/sanitizer-cdylib-link/program.rs | 17 - src/test/run-make/sanitizer-dylib-link/Makefile | 22 - src/test/run-make/sanitizer-dylib-link/library.rs | 15 - src/test/run-make/sanitizer-dylib-link/program.rs | 17 - .../run-make/sanitizer-invalid-cratetype/Makefile | 18 - .../run-make/sanitizer-invalid-cratetype/hello.rs | 13 - .../run-make/sanitizer-invalid-target/Makefile | 5 - .../run-make/sanitizer-invalid-target/hello.rs | 13 - src/test/run-make/sanitizer-leak/Makefile | 16 - src/test/run-make/sanitizer-leak/leak.rs | 16 - src/test/run-make/sanitizer-memory/Makefile | 10 - src/test/run-make/sanitizer-memory/uninit.rs | 16 - .../run-make/sanitizer-staticlib-link/Makefile | 18 - .../run-make/sanitizer-staticlib-link/library.rs | 15 - .../run-make/sanitizer-staticlib-link/program.c | 8 - src/test/run-make/save-analysis-fail/Makefile | 6 - src/test/run-make/save-analysis-fail/SameDir.rs | 15 - src/test/run-make/save-analysis-fail/SameDir3.rs | 13 - src/test/run-make/save-analysis-fail/SubDir/mod.rs | 37 -- src/test/run-make/save-analysis-fail/foo.rs | 468 --------------------- src/test/run-make/save-analysis-fail/krate2.rs | 18 - src/test/run-make/save-analysis/Makefile | 6 - src/test/run-make/save-analysis/SameDir.rs | 15 - src/test/run-make/save-analysis/SameDir3.rs | 13 - src/test/run-make/save-analysis/SubDir/mod.rs | 37 -- src/test/run-make/save-analysis/extra-docs.md | 1 - src/test/run-make/save-analysis/foo.rs | 467 -------------------- src/test/run-make/save-analysis/krate2.rs | 18 - src/test/run-make/sepcomp-cci-copies/Makefile | 12 - src/test/run-make/sepcomp-cci-copies/cci_lib.rs | 16 - src/test/run-make/sepcomp-cci-copies/foo.rs | 35 -- src/test/run-make/sepcomp-inlining/Makefile | 15 - src/test/run-make/sepcomp-inlining/foo.rs | 40 -- src/test/run-make/sepcomp-separate/Makefile | 9 - src/test/run-make/sepcomp-separate/foo.rs | 33 -- src/test/run-make/simd-ffi/Makefile | 47 --- src/test/run-make/simd-ffi/simd.rs | 83 ---- src/test/run-make/simple-dylib/Makefile | 5 - src/test/run-make/simple-dylib/bar.rs | 11 - src/test/run-make/simple-dylib/foo.rs | 15 - src/test/run-make/simple-rlib/Makefile | 5 - src/test/run-make/simple-rlib/bar.rs | 11 - src/test/run-make/simple-rlib/foo.rs | 15 - src/test/run-make/stable-symbol-names/Makefile | 40 -- .../stable-symbol-names/stable-symbol-names1.rs | 41 -- .../stable-symbol-names/stable-symbol-names2.rs | 28 -- src/test/run-make/static-dylib-by-default/Makefile | 16 - src/test/run-make/static-dylib-by-default/bar.rs | 18 - src/test/run-make/static-dylib-by-default/foo.rs | 14 - src/test/run-make/static-dylib-by-default/main.c | 16 - src/test/run-make/static-nobundle/Makefile | 21 - src/test/run-make/static-nobundle/aaa.c | 11 - src/test/run-make/static-nobundle/bbb.rs | 23 - src/test/run-make/static-nobundle/ccc.rs | 23 - src/test/run-make/static-nobundle/ddd.rs | 17 - src/test/run-make/static-unwinding/Makefile | 6 - src/test/run-make/static-unwinding/lib.rs | 25 -- src/test/run-make/static-unwinding/main.rs | 34 -- src/test/run-make/staticlib-blank-lib/Makefile | 6 - src/test/run-make/staticlib-blank-lib/foo.rs | 16 - src/test/run-make/stdin-non-utf8/Makefile | 6 - src/test/run-make/stdin-non-utf8/non-utf8 | 1 - src/test/run-make/suspicious-library/Makefile | 7 - src/test/run-make/suspicious-library/bar.rs | 13 - src/test/run-make/suspicious-library/foo.rs | 13 - src/test/run-make/symbol-visibility/Makefile | 60 --- src/test/run-make/symbol-visibility/a_cdylib.rs | 22 - .../run-make/symbol-visibility/a_rust_dylib.rs | 20 - .../run-make/symbol-visibility/an_executable.rs | 17 - src/test/run-make/symbol-visibility/an_rlib.rs | 16 - src/test/run-make/symbols-are-reasonable/Makefile | 13 - src/test/run-make/symbols-are-reasonable/lib.rs | 21 - .../run-make/symbols-include-type-name/Makefile | 9 - src/test/run-make/symbols-include-type-name/lib.rs | 24 -- src/test/run-make/symlinked-extern/Makefile | 16 - src/test/run-make/symlinked-extern/bar.rs | 16 - src/test/run-make/symlinked-extern/baz.rs | 16 - src/test/run-make/symlinked-extern/foo.rs | 15 - src/test/run-make/symlinked-libraries/Makefile | 15 - src/test/run-make/symlinked-libraries/bar.rs | 15 - src/test/run-make/symlinked-libraries/foo.rs | 13 - src/test/run-make/symlinked-rlib/Makefile | 14 - src/test/run-make/symlinked-rlib/bar.rs | 15 - src/test/run-make/symlinked-rlib/foo.rs | 11 - .../run-make/sysroot-crates-are-unstable/Makefile | 2 - .../run-make/sysroot-crates-are-unstable/test.py | 71 ---- src/test/run-make/target-cpu-native/Makefile | 5 - src/test/run-make/target-cpu-native/foo.rs | 12 - src/test/run-make/target-specs/Makefile | 9 - src/test/run-make/target-specs/foo.rs | 32 -- .../run-make/target-specs/my-awesome-platform.json | 11 - .../target-specs/my-incomplete-platform.json | 10 - .../run-make/target-specs/my-invalid-platform.json | 1 - .../my-x86_64-unknown-linux-gnu-platform.json | 12 - src/test/run-make/target-without-atomics/Makefile | 5 - src/test/run-make/test-harness/Makefile | 8 - src/test/run-make/test-harness/test-ignore-cfg.rs | 19 - src/test/run-make/tools.mk | 134 ------ src/test/run-make/treat-err-as-bug/Makefile | 5 - src/test/run-make/treat-err-as-bug/err.rs | 13 - .../type-mismatch-same-crate-name/Makefile | 19 - .../type-mismatch-same-crate-name/crateA.rs | 26 -- .../type-mismatch-same-crate-name/crateB.rs | 14 - .../type-mismatch-same-crate-name/crateC.rs | 35 -- src/test/run-make/use-extern-for-plugins/Makefile | 21 - src/test/run-make/use-extern-for-plugins/bar.rs | 19 - src/test/run-make/use-extern-for-plugins/baz.rs | 18 - src/test/run-make/use-extern-for-plugins/foo.rs | 18 - src/test/run-make/used/Makefile | 11 - src/test/run-make/used/used.rs | 17 - src/test/run-make/version/Makefile | 6 - src/test/run-make/volatile-intrinsics/Makefile | 9 - src/test/run-make/volatile-intrinsics/main.rs | 27 -- src/test/run-make/wasm-custom-section/Makefile | 10 + src/test/run-make/wasm-custom-section/bar.rs | 24 ++ src/test/run-make/wasm-custom-section/foo.js | 46 ++ src/test/run-make/wasm-custom-section/foo.rs | 19 + src/test/run-make/weird-output-filenames/Makefile | 15 - src/test/run-make/weird-output-filenames/foo.rs | 11 - src/test/run-make/windows-spawn/Makefile | 14 - src/test/run-make/windows-spawn/hello.rs | 13 - src/test/run-make/windows-spawn/spawn.rs | 22 - src/test/run-make/windows-subsystem/Makefile | 5 - src/test/run-make/windows-subsystem/console.rs | 14 - src/test/run-make/windows-subsystem/windows.rs | 13 - src/test/ui/feature-gate-wasm_custom_section.rs | 14 + .../ui/feature-gate-wasm_custom_section.stderr | 11 + src/test/ui/wasm-custom-section/malformed.rs | 19 + src/test/ui/wasm-custom-section/malformed.stderr | 14 + src/test/ui/wasm-custom-section/not-const.rs | 29 ++ src/test/ui/wasm-custom-section/not-const.stderr | 38 ++ src/test/ui/wasm-custom-section/not-slice.rs | 22 + src/test/ui/wasm-custom-section/not-slice.stderr | 20 + src/tools/compiletest/src/runtest.rs | 15 +- 1117 files changed, 11000 insertions(+), 10495 deletions(-) create mode 100644 src/librustc_trans/back/wasm.rs create mode 100644 src/test/run-make-fulldeps/a-b-a-linker-guard/Makefile create mode 100644 src/test/run-make-fulldeps/a-b-a-linker-guard/a.rs create mode 100644 src/test/run-make-fulldeps/a-b-a-linker-guard/b.rs create mode 100644 src/test/run-make-fulldeps/alloc-extern-crates/Makefile create mode 100644 src/test/run-make-fulldeps/alloc-extern-crates/fakealloc.rs create mode 100644 src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/Makefile create mode 100644 src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/foo.rs create mode 100644 src/test/run-make-fulldeps/allow-warnings-cmdline-stability/Makefile create mode 100644 src/test/run-make-fulldeps/allow-warnings-cmdline-stability/bar.rs create mode 100644 src/test/run-make-fulldeps/allow-warnings-cmdline-stability/foo.rs create mode 100644 src/test/run-make-fulldeps/archive-duplicate-names/Makefile create mode 100644 src/test/run-make-fulldeps/archive-duplicate-names/bar.c create mode 100644 src/test/run-make-fulldeps/archive-duplicate-names/bar.rs create mode 100644 src/test/run-make-fulldeps/archive-duplicate-names/foo.c create mode 100644 src/test/run-make-fulldeps/archive-duplicate-names/foo.rs create mode 100644 src/test/run-make-fulldeps/atomic-lock-free/Makefile create mode 100644 src/test/run-make-fulldeps/atomic-lock-free/atomic_lock_free.rs create mode 100644 src/test/run-make-fulldeps/bare-outfile/Makefile create mode 100644 src/test/run-make-fulldeps/bare-outfile/foo.rs create mode 100644 src/test/run-make-fulldeps/c-dynamic-dylib/Makefile create mode 100644 src/test/run-make-fulldeps/c-dynamic-dylib/bar.rs create mode 100644 src/test/run-make-fulldeps/c-dynamic-dylib/cfoo.c create mode 100644 src/test/run-make-fulldeps/c-dynamic-dylib/foo.rs create mode 100644 src/test/run-make-fulldeps/c-dynamic-rlib/Makefile create mode 100644 src/test/run-make-fulldeps/c-dynamic-rlib/bar.rs create mode 100644 src/test/run-make-fulldeps/c-dynamic-rlib/cfoo.c create mode 100644 src/test/run-make-fulldeps/c-dynamic-rlib/foo.rs create mode 100644 src/test/run-make-fulldeps/c-link-to-rust-dylib/Makefile create mode 100644 src/test/run-make-fulldeps/c-link-to-rust-dylib/bar.c create mode 100644 src/test/run-make-fulldeps/c-link-to-rust-dylib/foo.rs create mode 100644 src/test/run-make-fulldeps/c-link-to-rust-staticlib/Makefile create mode 100644 src/test/run-make-fulldeps/c-link-to-rust-staticlib/bar.c create mode 100644 src/test/run-make-fulldeps/c-link-to-rust-staticlib/foo.rs create mode 100644 src/test/run-make-fulldeps/c-static-dylib/Makefile create mode 100644 src/test/run-make-fulldeps/c-static-dylib/bar.rs create mode 100644 src/test/run-make-fulldeps/c-static-dylib/cfoo.c create mode 100644 src/test/run-make-fulldeps/c-static-dylib/foo.rs create mode 100644 src/test/run-make-fulldeps/c-static-rlib/Makefile create mode 100644 src/test/run-make-fulldeps/c-static-rlib/bar.rs create mode 100644 src/test/run-make-fulldeps/c-static-rlib/cfoo.c create mode 100644 src/test/run-make-fulldeps/c-static-rlib/foo.rs create mode 100644 src/test/run-make-fulldeps/cat-and-grep-sanity-check/Makefile create mode 100644 src/test/run-make-fulldeps/cdylib-fewer-symbols/Makefile create mode 100644 src/test/run-make-fulldeps/cdylib-fewer-symbols/foo.rs create mode 100644 src/test/run-make-fulldeps/cdylib/Makefile create mode 100644 src/test/run-make-fulldeps/cdylib/bar.rs create mode 100644 src/test/run-make-fulldeps/cdylib/foo.c create mode 100644 src/test/run-make-fulldeps/cdylib/foo.rs create mode 100644 src/test/run-make-fulldeps/codegen-options-parsing/Makefile create mode 100644 src/test/run-make-fulldeps/codegen-options-parsing/dummy.rs create mode 100644 src/test/run-make-fulldeps/compile-stdin/Makefile create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths-2/Makefile create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths-2/a.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths-2/b.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths-2/c.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/Makefile create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/a.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/b.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/c.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/d.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/e.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/e2.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/f.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/native.c create mode 100644 src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile create mode 100644 src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.cpp create mode 100644 src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.rs create mode 100644 src/test/run-make-fulldeps/crate-data-smoke/Makefile create mode 100644 src/test/run-make-fulldeps/crate-data-smoke/crate.rs create mode 100644 src/test/run-make-fulldeps/crate-data-smoke/lib.rs create mode 100644 src/test/run-make-fulldeps/crate-data-smoke/rlib.rs create mode 100644 src/test/run-make-fulldeps/crate-name-priority/Makefile create mode 100644 src/test/run-make-fulldeps/crate-name-priority/foo.rs create mode 100644 src/test/run-make-fulldeps/crate-name-priority/foo1.rs create mode 100644 src/test/run-make-fulldeps/debug-assertions/Makefile create mode 100644 src/test/run-make-fulldeps/debug-assertions/debug.rs create mode 100644 src/test/run-make-fulldeps/dep-info-doesnt-run-much/Makefile create mode 100644 src/test/run-make-fulldeps/dep-info-doesnt-run-much/foo.rs create mode 100644 src/test/run-make-fulldeps/dep-info-spaces/Makefile create mode 100644 src/test/run-make-fulldeps/dep-info-spaces/Makefile.foo create mode 100644 src/test/run-make-fulldeps/dep-info-spaces/bar.rs create mode 100644 src/test/run-make-fulldeps/dep-info-spaces/foo foo.rs create mode 100644 src/test/run-make-fulldeps/dep-info-spaces/lib.rs create mode 100644 src/test/run-make-fulldeps/dep-info/Makefile create mode 100644 src/test/run-make-fulldeps/dep-info/Makefile.foo create mode 100644 src/test/run-make-fulldeps/dep-info/bar.rs create mode 100644 src/test/run-make-fulldeps/dep-info/foo.rs create mode 100644 src/test/run-make-fulldeps/dep-info/lib.rs create mode 100644 src/test/run-make-fulldeps/dep-info/lib2.rs create mode 100644 src/test/run-make-fulldeps/duplicate-output-flavors/Makefile create mode 100644 src/test/run-make-fulldeps/duplicate-output-flavors/foo.rs create mode 100644 src/test/run-make-fulldeps/dylib-chain/Makefile create mode 100644 src/test/run-make-fulldeps/dylib-chain/m1.rs create mode 100644 src/test/run-make-fulldeps/dylib-chain/m2.rs create mode 100644 src/test/run-make-fulldeps/dylib-chain/m3.rs create mode 100644 src/test/run-make-fulldeps/dylib-chain/m4.rs create mode 100644 src/test/run-make-fulldeps/emit/Makefile create mode 100644 src/test/run-make-fulldeps/emit/test-24876.rs create mode 100644 src/test/run-make-fulldeps/emit/test-26235.rs create mode 100644 src/test/run-make-fulldeps/error-found-staticlib-instead-crate/Makefile create mode 100644 src/test/run-make-fulldeps/error-found-staticlib-instead-crate/bar.rs create mode 100644 src/test/run-make-fulldeps/error-found-staticlib-instead-crate/foo.rs create mode 100644 src/test/run-make-fulldeps/error-writing-dependencies/Makefile create mode 100644 src/test/run-make-fulldeps/error-writing-dependencies/foo.rs create mode 100644 src/test/run-make-fulldeps/extern-diff-internal-name/Makefile create mode 100644 src/test/run-make-fulldeps/extern-diff-internal-name/lib.rs create mode 100644 src/test/run-make-fulldeps/extern-diff-internal-name/test.rs create mode 100644 src/test/run-make-fulldeps/extern-flag-disambiguates/Makefile create mode 100644 src/test/run-make-fulldeps/extern-flag-disambiguates/a.rs create mode 100644 src/test/run-make-fulldeps/extern-flag-disambiguates/b.rs create mode 100644 src/test/run-make-fulldeps/extern-flag-disambiguates/c.rs create mode 100644 src/test/run-make-fulldeps/extern-flag-disambiguates/d.rs create mode 100644 src/test/run-make-fulldeps/extern-flag-fun/Makefile create mode 100644 src/test/run-make-fulldeps/extern-flag-fun/bar-alt.rs create mode 100644 src/test/run-make-fulldeps/extern-flag-fun/bar.rs create mode 100644 src/test/run-make-fulldeps/extern-flag-fun/foo.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-generic/Makefile create mode 100644 src/test/run-make-fulldeps/extern-fn-generic/test.c create mode 100644 src/test/run-make-fulldeps/extern-fn-generic/test.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-generic/testcrate.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-mangle/Makefile create mode 100644 src/test/run-make-fulldeps/extern-fn-mangle/test.c create mode 100644 src/test/run-make-fulldeps/extern-fn-mangle/test.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-reachable/Makefile create mode 100644 src/test/run-make-fulldeps/extern-fn-reachable/dylib.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-reachable/main.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-struct-passing-abi/Makefile create mode 100644 src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.c create mode 100644 src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-with-extern-types/Makefile create mode 100644 src/test/run-make-fulldeps/extern-fn-with-extern-types/ctest.c create mode 100644 src/test/run-make-fulldeps/extern-fn-with-extern-types/test.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-with-packed-struct/Makefile create mode 100644 src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.c create mode 100644 src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-with-union/Makefile create mode 100644 src/test/run-make-fulldeps/extern-fn-with-union/ctest.c create mode 100644 src/test/run-make-fulldeps/extern-fn-with-union/test.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-with-union/testcrate.rs create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies/Makefile create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies/bar.rs create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies/foo1.rs create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies/foo2.rs create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies2/Makefile create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies2/bar.rs create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies2/foo1.rs create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies2/foo2.rs create mode 100644 src/test/run-make-fulldeps/extern-overrides-distribution/Makefile create mode 100644 src/test/run-make-fulldeps/extern-overrides-distribution/libc.rs create mode 100644 src/test/run-make-fulldeps/extern-overrides-distribution/main.rs create mode 100644 src/test/run-make-fulldeps/extra-filename-with-temp-outputs/Makefile create mode 100644 src/test/run-make-fulldeps/extra-filename-with-temp-outputs/foo.rs create mode 100644 src/test/run-make-fulldeps/fpic/Makefile create mode 100644 src/test/run-make-fulldeps/fpic/hello.rs create mode 100644 src/test/run-make-fulldeps/hir-tree/Makefile create mode 100644 src/test/run-make-fulldeps/hir-tree/input.rs create mode 100644 src/test/run-make-fulldeps/hotplug_codegen_backend/Makefile create mode 100644 src/test/run-make-fulldeps/hotplug_codegen_backend/some_crate.rs create mode 100644 src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs create mode 100644 src/test/run-make-fulldeps/include_bytes_deps/Makefile create mode 100644 src/test/run-make-fulldeps/include_bytes_deps/input.bin create mode 100644 src/test/run-make-fulldeps/include_bytes_deps/input.md create mode 100644 src/test/run-make-fulldeps/include_bytes_deps/input.txt create mode 100644 src/test/run-make-fulldeps/include_bytes_deps/main.rs create mode 100644 src/test/run-make-fulldeps/inline-always-many-cgu/Makefile create mode 100644 src/test/run-make-fulldeps/inline-always-many-cgu/foo.rs create mode 100644 src/test/run-make-fulldeps/interdependent-c-libraries/Makefile create mode 100644 src/test/run-make-fulldeps/interdependent-c-libraries/bar.c create mode 100644 src/test/run-make-fulldeps/interdependent-c-libraries/bar.rs create mode 100644 src/test/run-make-fulldeps/interdependent-c-libraries/foo.c create mode 100644 src/test/run-make-fulldeps/interdependent-c-libraries/foo.rs create mode 100644 src/test/run-make-fulldeps/interdependent-c-libraries/main.rs create mode 100644 src/test/run-make-fulldeps/intrinsic-unreachable/Makefile create mode 100644 src/test/run-make-fulldeps/intrinsic-unreachable/exit-ret.rs create mode 100644 src/test/run-make-fulldeps/intrinsic-unreachable/exit-unreachable.rs create mode 100644 src/test/run-make-fulldeps/invalid-library/Makefile create mode 100644 src/test/run-make-fulldeps/invalid-library/foo.rs create mode 100644 src/test/run-make-fulldeps/invalid-staticlib/Makefile create mode 100644 src/test/run-make-fulldeps/issue-11908/Makefile create mode 100644 src/test/run-make-fulldeps/issue-11908/bar.rs create mode 100644 src/test/run-make-fulldeps/issue-11908/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-14500/Makefile create mode 100644 src/test/run-make-fulldeps/issue-14500/bar.rs create mode 100644 src/test/run-make-fulldeps/issue-14500/foo.c create mode 100644 src/test/run-make-fulldeps/issue-14500/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-14698/Makefile create mode 100644 src/test/run-make-fulldeps/issue-14698/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-15460/Makefile create mode 100644 src/test/run-make-fulldeps/issue-15460/bar.rs create mode 100644 src/test/run-make-fulldeps/issue-15460/foo.c create mode 100644 src/test/run-make-fulldeps/issue-15460/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-18943/Makefile create mode 100644 src/test/run-make-fulldeps/issue-18943/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-19371/Makefile create mode 100644 src/test/run-make-fulldeps/issue-19371/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-20626/Makefile create mode 100644 src/test/run-make-fulldeps/issue-20626/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-22131/Makefile create mode 100644 src/test/run-make-fulldeps/issue-22131/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-24445/Makefile create mode 100644 src/test/run-make-fulldeps/issue-24445/foo.c create mode 100644 src/test/run-make-fulldeps/issue-24445/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-25581/Makefile create mode 100644 src/test/run-make-fulldeps/issue-25581/test.c create mode 100644 src/test/run-make-fulldeps/issue-25581/test.rs create mode 100644 src/test/run-make-fulldeps/issue-26006/Makefile create mode 100644 src/test/run-make-fulldeps/issue-26006/in/libc/lib.rs create mode 100644 src/test/run-make-fulldeps/issue-26006/in/time/lib.rs create mode 100644 src/test/run-make-fulldeps/issue-26092/Makefile create mode 100644 src/test/run-make-fulldeps/issue-26092/blank.rs create mode 100644 src/test/run-make-fulldeps/issue-28595/Makefile create mode 100644 src/test/run-make-fulldeps/issue-28595/a.c create mode 100644 src/test/run-make-fulldeps/issue-28595/a.rs create mode 100644 src/test/run-make-fulldeps/issue-28595/b.c create mode 100644 src/test/run-make-fulldeps/issue-28595/b.rs create mode 100644 src/test/run-make-fulldeps/issue-28766/Makefile create mode 100644 src/test/run-make-fulldeps/issue-28766/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-28766/main.rs create mode 100644 src/test/run-make-fulldeps/issue-30063/Makefile create mode 100644 src/test/run-make-fulldeps/issue-30063/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-33329/Makefile create mode 100644 src/test/run-make-fulldeps/issue-33329/main.rs create mode 100644 src/test/run-make-fulldeps/issue-35164/Makefile create mode 100644 src/test/run-make-fulldeps/issue-35164/main.rs create mode 100644 src/test/run-make-fulldeps/issue-35164/submodule/mod.rs create mode 100644 src/test/run-make-fulldeps/issue-37839/Makefile create mode 100644 src/test/run-make-fulldeps/issue-37839/a.rs create mode 100644 src/test/run-make-fulldeps/issue-37839/b.rs create mode 100644 src/test/run-make-fulldeps/issue-37839/c.rs create mode 100644 src/test/run-make-fulldeps/issue-37893/Makefile create mode 100644 src/test/run-make-fulldeps/issue-37893/a.rs create mode 100644 src/test/run-make-fulldeps/issue-37893/b.rs create mode 100644 src/test/run-make-fulldeps/issue-37893/c.rs create mode 100644 src/test/run-make-fulldeps/issue-38237/Makefile create mode 100644 src/test/run-make-fulldeps/issue-38237/bar.rs create mode 100644 src/test/run-make-fulldeps/issue-38237/baz.rs create mode 100644 src/test/run-make-fulldeps/issue-38237/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-40535/Makefile create mode 100644 src/test/run-make-fulldeps/issue-40535/bar.rs create mode 100644 src/test/run-make-fulldeps/issue-40535/baz.rs create mode 100644 src/test/run-make-fulldeps/issue-40535/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-46239/Makefile create mode 100644 src/test/run-make-fulldeps/issue-46239/main.rs create mode 100644 src/test/run-make-fulldeps/issue-7349/Makefile create mode 100644 src/test/run-make-fulldeps/issue-7349/foo.rs create mode 100644 src/test/run-make-fulldeps/issues-41478-43796/Makefile create mode 100644 src/test/run-make-fulldeps/issues-41478-43796/a.rs create mode 100644 src/test/run-make-fulldeps/libs-and-bins/Makefile create mode 100644 src/test/run-make-fulldeps/libs-and-bins/foo.rs create mode 100644 src/test/run-make-fulldeps/libs-through-symlinks/Makefile create mode 100644 src/test/run-make-fulldeps/libs-through-symlinks/bar.rs create mode 100644 src/test/run-make-fulldeps/libs-through-symlinks/foo.rs create mode 100644 src/test/run-make-fulldeps/libtest-json/Makefile create mode 100644 src/test/run-make-fulldeps/libtest-json/f.rs create mode 100644 src/test/run-make-fulldeps/libtest-json/output.json create mode 100755 src/test/run-make-fulldeps/libtest-json/validate_json.py create mode 100644 src/test/run-make-fulldeps/link-arg/Makefile create mode 100644 src/test/run-make-fulldeps/link-arg/empty.rs create mode 100644 src/test/run-make-fulldeps/link-cfg/Makefile create mode 100644 src/test/run-make-fulldeps/link-cfg/dep-with-staticlib.rs create mode 100644 src/test/run-make-fulldeps/link-cfg/dep.rs create mode 100644 src/test/run-make-fulldeps/link-cfg/no-deps.rs create mode 100644 src/test/run-make-fulldeps/link-cfg/return1.c create mode 100644 src/test/run-make-fulldeps/link-cfg/return2.c create mode 100644 src/test/run-make-fulldeps/link-cfg/return3.c create mode 100644 src/test/run-make-fulldeps/link-cfg/with-deps.rs create mode 100644 src/test/run-make-fulldeps/link-cfg/with-staticlib-deps.rs create mode 100644 src/test/run-make-fulldeps/link-path-order/Makefile create mode 100644 src/test/run-make-fulldeps/link-path-order/correct.c create mode 100644 src/test/run-make-fulldeps/link-path-order/main.rs create mode 100644 src/test/run-make-fulldeps/link-path-order/wrong.c create mode 100644 src/test/run-make-fulldeps/linkage-attr-on-static/Makefile create mode 100644 src/test/run-make-fulldeps/linkage-attr-on-static/bar.rs create mode 100644 src/test/run-make-fulldeps/linkage-attr-on-static/foo.c create mode 100644 src/test/run-make-fulldeps/linker-output-non-utf8/Makefile create mode 100644 src/test/run-make-fulldeps/linker-output-non-utf8/exec.rs create mode 100644 src/test/run-make-fulldeps/linker-output-non-utf8/library.rs create mode 100644 src/test/run-make-fulldeps/llvm-pass/Makefile create mode 100644 src/test/run-make-fulldeps/llvm-pass/llvm-function-pass.so.cc create mode 100644 src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc create mode 100644 src/test/run-make-fulldeps/llvm-pass/main.rs create mode 100644 src/test/run-make-fulldeps/llvm-pass/plugin.rs create mode 100644 src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/Makefile create mode 100644 src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.bat create mode 100644 src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.rs create mode 100644 src/test/run-make-fulldeps/long-linker-command-lines/Makefile create mode 100644 src/test/run-make-fulldeps/long-linker-command-lines/foo.rs create mode 100644 src/test/run-make-fulldeps/longjmp-across-rust/Makefile create mode 100644 src/test/run-make-fulldeps/longjmp-across-rust/foo.c create mode 100644 src/test/run-make-fulldeps/longjmp-across-rust/main.rs create mode 100644 src/test/run-make-fulldeps/ls-metadata/Makefile create mode 100644 src/test/run-make-fulldeps/ls-metadata/foo.rs create mode 100644 src/test/run-make-fulldeps/lto-no-link-whole-rlib/Makefile create mode 100644 src/test/run-make-fulldeps/lto-no-link-whole-rlib/bar.c create mode 100644 src/test/run-make-fulldeps/lto-no-link-whole-rlib/foo.c create mode 100644 src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib1.rs create mode 100644 src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib2.rs create mode 100644 src/test/run-make-fulldeps/lto-no-link-whole-rlib/main.rs create mode 100644 src/test/run-make-fulldeps/lto-readonly-lib/Makefile create mode 100644 src/test/run-make-fulldeps/lto-readonly-lib/lib.rs create mode 100644 src/test/run-make-fulldeps/lto-readonly-lib/main.rs create mode 100644 src/test/run-make-fulldeps/lto-smoke-c/Makefile create mode 100644 src/test/run-make-fulldeps/lto-smoke-c/bar.c create mode 100644 src/test/run-make-fulldeps/lto-smoke-c/foo.rs create mode 100644 src/test/run-make-fulldeps/lto-smoke/Makefile create mode 100644 src/test/run-make-fulldeps/lto-smoke/lib.rs create mode 100644 src/test/run-make-fulldeps/lto-smoke/main.rs create mode 100644 src/test/run-make-fulldeps/manual-crate-name/Makefile create mode 100644 src/test/run-make-fulldeps/manual-crate-name/bar.rs create mode 100644 src/test/run-make-fulldeps/manual-link/Makefile create mode 100644 src/test/run-make-fulldeps/manual-link/bar.c create mode 100644 src/test/run-make-fulldeps/manual-link/foo.c create mode 100644 src/test/run-make-fulldeps/manual-link/foo.rs create mode 100644 src/test/run-make-fulldeps/manual-link/main.rs create mode 100644 src/test/run-make-fulldeps/many-crates-but-no-match/Makefile create mode 100644 src/test/run-make-fulldeps/many-crates-but-no-match/crateA1.rs create mode 100644 src/test/run-make-fulldeps/many-crates-but-no-match/crateA2.rs create mode 100644 src/test/run-make-fulldeps/many-crates-but-no-match/crateA3.rs create mode 100644 src/test/run-make-fulldeps/many-crates-but-no-match/crateB.rs create mode 100644 src/test/run-make-fulldeps/many-crates-but-no-match/crateC.rs create mode 100644 src/test/run-make-fulldeps/metadata-flag-frobs-symbols/Makefile create mode 100644 src/test/run-make-fulldeps/metadata-flag-frobs-symbols/bar.rs create mode 100644 src/test/run-make-fulldeps/metadata-flag-frobs-symbols/foo.rs create mode 100644 src/test/run-make-fulldeps/min-global-align/Makefile create mode 100644 src/test/run-make-fulldeps/min-global-align/min_global_align.rs create mode 100644 src/test/run-make-fulldeps/mismatching-target-triples/Makefile create mode 100644 src/test/run-make-fulldeps/mismatching-target-triples/bar.rs create mode 100644 src/test/run-make-fulldeps/mismatching-target-triples/foo.rs create mode 100644 src/test/run-make-fulldeps/missing-crate-dependency/Makefile create mode 100644 src/test/run-make-fulldeps/missing-crate-dependency/crateA.rs create mode 100644 src/test/run-make-fulldeps/missing-crate-dependency/crateB.rs create mode 100644 src/test/run-make-fulldeps/missing-crate-dependency/crateC.rs create mode 100644 src/test/run-make-fulldeps/mixing-deps/Makefile create mode 100644 src/test/run-make-fulldeps/mixing-deps/both.rs create mode 100644 src/test/run-make-fulldeps/mixing-deps/dylib.rs create mode 100644 src/test/run-make-fulldeps/mixing-deps/prog.rs create mode 100644 src/test/run-make-fulldeps/mixing-formats/Makefile create mode 100644 src/test/run-make-fulldeps/mixing-formats/bar1.rs create mode 100644 src/test/run-make-fulldeps/mixing-formats/bar2.rs create mode 100644 src/test/run-make-fulldeps/mixing-formats/baz.rs create mode 100644 src/test/run-make-fulldeps/mixing-formats/baz2.rs create mode 100644 src/test/run-make-fulldeps/mixing-formats/foo.rs create mode 100644 src/test/run-make-fulldeps/mixing-libs/Makefile create mode 100644 src/test/run-make-fulldeps/mixing-libs/dylib.rs create mode 100644 src/test/run-make-fulldeps/mixing-libs/prog.rs create mode 100644 src/test/run-make-fulldeps/mixing-libs/rlib.rs create mode 100644 src/test/run-make-fulldeps/msvc-opt-minsize/Makefile create mode 100644 src/test/run-make-fulldeps/msvc-opt-minsize/foo.rs create mode 100644 src/test/run-make-fulldeps/multiple-emits/Makefile create mode 100644 src/test/run-make-fulldeps/multiple-emits/foo.rs create mode 100644 src/test/run-make-fulldeps/no-builtins-lto/Makefile create mode 100644 src/test/run-make-fulldeps/no-builtins-lto/main.rs create mode 100644 src/test/run-make-fulldeps/no-builtins-lto/no_builtins.rs create mode 100644 src/test/run-make-fulldeps/no-duplicate-libs/Makefile create mode 100644 src/test/run-make-fulldeps/no-duplicate-libs/bar.c create mode 100644 src/test/run-make-fulldeps/no-duplicate-libs/foo.c create mode 100644 src/test/run-make-fulldeps/no-duplicate-libs/main.rs create mode 100644 src/test/run-make-fulldeps/no-integrated-as/Makefile create mode 100644 src/test/run-make-fulldeps/no-integrated-as/hello.rs create mode 100644 src/test/run-make-fulldeps/no-intermediate-extras/Makefile create mode 100644 src/test/run-make-fulldeps/no-intermediate-extras/foo.rs create mode 100644 src/test/run-make-fulldeps/obey-crate-type-flag/Makefile create mode 100644 src/test/run-make-fulldeps/obey-crate-type-flag/test.rs create mode 100644 src/test/run-make-fulldeps/output-filename-conflicts-with-directory/Makefile create mode 100644 src/test/run-make-fulldeps/output-filename-conflicts-with-directory/foo.rs create mode 100644 src/test/run-make-fulldeps/output-filename-overwrites-input/Makefile create mode 100644 src/test/run-make-fulldeps/output-filename-overwrites-input/bar.rs create mode 100644 src/test/run-make-fulldeps/output-filename-overwrites-input/foo.rs create mode 100644 src/test/run-make-fulldeps/output-type-permutations/Makefile create mode 100644 src/test/run-make-fulldeps/output-type-permutations/foo.rs create mode 100644 src/test/run-make-fulldeps/output-with-hyphens/Makefile create mode 100644 src/test/run-make-fulldeps/output-with-hyphens/foo-bar.rs create mode 100644 src/test/run-make-fulldeps/prefer-dylib/Makefile create mode 100644 src/test/run-make-fulldeps/prefer-dylib/bar.rs create mode 100644 src/test/run-make-fulldeps/prefer-dylib/foo.rs create mode 100644 src/test/run-make-fulldeps/prefer-rlib/Makefile create mode 100644 src/test/run-make-fulldeps/prefer-rlib/bar.rs create mode 100644 src/test/run-make-fulldeps/prefer-rlib/foo.rs create mode 100644 src/test/run-make-fulldeps/pretty-expanded-hygiene/Makefile create mode 100644 src/test/run-make-fulldeps/pretty-expanded-hygiene/input.pp.rs create mode 100644 src/test/run-make-fulldeps/pretty-expanded-hygiene/input.rs create mode 100644 src/test/run-make-fulldeps/pretty-expanded/Makefile create mode 100644 src/test/run-make-fulldeps/pretty-expanded/input.rs create mode 100644 src/test/run-make-fulldeps/pretty-print-path-suffix/Makefile create mode 100644 src/test/run-make-fulldeps/pretty-print-path-suffix/foo.pp create mode 100644 src/test/run-make-fulldeps/pretty-print-path-suffix/foo_method.pp create mode 100644 src/test/run-make-fulldeps/pretty-print-path-suffix/input.rs create mode 100644 src/test/run-make-fulldeps/pretty-print-path-suffix/nest_foo.pp create mode 100644 src/test/run-make-fulldeps/pretty-print-to-file/Makefile create mode 100644 src/test/run-make-fulldeps/pretty-print-to-file/input.pp create mode 100644 src/test/run-make-fulldeps/pretty-print-to-file/input.rs create mode 100644 src/test/run-make-fulldeps/print-cfg/Makefile create mode 100644 src/test/run-make-fulldeps/print-target-list/Makefile create mode 100644 src/test/run-make-fulldeps/profile/Makefile create mode 100644 src/test/run-make-fulldeps/profile/test.rs create mode 100644 src/test/run-make-fulldeps/prune-link-args/Makefile create mode 100644 src/test/run-make-fulldeps/prune-link-args/empty.rs create mode 100644 src/test/run-make-fulldeps/relocation-model/Makefile create mode 100644 src/test/run-make-fulldeps/relocation-model/foo.rs create mode 100644 src/test/run-make-fulldeps/relro-levels/Makefile create mode 100644 src/test/run-make-fulldeps/relro-levels/hello.rs create mode 100644 src/test/run-make-fulldeps/reproducible-build/Makefile create mode 100644 src/test/run-make-fulldeps/reproducible-build/linker.rs create mode 100644 src/test/run-make-fulldeps/reproducible-build/reproducible-build-aux.rs create mode 100644 src/test/run-make-fulldeps/reproducible-build/reproducible-build.rs create mode 100644 src/test/run-make-fulldeps/rlib-chain/Makefile create mode 100644 src/test/run-make-fulldeps/rlib-chain/m1.rs create mode 100644 src/test/run-make-fulldeps/rlib-chain/m2.rs create mode 100644 src/test/run-make-fulldeps/rlib-chain/m3.rs create mode 100644 src/test/run-make-fulldeps/rlib-chain/m4.rs create mode 100644 src/test/run-make-fulldeps/rustc-macro-dep-files/Makefile create mode 100644 src/test/run-make-fulldeps/rustc-macro-dep-files/bar.rs create mode 100644 src/test/run-make-fulldeps/rustc-macro-dep-files/foo.rs create mode 100644 src/test/run-make-fulldeps/rustdoc-error-lines/Makefile create mode 100644 src/test/run-make-fulldeps/rustdoc-error-lines/input.rs create mode 100644 src/test/run-make-fulldeps/rustdoc-output-path/Makefile create mode 100644 src/test/run-make-fulldeps/rustdoc-output-path/foo.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-address/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-address/overflow.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-cdylib-link/library.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-cdylib-link/program.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-dylib-link/library.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-dylib-link/program.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-invalid-cratetype/hello.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-invalid-target/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-invalid-target/hello.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-leak/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-leak/leak.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-memory/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-memory/uninit.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-staticlib-link/library.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-staticlib-link/program.c create mode 100644 src/test/run-make-fulldeps/save-analysis-fail/Makefile create mode 100644 src/test/run-make-fulldeps/save-analysis-fail/SameDir.rs create mode 100644 src/test/run-make-fulldeps/save-analysis-fail/SameDir3.rs create mode 100644 src/test/run-make-fulldeps/save-analysis-fail/SubDir/mod.rs create mode 100644 src/test/run-make-fulldeps/save-analysis-fail/foo.rs create mode 100644 src/test/run-make-fulldeps/save-analysis-fail/krate2.rs create mode 100644 src/test/run-make-fulldeps/save-analysis/Makefile create mode 100644 src/test/run-make-fulldeps/save-analysis/SameDir.rs create mode 100644 src/test/run-make-fulldeps/save-analysis/SameDir3.rs create mode 100644 src/test/run-make-fulldeps/save-analysis/SubDir/mod.rs create mode 100644 src/test/run-make-fulldeps/save-analysis/extra-docs.md create mode 100644 src/test/run-make-fulldeps/save-analysis/foo.rs create mode 100644 src/test/run-make-fulldeps/save-analysis/krate2.rs create mode 100644 src/test/run-make-fulldeps/sepcomp-cci-copies/Makefile create mode 100644 src/test/run-make-fulldeps/sepcomp-cci-copies/cci_lib.rs create mode 100644 src/test/run-make-fulldeps/sepcomp-cci-copies/foo.rs create mode 100644 src/test/run-make-fulldeps/sepcomp-inlining/Makefile create mode 100644 src/test/run-make-fulldeps/sepcomp-inlining/foo.rs create mode 100644 src/test/run-make-fulldeps/sepcomp-separate/Makefile create mode 100644 src/test/run-make-fulldeps/sepcomp-separate/foo.rs create mode 100644 src/test/run-make-fulldeps/simd-ffi/Makefile create mode 100644 src/test/run-make-fulldeps/simd-ffi/simd.rs create mode 100644 src/test/run-make-fulldeps/simple-dylib/Makefile create mode 100644 src/test/run-make-fulldeps/simple-dylib/bar.rs create mode 100644 src/test/run-make-fulldeps/simple-dylib/foo.rs create mode 100644 src/test/run-make-fulldeps/simple-rlib/Makefile create mode 100644 src/test/run-make-fulldeps/simple-rlib/bar.rs create mode 100644 src/test/run-make-fulldeps/simple-rlib/foo.rs create mode 100644 src/test/run-make-fulldeps/stable-symbol-names/Makefile create mode 100644 src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names1.rs create mode 100644 src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names2.rs create mode 100644 src/test/run-make-fulldeps/static-dylib-by-default/Makefile create mode 100644 src/test/run-make-fulldeps/static-dylib-by-default/bar.rs create mode 100644 src/test/run-make-fulldeps/static-dylib-by-default/foo.rs create mode 100644 src/test/run-make-fulldeps/static-dylib-by-default/main.c create mode 100644 src/test/run-make-fulldeps/static-nobundle/Makefile create mode 100644 src/test/run-make-fulldeps/static-nobundle/aaa.c create mode 100644 src/test/run-make-fulldeps/static-nobundle/bbb.rs create mode 100644 src/test/run-make-fulldeps/static-nobundle/ccc.rs create mode 100644 src/test/run-make-fulldeps/static-nobundle/ddd.rs create mode 100644 src/test/run-make-fulldeps/static-unwinding/Makefile create mode 100644 src/test/run-make-fulldeps/static-unwinding/lib.rs create mode 100644 src/test/run-make-fulldeps/static-unwinding/main.rs create mode 100644 src/test/run-make-fulldeps/staticlib-blank-lib/Makefile create mode 100644 src/test/run-make-fulldeps/staticlib-blank-lib/foo.rs create mode 100644 src/test/run-make-fulldeps/stdin-non-utf8/Makefile create mode 100644 src/test/run-make-fulldeps/stdin-non-utf8/non-utf8 create mode 100644 src/test/run-make-fulldeps/suspicious-library/Makefile create mode 100644 src/test/run-make-fulldeps/suspicious-library/bar.rs create mode 100644 src/test/run-make-fulldeps/suspicious-library/foo.rs create mode 100644 src/test/run-make-fulldeps/symbol-visibility/Makefile create mode 100644 src/test/run-make-fulldeps/symbol-visibility/a_cdylib.rs create mode 100644 src/test/run-make-fulldeps/symbol-visibility/a_rust_dylib.rs create mode 100644 src/test/run-make-fulldeps/symbol-visibility/an_executable.rs create mode 100644 src/test/run-make-fulldeps/symbol-visibility/an_rlib.rs create mode 100644 src/test/run-make-fulldeps/symbols-are-reasonable/Makefile create mode 100644 src/test/run-make-fulldeps/symbols-are-reasonable/lib.rs create mode 100644 src/test/run-make-fulldeps/symbols-include-type-name/Makefile create mode 100644 src/test/run-make-fulldeps/symbols-include-type-name/lib.rs create mode 100644 src/test/run-make-fulldeps/symlinked-extern/Makefile create mode 100644 src/test/run-make-fulldeps/symlinked-extern/bar.rs create mode 100644 src/test/run-make-fulldeps/symlinked-extern/baz.rs create mode 100644 src/test/run-make-fulldeps/symlinked-extern/foo.rs create mode 100644 src/test/run-make-fulldeps/symlinked-libraries/Makefile create mode 100644 src/test/run-make-fulldeps/symlinked-libraries/bar.rs create mode 100644 src/test/run-make-fulldeps/symlinked-libraries/foo.rs create mode 100644 src/test/run-make-fulldeps/symlinked-rlib/Makefile create mode 100644 src/test/run-make-fulldeps/symlinked-rlib/bar.rs create mode 100644 src/test/run-make-fulldeps/symlinked-rlib/foo.rs create mode 100644 src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile create mode 100644 src/test/run-make-fulldeps/sysroot-crates-are-unstable/test.py create mode 100644 src/test/run-make-fulldeps/target-cpu-native/Makefile create mode 100644 src/test/run-make-fulldeps/target-cpu-native/foo.rs create mode 100644 src/test/run-make-fulldeps/target-specs/Makefile create mode 100644 src/test/run-make-fulldeps/target-specs/foo.rs create mode 100644 src/test/run-make-fulldeps/target-specs/my-awesome-platform.json create mode 100644 src/test/run-make-fulldeps/target-specs/my-incomplete-platform.json create mode 100644 src/test/run-make-fulldeps/target-specs/my-invalid-platform.json create mode 100644 src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json create mode 100644 src/test/run-make-fulldeps/target-without-atomics/Makefile create mode 100644 src/test/run-make-fulldeps/test-harness/Makefile create mode 100644 src/test/run-make-fulldeps/test-harness/test-ignore-cfg.rs create mode 100644 src/test/run-make-fulldeps/tools.mk create mode 100644 src/test/run-make-fulldeps/treat-err-as-bug/Makefile create mode 100644 src/test/run-make-fulldeps/treat-err-as-bug/err.rs create mode 100644 src/test/run-make-fulldeps/type-mismatch-same-crate-name/Makefile create mode 100644 src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateA.rs create mode 100644 src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateB.rs create mode 100644 src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs create mode 100644 src/test/run-make-fulldeps/use-extern-for-plugins/Makefile create mode 100644 src/test/run-make-fulldeps/use-extern-for-plugins/bar.rs create mode 100644 src/test/run-make-fulldeps/use-extern-for-plugins/baz.rs create mode 100644 src/test/run-make-fulldeps/use-extern-for-plugins/foo.rs create mode 100644 src/test/run-make-fulldeps/used/Makefile create mode 100644 src/test/run-make-fulldeps/used/used.rs create mode 100644 src/test/run-make-fulldeps/version/Makefile create mode 100644 src/test/run-make-fulldeps/volatile-intrinsics/Makefile create mode 100644 src/test/run-make-fulldeps/volatile-intrinsics/main.rs create mode 100644 src/test/run-make-fulldeps/weird-output-filenames/Makefile create mode 100644 src/test/run-make-fulldeps/weird-output-filenames/foo.rs create mode 100644 src/test/run-make-fulldeps/windows-spawn/Makefile create mode 100644 src/test/run-make-fulldeps/windows-spawn/hello.rs create mode 100644 src/test/run-make-fulldeps/windows-spawn/spawn.rs create mode 100644 src/test/run-make-fulldeps/windows-subsystem/Makefile create mode 100644 src/test/run-make-fulldeps/windows-subsystem/console.rs create mode 100644 src/test/run-make-fulldeps/windows-subsystem/windows.rs delete mode 100644 src/test/run-make/a-b-a-linker-guard/Makefile delete mode 100644 src/test/run-make/a-b-a-linker-guard/a.rs delete mode 100644 src/test/run-make/a-b-a-linker-guard/b.rs delete mode 100644 src/test/run-make/alloc-extern-crates/Makefile delete mode 100644 src/test/run-make/alloc-extern-crates/fakealloc.rs delete mode 100644 src/test/run-make/allow-non-lint-warnings-cmdline/Makefile delete mode 100644 src/test/run-make/allow-non-lint-warnings-cmdline/foo.rs delete mode 100644 src/test/run-make/allow-warnings-cmdline-stability/Makefile delete mode 100644 src/test/run-make/allow-warnings-cmdline-stability/bar.rs delete mode 100644 src/test/run-make/allow-warnings-cmdline-stability/foo.rs delete mode 100644 src/test/run-make/archive-duplicate-names/Makefile delete mode 100644 src/test/run-make/archive-duplicate-names/bar.c delete mode 100644 src/test/run-make/archive-duplicate-names/bar.rs delete mode 100644 src/test/run-make/archive-duplicate-names/foo.c delete mode 100644 src/test/run-make/archive-duplicate-names/foo.rs delete mode 100644 src/test/run-make/atomic-lock-free/Makefile delete mode 100644 src/test/run-make/atomic-lock-free/atomic_lock_free.rs delete mode 100644 src/test/run-make/bare-outfile/Makefile delete mode 100644 src/test/run-make/bare-outfile/foo.rs delete mode 100644 src/test/run-make/c-dynamic-dylib/Makefile delete mode 100644 src/test/run-make/c-dynamic-dylib/bar.rs delete mode 100644 src/test/run-make/c-dynamic-dylib/cfoo.c delete mode 100644 src/test/run-make/c-dynamic-dylib/foo.rs delete mode 100644 src/test/run-make/c-dynamic-rlib/Makefile delete mode 100644 src/test/run-make/c-dynamic-rlib/bar.rs delete mode 100644 src/test/run-make/c-dynamic-rlib/cfoo.c delete mode 100644 src/test/run-make/c-dynamic-rlib/foo.rs delete mode 100644 src/test/run-make/c-link-to-rust-dylib/Makefile delete mode 100644 src/test/run-make/c-link-to-rust-dylib/bar.c delete mode 100644 src/test/run-make/c-link-to-rust-dylib/foo.rs delete mode 100644 src/test/run-make/c-link-to-rust-staticlib/Makefile delete mode 100644 src/test/run-make/c-link-to-rust-staticlib/bar.c delete mode 100644 src/test/run-make/c-link-to-rust-staticlib/foo.rs delete mode 100644 src/test/run-make/c-static-dylib/Makefile delete mode 100644 src/test/run-make/c-static-dylib/bar.rs delete mode 100644 src/test/run-make/c-static-dylib/cfoo.c delete mode 100644 src/test/run-make/c-static-dylib/foo.rs delete mode 100644 src/test/run-make/c-static-rlib/Makefile delete mode 100644 src/test/run-make/c-static-rlib/bar.rs delete mode 100644 src/test/run-make/c-static-rlib/cfoo.c delete mode 100644 src/test/run-make/c-static-rlib/foo.rs delete mode 100644 src/test/run-make/cat-and-grep-sanity-check/Makefile delete mode 100644 src/test/run-make/cdylib-fewer-symbols/Makefile delete mode 100644 src/test/run-make/cdylib-fewer-symbols/foo.rs delete mode 100644 src/test/run-make/cdylib/Makefile delete mode 100644 src/test/run-make/cdylib/bar.rs delete mode 100644 src/test/run-make/cdylib/foo.c delete mode 100644 src/test/run-make/cdylib/foo.rs delete mode 100644 src/test/run-make/codegen-options-parsing/Makefile delete mode 100644 src/test/run-make/codegen-options-parsing/dummy.rs delete mode 100644 src/test/run-make/compile-stdin/Makefile delete mode 100644 src/test/run-make/compiler-lookup-paths-2/Makefile delete mode 100644 src/test/run-make/compiler-lookup-paths-2/a.rs delete mode 100644 src/test/run-make/compiler-lookup-paths-2/b.rs delete mode 100644 src/test/run-make/compiler-lookup-paths-2/c.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/Makefile delete mode 100644 src/test/run-make/compiler-lookup-paths/a.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/b.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/c.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/d.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/e.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/e2.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/f.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/native.c delete mode 100644 src/test/run-make/compiler-rt-works-on-mingw/Makefile delete mode 100644 src/test/run-make/compiler-rt-works-on-mingw/foo.cpp delete mode 100644 src/test/run-make/compiler-rt-works-on-mingw/foo.rs delete mode 100644 src/test/run-make/crate-data-smoke/Makefile delete mode 100644 src/test/run-make/crate-data-smoke/crate.rs delete mode 100644 src/test/run-make/crate-data-smoke/lib.rs delete mode 100644 src/test/run-make/crate-data-smoke/rlib.rs delete mode 100644 src/test/run-make/crate-name-priority/Makefile delete mode 100644 src/test/run-make/crate-name-priority/foo.rs delete mode 100644 src/test/run-make/crate-name-priority/foo1.rs delete mode 100644 src/test/run-make/debug-assertions/Makefile delete mode 100644 src/test/run-make/debug-assertions/debug.rs delete mode 100644 src/test/run-make/dep-info-doesnt-run-much/Makefile delete mode 100644 src/test/run-make/dep-info-doesnt-run-much/foo.rs delete mode 100644 src/test/run-make/dep-info-spaces/Makefile delete mode 100644 src/test/run-make/dep-info-spaces/Makefile.foo delete mode 100644 src/test/run-make/dep-info-spaces/bar.rs delete mode 100644 src/test/run-make/dep-info-spaces/foo foo.rs delete mode 100644 src/test/run-make/dep-info-spaces/lib.rs delete mode 100644 src/test/run-make/dep-info/Makefile delete mode 100644 src/test/run-make/dep-info/Makefile.foo delete mode 100644 src/test/run-make/dep-info/bar.rs delete mode 100644 src/test/run-make/dep-info/foo.rs delete mode 100644 src/test/run-make/dep-info/lib.rs delete mode 100644 src/test/run-make/dep-info/lib2.rs delete mode 100644 src/test/run-make/duplicate-output-flavors/Makefile delete mode 100644 src/test/run-make/duplicate-output-flavors/foo.rs delete mode 100644 src/test/run-make/dylib-chain/Makefile delete mode 100644 src/test/run-make/dylib-chain/m1.rs delete mode 100644 src/test/run-make/dylib-chain/m2.rs delete mode 100644 src/test/run-make/dylib-chain/m3.rs delete mode 100644 src/test/run-make/dylib-chain/m4.rs delete mode 100644 src/test/run-make/emit/Makefile delete mode 100644 src/test/run-make/emit/test-24876.rs delete mode 100644 src/test/run-make/emit/test-26235.rs delete mode 100644 src/test/run-make/error-found-staticlib-instead-crate/Makefile delete mode 100644 src/test/run-make/error-found-staticlib-instead-crate/bar.rs delete mode 100644 src/test/run-make/error-found-staticlib-instead-crate/foo.rs delete mode 100644 src/test/run-make/error-writing-dependencies/Makefile delete mode 100644 src/test/run-make/error-writing-dependencies/foo.rs delete mode 100644 src/test/run-make/extern-diff-internal-name/Makefile delete mode 100644 src/test/run-make/extern-diff-internal-name/lib.rs delete mode 100644 src/test/run-make/extern-diff-internal-name/test.rs delete mode 100644 src/test/run-make/extern-flag-disambiguates/Makefile delete mode 100644 src/test/run-make/extern-flag-disambiguates/a.rs delete mode 100644 src/test/run-make/extern-flag-disambiguates/b.rs delete mode 100644 src/test/run-make/extern-flag-disambiguates/c.rs delete mode 100644 src/test/run-make/extern-flag-disambiguates/d.rs delete mode 100644 src/test/run-make/extern-flag-fun/Makefile delete mode 100644 src/test/run-make/extern-flag-fun/bar-alt.rs delete mode 100644 src/test/run-make/extern-flag-fun/bar.rs delete mode 100644 src/test/run-make/extern-flag-fun/foo.rs delete mode 100644 src/test/run-make/extern-fn-generic/Makefile delete mode 100644 src/test/run-make/extern-fn-generic/test.c delete mode 100644 src/test/run-make/extern-fn-generic/test.rs delete mode 100644 src/test/run-make/extern-fn-generic/testcrate.rs delete mode 100644 src/test/run-make/extern-fn-mangle/Makefile delete mode 100644 src/test/run-make/extern-fn-mangle/test.c delete mode 100644 src/test/run-make/extern-fn-mangle/test.rs delete mode 100644 src/test/run-make/extern-fn-reachable/Makefile delete mode 100644 src/test/run-make/extern-fn-reachable/dylib.rs delete mode 100644 src/test/run-make/extern-fn-reachable/main.rs delete mode 100644 src/test/run-make/extern-fn-struct-passing-abi/Makefile delete mode 100644 src/test/run-make/extern-fn-struct-passing-abi/test.c delete mode 100644 src/test/run-make/extern-fn-struct-passing-abi/test.rs delete mode 100644 src/test/run-make/extern-fn-with-extern-types/Makefile delete mode 100644 src/test/run-make/extern-fn-with-extern-types/ctest.c delete mode 100644 src/test/run-make/extern-fn-with-extern-types/test.rs delete mode 100644 src/test/run-make/extern-fn-with-packed-struct/Makefile delete mode 100644 src/test/run-make/extern-fn-with-packed-struct/test.c delete mode 100644 src/test/run-make/extern-fn-with-packed-struct/test.rs delete mode 100644 src/test/run-make/extern-fn-with-union/Makefile delete mode 100644 src/test/run-make/extern-fn-with-union/ctest.c delete mode 100644 src/test/run-make/extern-fn-with-union/test.rs delete mode 100644 src/test/run-make/extern-fn-with-union/testcrate.rs delete mode 100644 src/test/run-make/extern-multiple-copies/Makefile delete mode 100644 src/test/run-make/extern-multiple-copies/bar.rs delete mode 100644 src/test/run-make/extern-multiple-copies/foo1.rs delete mode 100644 src/test/run-make/extern-multiple-copies/foo2.rs delete mode 100644 src/test/run-make/extern-multiple-copies2/Makefile delete mode 100644 src/test/run-make/extern-multiple-copies2/bar.rs delete mode 100644 src/test/run-make/extern-multiple-copies2/foo1.rs delete mode 100644 src/test/run-make/extern-multiple-copies2/foo2.rs delete mode 100644 src/test/run-make/extern-overrides-distribution/Makefile delete mode 100644 src/test/run-make/extern-overrides-distribution/libc.rs delete mode 100644 src/test/run-make/extern-overrides-distribution/main.rs delete mode 100644 src/test/run-make/extra-filename-with-temp-outputs/Makefile delete mode 100644 src/test/run-make/extra-filename-with-temp-outputs/foo.rs delete mode 100644 src/test/run-make/fpic/Makefile delete mode 100644 src/test/run-make/fpic/hello.rs delete mode 100644 src/test/run-make/hir-tree/Makefile delete mode 100644 src/test/run-make/hir-tree/input.rs delete mode 100644 src/test/run-make/hotplug_codegen_backend/Makefile delete mode 100644 src/test/run-make/hotplug_codegen_backend/some_crate.rs delete mode 100644 src/test/run-make/hotplug_codegen_backend/the_backend.rs delete mode 100644 src/test/run-make/include_bytes_deps/Makefile delete mode 100644 src/test/run-make/include_bytes_deps/input.bin delete mode 100644 src/test/run-make/include_bytes_deps/input.md delete mode 100644 src/test/run-make/include_bytes_deps/input.txt delete mode 100644 src/test/run-make/include_bytes_deps/main.rs delete mode 100644 src/test/run-make/inline-always-many-cgu/Makefile delete mode 100644 src/test/run-make/inline-always-many-cgu/foo.rs delete mode 100644 src/test/run-make/interdependent-c-libraries/Makefile delete mode 100644 src/test/run-make/interdependent-c-libraries/bar.c delete mode 100644 src/test/run-make/interdependent-c-libraries/bar.rs delete mode 100644 src/test/run-make/interdependent-c-libraries/foo.c delete mode 100644 src/test/run-make/interdependent-c-libraries/foo.rs delete mode 100644 src/test/run-make/interdependent-c-libraries/main.rs delete mode 100644 src/test/run-make/intrinsic-unreachable/Makefile delete mode 100644 src/test/run-make/intrinsic-unreachable/exit-ret.rs delete mode 100644 src/test/run-make/intrinsic-unreachable/exit-unreachable.rs delete mode 100644 src/test/run-make/invalid-library/Makefile delete mode 100644 src/test/run-make/invalid-library/foo.rs delete mode 100644 src/test/run-make/invalid-staticlib/Makefile delete mode 100644 src/test/run-make/issue-11908/Makefile delete mode 100644 src/test/run-make/issue-11908/bar.rs delete mode 100644 src/test/run-make/issue-11908/foo.rs delete mode 100644 src/test/run-make/issue-14500/Makefile delete mode 100644 src/test/run-make/issue-14500/bar.rs delete mode 100644 src/test/run-make/issue-14500/foo.c delete mode 100644 src/test/run-make/issue-14500/foo.rs delete mode 100644 src/test/run-make/issue-14698/Makefile delete mode 100644 src/test/run-make/issue-14698/foo.rs delete mode 100644 src/test/run-make/issue-15460/Makefile delete mode 100644 src/test/run-make/issue-15460/bar.rs delete mode 100644 src/test/run-make/issue-15460/foo.c delete mode 100644 src/test/run-make/issue-15460/foo.rs delete mode 100644 src/test/run-make/issue-18943/Makefile delete mode 100644 src/test/run-make/issue-18943/foo.rs delete mode 100644 src/test/run-make/issue-19371/Makefile delete mode 100644 src/test/run-make/issue-19371/foo.rs delete mode 100644 src/test/run-make/issue-20626/Makefile delete mode 100644 src/test/run-make/issue-20626/foo.rs delete mode 100644 src/test/run-make/issue-22131/Makefile delete mode 100644 src/test/run-make/issue-22131/foo.rs delete mode 100644 src/test/run-make/issue-24445/Makefile delete mode 100644 src/test/run-make/issue-24445/foo.c delete mode 100644 src/test/run-make/issue-24445/foo.rs delete mode 100644 src/test/run-make/issue-25581/Makefile delete mode 100644 src/test/run-make/issue-25581/test.c delete mode 100644 src/test/run-make/issue-25581/test.rs delete mode 100644 src/test/run-make/issue-26006/Makefile delete mode 100644 src/test/run-make/issue-26006/in/libc/lib.rs delete mode 100644 src/test/run-make/issue-26006/in/time/lib.rs delete mode 100644 src/test/run-make/issue-26092/Makefile delete mode 100644 src/test/run-make/issue-26092/blank.rs delete mode 100644 src/test/run-make/issue-28595/Makefile delete mode 100644 src/test/run-make/issue-28595/a.c delete mode 100644 src/test/run-make/issue-28595/a.rs delete mode 100644 src/test/run-make/issue-28595/b.c delete mode 100644 src/test/run-make/issue-28595/b.rs delete mode 100644 src/test/run-make/issue-28766/Makefile delete mode 100644 src/test/run-make/issue-28766/foo.rs delete mode 100644 src/test/run-make/issue-28766/main.rs delete mode 100644 src/test/run-make/issue-30063/Makefile delete mode 100644 src/test/run-make/issue-30063/foo.rs delete mode 100644 src/test/run-make/issue-33329/Makefile delete mode 100644 src/test/run-make/issue-33329/main.rs delete mode 100644 src/test/run-make/issue-35164/Makefile delete mode 100644 src/test/run-make/issue-35164/main.rs delete mode 100644 src/test/run-make/issue-35164/submodule/mod.rs delete mode 100644 src/test/run-make/issue-37839/Makefile delete mode 100644 src/test/run-make/issue-37839/a.rs delete mode 100644 src/test/run-make/issue-37839/b.rs delete mode 100644 src/test/run-make/issue-37839/c.rs delete mode 100644 src/test/run-make/issue-37893/Makefile delete mode 100644 src/test/run-make/issue-37893/a.rs delete mode 100644 src/test/run-make/issue-37893/b.rs delete mode 100644 src/test/run-make/issue-37893/c.rs delete mode 100644 src/test/run-make/issue-38237/Makefile delete mode 100644 src/test/run-make/issue-38237/bar.rs delete mode 100644 src/test/run-make/issue-38237/baz.rs delete mode 100644 src/test/run-make/issue-38237/foo.rs delete mode 100644 src/test/run-make/issue-40535/Makefile delete mode 100644 src/test/run-make/issue-40535/bar.rs delete mode 100644 src/test/run-make/issue-40535/baz.rs delete mode 100644 src/test/run-make/issue-40535/foo.rs delete mode 100644 src/test/run-make/issue-46239/Makefile delete mode 100644 src/test/run-make/issue-46239/main.rs delete mode 100644 src/test/run-make/issue-7349/Makefile delete mode 100644 src/test/run-make/issue-7349/foo.rs delete mode 100644 src/test/run-make/issues-41478-43796/Makefile delete mode 100644 src/test/run-make/issues-41478-43796/a.rs delete mode 100644 src/test/run-make/libs-and-bins/Makefile delete mode 100644 src/test/run-make/libs-and-bins/foo.rs delete mode 100644 src/test/run-make/libs-through-symlinks/Makefile delete mode 100644 src/test/run-make/libs-through-symlinks/bar.rs delete mode 100644 src/test/run-make/libs-through-symlinks/foo.rs delete mode 100644 src/test/run-make/libtest-json/Makefile delete mode 100644 src/test/run-make/libtest-json/f.rs delete mode 100644 src/test/run-make/libtest-json/output.json delete mode 100755 src/test/run-make/libtest-json/validate_json.py delete mode 100644 src/test/run-make/link-arg/Makefile delete mode 100644 src/test/run-make/link-arg/empty.rs delete mode 100644 src/test/run-make/link-cfg/Makefile delete mode 100644 src/test/run-make/link-cfg/dep-with-staticlib.rs delete mode 100644 src/test/run-make/link-cfg/dep.rs delete mode 100644 src/test/run-make/link-cfg/no-deps.rs delete mode 100644 src/test/run-make/link-cfg/return1.c delete mode 100644 src/test/run-make/link-cfg/return2.c delete mode 100644 src/test/run-make/link-cfg/return3.c delete mode 100644 src/test/run-make/link-cfg/with-deps.rs delete mode 100644 src/test/run-make/link-cfg/with-staticlib-deps.rs delete mode 100644 src/test/run-make/link-path-order/Makefile delete mode 100644 src/test/run-make/link-path-order/correct.c delete mode 100644 src/test/run-make/link-path-order/main.rs delete mode 100644 src/test/run-make/link-path-order/wrong.c delete mode 100644 src/test/run-make/linkage-attr-on-static/Makefile delete mode 100644 src/test/run-make/linkage-attr-on-static/bar.rs delete mode 100644 src/test/run-make/linkage-attr-on-static/foo.c delete mode 100644 src/test/run-make/linker-output-non-utf8/Makefile delete mode 100644 src/test/run-make/linker-output-non-utf8/exec.rs delete mode 100644 src/test/run-make/linker-output-non-utf8/library.rs delete mode 100644 src/test/run-make/llvm-pass/Makefile delete mode 100644 src/test/run-make/llvm-pass/llvm-function-pass.so.cc delete mode 100644 src/test/run-make/llvm-pass/llvm-module-pass.so.cc delete mode 100644 src/test/run-make/llvm-pass/main.rs delete mode 100644 src/test/run-make/llvm-pass/plugin.rs delete mode 100644 src/test/run-make/long-linker-command-lines-cmd-exe/Makefile delete mode 100644 src/test/run-make/long-linker-command-lines-cmd-exe/foo.bat delete mode 100644 src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs delete mode 100644 src/test/run-make/long-linker-command-lines/Makefile delete mode 100644 src/test/run-make/long-linker-command-lines/foo.rs delete mode 100644 src/test/run-make/longjmp-across-rust/Makefile delete mode 100644 src/test/run-make/longjmp-across-rust/foo.c delete mode 100644 src/test/run-make/longjmp-across-rust/main.rs delete mode 100644 src/test/run-make/ls-metadata/Makefile delete mode 100644 src/test/run-make/ls-metadata/foo.rs delete mode 100644 src/test/run-make/lto-no-link-whole-rlib/Makefile delete mode 100644 src/test/run-make/lto-no-link-whole-rlib/bar.c delete mode 100644 src/test/run-make/lto-no-link-whole-rlib/foo.c delete mode 100644 src/test/run-make/lto-no-link-whole-rlib/lib1.rs delete mode 100644 src/test/run-make/lto-no-link-whole-rlib/lib2.rs delete mode 100644 src/test/run-make/lto-no-link-whole-rlib/main.rs delete mode 100644 src/test/run-make/lto-readonly-lib/Makefile delete mode 100644 src/test/run-make/lto-readonly-lib/lib.rs delete mode 100644 src/test/run-make/lto-readonly-lib/main.rs delete mode 100644 src/test/run-make/lto-smoke-c/Makefile delete mode 100644 src/test/run-make/lto-smoke-c/bar.c delete mode 100644 src/test/run-make/lto-smoke-c/foo.rs delete mode 100644 src/test/run-make/lto-smoke/Makefile delete mode 100644 src/test/run-make/lto-smoke/lib.rs delete mode 100644 src/test/run-make/lto-smoke/main.rs delete mode 100644 src/test/run-make/manual-crate-name/Makefile delete mode 100644 src/test/run-make/manual-crate-name/bar.rs delete mode 100644 src/test/run-make/manual-link/Makefile delete mode 100644 src/test/run-make/manual-link/bar.c delete mode 100644 src/test/run-make/manual-link/foo.c delete mode 100644 src/test/run-make/manual-link/foo.rs delete mode 100644 src/test/run-make/manual-link/main.rs delete mode 100644 src/test/run-make/many-crates-but-no-match/Makefile delete mode 100644 src/test/run-make/many-crates-but-no-match/crateA1.rs delete mode 100644 src/test/run-make/many-crates-but-no-match/crateA2.rs delete mode 100644 src/test/run-make/many-crates-but-no-match/crateA3.rs delete mode 100644 src/test/run-make/many-crates-but-no-match/crateB.rs delete mode 100644 src/test/run-make/many-crates-but-no-match/crateC.rs delete mode 100644 src/test/run-make/metadata-flag-frobs-symbols/Makefile delete mode 100644 src/test/run-make/metadata-flag-frobs-symbols/bar.rs delete mode 100644 src/test/run-make/metadata-flag-frobs-symbols/foo.rs delete mode 100644 src/test/run-make/min-global-align/Makefile delete mode 100644 src/test/run-make/min-global-align/min_global_align.rs delete mode 100644 src/test/run-make/mismatching-target-triples/Makefile delete mode 100644 src/test/run-make/mismatching-target-triples/bar.rs delete mode 100644 src/test/run-make/mismatching-target-triples/foo.rs delete mode 100644 src/test/run-make/missing-crate-dependency/Makefile delete mode 100644 src/test/run-make/missing-crate-dependency/crateA.rs delete mode 100644 src/test/run-make/missing-crate-dependency/crateB.rs delete mode 100644 src/test/run-make/missing-crate-dependency/crateC.rs delete mode 100644 src/test/run-make/mixing-deps/Makefile delete mode 100644 src/test/run-make/mixing-deps/both.rs delete mode 100644 src/test/run-make/mixing-deps/dylib.rs delete mode 100644 src/test/run-make/mixing-deps/prog.rs delete mode 100644 src/test/run-make/mixing-formats/Makefile delete mode 100644 src/test/run-make/mixing-formats/bar1.rs delete mode 100644 src/test/run-make/mixing-formats/bar2.rs delete mode 100644 src/test/run-make/mixing-formats/baz.rs delete mode 100644 src/test/run-make/mixing-formats/baz2.rs delete mode 100644 src/test/run-make/mixing-formats/foo.rs delete mode 100644 src/test/run-make/mixing-libs/Makefile delete mode 100644 src/test/run-make/mixing-libs/dylib.rs delete mode 100644 src/test/run-make/mixing-libs/prog.rs delete mode 100644 src/test/run-make/mixing-libs/rlib.rs delete mode 100644 src/test/run-make/msvc-opt-minsize/Makefile delete mode 100644 src/test/run-make/msvc-opt-minsize/foo.rs delete mode 100644 src/test/run-make/multiple-emits/Makefile delete mode 100644 src/test/run-make/multiple-emits/foo.rs delete mode 100644 src/test/run-make/no-builtins-lto/Makefile delete mode 100644 src/test/run-make/no-builtins-lto/main.rs delete mode 100644 src/test/run-make/no-builtins-lto/no_builtins.rs delete mode 100644 src/test/run-make/no-duplicate-libs/Makefile delete mode 100644 src/test/run-make/no-duplicate-libs/bar.c delete mode 100644 src/test/run-make/no-duplicate-libs/foo.c delete mode 100644 src/test/run-make/no-duplicate-libs/main.rs delete mode 100644 src/test/run-make/no-integrated-as/Makefile delete mode 100644 src/test/run-make/no-integrated-as/hello.rs delete mode 100644 src/test/run-make/no-intermediate-extras/Makefile delete mode 100644 src/test/run-make/no-intermediate-extras/foo.rs delete mode 100644 src/test/run-make/obey-crate-type-flag/Makefile delete mode 100644 src/test/run-make/obey-crate-type-flag/test.rs delete mode 100644 src/test/run-make/output-filename-conflicts-with-directory/Makefile delete mode 100644 src/test/run-make/output-filename-conflicts-with-directory/foo.rs delete mode 100644 src/test/run-make/output-filename-overwrites-input/Makefile delete mode 100644 src/test/run-make/output-filename-overwrites-input/bar.rs delete mode 100644 src/test/run-make/output-filename-overwrites-input/foo.rs delete mode 100644 src/test/run-make/output-type-permutations/Makefile delete mode 100644 src/test/run-make/output-type-permutations/foo.rs delete mode 100644 src/test/run-make/output-with-hyphens/Makefile delete mode 100644 src/test/run-make/output-with-hyphens/foo-bar.rs delete mode 100644 src/test/run-make/prefer-dylib/Makefile delete mode 100644 src/test/run-make/prefer-dylib/bar.rs delete mode 100644 src/test/run-make/prefer-dylib/foo.rs delete mode 100644 src/test/run-make/prefer-rlib/Makefile delete mode 100644 src/test/run-make/prefer-rlib/bar.rs delete mode 100644 src/test/run-make/prefer-rlib/foo.rs delete mode 100644 src/test/run-make/pretty-expanded-hygiene/Makefile delete mode 100644 src/test/run-make/pretty-expanded-hygiene/input.pp.rs delete mode 100644 src/test/run-make/pretty-expanded-hygiene/input.rs delete mode 100644 src/test/run-make/pretty-expanded/Makefile delete mode 100644 src/test/run-make/pretty-expanded/input.rs delete mode 100644 src/test/run-make/pretty-print-path-suffix/Makefile delete mode 100644 src/test/run-make/pretty-print-path-suffix/foo.pp delete mode 100644 src/test/run-make/pretty-print-path-suffix/foo_method.pp delete mode 100644 src/test/run-make/pretty-print-path-suffix/input.rs delete mode 100644 src/test/run-make/pretty-print-path-suffix/nest_foo.pp delete mode 100644 src/test/run-make/pretty-print-to-file/Makefile delete mode 100644 src/test/run-make/pretty-print-to-file/input.pp delete mode 100644 src/test/run-make/pretty-print-to-file/input.rs delete mode 100644 src/test/run-make/print-cfg/Makefile delete mode 100644 src/test/run-make/print-target-list/Makefile delete mode 100644 src/test/run-make/profile/Makefile delete mode 100644 src/test/run-make/profile/test.rs delete mode 100644 src/test/run-make/prune-link-args/Makefile delete mode 100644 src/test/run-make/prune-link-args/empty.rs delete mode 100644 src/test/run-make/relocation-model/Makefile delete mode 100644 src/test/run-make/relocation-model/foo.rs delete mode 100644 src/test/run-make/relro-levels/Makefile delete mode 100644 src/test/run-make/relro-levels/hello.rs delete mode 100644 src/test/run-make/reproducible-build/Makefile delete mode 100644 src/test/run-make/reproducible-build/linker.rs delete mode 100644 src/test/run-make/reproducible-build/reproducible-build-aux.rs delete mode 100644 src/test/run-make/reproducible-build/reproducible-build.rs delete mode 100644 src/test/run-make/rlib-chain/Makefile delete mode 100644 src/test/run-make/rlib-chain/m1.rs delete mode 100644 src/test/run-make/rlib-chain/m2.rs delete mode 100644 src/test/run-make/rlib-chain/m3.rs delete mode 100644 src/test/run-make/rlib-chain/m4.rs delete mode 100644 src/test/run-make/rustc-macro-dep-files/Makefile delete mode 100644 src/test/run-make/rustc-macro-dep-files/bar.rs delete mode 100644 src/test/run-make/rustc-macro-dep-files/foo.rs delete mode 100644 src/test/run-make/rustdoc-error-lines/Makefile delete mode 100644 src/test/run-make/rustdoc-error-lines/input.rs delete mode 100644 src/test/run-make/rustdoc-output-path/Makefile delete mode 100644 src/test/run-make/rustdoc-output-path/foo.rs delete mode 100644 src/test/run-make/sanitizer-address/Makefile delete mode 100644 src/test/run-make/sanitizer-address/overflow.rs delete mode 100644 src/test/run-make/sanitizer-cdylib-link/Makefile delete mode 100644 src/test/run-make/sanitizer-cdylib-link/library.rs delete mode 100644 src/test/run-make/sanitizer-cdylib-link/program.rs delete mode 100644 src/test/run-make/sanitizer-dylib-link/Makefile delete mode 100644 src/test/run-make/sanitizer-dylib-link/library.rs delete mode 100644 src/test/run-make/sanitizer-dylib-link/program.rs delete mode 100644 src/test/run-make/sanitizer-invalid-cratetype/Makefile delete mode 100644 src/test/run-make/sanitizer-invalid-cratetype/hello.rs delete mode 100644 src/test/run-make/sanitizer-invalid-target/Makefile delete mode 100644 src/test/run-make/sanitizer-invalid-target/hello.rs delete mode 100644 src/test/run-make/sanitizer-leak/Makefile delete mode 100644 src/test/run-make/sanitizer-leak/leak.rs delete mode 100644 src/test/run-make/sanitizer-memory/Makefile delete mode 100644 src/test/run-make/sanitizer-memory/uninit.rs delete mode 100644 src/test/run-make/sanitizer-staticlib-link/Makefile delete mode 100644 src/test/run-make/sanitizer-staticlib-link/library.rs delete mode 100644 src/test/run-make/sanitizer-staticlib-link/program.c delete mode 100644 src/test/run-make/save-analysis-fail/Makefile delete mode 100644 src/test/run-make/save-analysis-fail/SameDir.rs delete mode 100644 src/test/run-make/save-analysis-fail/SameDir3.rs delete mode 100644 src/test/run-make/save-analysis-fail/SubDir/mod.rs delete mode 100644 src/test/run-make/save-analysis-fail/foo.rs delete mode 100644 src/test/run-make/save-analysis-fail/krate2.rs delete mode 100644 src/test/run-make/save-analysis/Makefile delete mode 100644 src/test/run-make/save-analysis/SameDir.rs delete mode 100644 src/test/run-make/save-analysis/SameDir3.rs delete mode 100644 src/test/run-make/save-analysis/SubDir/mod.rs delete mode 100644 src/test/run-make/save-analysis/extra-docs.md delete mode 100644 src/test/run-make/save-analysis/foo.rs delete mode 100644 src/test/run-make/save-analysis/krate2.rs delete mode 100644 src/test/run-make/sepcomp-cci-copies/Makefile delete mode 100644 src/test/run-make/sepcomp-cci-copies/cci_lib.rs delete mode 100644 src/test/run-make/sepcomp-cci-copies/foo.rs delete mode 100644 src/test/run-make/sepcomp-inlining/Makefile delete mode 100644 src/test/run-make/sepcomp-inlining/foo.rs delete mode 100644 src/test/run-make/sepcomp-separate/Makefile delete mode 100644 src/test/run-make/sepcomp-separate/foo.rs delete mode 100644 src/test/run-make/simd-ffi/Makefile delete mode 100644 src/test/run-make/simd-ffi/simd.rs delete mode 100644 src/test/run-make/simple-dylib/Makefile delete mode 100644 src/test/run-make/simple-dylib/bar.rs delete mode 100644 src/test/run-make/simple-dylib/foo.rs delete mode 100644 src/test/run-make/simple-rlib/Makefile delete mode 100644 src/test/run-make/simple-rlib/bar.rs delete mode 100644 src/test/run-make/simple-rlib/foo.rs delete mode 100644 src/test/run-make/stable-symbol-names/Makefile delete mode 100644 src/test/run-make/stable-symbol-names/stable-symbol-names1.rs delete mode 100644 src/test/run-make/stable-symbol-names/stable-symbol-names2.rs delete mode 100644 src/test/run-make/static-dylib-by-default/Makefile delete mode 100644 src/test/run-make/static-dylib-by-default/bar.rs delete mode 100644 src/test/run-make/static-dylib-by-default/foo.rs delete mode 100644 src/test/run-make/static-dylib-by-default/main.c delete mode 100644 src/test/run-make/static-nobundle/Makefile delete mode 100644 src/test/run-make/static-nobundle/aaa.c delete mode 100644 src/test/run-make/static-nobundle/bbb.rs delete mode 100644 src/test/run-make/static-nobundle/ccc.rs delete mode 100644 src/test/run-make/static-nobundle/ddd.rs delete mode 100644 src/test/run-make/static-unwinding/Makefile delete mode 100644 src/test/run-make/static-unwinding/lib.rs delete mode 100644 src/test/run-make/static-unwinding/main.rs delete mode 100644 src/test/run-make/staticlib-blank-lib/Makefile delete mode 100644 src/test/run-make/staticlib-blank-lib/foo.rs delete mode 100644 src/test/run-make/stdin-non-utf8/Makefile delete mode 100644 src/test/run-make/stdin-non-utf8/non-utf8 delete mode 100644 src/test/run-make/suspicious-library/Makefile delete mode 100644 src/test/run-make/suspicious-library/bar.rs delete mode 100644 src/test/run-make/suspicious-library/foo.rs delete mode 100644 src/test/run-make/symbol-visibility/Makefile delete mode 100644 src/test/run-make/symbol-visibility/a_cdylib.rs delete mode 100644 src/test/run-make/symbol-visibility/a_rust_dylib.rs delete mode 100644 src/test/run-make/symbol-visibility/an_executable.rs delete mode 100644 src/test/run-make/symbol-visibility/an_rlib.rs delete mode 100644 src/test/run-make/symbols-are-reasonable/Makefile delete mode 100644 src/test/run-make/symbols-are-reasonable/lib.rs delete mode 100644 src/test/run-make/symbols-include-type-name/Makefile delete mode 100644 src/test/run-make/symbols-include-type-name/lib.rs delete mode 100644 src/test/run-make/symlinked-extern/Makefile delete mode 100644 src/test/run-make/symlinked-extern/bar.rs delete mode 100644 src/test/run-make/symlinked-extern/baz.rs delete mode 100644 src/test/run-make/symlinked-extern/foo.rs delete mode 100644 src/test/run-make/symlinked-libraries/Makefile delete mode 100644 src/test/run-make/symlinked-libraries/bar.rs delete mode 100644 src/test/run-make/symlinked-libraries/foo.rs delete mode 100644 src/test/run-make/symlinked-rlib/Makefile delete mode 100644 src/test/run-make/symlinked-rlib/bar.rs delete mode 100644 src/test/run-make/symlinked-rlib/foo.rs delete mode 100644 src/test/run-make/sysroot-crates-are-unstable/Makefile delete mode 100644 src/test/run-make/sysroot-crates-are-unstable/test.py delete mode 100644 src/test/run-make/target-cpu-native/Makefile delete mode 100644 src/test/run-make/target-cpu-native/foo.rs delete mode 100644 src/test/run-make/target-specs/Makefile delete mode 100644 src/test/run-make/target-specs/foo.rs delete mode 100644 src/test/run-make/target-specs/my-awesome-platform.json delete mode 100644 src/test/run-make/target-specs/my-incomplete-platform.json delete mode 100644 src/test/run-make/target-specs/my-invalid-platform.json delete mode 100644 src/test/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json delete mode 100644 src/test/run-make/target-without-atomics/Makefile delete mode 100644 src/test/run-make/test-harness/Makefile delete mode 100644 src/test/run-make/test-harness/test-ignore-cfg.rs delete mode 100644 src/test/run-make/tools.mk delete mode 100644 src/test/run-make/treat-err-as-bug/Makefile delete mode 100644 src/test/run-make/treat-err-as-bug/err.rs delete mode 100644 src/test/run-make/type-mismatch-same-crate-name/Makefile delete mode 100644 src/test/run-make/type-mismatch-same-crate-name/crateA.rs delete mode 100644 src/test/run-make/type-mismatch-same-crate-name/crateB.rs delete mode 100644 src/test/run-make/type-mismatch-same-crate-name/crateC.rs delete mode 100644 src/test/run-make/use-extern-for-plugins/Makefile delete mode 100644 src/test/run-make/use-extern-for-plugins/bar.rs delete mode 100644 src/test/run-make/use-extern-for-plugins/baz.rs delete mode 100644 src/test/run-make/use-extern-for-plugins/foo.rs delete mode 100644 src/test/run-make/used/Makefile delete mode 100644 src/test/run-make/used/used.rs delete mode 100644 src/test/run-make/version/Makefile delete mode 100644 src/test/run-make/volatile-intrinsics/Makefile delete mode 100644 src/test/run-make/volatile-intrinsics/main.rs create mode 100644 src/test/run-make/wasm-custom-section/Makefile create mode 100644 src/test/run-make/wasm-custom-section/bar.rs create mode 100644 src/test/run-make/wasm-custom-section/foo.js create mode 100644 src/test/run-make/wasm-custom-section/foo.rs delete mode 100644 src/test/run-make/weird-output-filenames/Makefile delete mode 100644 src/test/run-make/weird-output-filenames/foo.rs delete mode 100644 src/test/run-make/windows-spawn/Makefile delete mode 100644 src/test/run-make/windows-spawn/hello.rs delete mode 100644 src/test/run-make/windows-spawn/spawn.rs delete mode 100644 src/test/run-make/windows-subsystem/Makefile delete mode 100644 src/test/run-make/windows-subsystem/console.rs delete mode 100644 src/test/run-make/windows-subsystem/windows.rs create mode 100644 src/test/ui/feature-gate-wasm_custom_section.rs create mode 100644 src/test/ui/feature-gate-wasm_custom_section.stderr create mode 100644 src/test/ui/wasm-custom-section/malformed.rs create mode 100644 src/test/ui/wasm-custom-section/malformed.stderr create mode 100644 src/test/ui/wasm-custom-section/not-const.rs create mode 100644 src/test/ui/wasm-custom-section/not-const.stderr create mode 100644 src/test/ui/wasm-custom-section/not-slice.rs create mode 100644 src/test/ui/wasm-custom-section/not-slice.stderr (limited to 'src/libsyntax') diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index a398bcc9737..2e094a88982 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -313,6 +313,7 @@ impl<'a> Builder<'a> { test::RunPassFullDepsPretty, test::RunFailFullDepsPretty, test::Crate, test::CrateLibrustc, test::CrateRustdoc, test::Linkcheck, test::Cargotest, test::Cargo, test::Rls, test::ErrorIndex, test::Distcheck, + test::RunMakeFullDeps, test::Nomicon, test::Reference, test::RustdocBook, test::RustByExample, test::TheBook, test::UnstableBook, test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme, diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 86263c8fa07..2640248373c 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -915,7 +915,7 @@ impl Step for Assemble { } } - let lld_install = if build.config.lld_enabled && target_compiler.stage > 0 { + let lld_install = if build.config.lld_enabled { Some(builder.ensure(native::Lld { target: target_compiler.host, })) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index de938ec8e83..6c19da4648a 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -759,12 +759,18 @@ test!(RunFailFullDepsPretty { host: true }); -host_test!(RunMake { +default_test!(RunMake { path: "src/test/run-make", mode: "run-make", suite: "run-make" }); +host_test!(RunMakeFullDeps { + path: "src/test/run-make-fulldeps", + mode: "run-make", + suite: "run-make-fulldeps" +}); + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] struct Compiletest { compiler: Compiler, @@ -827,8 +833,7 @@ impl Step for Compiletest { // FIXME: Does pretty need librustc compiled? Note that there are // fulldeps test suites with mode = pretty as well. mode == "pretty" || - mode == "rustdoc" || - mode == "run-make" { + mode == "rustdoc" { builder.ensure(compile::Rustc { compiler, target }); } @@ -849,7 +854,7 @@ impl Step for Compiletest { cmd.arg("--rustc-path").arg(builder.rustc(compiler)); // Avoid depending on rustdoc when we don't need it. - if mode == "rustdoc" || mode == "run-make" { + if mode == "rustdoc" || (mode == "run-make" && suite.ends_with("fulldeps")) { cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host)); } @@ -931,7 +936,7 @@ impl Step for Compiletest { // Only pass correct values for these flags for the `run-make` suite as it // requires that a C++ compiler was configured which isn't always the case. - if suite == "run-make" { + if suite == "run-make-fulldeps" { let llvm_components = output(Command::new(&llvm_config).arg("--components")); let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags")); cmd.arg("--cc").arg(build.cc(target)) @@ -944,12 +949,12 @@ impl Step for Compiletest { } } } - if suite == "run-make" && !build.config.llvm_enabled { + if suite == "run-make-fulldeps" && !build.config.llvm_enabled { println!("Ignoring run-make test suite as they generally don't work without LLVM"); return; } - if suite != "run-make" { + if suite != "run-make-fulldeps" { cmd.arg("--cc").arg("") .arg("--cxx").arg("") .arg("--cflags").arg("") diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 1e2e4e5a69f..09d7ce599ab 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -650,6 +650,8 @@ define_dep_nodes!( <'tcx> [] GetSymbolExportLevel(DefId), + [] WasmCustomSections(CrateNum), + [input] Features, [] ProgramClausesFor(DefId), diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index d7194e9c2ca..f141cac1614 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -25,6 +25,7 @@ enum Target { Struct, Union, Enum, + Const, Other, } @@ -35,6 +36,7 @@ impl Target { hir::ItemStruct(..) => Target::Struct, hir::ItemUnion(..) => Target::Union, hir::ItemEnum(..) => Target::Enum, + hir::ItemConst(..) => Target::Const, _ => Target::Other, } } @@ -60,6 +62,17 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> { if name == "inline" { self.check_inline(attr, item, target) } + + if name == "wasm_custom_section" { + if target != Target::Const { + self.tcx.sess.span_err(attr.span, "only allowed on consts"); + } + + if attr.value_str().is_none() { + self.tcx.sess.span_err(attr.span, "must be of the form \ + #[wasm_custom_section = \"foo\"]"); + } + } } } diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 1ff9c7a8629..abd52624c30 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -318,6 +318,11 @@ fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt, return true; } + // These constants are special for wasm + if attr::contains_name(attrs, "wasm_custom_section") { + return true; + } + tcx.lint_level_at_node(lint::builtin::DEAD_CODE, id).0 == lint::Allow } diff --git a/src/librustc/ty/maps/config.rs b/src/librustc/ty/maps/config.rs index 117d9219312..0b41c3ab2fa 100644 --- a/src/librustc/ty/maps/config.rs +++ b/src/librustc/ty/maps/config.rs @@ -678,6 +678,12 @@ impl<'tcx> QueryDescription<'tcx> for queries::instance_def_size_estimate<'tcx> } } +impl<'tcx> QueryDescription<'tcx> for queries::wasm_custom_sections<'tcx> { + fn describe(_tcx: TyCtxt, _: CrateNum) -> String { + format!("custom wasm sections for a crate") + } +} + impl<'tcx> QueryDescription<'tcx> for queries::generics_of<'tcx> { #[inline] fn cache_on_disk(def_id: Self::Key) -> bool { diff --git a/src/librustc/ty/maps/mod.rs b/src/librustc/ty/maps/mod.rs index 6c3b4efb932..2b4c1992762 100644 --- a/src/librustc/ty/maps/mod.rs +++ b/src/librustc/ty/maps/mod.rs @@ -424,6 +424,8 @@ define_maps! { <'tcx> [] fn features_query: features_node(CrateNum) -> Lrc, [] fn program_clauses_for: ProgramClausesFor(DefId) -> Lrc>>, + + [] fn wasm_custom_sections: WasmCustomSections(CrateNum) -> Lrc>, } ////////////////////////////////////////////////////////////////////// diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index 4170fa76797..910c00b832e 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -940,6 +940,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, DepKind::Features => { force!(features_query, LOCAL_CRATE); } DepKind::ProgramClausesFor => { force!(program_clauses_for, def_id!()); } + DepKind::WasmCustomSections => { force!(wasm_custom_sections, krate!()); } } true diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 2de27f3a1c3..3c2f984ef8b 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -271,6 +271,8 @@ provide! { <'tcx> tcx, def_id, other, cdata, Arc::new(cdata.exported_symbols()) } + + wasm_custom_sections => { Lrc::new(cdata.wasm_custom_sections()) } } pub fn provide<'tcx>(providers: &mut Providers<'tcx>) { diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index b0c945fbf2a..0e5df3142af 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -1067,6 +1067,16 @@ impl<'a, 'tcx> CrateMetadata { .collect() } + pub fn wasm_custom_sections(&self) -> Vec { + let sections = self.root + .wasm_custom_sections + .decode(self) + .map(|def_index| self.local_def_id(def_index)) + .collect::>(); + info!("loaded wasm sections {:?}", sections); + return sections + } + pub fn get_macro(&self, id: DefIndex) -> (InternedString, MacroDef) { let entry = self.entry(id); match entry.kind { diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 6b3453f2c99..56981b8f4a1 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -435,6 +435,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { &exported_symbols); let exported_symbols_bytes = self.position() - i; + // encode wasm custom sections + let wasm_custom_sections = self.tcx.wasm_custom_sections(LOCAL_CRATE); + let wasm_custom_sections = self.tracked( + IsolatedEncoder::encode_wasm_custom_sections, + &wasm_custom_sections); + // Encode and index the items. i = self.position(); let items = self.encode_info_for_items(); @@ -478,6 +484,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { def_path_table, impls, exported_symbols, + wasm_custom_sections, index, }); @@ -1444,6 +1451,11 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { .cloned()) } + fn encode_wasm_custom_sections(&mut self, statics: &[DefId]) -> LazySeq { + info!("encoding custom wasm section constants {:?}", statics); + self.lazy_seq(statics.iter().map(|id| id.index)) + } + fn encode_dylib_dependency_formats(&mut self, _: ()) -> LazySeq> { match self.tcx.sess.dependency_formats.borrow().get(&config::CrateTypeDylib) { Some(arr) => { diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index 593f08e90bb..001772623e7 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -204,6 +204,7 @@ pub struct CrateRoot { pub def_path_table: Lazy, pub impls: LazySeq, pub exported_symbols: LazySeq<(ExportedSymbol, SymbolExportLevel)>, + pub wasm_custom_sections: LazySeq, pub index: LazySeq, } diff --git a/src/librustc_trans/attributes.rs b/src/librustc_trans/attributes.rs index 040d9455334..16253aa92ac 100644 --- a/src/librustc_trans/attributes.rs +++ b/src/librustc_trans/attributes.rs @@ -11,9 +11,11 @@ use std::ffi::{CStr, CString}; -use rustc::hir::TransFnAttrFlags; +use rustc::hir::{self, TransFnAttrFlags}; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; +use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::session::config::Sanitizer; +use rustc::ty::TyCtxt; use rustc::ty::maps::Providers; use rustc_data_structures::sync::Lrc; @@ -161,4 +163,32 @@ pub fn provide(providers: &mut Providers) { .collect()) } }; + + providers.wasm_custom_sections = |tcx, cnum| { + assert_eq!(cnum, LOCAL_CRATE); + let mut finder = WasmSectionFinder { tcx, list: Vec::new() }; + tcx.hir.krate().visit_all_item_likes(&mut finder); + Lrc::new(finder.list) + }; +} + +struct WasmSectionFinder<'a, 'tcx: 'a> { + tcx: TyCtxt<'a, 'tcx, 'tcx>, + list: Vec, +} + +impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for WasmSectionFinder<'a, 'tcx> { + fn visit_item(&mut self, i: &'tcx hir::Item) { + match i.node { + hir::ItemConst(..) => {} + _ => return, + } + if i.attrs.iter().any(|i| i.check_name("wasm_custom_section")) { + self.list.push(self.tcx.hir.local_def_id(i.id)); + } + } + + fn visit_trait_item(&mut self, _: &'tcx hir::TraitItem) {} + + fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem) {} } diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index bdda7741221..8e8ba823b6f 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use back::wasm; use cc::windows_registry; use super::archive::{ArchiveBuilder, ArchiveConfig}; use super::bytecode::RLIB_BYTECODE_EXTENSION; @@ -810,6 +811,11 @@ fn link_natively(sess: &Session, Err(e) => sess.fatal(&format!("failed to run dsymutil: {}", e)), } } + + if sess.opts.target_triple == "wasm32-unknown-unknown" { + wasm::add_custom_sections(&out_filename, + &trans.crate_info.wasm_custom_sections); + } } fn exec_linker(sess: &Session, cmd: &mut Command, tmpdir: &Path) diff --git a/src/librustc_trans/back/wasm.rs b/src/librustc_trans/back/wasm.rs new file mode 100644 index 00000000000..99f1e4b7e78 --- /dev/null +++ b/src/librustc_trans/back/wasm.rs @@ -0,0 +1,44 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fs; +use std::path::Path; +use std::collections::BTreeMap; + +use serialize::leb128; + +pub fn add_custom_sections(path: &Path, sections: &BTreeMap>) { + let mut wasm = fs::read(path).expect("failed to read wasm output"); + + // see https://webassembly.github.io/spec/core/binary/modules.html#custom-section + for (section, bytes) in sections { + // write the `id` identifier, 0 for a custom section + let len = wasm.len(); + leb128::write_u32_leb128(&mut wasm, len, 0); + + // figure out how long our name descriptor will be + let mut name = Vec::new(); + leb128::write_u32_leb128(&mut name, 0, section.len() as u32); + name.extend_from_slice(section.as_bytes()); + + // write the length of the payload + let len = wasm.len(); + let total_len = bytes.len() + name.len(); + leb128::write_u32_leb128(&mut wasm, len, total_len as u32); + + // write out the name section + wasm.extend(name); + + // and now the payload itself + wasm.extend_from_slice(bytes); + } + + fs::write(path, &wasm).expect("failed to write wasm output"); +} diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 4da082e9d50..11f952bc5bc 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -74,6 +74,7 @@ use rustc::util::nodemap::{FxHashMap, FxHashSet, DefIdSet}; use CrateInfo; use std::any::Any; +use std::collections::BTreeMap; use std::ffi::CString; use std::str; use std::sync::Arc; @@ -1070,8 +1071,24 @@ impl CrateInfo { used_crates_dynamic: cstore::used_crates(tcx, LinkagePreference::RequireDynamic), used_crates_static: cstore::used_crates(tcx, LinkagePreference::RequireStatic), used_crate_source: FxHashMap(), + wasm_custom_sections: BTreeMap::new(), }; + let load_wasm_sections = tcx.sess.crate_types.borrow() + .iter() + .any(|c| *c != config::CrateTypeRlib) && + tcx.sess.opts.target_triple == "wasm32-unknown-unknown"; + + if load_wasm_sections { + info!("attempting to load all wasm sections"); + for &id in tcx.wasm_custom_sections(LOCAL_CRATE).iter() { + let (name, contents) = fetch_wasm_section(tcx, id); + info.wasm_custom_sections.entry(name) + .or_insert(Vec::new()) + .extend(contents); + } + } + for &cnum in tcx.crates().iter() { info.native_libraries.insert(cnum, tcx.native_libraries(cnum)); info.crate_name.insert(cnum, tcx.crate_name(cnum).to_string()); @@ -1091,6 +1108,14 @@ impl CrateInfo { if tcx.is_no_builtins(cnum) { info.is_no_builtins.insert(cnum); } + if load_wasm_sections { + for &id in tcx.wasm_custom_sections(cnum).iter() { + let (name, contents) = fetch_wasm_section(tcx, id); + info.wasm_custom_sections.entry(name) + .or_insert(Vec::new()) + .extend(contents); + } + } } @@ -1270,3 +1295,44 @@ mod temp_stable_hash_impls { } } } + +fn fetch_wasm_section(tcx: TyCtxt, id: DefId) -> (String, Vec) { + use rustc::mir::interpret::{GlobalId, Value, PrimVal}; + use rustc::middle::const_val::ConstVal; + + info!("loading wasm section {:?}", id); + + let section = tcx.get_attrs(id) + .iter() + .find(|a| a.check_name("wasm_custom_section")) + .expect("missing #[wasm_custom_section] attribute") + .value_str() + .expect("malformed #[wasm_custom_section] attribute"); + + let instance = ty::Instance::mono(tcx, id); + let cid = GlobalId { + instance, + promoted: None + }; + let param_env = ty::ParamEnv::reveal_all(); + let val = tcx.const_eval(param_env.and(cid)).unwrap(); + + let val = match val.val { + ConstVal::Value(val) => val, + ConstVal::Unevaluated(..) => bug!("should be evaluated"), + }; + let val = match val { + Value::ByRef(ptr, _align) => ptr.into_inner_primval(), + ref v => bug!("should be ByRef, was {:?}", v), + }; + let mem = match val { + PrimVal::Ptr(mem) => mem, + ref v => bug!("should be Ptr, was {:?}", v), + }; + assert_eq!(mem.offset, 0); + let alloc = tcx + .interpret_interner + .get_alloc(mem.alloc_id) + .expect("miri allocation never successfully created"); + (section.to_string(), alloc.bytes.clone()) +} diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 337f85a3813..bb2aeca3748 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -72,6 +72,7 @@ pub use llvm_util::target_features; use std::any::Any; use std::path::PathBuf; use std::sync::mpsc; +use std::collections::BTreeMap; use rustc_data_structures::sync::Lrc; use rustc::dep_graph::DepGraph; @@ -98,6 +99,7 @@ mod back { pub mod symbol_export; pub mod write; mod rpath; + mod wasm; } mod abi; @@ -400,6 +402,7 @@ struct CrateInfo { used_crate_source: FxHashMap>, used_crates_static: Vec<(CrateNum, LibSource)>, used_crates_dynamic: Vec<(CrateNum, LibSource)>, + wasm_custom_sections: BTreeMap>, } __build_diagnostic_array! { librustc_trans, DIAGNOSTICS } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 69879bbe85d..f86fe1fb756 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1182,9 +1182,15 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item let _indenter = indenter(); match it.node { // Consts can play a role in type-checking, so they are included here. - hir::ItemStatic(..) | + hir::ItemStatic(..) => { + tcx.typeck_tables_of(tcx.hir.local_def_id(it.id)); + } hir::ItemConst(..) => { tcx.typeck_tables_of(tcx.hir.local_def_id(it.id)); + if it.attrs.iter().any(|a| a.check_name("wasm_custom_section")) { + let def_id = tcx.hir.local_def_id(it.id); + check_const_is_u8_array(tcx, def_id, it.span); + } } hir::ItemEnum(ref enum_definition, _) => { check_enum(tcx, @@ -1256,6 +1262,21 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item } } +fn check_const_is_u8_array<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, + def_id: DefId, + span: Span) { + match tcx.type_of(def_id).sty { + ty::TyArray(t, _) => { + match t.sty { + ty::TyUint(ast::UintTy::U8) => return, + _ => {} + } + } + _ => {} + } + tcx.sess.span_err(span, "must be an array of bytes like `[u8; N]`"); +} + fn check_on_unimplemented<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_def_id: DefId, item: &hir::Item) { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 915396d29fe..dbcfee208ca 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -451,6 +451,9 @@ declare_features! ( // `use path as _;` and `extern crate c as _;` (active, underscore_imports, "1.26.0", Some(48216), None), + + // The #[wasm_custom_section] attribute + (active, wasm_custom_section, "1.26.0", None, None), ); declare_features! ( @@ -1004,6 +1007,11 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG "never will be stable", cfg_fn!(rustc_attrs))), + ("wasm_custom_section", Whitelisted, Gated(Stability::Unstable, + "wasm_custom_section", + "attribute is currently unstable", + cfg_fn!(wasm_custom_section))), + // Crate level attributes ("crate_name", CrateLevel, Ungated), ("crate_type", CrateLevel, Ungated), diff --git a/src/test/run-make-fulldeps/a-b-a-linker-guard/Makefile b/src/test/run-make-fulldeps/a-b-a-linker-guard/Makefile new file mode 100644 index 00000000000..0962ebfbff5 --- /dev/null +++ b/src/test/run-make-fulldeps/a-b-a-linker-guard/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +# Test that if we build `b` against a version of `a` that has one set +# of types, it will not run with a dylib that has a different set of +# types. + +all: + $(RUSTC) a.rs --cfg x -C prefer-dynamic + $(RUSTC) b.rs -C prefer-dynamic + $(call RUN,b) + $(RUSTC) a.rs --cfg y -C prefer-dynamic + $(call FAIL,b) diff --git a/src/test/run-make-fulldeps/a-b-a-linker-guard/a.rs b/src/test/run-make-fulldeps/a-b-a-linker-guard/a.rs new file mode 100644 index 00000000000..c6680a78819 --- /dev/null +++ b/src/test/run-make-fulldeps/a-b-a-linker-guard/a.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "a"] +#![crate_type = "dylib"] + +#[cfg(x)] +pub fn foo(x: u32) { } + +#[cfg(y)] +pub fn foo(x: i32) { } diff --git a/src/test/run-make-fulldeps/a-b-a-linker-guard/b.rs b/src/test/run-make-fulldeps/a-b-a-linker-guard/b.rs new file mode 100644 index 00000000000..89fd48de5bb --- /dev/null +++ b/src/test/run-make-fulldeps/a-b-a-linker-guard/b.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "b"] + +extern crate a; + +fn main() { + a::foo(22_u32); +} diff --git a/src/test/run-make-fulldeps/alloc-extern-crates/Makefile b/src/test/run-make-fulldeps/alloc-extern-crates/Makefile new file mode 100644 index 00000000000..7197f4e17e3 --- /dev/null +++ b/src/test/run-make-fulldeps/alloc-extern-crates/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) fakealloc.rs + $(RUSTC) --crate-type=rlib ../../../liballoc/lib.rs --cfg feature=\"external_crate\" --extern external=$(TMPDIR)/$(shell $(RUSTC) --print file-names fakealloc.rs) diff --git a/src/test/run-make-fulldeps/alloc-extern-crates/fakealloc.rs b/src/test/run-make-fulldeps/alloc-extern-crates/fakealloc.rs new file mode 100644 index 00000000000..43f97489314 --- /dev/null +++ b/src/test/run-make-fulldeps/alloc-extern-crates/fakealloc.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![no_std] + +#[inline] +pub unsafe fn allocate(_size: usize, _align: usize) -> *mut u8 { 0 as *mut u8 } + +#[inline] +pub unsafe fn deallocate(_ptr: *mut u8, _old_size: usize, _align: usize) { } + +#[inline] +pub unsafe fn reallocate(_ptr: *mut u8, _old_size: usize, _size: usize, _align: usize) -> *mut u8 { + 0 as *mut u8 +} + +#[inline] +pub unsafe fn reallocate_inplace(_ptr: *mut u8, old_size: usize, _size: usize, + _align: usize) -> usize { old_size } + +#[inline] +pub fn usable_size(size: usize, _align: usize) -> usize { size } + +#[inline] +pub fn stats_print() { } diff --git a/src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/Makefile b/src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/Makefile new file mode 100644 index 00000000000..c14006cc2e0 --- /dev/null +++ b/src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +# Test that -A warnings makes the 'empty trait list for derive' warning go away +OUT=$(shell $(RUSTC) foo.rs -A warnings 2>&1 | grep "warning" ) + +all: foo + test -z '$(OUT)' + +# This is just to make sure the above command actually succeeds +foo: + $(RUSTC) foo.rs -A warnings diff --git a/src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/foo.rs b/src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/foo.rs new file mode 100644 index 00000000000..a9e18f5a8f1 --- /dev/null +++ b/src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive()] +#[derive(Copy, Clone)] +pub struct Foo; + +pub fn main() { } diff --git a/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/Makefile b/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/Makefile new file mode 100644 index 00000000000..3eecaf93142 --- /dev/null +++ b/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/Makefile @@ -0,0 +1,15 @@ +-include ../tools.mk + +# Test that -A warnings makes the 'empty trait list for derive' warning go away +DEP=$(shell $(RUSTC) bar.rs) +OUT=$(shell $(RUSTC) foo.rs -A warnings 2>&1 | grep "warning" ) + +all: foo bar + test -z '$(OUT)' + +# These are just to ensure that the above commands actually work +bar: + $(RUSTC) bar.rs + +foo: bar + $(RUSTC) foo.rs -A warnings diff --git a/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/bar.rs b/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/bar.rs new file mode 100644 index 00000000000..fed1405b7f4 --- /dev/null +++ b/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#![feature(staged_api)] +#![unstable(feature = "test_feature", issue = "0")] + +pub fn baz() { } diff --git a/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/foo.rs b/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/foo.rs new file mode 100644 index 00000000000..a36cc474c2b --- /dev/null +++ b/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(test_feature)] + +extern crate bar; + +pub fn main() { bar::baz() } diff --git a/src/test/run-make-fulldeps/archive-duplicate-names/Makefile b/src/test/run-make-fulldeps/archive-duplicate-names/Makefile new file mode 100644 index 00000000000..93711c41d79 --- /dev/null +++ b/src/test/run-make-fulldeps/archive-duplicate-names/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +all: + mkdir $(TMPDIR)/a + mkdir $(TMPDIR)/b + $(call COMPILE_OBJ,$(TMPDIR)/a/foo.o,foo.c) + $(call COMPILE_OBJ,$(TMPDIR)/b/foo.o,bar.c) + $(AR) crus $(TMPDIR)/libfoo.a $(TMPDIR)/a/foo.o $(TMPDIR)/b/foo.o + $(RUSTC) foo.rs + $(RUSTC) bar.rs + $(call RUN,bar) diff --git a/src/test/run-make-fulldeps/archive-duplicate-names/bar.c b/src/test/run-make-fulldeps/archive-duplicate-names/bar.c new file mode 100644 index 00000000000..a25fa10f4d3 --- /dev/null +++ b/src/test/run-make-fulldeps/archive-duplicate-names/bar.c @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void bar() {} diff --git a/src/test/run-make-fulldeps/archive-duplicate-names/bar.rs b/src/test/run-make-fulldeps/archive-duplicate-names/bar.rs new file mode 100644 index 00000000000..1200a6de8e2 --- /dev/null +++ b/src/test/run-make-fulldeps/archive-duplicate-names/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::baz(); +} diff --git a/src/test/run-make-fulldeps/archive-duplicate-names/foo.c b/src/test/run-make-fulldeps/archive-duplicate-names/foo.c new file mode 100644 index 00000000000..61d5d154078 --- /dev/null +++ b/src/test/run-make-fulldeps/archive-duplicate-names/foo.c @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void foo() {} diff --git a/src/test/run-make-fulldeps/archive-duplicate-names/foo.rs b/src/test/run-make-fulldeps/archive-duplicate-names/foo.rs new file mode 100644 index 00000000000..24b4734f2cd --- /dev/null +++ b/src/test/run-make-fulldeps/archive-duplicate-names/foo.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[link(name = "foo", kind = "static")] +extern { + fn foo(); + fn bar(); +} + +pub fn baz() { + unsafe { + foo(); + bar(); + } +} diff --git a/src/test/run-make-fulldeps/atomic-lock-free/Makefile b/src/test/run-make-fulldeps/atomic-lock-free/Makefile new file mode 100644 index 00000000000..a7df821f92d --- /dev/null +++ b/src/test/run-make-fulldeps/atomic-lock-free/Makefile @@ -0,0 +1,46 @@ +-include ../tools.mk + +# This tests ensure that atomic types are never lowered into runtime library calls that are not +# guaranteed to be lock-free. + +all: +ifeq ($(UNAME),Linux) +ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86) + $(RUSTC) --target=i686-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add + $(RUSTC) --target=x86_64-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add +endif +ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm) + $(RUSTC) --target=arm-unknown-linux-gnueabi atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add + $(RUSTC) --target=arm-unknown-linux-gnueabihf atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add + $(RUSTC) --target=armv7-unknown-linux-gnueabihf atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add +endif +ifeq ($(filter aarch64,$(LLVM_COMPONENTS)),aarch64) + $(RUSTC) --target=aarch64-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add +endif +ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips) + $(RUSTC) --target=mips-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add + $(RUSTC) --target=mipsel-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add +endif +ifeq ($(filter powerpc,$(LLVM_COMPONENTS)),powerpc) + $(RUSTC) --target=powerpc-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add + $(RUSTC) --target=powerpc-unknown-linux-gnuspe atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add + $(RUSTC) --target=powerpc64-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add + $(RUSTC) --target=powerpc64le-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add +endif +ifeq ($(filter systemz,$(LLVM_COMPONENTS)),systemz) + $(RUSTC) --target=s390x-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add +endif +endif diff --git a/src/test/run-make-fulldeps/atomic-lock-free/atomic_lock_free.rs b/src/test/run-make-fulldeps/atomic-lock-free/atomic_lock_free.rs new file mode 100644 index 00000000000..b41e8e9226b --- /dev/null +++ b/src/test/run-make-fulldeps/atomic-lock-free/atomic_lock_free.rs @@ -0,0 +1,66 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(cfg_target_has_atomic, no_core, intrinsics, lang_items)] +#![crate_type="rlib"] +#![no_core] + +extern "rust-intrinsic" { + fn atomic_xadd(dst: *mut T, src: T) -> T; +} + +#[lang = "sized"] +trait Sized {} +#[lang = "copy"] +trait Copy {} +#[lang = "freeze"] +trait Freeze {} + +#[cfg(target_has_atomic = "8")] +pub unsafe fn atomic_u8(x: *mut u8) { + atomic_xadd(x, 1); + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "8")] +pub unsafe fn atomic_i8(x: *mut i8) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "16")] +pub unsafe fn atomic_u16(x: *mut u16) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "16")] +pub unsafe fn atomic_i16(x: *mut i16) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "32")] +pub unsafe fn atomic_u32(x: *mut u32) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "32")] +pub unsafe fn atomic_i32(x: *mut i32) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "64")] +pub unsafe fn atomic_u64(x: *mut u64) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "64")] +pub unsafe fn atomic_i64(x: *mut i64) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "ptr")] +pub unsafe fn atomic_usize(x: *mut usize) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "ptr")] +pub unsafe fn atomic_isize(x: *mut isize) { + atomic_xadd(x, 1); +} diff --git a/src/test/run-make-fulldeps/bare-outfile/Makefile b/src/test/run-make-fulldeps/bare-outfile/Makefile new file mode 100644 index 00000000000..baa4c1c0237 --- /dev/null +++ b/src/test/run-make-fulldeps/bare-outfile/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + cp foo.rs $(TMPDIR) + cd $(TMPDIR) && $(RUSTC) -o foo foo.rs + $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/bare-outfile/foo.rs b/src/test/run-make-fulldeps/bare-outfile/foo.rs new file mode 100644 index 00000000000..63e747901ae --- /dev/null +++ b/src/test/run-make-fulldeps/bare-outfile/foo.rs @@ -0,0 +1,12 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { +} diff --git a/src/test/run-make-fulldeps/c-dynamic-dylib/Makefile b/src/test/run-make-fulldeps/c-dynamic-dylib/Makefile new file mode 100644 index 00000000000..83bddd4c73c --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-dylib/Makefile @@ -0,0 +1,14 @@ +-include ../tools.mk + +# This hits an assertion in the linker on older versions of osx apparently +ifeq ($(shell uname),Darwin) +all: + echo ignored +else +all: $(call DYLIB,cfoo) + $(RUSTC) foo.rs -C prefer-dynamic + $(RUSTC) bar.rs + $(call RUN,bar) + $(call REMOVE_DYLIBS,cfoo) + $(call FAIL,bar) +endif diff --git a/src/test/run-make-fulldeps/c-dynamic-dylib/bar.rs b/src/test/run-make-fulldeps/c-dynamic-dylib/bar.rs new file mode 100644 index 00000000000..37b120decd1 --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-dylib/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::rsfoo(); +} diff --git a/src/test/run-make-fulldeps/c-dynamic-dylib/cfoo.c b/src/test/run-make-fulldeps/c-dynamic-dylib/cfoo.c new file mode 100644 index 00000000000..a9755493541 --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-dylib/cfoo.c @@ -0,0 +1,5 @@ +// ignore-license +#ifdef _WIN32 +__declspec(dllexport) +#endif +int foo() { return 0; } diff --git a/src/test/run-make-fulldeps/c-dynamic-dylib/foo.rs b/src/test/run-make-fulldeps/c-dynamic-dylib/foo.rs new file mode 100644 index 00000000000..04253be71d4 --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-dylib/foo.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +#[link(name = "cfoo")] +extern { + fn foo(); +} + +pub fn rsfoo() { + unsafe { foo() } +} diff --git a/src/test/run-make-fulldeps/c-dynamic-rlib/Makefile b/src/test/run-make-fulldeps/c-dynamic-rlib/Makefile new file mode 100644 index 00000000000..e15cfd34d6c --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-rlib/Makefile @@ -0,0 +1,17 @@ +-include ../tools.mk + +# This overrides the LD_LIBRARY_PATH for RUN +TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR) + +# This hits an assertion in the linker on older versions of osx apparently +ifeq ($(shell uname),Darwin) +all: + echo ignored +else +all: $(call DYLIB,cfoo) + $(RUSTC) foo.rs + $(RUSTC) bar.rs + $(call RUN,bar) + $(call REMOVE_DYLIBS,cfoo) + $(call FAIL,bar) +endif diff --git a/src/test/run-make-fulldeps/c-dynamic-rlib/bar.rs b/src/test/run-make-fulldeps/c-dynamic-rlib/bar.rs new file mode 100644 index 00000000000..37b120decd1 --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-rlib/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::rsfoo(); +} diff --git a/src/test/run-make-fulldeps/c-dynamic-rlib/cfoo.c b/src/test/run-make-fulldeps/c-dynamic-rlib/cfoo.c new file mode 100644 index 00000000000..b2849326a75 --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-rlib/cfoo.c @@ -0,0 +1,6 @@ +// ignore-license + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int foo() { return 0; } diff --git a/src/test/run-make-fulldeps/c-dynamic-rlib/foo.rs b/src/test/run-make-fulldeps/c-dynamic-rlib/foo.rs new file mode 100644 index 00000000000..a1f01bd2b62 --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-rlib/foo.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[link(name = "cfoo")] +extern { + fn foo(); +} + +pub fn rsfoo() { + unsafe { foo() } +} diff --git a/src/test/run-make-fulldeps/c-link-to-rust-dylib/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-dylib/Makefile new file mode 100644 index 00000000000..98e112a3744 --- /dev/null +++ b/src/test/run-make-fulldeps/c-link-to-rust-dylib/Makefile @@ -0,0 +1,17 @@ +-include ../tools.mk + +all: $(TMPDIR)/$(call BIN,bar) + $(call RUN,bar) + $(call REMOVE_DYLIBS,foo) + $(call FAIL,bar) + +ifdef IS_MSVC +$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo) + $(CC) bar.c $(TMPDIR)/foo.dll.lib $(call OUT_EXE,bar) +else +$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo) + $(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) -L $(TMPDIR) +endif + +$(call DYLIB,foo): foo.rs + $(RUSTC) foo.rs diff --git a/src/test/run-make-fulldeps/c-link-to-rust-dylib/bar.c b/src/test/run-make-fulldeps/c-link-to-rust-dylib/bar.c new file mode 100644 index 00000000000..5729d411c5b --- /dev/null +++ b/src/test/run-make-fulldeps/c-link-to-rust-dylib/bar.c @@ -0,0 +1,7 @@ +// ignore-license +void foo(); + +int main() { + foo(); + return 0; +} diff --git a/src/test/run-make-fulldeps/c-link-to-rust-dylib/foo.rs b/src/test/run-make-fulldeps/c-link-to-rust-dylib/foo.rs new file mode 100644 index 00000000000..32675bcba1e --- /dev/null +++ b/src/test/run-make-fulldeps/c-link-to-rust-dylib/foo.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +#[no_mangle] +pub extern "C" fn foo() {} diff --git a/src/test/run-make-fulldeps/c-link-to-rust-staticlib/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-staticlib/Makefile new file mode 100644 index 00000000000..47264e82165 --- /dev/null +++ b/src/test/run-make-fulldeps/c-link-to-rust-staticlib/Makefile @@ -0,0 +1,16 @@ +-include ../tools.mk + +# FIXME: ignore freebsd +ifneq ($(shell uname),FreeBSD) +all: + $(RUSTC) foo.rs + $(CC) bar.c $(call STATICLIB,foo) $(call OUT_EXE,bar) \ + $(EXTRACFLAGS) $(EXTRACXXFLAGS) + $(call RUN,bar) + rm $(call STATICLIB,foo) + $(call RUN,bar) + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/c-link-to-rust-staticlib/bar.c b/src/test/run-make-fulldeps/c-link-to-rust-staticlib/bar.c new file mode 100644 index 00000000000..5729d411c5b --- /dev/null +++ b/src/test/run-make-fulldeps/c-link-to-rust-staticlib/bar.c @@ -0,0 +1,7 @@ +// ignore-license +void foo(); + +int main() { + foo(); + return 0; +} diff --git a/src/test/run-make-fulldeps/c-link-to-rust-staticlib/foo.rs b/src/test/run-make-fulldeps/c-link-to-rust-staticlib/foo.rs new file mode 100644 index 00000000000..1bb19016700 --- /dev/null +++ b/src/test/run-make-fulldeps/c-link-to-rust-staticlib/foo.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "staticlib"] + +#[no_mangle] +pub extern "C" fn foo() {} diff --git a/src/test/run-make-fulldeps/c-static-dylib/Makefile b/src/test/run-make-fulldeps/c-static-dylib/Makefile new file mode 100644 index 00000000000..f88786857cc --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-dylib/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,cfoo) + $(RUSTC) foo.rs -C prefer-dynamic + $(RUSTC) bar.rs + rm $(call NATIVE_STATICLIB,cfoo) + $(call RUN,bar) + $(call REMOVE_DYLIBS,foo) + $(call FAIL,bar) diff --git a/src/test/run-make-fulldeps/c-static-dylib/bar.rs b/src/test/run-make-fulldeps/c-static-dylib/bar.rs new file mode 100644 index 00000000000..37b120decd1 --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-dylib/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::rsfoo(); +} diff --git a/src/test/run-make-fulldeps/c-static-dylib/cfoo.c b/src/test/run-make-fulldeps/c-static-dylib/cfoo.c new file mode 100644 index 00000000000..113717a776a --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-dylib/cfoo.c @@ -0,0 +1,2 @@ +// ignore-license +int foo() { return 0; } diff --git a/src/test/run-make-fulldeps/c-static-dylib/foo.rs b/src/test/run-make-fulldeps/c-static-dylib/foo.rs new file mode 100644 index 00000000000..44be5ac890d --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-dylib/foo.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +#[link(name = "cfoo", kind = "static")] +extern { + fn foo(); +} + +pub fn rsfoo() { + unsafe { foo() } +} diff --git a/src/test/run-make-fulldeps/c-static-rlib/Makefile b/src/test/run-make-fulldeps/c-static-rlib/Makefile new file mode 100644 index 00000000000..be22b2728f0 --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-rlib/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,cfoo) + $(RUSTC) foo.rs + $(RUSTC) bar.rs + $(call REMOVE_RLIBS,foo) + rm $(call NATIVE_STATICLIB,cfoo) + $(call RUN,bar) diff --git a/src/test/run-make-fulldeps/c-static-rlib/bar.rs b/src/test/run-make-fulldeps/c-static-rlib/bar.rs new file mode 100644 index 00000000000..37b120decd1 --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-rlib/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::rsfoo(); +} diff --git a/src/test/run-make-fulldeps/c-static-rlib/cfoo.c b/src/test/run-make-fulldeps/c-static-rlib/cfoo.c new file mode 100644 index 00000000000..113717a776a --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-rlib/cfoo.c @@ -0,0 +1,2 @@ +// ignore-license +int foo() { return 0; } diff --git a/src/test/run-make-fulldeps/c-static-rlib/foo.rs b/src/test/run-make-fulldeps/c-static-rlib/foo.rs new file mode 100644 index 00000000000..cbd7b020bd8 --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-rlib/foo.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[link(name = "cfoo", kind = "static")] +extern { + fn foo(); +} + +pub fn rsfoo() { + unsafe { foo() } +} diff --git a/src/test/run-make-fulldeps/cat-and-grep-sanity-check/Makefile b/src/test/run-make-fulldeps/cat-and-grep-sanity-check/Makefile new file mode 100644 index 00000000000..fead197ce39 --- /dev/null +++ b/src/test/run-make-fulldeps/cat-and-grep-sanity-check/Makefile @@ -0,0 +1,46 @@ +-include ../tools.mk + +all: + echo a | $(CGREP) a + ! echo b | $(CGREP) a + echo xyz | $(CGREP) x y z + ! echo abc | $(CGREP) b c d + printf "x\ny\nz" | $(CGREP) x y z + + echo AbCd | $(CGREP) -i a b C D + ! echo AbCd | $(CGREP) a b C D + + true | $(CGREP) -v nothing + ! echo nothing | $(CGREP) -v nothing + ! echo xyz | $(CGREP) -v w x y + ! echo xyz | $(CGREP) -v x y z + echo xyz | $(CGREP) -v a b c + + ! echo 'foo bar baz' | $(CGREP) 'foo baz' + echo 'foo bar baz' | $(CGREP) foo baz + echo 'x a `b` c y z' | $(CGREP) 'a `b` c' + + echo baaac | $(CGREP) -e 'ba*c' + echo bc | $(CGREP) -e 'ba*c' + ! echo aaac | $(CGREP) -e 'ba*c' + + echo aaa | $(CGREP) -e 'a+' + ! echo bbb | $(CGREP) -e 'a+' + + echo abc | $(CGREP) -e 'a|e|i|o|u' + ! echo fgh | $(CGREP) -e 'a|e|i|o|u' + echo abc | $(CGREP) -e '[aeiou]' + ! echo fgh | $(CGREP) -e '[aeiou]' + ! echo abc | $(CGREP) -e '[^aeiou]{3}' + echo fgh | $(CGREP) -e '[^aeiou]{3}' + echo ab cd ef gh | $(CGREP) -e '\bcd\b' + ! echo abcdefgh | $(CGREP) -e '\bcd\b' + echo xyz | $(CGREP) -e '...' + ! echo xy | $(CGREP) -e '...' + ! echo xyz | $(CGREP) -e '\.\.\.' + echo ... | $(CGREP) -e '\.\.\.' + + echo foo bar baz | $(CGREP) -e 'foo.*baz' + ! echo foo bar baz | $(CGREP) -ve 'foo.*baz' + ! echo foo bar baz | $(CGREP) -e 'baz.*foo' + echo foo bar baz | $(CGREP) -ve 'baz.*foo' diff --git a/src/test/run-make-fulldeps/cdylib-fewer-symbols/Makefile b/src/test/run-make-fulldeps/cdylib-fewer-symbols/Makefile new file mode 100644 index 00000000000..1a0664dfafd --- /dev/null +++ b/src/test/run-make-fulldeps/cdylib-fewer-symbols/Makefile @@ -0,0 +1,15 @@ +# Test that allocator-related symbols don't show up as exported from a cdylib as +# they're internal to Rust and not part of the public ABI. + +-include ../tools.mk + +# FIXME: The __rdl_ and __rust_ symbol still remains, no matter using MSVC or GNU +# See https://github.com/rust-lang/rust/pull/46207#issuecomment-347561753 +ifdef IS_WINDOWS +all: + true +else +all: + $(RUSTC) foo.rs + nm -g "$(call DYLIB,foo)" | $(CGREP) -v __rdl_ __rde_ __rg_ __rust_ +endif diff --git a/src/test/run-make-fulldeps/cdylib-fewer-symbols/foo.rs b/src/test/run-make-fulldeps/cdylib-fewer-symbols/foo.rs new file mode 100644 index 00000000000..4ec8d4ee860 --- /dev/null +++ b/src/test/run-make-fulldeps/cdylib-fewer-symbols/foo.rs @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "cdylib"] + +#[no_mangle] +pub extern fn foo() -> u32 { + 3 +} diff --git a/src/test/run-make-fulldeps/cdylib/Makefile b/src/test/run-make-fulldeps/cdylib/Makefile new file mode 100644 index 00000000000..47ec762b3e9 --- /dev/null +++ b/src/test/run-make-fulldeps/cdylib/Makefile @@ -0,0 +1,19 @@ +include ../tools.mk + +all: $(call RUN_BINFILE,foo) + $(call RUN,foo) + rm $(call DYLIB,foo) + $(RUSTC) foo.rs -C lto + $(call RUN,foo) + +ifdef IS_MSVC +$(call RUN_BINFILE,foo): $(call DYLIB,foo) + $(CC) $(CFLAGS) foo.c $(TMPDIR)/foo.dll.lib $(call OUT_EXE,foo) +else +$(call RUN_BINFILE,foo): $(call DYLIB,foo) + $(CC) $(CFLAGS) foo.c -lfoo -o $(call RUN_BINFILE,foo) -L $(TMPDIR) +endif + +$(call DYLIB,foo): + $(RUSTC) bar.rs + $(RUSTC) foo.rs diff --git a/src/test/run-make-fulldeps/cdylib/bar.rs b/src/test/run-make-fulldeps/cdylib/bar.rs new file mode 100644 index 00000000000..2c97298604c --- /dev/null +++ b/src/test/run-make-fulldeps/cdylib/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +pub fn bar() { + println!("hello!"); +} diff --git a/src/test/run-make-fulldeps/cdylib/foo.c b/src/test/run-make-fulldeps/cdylib/foo.c new file mode 100644 index 00000000000..1c950427c65 --- /dev/null +++ b/src/test/run-make-fulldeps/cdylib/foo.c @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#include + +extern void foo(); +extern unsigned bar(unsigned a, unsigned b); + +int main() { + foo(); + assert(bar(1, 2) == 3); + return 0; +} diff --git a/src/test/run-make-fulldeps/cdylib/foo.rs b/src/test/run-make-fulldeps/cdylib/foo.rs new file mode 100644 index 00000000000..cdac6d19035 --- /dev/null +++ b/src/test/run-make-fulldeps/cdylib/foo.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "cdylib"] + +extern crate bar; + +#[no_mangle] +pub extern fn foo() { + bar::bar(); +} + +#[no_mangle] +pub extern fn bar(a: u32, b: u32) -> u32 { + a + b +} diff --git a/src/test/run-make-fulldeps/codegen-options-parsing/Makefile b/src/test/run-make-fulldeps/codegen-options-parsing/Makefile new file mode 100644 index 00000000000..fda96a8b1fb --- /dev/null +++ b/src/test/run-make-fulldeps/codegen-options-parsing/Makefile @@ -0,0 +1,31 @@ +-include ../tools.mk + +all: + #Option taking a number + $(RUSTC) -C codegen-units dummy.rs 2>&1 | \ + $(CGREP) 'codegen option `codegen-units` requires a number' + $(RUSTC) -C codegen-units= dummy.rs 2>&1 | \ + $(CGREP) 'incorrect value `` for codegen option `codegen-units` - a number was expected' + $(RUSTC) -C codegen-units=foo dummy.rs 2>&1 | \ + $(CGREP) 'incorrect value `foo` for codegen option `codegen-units` - a number was expected' + $(RUSTC) -C codegen-units=1 dummy.rs + #Option taking a string + $(RUSTC) -C extra-filename dummy.rs 2>&1 | \ + $(CGREP) 'codegen option `extra-filename` requires a string' + $(RUSTC) -C extra-filename= dummy.rs 2>&1 + $(RUSTC) -C extra-filename=foo dummy.rs 2>&1 + #Option taking no argument + $(RUSTC) -C lto= dummy.rs 2>&1 | \ + $(CGREP) 'codegen option `lto` - one of `thin`, `fat`, or' + $(RUSTC) -C lto=1 dummy.rs 2>&1 | \ + $(CGREP) 'codegen option `lto` - one of `thin`, `fat`, or' + $(RUSTC) -C lto=foo dummy.rs 2>&1 | \ + $(CGREP) 'codegen option `lto` - one of `thin`, `fat`, or' + $(RUSTC) -C lto dummy.rs + + # Should not link dead code... + $(RUSTC) -Z print-link-args dummy.rs 2>&1 | \ + $(CGREP) -e '--gc-sections|-z[^ ]* [^ ]*|-dead_strip|/OPT:REF' + # ... unless you specifically ask to keep it + $(RUSTC) -Z print-link-args -C link-dead-code dummy.rs 2>&1 | \ + $(CGREP) -ve '--gc-sections|-z[^ ]* [^ ]*|-dead_strip|/OPT:REF' diff --git a/src/test/run-make-fulldeps/codegen-options-parsing/dummy.rs b/src/test/run-make-fulldeps/codegen-options-parsing/dummy.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/codegen-options-parsing/dummy.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/compile-stdin/Makefile b/src/test/run-make-fulldeps/compile-stdin/Makefile new file mode 100644 index 00000000000..1442224cf9a --- /dev/null +++ b/src/test/run-make-fulldeps/compile-stdin/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + echo 'fn main(){}' | $(RUSTC) - + $(call RUN,rust_out) diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths-2/Makefile b/src/test/run-make-fulldeps/compiler-lookup-paths-2/Makefile new file mode 100644 index 00000000000..bd7f62d5c2d --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths-2/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: + mkdir -p $(TMPDIR)/a $(TMPDIR)/b + $(RUSTC) a.rs && mv $(TMPDIR)/liba.rlib $(TMPDIR)/a + $(RUSTC) b.rs -L $(TMPDIR)/a && mv $(TMPDIR)/libb.rlib $(TMPDIR)/b + $(RUSTC) c.rs -L crate=$(TMPDIR)/b -L dependency=$(TMPDIR)/a \ + && exit 1 || exit 0 diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths-2/a.rs b/src/test/run-make-fulldeps/compiler-lookup-paths-2/a.rs new file mode 100644 index 00000000000..e7572a5f615 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths-2/a.rs @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths-2/b.rs b/src/test/run-make-fulldeps/compiler-lookup-paths-2/b.rs new file mode 100644 index 00000000000..fee0da9b4c1 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths-2/b.rs @@ -0,0 +1,12 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +extern crate a; diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths-2/c.rs b/src/test/run-make-fulldeps/compiler-lookup-paths-2/c.rs new file mode 100644 index 00000000000..66fe51d1099 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths-2/c.rs @@ -0,0 +1,13 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +extern crate b; +extern crate a; diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/Makefile b/src/test/run-make-fulldeps/compiler-lookup-paths/Makefile new file mode 100644 index 00000000000..e22b937a087 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/Makefile @@ -0,0 +1,38 @@ +-include ../tools.mk + +all: $(TMPDIR)/libnative.a + mkdir -p $(TMPDIR)/crate + mkdir -p $(TMPDIR)/native + mv $(TMPDIR)/libnative.a $(TMPDIR)/native + $(RUSTC) a.rs + mv $(TMPDIR)/liba.rlib $(TMPDIR)/crate + $(RUSTC) b.rs -L native=$(TMPDIR)/crate && exit 1 || exit 0 + $(RUSTC) b.rs -L dependency=$(TMPDIR)/crate && exit 1 || exit 0 + $(RUSTC) b.rs -L crate=$(TMPDIR)/crate + $(RUSTC) b.rs -L all=$(TMPDIR)/crate + $(RUSTC) c.rs -L native=$(TMPDIR)/crate && exit 1 || exit 0 + $(RUSTC) c.rs -L crate=$(TMPDIR)/crate && exit 1 || exit 0 + $(RUSTC) c.rs -L dependency=$(TMPDIR)/crate + $(RUSTC) c.rs -L all=$(TMPDIR)/crate + $(RUSTC) d.rs -L dependency=$(TMPDIR)/native && exit 1 || exit 0 + $(RUSTC) d.rs -L crate=$(TMPDIR)/native && exit 1 || exit 0 + $(RUSTC) d.rs -L native=$(TMPDIR)/native + $(RUSTC) d.rs -L all=$(TMPDIR)/native + # Deduplication tests: + # Same hash, no errors. + mkdir -p $(TMPDIR)/e1 + mkdir -p $(TMPDIR)/e2 + $(RUSTC) e.rs -o $(TMPDIR)/e1/libe.rlib + $(RUSTC) e.rs -o $(TMPDIR)/e2/libe.rlib + $(RUSTC) f.rs -L $(TMPDIR)/e1 -L $(TMPDIR)/e2 + $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L $(TMPDIR)/e2 + $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2 + # Different hash, errors. + $(RUSTC) e2.rs -o $(TMPDIR)/e2/libe.rlib + $(RUSTC) f.rs -L $(TMPDIR)/e1 -L $(TMPDIR)/e2 && exit 1 || exit 0 + $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L $(TMPDIR)/e2 && exit 1 || exit 0 + $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2 && exit 1 || exit 0 + # Native/dependency paths don't cause errors. + $(RUSTC) f.rs -L native=$(TMPDIR)/e1 -L $(TMPDIR)/e2 + $(RUSTC) f.rs -L dependency=$(TMPDIR)/e1 -L $(TMPDIR)/e2 + $(RUSTC) f.rs -L dependency=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2 diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/a.rs b/src/test/run-make-fulldeps/compiler-lookup-paths/a.rs new file mode 100644 index 00000000000..4ddf231fba2 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/a.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/b.rs b/src/test/run-make-fulldeps/compiler-lookup-paths/b.rs new file mode 100644 index 00000000000..c38300f976e --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/b.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +extern crate a; diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/c.rs b/src/test/run-make-fulldeps/compiler-lookup-paths/c.rs new file mode 100644 index 00000000000..b5c54558a4f --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/c.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +extern crate b; diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/d.rs b/src/test/run-make-fulldeps/compiler-lookup-paths/d.rs new file mode 100644 index 00000000000..295b6e00e41 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/d.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[link(name = "native", kind = "static")] +extern {} diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/e.rs b/src/test/run-make-fulldeps/compiler-lookup-paths/e.rs new file mode 100644 index 00000000000..c0407aba7c9 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/e.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "e"] +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/e2.rs b/src/test/run-make-fulldeps/compiler-lookup-paths/e2.rs new file mode 100644 index 00000000000..f8c8c029c0b --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/e2.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "e"] +#![crate_type = "rlib"] + +pub fn f() {} diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/f.rs b/src/test/run-make-fulldeps/compiler-lookup-paths/f.rs new file mode 100644 index 00000000000..e6160422576 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/f.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +extern crate e; diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/native.c b/src/test/run-make-fulldeps/compiler-lookup-paths/native.c new file mode 100644 index 00000000000..30669470522 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/native.c @@ -0,0 +1,9 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile new file mode 100644 index 00000000000..06d1bb6698e --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile @@ -0,0 +1,17 @@ +-include ../tools.mk + +ifneq (,$(findstring MINGW,$(UNAME))) +ifndef IS_MSVC +all: + $(CXX) foo.cpp -c -o $(TMPDIR)/foo.o + $(AR) crus $(TMPDIR)/libfoo.a $(TMPDIR)/foo.o + $(RUSTC) foo.rs -lfoo -lstdc++ + $(call RUN,foo) +else +all: + +endif +else +all: + +endif diff --git a/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.cpp b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.cpp new file mode 100644 index 00000000000..aac3ba42201 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.cpp @@ -0,0 +1,5 @@ +// ignore-license +extern "C" void foo() { + int *a = new int(3); + delete a; +} diff --git a/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.rs b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.rs new file mode 100644 index 00000000000..293f9d58294 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern { fn foo(); } + +pub fn main() { + unsafe { foo(); } + assert_eq!(7f32.powi(3), 343f32); +} diff --git a/src/test/run-make-fulldeps/crate-data-smoke/Makefile b/src/test/run-make-fulldeps/crate-data-smoke/Makefile new file mode 100644 index 00000000000..1afda457411 --- /dev/null +++ b/src/test/run-make-fulldeps/crate-data-smoke/Makefile @@ -0,0 +1,10 @@ +-include ../tools.mk + +all: + [ `$(RUSTC) --print crate-name crate.rs` = "foo" ] + [ `$(RUSTC) --print file-names crate.rs` = "$(call BIN,foo)" ] + [ `$(RUSTC) --print file-names --crate-type=lib \ + --test crate.rs` = "$(call BIN,foo)" ] + [ `$(RUSTC) --print file-names --test lib.rs` = "$(call BIN,mylib)" ] + $(RUSTC) --print file-names lib.rs + $(RUSTC) --print file-names rlib.rs diff --git a/src/test/run-make-fulldeps/crate-data-smoke/crate.rs b/src/test/run-make-fulldeps/crate-data-smoke/crate.rs new file mode 100644 index 00000000000..305b3dc70a6 --- /dev/null +++ b/src/test/run-make-fulldeps/crate-data-smoke/crate.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] + +// Querying about the crate metadata should *not* parse the entire crate, it +// only needs the crate attributes (which are guaranteed to be at the top) be +// sure that if we have an error like a missing module that we can still query +// about the crate id. +mod error; diff --git a/src/test/run-make-fulldeps/crate-data-smoke/lib.rs b/src/test/run-make-fulldeps/crate-data-smoke/lib.rs new file mode 100644 index 00000000000..639a5d0387b --- /dev/null +++ b/src/test/run-make-fulldeps/crate-data-smoke/lib.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "mylib"] +#![crate_type = "lib"] diff --git a/src/test/run-make-fulldeps/crate-data-smoke/rlib.rs b/src/test/run-make-fulldeps/crate-data-smoke/rlib.rs new file mode 100644 index 00000000000..4e093748600 --- /dev/null +++ b/src/test/run-make-fulldeps/crate-data-smoke/rlib.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "mylib"] +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/crate-name-priority/Makefile b/src/test/run-make-fulldeps/crate-name-priority/Makefile new file mode 100644 index 00000000000..17ecb33ab28 --- /dev/null +++ b/src/test/run-make-fulldeps/crate-name-priority/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --crate-name bar + rm $(TMPDIR)/$(call BIN,bar) + $(RUSTC) foo1.rs + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo1.rs -o $(TMPDIR)/$(call BIN,bar1) + rm $(TMPDIR)/$(call BIN,bar1) diff --git a/src/test/run-make-fulldeps/crate-name-priority/foo.rs b/src/test/run-make-fulldeps/crate-name-priority/foo.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/crate-name-priority/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/crate-name-priority/foo1.rs b/src/test/run-make-fulldeps/crate-name-priority/foo1.rs new file mode 100644 index 00000000000..a397d6bc749 --- /dev/null +++ b/src/test/run-make-fulldeps/crate-name-priority/foo1.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] + +fn main() {} diff --git a/src/test/run-make-fulldeps/debug-assertions/Makefile b/src/test/run-make-fulldeps/debug-assertions/Makefile new file mode 100644 index 00000000000..76ada90f1e2 --- /dev/null +++ b/src/test/run-make-fulldeps/debug-assertions/Makefile @@ -0,0 +1,25 @@ +-include ../tools.mk + +all: + $(RUSTC) debug.rs -C debug-assertions=no + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=0 + $(call RUN,debug) bad + $(RUSTC) debug.rs -C opt-level=1 + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=2 + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=3 + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=s + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=z + $(call RUN,debug) good + $(RUSTC) debug.rs -O + $(call RUN,debug) good + $(RUSTC) debug.rs + $(call RUN,debug) bad + $(RUSTC) debug.rs -C debug-assertions=yes -O + $(call RUN,debug) bad + $(RUSTC) debug.rs -C debug-assertions=yes -C opt-level=1 + $(call RUN,debug) bad diff --git a/src/test/run-make-fulldeps/debug-assertions/debug.rs b/src/test/run-make-fulldeps/debug-assertions/debug.rs new file mode 100644 index 00000000000..65682cb86c3 --- /dev/null +++ b/src/test/run-make-fulldeps/debug-assertions/debug.rs @@ -0,0 +1,43 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![deny(warnings)] + +use std::env; +use std::thread; + +fn main() { + let should_fail = env::args().nth(1) == Some("bad".to_string()); + + assert_eq!(thread::spawn(debug_assert_eq).join().is_err(), should_fail); + assert_eq!(thread::spawn(debug_assert).join().is_err(), should_fail); + assert_eq!(thread::spawn(overflow).join().is_err(), should_fail); +} + +fn debug_assert_eq() { + let mut hit1 = false; + let mut hit2 = false; + debug_assert_eq!({ hit1 = true; 1 }, { hit2 = true; 2 }); + assert!(!hit1); + assert!(!hit2); +} + +fn debug_assert() { + let mut hit = false; + debug_assert!({ hit = true; false }); + assert!(!hit); +} + +fn overflow() { + fn add(a: u8, b: u8) -> u8 { a + b } + + add(200u8, 200u8); +} diff --git a/src/test/run-make-fulldeps/dep-info-doesnt-run-much/Makefile b/src/test/run-make-fulldeps/dep-info-doesnt-run-much/Makefile new file mode 100644 index 00000000000..2fd84639f21 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info-doesnt-run-much/Makefile @@ -0,0 +1,4 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs --emit dep-info diff --git a/src/test/run-make-fulldeps/dep-info-doesnt-run-much/foo.rs b/src/test/run-make-fulldeps/dep-info-doesnt-run-much/foo.rs new file mode 100644 index 00000000000..35911821044 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info-doesnt-run-much/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// We're only emitting dep info, so we shouldn't be running static analysis to +// figure out that this program is erroneous. +fn main() { + let a: u8 = "a"; +} diff --git a/src/test/run-make-fulldeps/dep-info-spaces/Makefile b/src/test/run-make-fulldeps/dep-info-spaces/Makefile new file mode 100644 index 00000000000..82686ffdd9d --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info-spaces/Makefile @@ -0,0 +1,28 @@ +-include ../tools.mk + +# FIXME: ignore freebsd/windows +# (windows: see `../dep-info/Makefile`) +ifneq ($(shell uname),FreeBSD) +ifndef IS_WINDOWS +all: + cp lib.rs $(TMPDIR)/ + cp 'foo foo.rs' $(TMPDIR)/ + cp bar.rs $(TMPDIR)/ + $(RUSTC) --emit link,dep-info --crate-type=lib $(TMPDIR)/lib.rs + sleep 1 + touch $(TMPDIR)/'foo foo.rs' + -rm -f $(TMPDIR)/done + $(MAKE) -drf Makefile.foo + rm $(TMPDIR)/done + pwd + $(MAKE) -drf Makefile.foo + rm $(TMPDIR)/done && exit 1 || exit 0 +else +all: + +endif + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/dep-info-spaces/Makefile.foo b/src/test/run-make-fulldeps/dep-info-spaces/Makefile.foo new file mode 100644 index 00000000000..80a5d4333cd --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info-spaces/Makefile.foo @@ -0,0 +1,7 @@ +LIB := $(shell $(RUSTC) --print file-names --crate-type=lib $(TMPDIR)/lib.rs) + +$(TMPDIR)/$(LIB): + $(RUSTC) --emit link,dep-info --crate-type=lib $(TMPDIR)/lib.rs + touch $(TMPDIR)/done + +-include $(TMPDIR)/lib.d diff --git a/src/test/run-make-fulldeps/dep-info-spaces/bar.rs b/src/test/run-make-fulldeps/dep-info-spaces/bar.rs new file mode 100644 index 00000000000..4c79f7e2855 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info-spaces/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/dep-info-spaces/foo foo.rs b/src/test/run-make-fulldeps/dep-info-spaces/foo foo.rs new file mode 100644 index 00000000000..2661b1f4eb4 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info-spaces/foo foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/run-make-fulldeps/dep-info-spaces/lib.rs b/src/test/run-make-fulldeps/dep-info-spaces/lib.rs new file mode 100644 index 00000000000..bfbe41baeac --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info-spaces/lib.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[path="foo foo.rs"] +pub mod foo; + +pub mod bar; diff --git a/src/test/run-make-fulldeps/dep-info/Makefile b/src/test/run-make-fulldeps/dep-info/Makefile new file mode 100644 index 00000000000..9b79d1af521 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info/Makefile @@ -0,0 +1,34 @@ +-include ../tools.mk + +# FIXME: ignore freebsd/windows +# on windows `rustc --dep-info` produces Makefile dependency with +# windows native paths (e.g. `c:\path\to\libfoo.a`) +# but msys make seems to fail to recognize such paths, so test fails. +ifneq ($(shell uname),FreeBSD) +ifndef IS_WINDOWS +all: + cp *.rs $(TMPDIR) + $(RUSTC) --emit dep-info,link --crate-type=lib $(TMPDIR)/lib.rs + sleep 2 + touch $(TMPDIR)/foo.rs + -rm -f $(TMPDIR)/done + $(MAKE) -drf Makefile.foo + sleep 2 + rm $(TMPDIR)/done + pwd + $(MAKE) -drf Makefile.foo + rm $(TMPDIR)/done && exit 1 || exit 0 + + # When a source file is deleted `make` should still work + rm $(TMPDIR)/bar.rs + cp $(TMPDIR)/lib2.rs $(TMPDIR)/lib.rs + $(MAKE) -drf Makefile.foo +else +all: + +endif + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/dep-info/Makefile.foo b/src/test/run-make-fulldeps/dep-info/Makefile.foo new file mode 100644 index 00000000000..e5df31f88c1 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info/Makefile.foo @@ -0,0 +1,7 @@ +LIB := $(shell $(RUSTC) --print file-names --crate-type=lib lib.rs) + +$(TMPDIR)/$(LIB): + $(RUSTC) --emit dep-info,link --crate-type=lib lib.rs + touch $(TMPDIR)/done + +-include $(TMPDIR)/foo.d diff --git a/src/test/run-make-fulldeps/dep-info/bar.rs b/src/test/run-make-fulldeps/dep-info/bar.rs new file mode 100644 index 00000000000..4c79f7e2855 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/dep-info/foo.rs b/src/test/run-make-fulldeps/dep-info/foo.rs new file mode 100644 index 00000000000..2661b1f4eb4 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/run-make-fulldeps/dep-info/lib.rs b/src/test/run-make-fulldeps/dep-info/lib.rs new file mode 100644 index 00000000000..7c15785bbb2 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info/lib.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] + +pub mod foo; +pub mod bar; diff --git a/src/test/run-make-fulldeps/dep-info/lib2.rs b/src/test/run-make-fulldeps/dep-info/lib2.rs new file mode 100644 index 00000000000..1b70fb4eb4b --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info/lib2.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] + +pub mod foo; diff --git a/src/test/run-make-fulldeps/duplicate-output-flavors/Makefile b/src/test/run-make-fulldeps/duplicate-output-flavors/Makefile new file mode 100644 index 00000000000..e33279966c9 --- /dev/null +++ b/src/test/run-make-fulldeps/duplicate-output-flavors/Makefile @@ -0,0 +1,5 @@ +include ../tools.mk + +all: + $(RUSTC) --crate-type=rlib foo.rs + $(RUSTC) --crate-type=rlib,rlib foo.rs diff --git a/src/test/run-make-fulldeps/duplicate-output-flavors/foo.rs b/src/test/run-make-fulldeps/duplicate-output-flavors/foo.rs new file mode 100644 index 00000000000..04d3ae67207 --- /dev/null +++ b/src/test/run-make-fulldeps/duplicate-output-flavors/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/dylib-chain/Makefile b/src/test/run-make-fulldeps/dylib-chain/Makefile new file mode 100644 index 00000000000..a33177197b1 --- /dev/null +++ b/src/test/run-make-fulldeps/dylib-chain/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +all: + $(RUSTC) m1.rs -C prefer-dynamic + $(RUSTC) m2.rs -C prefer-dynamic + $(RUSTC) m3.rs -C prefer-dynamic + $(RUSTC) m4.rs + $(call RUN,m4) + $(call REMOVE_DYLIBS,m1) + $(call REMOVE_DYLIBS,m2) + $(call REMOVE_DYLIBS,m3) + $(call FAIL,m4) diff --git a/src/test/run-make-fulldeps/dylib-chain/m1.rs b/src/test/run-make-fulldeps/dylib-chain/m1.rs new file mode 100644 index 00000000000..5437c935c4e --- /dev/null +++ b/src/test/run-make-fulldeps/dylib-chain/m1.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] +pub fn m1() {} diff --git a/src/test/run-make-fulldeps/dylib-chain/m2.rs b/src/test/run-make-fulldeps/dylib-chain/m2.rs new file mode 100644 index 00000000000..b464f32eae2 --- /dev/null +++ b/src/test/run-make-fulldeps/dylib-chain/m2.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] +extern crate m1; + +pub fn m2() { m1::m1() } diff --git a/src/test/run-make-fulldeps/dylib-chain/m3.rs b/src/test/run-make-fulldeps/dylib-chain/m3.rs new file mode 100644 index 00000000000..bf431cc827b --- /dev/null +++ b/src/test/run-make-fulldeps/dylib-chain/m3.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] +extern crate m2; + +pub fn m3() { m2::m2() } diff --git a/src/test/run-make-fulldeps/dylib-chain/m4.rs b/src/test/run-make-fulldeps/dylib-chain/m4.rs new file mode 100644 index 00000000000..6c2a6685802 --- /dev/null +++ b/src/test/run-make-fulldeps/dylib-chain/m4.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate m3; + +fn main() { m3::m3() } diff --git a/src/test/run-make-fulldeps/emit/Makefile b/src/test/run-make-fulldeps/emit/Makefile new file mode 100644 index 00000000000..e0b57107e5b --- /dev/null +++ b/src/test/run-make-fulldeps/emit/Makefile @@ -0,0 +1,21 @@ +-include ../tools.mk + +all: + $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 + $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 + $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 + $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 + $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 + $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 diff --git a/src/test/run-make-fulldeps/emit/test-24876.rs b/src/test/run-make-fulldeps/emit/test-24876.rs new file mode 100644 index 00000000000..ab69decbf00 --- /dev/null +++ b/src/test/run-make-fulldeps/emit/test-24876.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Checks for issue #24876 + +fn main() { + let mut v = 0; + for i in 0..0 { + v += i; + } + println!("{}", v) +} diff --git a/src/test/run-make-fulldeps/emit/test-26235.rs b/src/test/run-make-fulldeps/emit/test-26235.rs new file mode 100644 index 00000000000..97b58a3671b --- /dev/null +++ b/src/test/run-make-fulldeps/emit/test-26235.rs @@ -0,0 +1,56 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Checks for issue #26235 + +fn main() { + use std::thread; + + type Key = u32; + const NUM_THREADS: usize = 2; + + #[derive(Clone,Copy)] + struct Stats { + upsert: S, + delete: S, + insert: S, + update: S + }; + + impl Stats where S: Copy { + fn dot(self, s: Stats, f: F) -> Stats where F: Fn(S, T) -> B { + let Stats { upsert: u1, delete: d1, insert: i1, update: p1 } = self; + let Stats { upsert: u2, delete: d2, insert: i2, update: p2 } = s; + Stats { upsert: f(u1, u2), delete: f(d1, d2), insert: f(i1, i2), update: f(p1, p2) } + } + + fn new(init: S) -> Self { + Stats { upsert: init, delete: init, insert: init, update: init } + } + } + + fn make_threads() -> Vec> { + let mut t = Vec::with_capacity(NUM_THREADS); + for _ in 0..NUM_THREADS { + t.push(thread::spawn(move || {})); + } + t + } + + let stats = [Stats::new(0); NUM_THREADS]; + make_threads(); + + { + let Stats { ref upsert, ref delete, ref insert, ref update } = stats.iter().fold( + Stats::new(0), |res, &s| res.dot(s, |x: Key, y: Key| x.wrapping_add(y))); + println!("upserts: {}, deletes: {}, inserts: {}, updates: {}", + upsert, delete, insert, update); + } +} diff --git a/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/Makefile b/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/Makefile new file mode 100644 index 00000000000..fef12c4da67 --- /dev/null +++ b/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs --crate-type staticlib + $(RUSTC) bar.rs 2>&1 | $(CGREP) "found staticlib" diff --git a/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/bar.rs b/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/bar.rs new file mode 100644 index 00000000000..5ab3e5ee99d --- /dev/null +++ b/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::foo(); +} diff --git a/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/foo.rs b/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/foo.rs new file mode 100644 index 00000000000..222d98a12de --- /dev/null +++ b/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/run-make-fulldeps/error-writing-dependencies/Makefile b/src/test/run-make-fulldeps/error-writing-dependencies/Makefile new file mode 100644 index 00000000000..cbc96901a38 --- /dev/null +++ b/src/test/run-make-fulldeps/error-writing-dependencies/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: + # Let's get a nice error message + $(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | \ + $(CGREP) "error writing dependencies" + # Make sure the filename shows up + $(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | $(CGREP) "baz" diff --git a/src/test/run-make-fulldeps/error-writing-dependencies/foo.rs b/src/test/run-make-fulldeps/error-writing-dependencies/foo.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/error-writing-dependencies/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/extern-diff-internal-name/Makefile b/src/test/run-make-fulldeps/extern-diff-internal-name/Makefile new file mode 100644 index 00000000000..b84e930757b --- /dev/null +++ b/src/test/run-make-fulldeps/extern-diff-internal-name/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) lib.rs + $(RUSTC) test.rs --extern foo=$(TMPDIR)/libbar.rlib diff --git a/src/test/run-make-fulldeps/extern-diff-internal-name/lib.rs b/src/test/run-make-fulldeps/extern-diff-internal-name/lib.rs new file mode 100644 index 00000000000..e8779bba13c --- /dev/null +++ b/src/test/run-make-fulldeps/extern-diff-internal-name/lib.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "bar"] +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/extern-diff-internal-name/test.rs b/src/test/run-make-fulldeps/extern-diff-internal-name/test.rs new file mode 100644 index 00000000000..11e042c8c4a --- /dev/null +++ b/src/test/run-make-fulldeps/extern-diff-internal-name/test.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_use] +extern crate foo; + +fn main() { +} diff --git a/src/test/run-make-fulldeps/extern-flag-disambiguates/Makefile b/src/test/run-make-fulldeps/extern-flag-disambiguates/Makefile new file mode 100644 index 00000000000..81930e969a9 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-disambiguates/Makefile @@ -0,0 +1,25 @@ +-include ../tools.mk + +# Attempt to build this dependency tree: +# +# A.1 A.2 +# |\ | +# | \ | +# B \ C +# \ | / +# \|/ +# D +# +# Note that A.1 and A.2 are crates with the same name. + +all: + $(RUSTC) -C metadata=1 -C extra-filename=-1 a.rs + $(RUSTC) -C metadata=2 -C extra-filename=-2 a.rs + $(RUSTC) b.rs --extern a=$(TMPDIR)/liba-1.rlib + $(RUSTC) c.rs --extern a=$(TMPDIR)/liba-2.rlib + @echo before + $(RUSTC) --cfg before d.rs --extern a=$(TMPDIR)/liba-1.rlib + $(call RUN,d) + @echo after + $(RUSTC) --cfg after d.rs --extern a=$(TMPDIR)/liba-1.rlib + $(call RUN,d) diff --git a/src/test/run-make-fulldeps/extern-flag-disambiguates/a.rs b/src/test/run-make-fulldeps/extern-flag-disambiguates/a.rs new file mode 100644 index 00000000000..ac92aede789 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-disambiguates/a.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "a"] +#![crate_type = "rlib"] + +static FOO: usize = 3; + +pub fn token() -> &'static usize { &FOO } diff --git a/src/test/run-make-fulldeps/extern-flag-disambiguates/b.rs b/src/test/run-make-fulldeps/extern-flag-disambiguates/b.rs new file mode 100644 index 00000000000..8ae238f5a48 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-disambiguates/b.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "b"] +#![crate_type = "rlib"] + +extern crate a; + +static FOO: usize = 3; + +pub fn token() -> &'static usize { &FOO } +pub fn a_token() -> &'static usize { a::token() } diff --git a/src/test/run-make-fulldeps/extern-flag-disambiguates/c.rs b/src/test/run-make-fulldeps/extern-flag-disambiguates/c.rs new file mode 100644 index 00000000000..6eccdf7e5c8 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-disambiguates/c.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "c"] +#![crate_type = "rlib"] + +extern crate a; + +static FOO: usize = 3; + +pub fn token() -> &'static usize { &FOO } +pub fn a_token() -> &'static usize { a::token() } diff --git a/src/test/run-make-fulldeps/extern-flag-disambiguates/d.rs b/src/test/run-make-fulldeps/extern-flag-disambiguates/d.rs new file mode 100644 index 00000000000..9923ff83a91 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-disambiguates/d.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[cfg(before)] extern crate a; +extern crate b; +extern crate c; +#[cfg(after)] extern crate a; + +fn t(a: &'static usize) -> usize { a as *const _ as usize } + +fn main() { + assert_eq!(t(a::token()), t(b::a_token())); + assert!(t(a::token()) != t(c::a_token())); +} diff --git a/src/test/run-make-fulldeps/extern-flag-fun/Makefile b/src/test/run-make-fulldeps/extern-flag-fun/Makefile new file mode 100644 index 00000000000..a9f25853350 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-fun/Makefile @@ -0,0 +1,17 @@ +-include ../tools.mk + +all: + $(RUSTC) bar.rs --crate-type=rlib + $(RUSTC) bar.rs --crate-type=rlib -C extra-filename=-a + $(RUSTC) bar-alt.rs --crate-type=rlib + $(RUSTC) foo.rs --extern hello && exit 1 || exit 0 + $(RUSTC) foo.rs --extern bar=no-exist && exit 1 || exit 0 + $(RUSTC) foo.rs --extern bar=foo.rs && exit 1 || exit 0 + $(RUSTC) foo.rs \ + --extern bar=$(TMPDIR)/libbar.rlib \ + --extern bar=$(TMPDIR)/libbar-alt.rlib \ + && exit 1 || exit 0 + $(RUSTC) foo.rs \ + --extern bar=$(TMPDIR)/libbar.rlib \ + --extern bar=$(TMPDIR)/libbar-a.rlib + $(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib diff --git a/src/test/run-make-fulldeps/extern-flag-fun/bar-alt.rs b/src/test/run-make-fulldeps/extern-flag-fun/bar-alt.rs new file mode 100644 index 00000000000..d6ebd9d896f --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-fun/bar-alt.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn f() {} diff --git a/src/test/run-make-fulldeps/extern-flag-fun/bar.rs b/src/test/run-make-fulldeps/extern-flag-fun/bar.rs new file mode 100644 index 00000000000..e6c76025738 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-fun/bar.rs @@ -0,0 +1,9 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/run-make-fulldeps/extern-flag-fun/foo.rs b/src/test/run-make-fulldeps/extern-flag-fun/foo.rs new file mode 100644 index 00000000000..52741668640 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-fun/foo.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar; + +fn main() {} diff --git a/src/test/run-make-fulldeps/extern-fn-generic/Makefile b/src/test/run-make-fulldeps/extern-fn-generic/Makefile new file mode 100644 index 00000000000..cf897dba1f2 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-generic/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,test) + $(RUSTC) testcrate.rs + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/src/test/run-make-fulldeps/extern-fn-generic/test.c b/src/test/run-make-fulldeps/extern-fn-generic/test.c new file mode 100644 index 00000000000..f9faef64afc --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-generic/test.c @@ -0,0 +1,17 @@ +// ignore-license +#include + +typedef struct TestStruct { + uint8_t x; + int32_t y; +} TestStruct; + +typedef int callback(TestStruct s); + +uint32_t call(callback *c) { + TestStruct s; + s.x = 'a'; + s.y = 3; + + return c(s); +} diff --git a/src/test/run-make-fulldeps/extern-fn-generic/test.rs b/src/test/run-make-fulldeps/extern-fn-generic/test.rs new file mode 100644 index 00000000000..8f5ff091b3b --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-generic/test.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate testcrate; + +extern "C" fn bar(ts: testcrate::TestStruct) -> T { ts.y } + +#[link(name = "test", kind = "static")] +extern { + fn call(c: extern "C" fn(testcrate::TestStruct) -> i32) -> i32; +} + +fn main() { + // Let's test calling it cross crate + let back = unsafe { + testcrate::call(testcrate::foo::) + }; + assert_eq!(3, back); + + // And just within this crate + let back = unsafe { + call(bar::) + }; + assert_eq!(3, back); +} diff --git a/src/test/run-make-fulldeps/extern-fn-generic/testcrate.rs b/src/test/run-make-fulldeps/extern-fn-generic/testcrate.rs new file mode 100644 index 00000000000..d02c05047c0 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-generic/testcrate.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +#[repr(C)] +pub struct TestStruct { + pub x: u8, + pub y: T +} + +pub extern "C" fn foo(ts: TestStruct) -> T { ts.y } + +#[link(name = "test", kind = "static")] +extern { + pub fn call(c: extern "C" fn(TestStruct) -> i32) -> i32; +} diff --git a/src/test/run-make-fulldeps/extern-fn-mangle/Makefile b/src/test/run-make-fulldeps/extern-fn-mangle/Makefile new file mode 100644 index 00000000000..042048ec25f --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-mangle/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,test) + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/src/test/run-make-fulldeps/extern-fn-mangle/test.c b/src/test/run-make-fulldeps/extern-fn-mangle/test.c new file mode 100644 index 00000000000..1a9855dedec --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-mangle/test.c @@ -0,0 +1,9 @@ +// ignore-license +#include + +uint32_t foo(); +uint32_t bar(); + +uint32_t add() { + return foo() + bar(); +} diff --git a/src/test/run-make-fulldeps/extern-fn-mangle/test.rs b/src/test/run-make-fulldeps/extern-fn-mangle/test.rs new file mode 100644 index 00000000000..35b5a9278a4 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-mangle/test.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern "C" fn foo() -> i32 { 3 } + +#[no_mangle] +pub extern "C" fn bar() -> i32 { 5 } + +#[link(name = "test", kind = "static")] +extern { + fn add() -> i32; +} + +fn main() { + let back = unsafe { add() }; + assert_eq!(8, back); +} diff --git a/src/test/run-make-fulldeps/extern-fn-reachable/Makefile b/src/test/run-make-fulldeps/extern-fn-reachable/Makefile new file mode 100644 index 00000000000..79a9a3c640f --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-reachable/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +# This overrides the LD_LIBRARY_PATH for RUN +TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR) + +all: + $(RUSTC) dylib.rs -o $(TMPDIR)/libdylib.so -C prefer-dynamic + $(RUSTC) main.rs -C prefer-dynamic + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/extern-fn-reachable/dylib.rs b/src/test/run-make-fulldeps/extern-fn-reachable/dylib.rs new file mode 100644 index 00000000000..f24265e7a52 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-reachable/dylib.rs @@ -0,0 +1,24 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] +#![allow(dead_code)] + +#[no_mangle] pub extern "C" fn fun1() {} +#[no_mangle] extern "C" fn fun2() {} + +mod foo { + #[no_mangle] pub extern "C" fn fun3() {} +} +pub mod bar { + #[no_mangle] pub extern "C" fn fun4() {} +} + +#[no_mangle] pub fn fun5() {} diff --git a/src/test/run-make-fulldeps/extern-fn-reachable/main.rs b/src/test/run-make-fulldeps/extern-fn-reachable/main.rs new file mode 100644 index 00000000000..27387332c1c --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-reachable/main.rs @@ -0,0 +1,28 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_private)] + +extern crate rustc_metadata; + +use rustc_metadata::dynamic_lib::DynamicLibrary; +use std::path::Path; + +pub fn main() { + unsafe { + let path = Path::new("libdylib.so"); + let a = DynamicLibrary::open(Some(&path)).unwrap(); + assert!(a.symbol::("fun1").is_ok()); + assert!(a.symbol::("fun2").is_err()); + assert!(a.symbol::("fun3").is_err()); + assert!(a.symbol::("fun4").is_ok()); + assert!(a.symbol::("fun5").is_ok()); + } +} diff --git a/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/Makefile b/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/Makefile new file mode 100644 index 00000000000..042048ec25f --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,test) + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.c b/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.c new file mode 100644 index 00000000000..25cd6da10b8 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.c @@ -0,0 +1,324 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#include +#include + +struct Rect { + int32_t a; + int32_t b; + int32_t c; + int32_t d; +}; + +struct BiggerRect { + struct Rect s; + int32_t a; + int32_t b; +}; + +struct FloatRect { + int32_t a; + int32_t b; + double c; +}; + +struct Huge { + int32_t a; + int32_t b; + int32_t c; + int32_t d; + int32_t e; +}; + +struct FloatPoint { + double x; + double y; +}; + +struct FloatOne { + double x; +}; + +struct IntOdd { + int8_t a; + int8_t b; + int8_t c; +}; + +// System V x86_64 ABI: +// a, b, c, d, e should be in registers +// s should be byval pointer +// +// Win64 ABI: +// a, b, c, d should be in registers +// e should be on the stack +// s should be byval pointer +void byval_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(c == 3); + assert(d == 4); + assert(e == 5); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); +} + +// System V x86_64 ABI: +// a, b, c, d, e, f should be in registers +// s should be byval pointer on the stack +// +// Win64 ABI: +// a, b, c, d should be in registers +// e, f should be on the stack +// s should be byval pointer on the stack +void byval_many_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, + int32_t f, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(c == 3); + assert(d == 4); + assert(e == 5); + assert(f == 6); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); +} + +// System V x86_64 ABI: +// a, b, c, d, e, f, g should be in sse registers +// s should be split across 2 registers +// t should be byval pointer +// +// Win64 ABI: +// a, b, c, d should be in sse registers +// e, f, g should be on the stack +// s should be on the stack (treated as 2 i64's) +// t should be on the stack (treated as an i64 and a double) +void byval_rect_floats(float a, float b, double c, float d, float e, + float f, double g, struct Rect s, struct FloatRect t) { + assert(a == 1.); + assert(b == 2.); + assert(c == 3.); + assert(d == 4.); + assert(e == 5.); + assert(f == 6.); + assert(g == 7.); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); + assert(t.a == 3489); + assert(t.b == 3490); + assert(t.c == 8.); +} + +// System V x86_64 ABI: +// a, b, d, e, f should be in registers +// c passed via sse registers +// s should be byval pointer +// +// Win64 ABI: +// a, b, d should be in registers +// c passed via sse registers +// e, f should be on the stack +// s should be byval pointer +void byval_rect_with_float(int32_t a, int32_t b, float c, int32_t d, + int32_t e, int32_t f, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(c == 3.); + assert(d == 4); + assert(e == 5); + assert(f == 6); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); +} + +// System V x86_64 ABI: +// a, b, d, e, f should be byval pointer (on the stack) +// g passed via register (fixes #41375) +// +// Win64 ABI: +// a, b, d, e, f, g should be byval pointer +void byval_rect_with_many_huge(struct Huge a, struct Huge b, struct Huge c, + struct Huge d, struct Huge e, struct Huge f, + struct Rect g) { + assert(g.a == 123); + assert(g.b == 456); + assert(g.c == 789); + assert(g.d == 420); +} + +// System V x86_64 & Win64 ABI: +// a, b should be in registers +// s should be split across 2 integer registers +void split_rect(int32_t a, int32_t b, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); +} + +// System V x86_64 & Win64 ABI: +// a, b should be in sse registers +// s should be split across integer & sse registers +void split_rect_floats(float a, float b, struct FloatRect s) { + assert(a == 1.); + assert(b == 2.); + assert(s.a == 3489); + assert(s.b == 3490); + assert(s.c == 8.); +} + +// System V x86_64 ABI: +// a, b, d, f should be in registers +// c, e passed via sse registers +// s should be split across 2 registers +// +// Win64 ABI: +// a, b, d should be in registers +// c passed via sse registers +// e, f should be on the stack +// s should be on the stack (treated as 2 i64's) +void split_rect_with_floats(int32_t a, int32_t b, float c, + int32_t d, float e, int32_t f, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(c == 3.); + assert(d == 4); + assert(e == 5.); + assert(f == 6); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); +} + +// System V x86_64 & Win64 ABI: +// a, b, c should be in registers +// s should be split across 2 registers +// t should be a byval pointer +void split_and_byval_rect(int32_t a, int32_t b, int32_t c, struct Rect s, struct Rect t) { + assert(a == 1); + assert(b == 2); + assert(c == 3); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); + assert(t.a == 553); + assert(t.b == 554); + assert(t.c == 555); + assert(t.d == 556); +} + +// System V x86_64 & Win64 ABI: +// a, b should in registers +// s and return should be split across 2 registers +struct Rect split_ret_byval_struct(int32_t a, int32_t b, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); + return s; +} + +// System V x86_64 & Win64 ABI: +// a, b, c, d should be in registers +// return should be in a hidden sret pointer +// s should be a byval pointer +struct BiggerRect sret_byval_struct(int32_t a, int32_t b, int32_t c, int32_t d, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(c == 3); + assert(d == 4); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); + + struct BiggerRect t; + t.s = s; t.a = 27834; t.b = 7657; + return t; +} + +// System V x86_64 & Win64 ABI: +// a, b should be in registers +// return should be in a hidden sret pointer +// s should be split across 2 registers +struct BiggerRect sret_split_struct(int32_t a, int32_t b, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); + + struct BiggerRect t; + t.s = s; t.a = 27834; t.b = 7657; + return t; +} + +// System V x86_64 & Win64 ABI: +// s should be byval pointer (since sizeof(s) > 16) +// return should in a hidden sret pointer +struct Huge huge_struct(struct Huge s) { + assert(s.a == 5647); + assert(s.b == 5648); + assert(s.c == 5649); + assert(s.d == 5650); + assert(s.e == 5651); + + return s; +} + +// System V x86_64 ABI: +// p should be in registers +// return should be in registers +// +// Win64 ABI and 64-bit PowerPC ELFv1 ABI: +// p should be a byval pointer +// return should be in a hidden sret pointer +struct FloatPoint float_point(struct FloatPoint p) { + assert(p.x == 5.); + assert(p.y == -3.); + + return p; +} + +// 64-bit PowerPC ELFv1 ABI: +// f1 should be in a register +// return should be in a hidden sret pointer +struct FloatOne float_one(struct FloatOne f1) { + assert(f1.x == 7.); + + return f1; +} + +// 64-bit PowerPC ELFv1 ABI: +// i should be in the least-significant bits of a register +// return should be in a hidden sret pointer +struct IntOdd int_odd(struct IntOdd i) { + assert(i.a == 1); + assert(i.b == 2); + assert(i.c == 3); + + return i; +} diff --git a/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.rs b/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.rs new file mode 100644 index 00000000000..54a4f868eb4 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.rs @@ -0,0 +1,144 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Passing structs via FFI should work regardless of whether +// they get passed in multiple registers, byval pointers or the stack + +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(C)] +struct Rect { + a: i32, + b: i32, + c: i32, + d: i32 +} + +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(C)] +struct BiggerRect { + s: Rect, + a: i32, + b: i32 +} + +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(C)] +struct FloatRect { + a: i32, + b: i32, + c: f64 +} + +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(C)] +struct Huge { + a: i32, + b: i32, + c: i32, + d: i32, + e: i32 +} + +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(C)] +struct FloatPoint { + x: f64, + y: f64 +} + +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(C)] +struct FloatOne { + x: f64, +} + +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(C)] +struct IntOdd { + a: i8, + b: i8, + c: i8, +} + +#[link(name = "test", kind = "static")] +extern { + fn byval_rect(a: i32, b: i32, c: i32, d: i32, e: i32, s: Rect); + + fn byval_many_rect(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, s: Rect); + + fn byval_rect_floats(a: f32, b: f32, c: f64, d: f32, e: f32, + f: f32, g: f64, s: Rect, t: FloatRect); + + fn byval_rect_with_float(a: i32, b: i32, c: f32, d: i32, e: i32, f: i32, s: Rect); + + fn byval_rect_with_many_huge(a: Huge, b: Huge, c: Huge, d: Huge, e: Huge, f: Huge, g: Rect); + + fn split_rect(a: i32, b: i32, s: Rect); + + fn split_rect_floats(a: f32, b: f32, s: FloatRect); + + fn split_rect_with_floats(a: i32, b: i32, c: f32, d: i32, e: f32, f: i32, s: Rect); + + fn split_and_byval_rect(a: i32, b: i32, c: i32, s: Rect, t: Rect); + + fn split_ret_byval_struct(a: i32, b: i32, s: Rect) -> Rect; + + fn sret_byval_struct(a: i32, b: i32, c: i32, d: i32, s: Rect) -> BiggerRect; + + fn sret_split_struct(a: i32, b: i32, s: Rect) -> BiggerRect; + + fn huge_struct(s: Huge) -> Huge; + + fn float_point(p: FloatPoint) -> FloatPoint; + + fn float_one(f: FloatOne) -> FloatOne; + + fn int_odd(i: IntOdd) -> IntOdd; +} + +fn main() { + let s = Rect { a: 553, b: 554, c: 555, d: 556 }; + let t = BiggerRect { s: s, a: 27834, b: 7657 }; + let u = FloatRect { a: 3489, b: 3490, c: 8. }; + let v = Huge { a: 5647, b: 5648, c: 5649, d: 5650, e: 5651 }; + let p = FloatPoint { x: 5., y: -3. }; + let f1 = FloatOne { x: 7. }; + let i = IntOdd { a: 1, b: 2, c: 3 }; + + unsafe { + byval_rect(1, 2, 3, 4, 5, s); + byval_many_rect(1, 2, 3, 4, 5, 6, s); + byval_rect_floats(1., 2., 3., 4., 5., 6., 7., s, u); + byval_rect_with_float(1, 2, 3.0, 4, 5, 6, s); + byval_rect_with_many_huge(v, v, v, v, v, v, Rect { + a: 123, + b: 456, + c: 789, + d: 420 + }); + split_rect(1, 2, s); + split_rect_floats(1., 2., u); + split_rect_with_floats(1, 2, 3.0, 4, 5.0, 6, s); + split_and_byval_rect(1, 2, 3, s, s); + split_rect(1, 2, s); + assert_eq!(huge_struct(v), v); + assert_eq!(split_ret_byval_struct(1, 2, s), s); + assert_eq!(sret_byval_struct(1, 2, 3, 4, s), t); + assert_eq!(sret_split_struct(1, 2, s), t); + assert_eq!(float_point(p), p); + assert_eq!(int_odd(i), i); + + // MSVC/GCC/Clang are not consistent in the ABI of single-float aggregates. + // x86_64: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82028 + // i686: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82041 + #[cfg(not(all(windows, target_env = "gnu")))] + assert_eq!(float_one(f1), f1); + } +} diff --git a/src/test/run-make-fulldeps/extern-fn-with-extern-types/Makefile b/src/test/run-make-fulldeps/extern-fn-with-extern-types/Makefile new file mode 100644 index 00000000000..8977e14c3ad --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-extern-types/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,ctest) + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/src/test/run-make-fulldeps/extern-fn-with-extern-types/ctest.c b/src/test/run-make-fulldeps/extern-fn-with-extern-types/ctest.c new file mode 100644 index 00000000000..c3d6166fb12 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-extern-types/ctest.c @@ -0,0 +1,17 @@ +// ignore-license +#include +#include + +typedef struct data { + uint32_t magic; +} data; + +data* data_create(uint32_t magic) { + static data d; + d.magic = magic; + return &d; +} + +uint32_t data_get(data* p) { + return p->magic; +} diff --git a/src/test/run-make-fulldeps/extern-fn-with-extern-types/test.rs b/src/test/run-make-fulldeps/extern-fn-with-extern-types/test.rs new file mode 100644 index 00000000000..9d6c87885b1 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-extern-types/test.rs @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(extern_types)] + +#[link(name = "ctest", kind = "static")] +extern { + type data; + + fn data_create(magic: u32) -> *mut data; + fn data_get(data: *mut data) -> u32; +} + +const MAGIC: u32 = 0xdeadbeef; +fn main() { + unsafe { + let data = data_create(MAGIC); + assert_eq!(data_get(data), MAGIC); + } +} diff --git a/src/test/run-make-fulldeps/extern-fn-with-packed-struct/Makefile b/src/test/run-make-fulldeps/extern-fn-with-packed-struct/Makefile new file mode 100644 index 00000000000..042048ec25f --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-packed-struct/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,test) + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.c b/src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.c new file mode 100644 index 00000000000..4124e202c1d --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.c @@ -0,0 +1,27 @@ +// ignore-license +// Pragma needed cause of gcc bug on windows: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991 + +#include + +#ifdef _MSC_VER +#pragma pack(push,1) +struct Foo { + char a; + short b; + char c; +}; +#else +#pragma pack(1) +struct __attribute__((packed)) Foo { + char a; + short b; + char c; +}; +#endif + +struct Foo foo(struct Foo foo) { + assert(foo.a == 1); + assert(foo.b == 2); + assert(foo.c == 3); + return foo; +} diff --git a/src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.rs b/src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.rs new file mode 100644 index 00000000000..d2540ad6154 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.rs @@ -0,0 +1,30 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[repr(C, packed)] +#[derive(Copy, Clone, Debug, PartialEq)] +struct Foo { + a: i8, + b: i16, + c: i8 +} + +#[link(name = "test", kind = "static")] +extern { + fn foo(f: Foo) -> Foo; +} + +fn main() { + unsafe { + let a = Foo { a: 1, b: 2, c: 3 }; + let b = foo(a); + assert_eq!(a, b); + } +} diff --git a/src/test/run-make-fulldeps/extern-fn-with-union/Makefile b/src/test/run-make-fulldeps/extern-fn-with-union/Makefile new file mode 100644 index 00000000000..71a5407e882 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-union/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,ctest) + $(RUSTC) testcrate.rs + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/src/test/run-make-fulldeps/extern-fn-with-union/ctest.c b/src/test/run-make-fulldeps/extern-fn-with-union/ctest.c new file mode 100644 index 00000000000..8c87c230693 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-union/ctest.c @@ -0,0 +1,11 @@ +// ignore-license +#include +#include + +typedef union TestUnion { + uint64_t bits; +} TestUnion; + +uint64_t give_back(TestUnion tu) { + return tu.bits; +} diff --git a/src/test/run-make-fulldeps/extern-fn-with-union/test.rs b/src/test/run-make-fulldeps/extern-fn-with-union/test.rs new file mode 100644 index 00000000000..f9277ba11f4 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-union/test.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate testcrate; + +use std::mem; + +extern { + fn give_back(tu: testcrate::TestUnion) -> u64; +} + +fn main() { + let magic: u64 = 0xDEADBEEF; + + // Let's test calling it cross crate + let back = unsafe { + testcrate::give_back(mem::transmute(magic)) + }; + assert_eq!(magic, back); + + // And just within this crate + let back = unsafe { + give_back(mem::transmute(magic)) + }; + assert_eq!(magic, back); +} diff --git a/src/test/run-make-fulldeps/extern-fn-with-union/testcrate.rs b/src/test/run-make-fulldeps/extern-fn-with-union/testcrate.rs new file mode 100644 index 00000000000..66978c38511 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-union/testcrate.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +#[repr(C)] +pub struct TestUnion { + _val: u64 +} + +#[link(name = "ctest", kind = "static")] +extern { + pub fn give_back(tu: TestUnion) -> u64; +} diff --git a/src/test/run-make-fulldeps/extern-multiple-copies/Makefile b/src/test/run-make-fulldeps/extern-multiple-copies/Makefile new file mode 100644 index 00000000000..1631aa806af --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: + $(RUSTC) foo1.rs + $(RUSTC) foo2.rs + mkdir $(TMPDIR)/foo + cp $(TMPDIR)/libfoo1.rlib $(TMPDIR)/foo/libfoo1.rlib + $(RUSTC) bar.rs --extern foo1=$(TMPDIR)/libfoo1.rlib -L $(TMPDIR)/foo diff --git a/src/test/run-make-fulldeps/extern-multiple-copies/bar.rs b/src/test/run-make-fulldeps/extern-multiple-copies/bar.rs new file mode 100644 index 00000000000..a50f5de384c --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies/bar.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo2; // foo2 first to exhibit the bug +extern crate foo1; + +fn main() { + /* ... */ +} diff --git a/src/test/run-make-fulldeps/extern-multiple-copies/foo1.rs b/src/test/run-make-fulldeps/extern-multiple-copies/foo1.rs new file mode 100644 index 00000000000..0be200ddcd2 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies/foo1.rs @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/extern-multiple-copies/foo2.rs b/src/test/run-make-fulldeps/extern-multiple-copies/foo2.rs new file mode 100644 index 00000000000..0be200ddcd2 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies/foo2.rs @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/extern-multiple-copies2/Makefile b/src/test/run-make-fulldeps/extern-multiple-copies2/Makefile new file mode 100644 index 00000000000..567d7e78a57 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies2/Makefile @@ -0,0 +1,10 @@ +-include ../tools.mk + +all: + $(RUSTC) foo1.rs + $(RUSTC) foo2.rs + mkdir $(TMPDIR)/foo + cp $(TMPDIR)/libfoo1.rlib $(TMPDIR)/foo/libfoo1.rlib + $(RUSTC) bar.rs \ + --extern foo1=$(TMPDIR)/foo/libfoo1.rlib \ + --extern foo2=$(TMPDIR)/libfoo2.rlib diff --git a/src/test/run-make-fulldeps/extern-multiple-copies2/bar.rs b/src/test/run-make-fulldeps/extern-multiple-copies2/bar.rs new file mode 100644 index 00000000000..b8ac34aa53e --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies2/bar.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_use] +extern crate foo2; // foo2 first to exhibit the bug +#[macro_use] +extern crate foo1; + +fn main() { + foo2::foo2(foo1::A); +} diff --git a/src/test/run-make-fulldeps/extern-multiple-copies2/foo1.rs b/src/test/run-make-fulldeps/extern-multiple-copies2/foo1.rs new file mode 100644 index 00000000000..1787772053b --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies2/foo1.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +pub struct A; + +pub fn foo1(a: A) { + drop(a); +} diff --git a/src/test/run-make-fulldeps/extern-multiple-copies2/foo2.rs b/src/test/run-make-fulldeps/extern-multiple-copies2/foo2.rs new file mode 100644 index 00000000000..bad10304387 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies2/foo2.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[macro_use] +extern crate foo1; + +pub fn foo2(a: foo1::A) { + foo1::foo1(a); +} diff --git a/src/test/run-make-fulldeps/extern-overrides-distribution/Makefile b/src/test/run-make-fulldeps/extern-overrides-distribution/Makefile new file mode 100644 index 00000000000..7d063a4c83c --- /dev/null +++ b/src/test/run-make-fulldeps/extern-overrides-distribution/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) libc.rs -Cmetadata=foo + $(RUSTC) main.rs --extern libc=$(TMPDIR)/liblibc.rlib diff --git a/src/test/run-make-fulldeps/extern-overrides-distribution/libc.rs b/src/test/run-make-fulldeps/extern-overrides-distribution/libc.rs new file mode 100644 index 00000000000..a489d834a92 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-overrides-distribution/libc.rs @@ -0,0 +1,13 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +pub fn foo() {} diff --git a/src/test/run-make-fulldeps/extern-overrides-distribution/main.rs b/src/test/run-make-fulldeps/extern-overrides-distribution/main.rs new file mode 100644 index 00000000000..451841e7368 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-overrides-distribution/main.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate libc; + +fn main() { + libc::foo(); +} diff --git a/src/test/run-make-fulldeps/extra-filename-with-temp-outputs/Makefile b/src/test/run-make-fulldeps/extra-filename-with-temp-outputs/Makefile new file mode 100644 index 00000000000..6de4f97df0c --- /dev/null +++ b/src/test/run-make-fulldeps/extra-filename-with-temp-outputs/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) -C extra-filename=bar foo.rs -C save-temps + rm $(TMPDIR)/foobar.foo0.rcgu.o + rm $(TMPDIR)/$(call BIN,foobar) diff --git a/src/test/run-make-fulldeps/extra-filename-with-temp-outputs/foo.rs b/src/test/run-make-fulldeps/extra-filename-with-temp-outputs/foo.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/extra-filename-with-temp-outputs/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/fpic/Makefile b/src/test/run-make-fulldeps/fpic/Makefile new file mode 100644 index 00000000000..6de58c2db18 --- /dev/null +++ b/src/test/run-make-fulldeps/fpic/Makefile @@ -0,0 +1,13 @@ +-include ../tools.mk + +# Test for #39529. +# `-z text` causes ld to error if there are any non-PIC sections + +ifeq ($(UNAME),Darwin) +all: +else ifdef IS_WINDOWS +all: +else +all: + $(RUSTC) hello.rs -C link-args=-Wl,-z,text +endif diff --git a/src/test/run-make-fulldeps/fpic/hello.rs b/src/test/run-make-fulldeps/fpic/hello.rs new file mode 100644 index 00000000000..a9e231b0ea8 --- /dev/null +++ b/src/test/run-make-fulldeps/fpic/hello.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { } diff --git a/src/test/run-make-fulldeps/hir-tree/Makefile b/src/test/run-make-fulldeps/hir-tree/Makefile new file mode 100644 index 00000000000..2e100b269e1 --- /dev/null +++ b/src/test/run-make-fulldeps/hir-tree/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +# Test that hir-tree output doens't crash and includes +# the string constant we would expect to see. + +all: + $(RUSTC) -o $(TMPDIR)/input.hir -Z unpretty=hir-tree input.rs + $(CGREP) '"Hello, Rustaceans!\n"' < $(TMPDIR)/input.hir diff --git a/src/test/run-make-fulldeps/hir-tree/input.rs b/src/test/run-make-fulldeps/hir-tree/input.rs new file mode 100644 index 00000000000..12adc083bcd --- /dev/null +++ b/src/test/run-make-fulldeps/hir-tree/input.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("Hello, Rustaceans!"); +} diff --git a/src/test/run-make-fulldeps/hotplug_codegen_backend/Makefile b/src/test/run-make-fulldeps/hotplug_codegen_backend/Makefile new file mode 100644 index 00000000000..2ddf3aa5439 --- /dev/null +++ b/src/test/run-make-fulldeps/hotplug_codegen_backend/Makefile @@ -0,0 +1,9 @@ +include ../tools.mk + +all: + /bin/echo || exit 0 # This test requires /bin/echo to exist + $(RUSTC) the_backend.rs --crate-name the_backend --crate-type dylib \ + -o $(TMPDIR)/the_backend.dylib + $(RUSTC) some_crate.rs --crate-name some_crate --crate-type bin -o $(TMPDIR)/some_crate \ + -Z codegen-backend=$(TMPDIR)/the_backend.dylib -Z unstable-options + grep -x "This has been \"compiled\" successfully." $(TMPDIR)/some_crate diff --git a/src/test/run-make-fulldeps/hotplug_codegen_backend/some_crate.rs b/src/test/run-make-fulldeps/hotplug_codegen_backend/some_crate.rs new file mode 100644 index 00000000000..26ffce01b2e --- /dev/null +++ b/src/test/run-make-fulldeps/hotplug_codegen_backend/some_crate.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + ::std::process::exit(1); +} diff --git a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs new file mode 100644 index 00000000000..e266b0f5e83 --- /dev/null +++ b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs @@ -0,0 +1,82 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_private)] + +extern crate syntax; +extern crate rustc; +extern crate rustc_trans_utils; + +use std::any::Any; +use std::sync::mpsc; +use syntax::symbol::Symbol; +use rustc::session::{Session, CompileIncomplete}; +use rustc::session::config::OutputFilenames; +use rustc::ty::TyCtxt; +use rustc::ty::maps::Providers; +use rustc::middle::cstore::MetadataLoader; +use rustc::dep_graph::DepGraph; +use rustc_trans_utils::trans_crate::{TransCrate, MetadataOnlyTransCrate}; + +struct TheBackend(Box); + +impl TransCrate for TheBackend { + fn metadata_loader(&self) -> Box { + self.0.metadata_loader() + } + + fn provide(&self, providers: &mut Providers) { + self.0.provide(providers); + } + + fn provide_extern(&self, providers: &mut Providers) { + self.0.provide_extern(providers); + } + + fn trans_crate<'a, 'tcx>( + &self, + tcx: TyCtxt<'a, 'tcx, 'tcx>, + _rx: mpsc::Receiver> + ) -> Box { + use rustc::hir::def_id::LOCAL_CRATE; + + Box::new(tcx.crate_name(LOCAL_CRATE) as Symbol) + } + + fn join_trans_and_link( + &self, + trans: Box, + sess: &Session, + _dep_graph: &DepGraph, + outputs: &OutputFilenames, + ) -> Result<(), CompileIncomplete> { + use std::io::Write; + use rustc::session::config::CrateType; + use rustc_trans_utils::link::out_filename; + let crate_name = trans.downcast::() + .expect("in join_trans_and_link: trans is not a Symbol"); + for &crate_type in sess.opts.crate_types.iter() { + if crate_type != CrateType::CrateTypeExecutable { + sess.fatal(&format!("Crate type is {:?}", crate_type)); + } + let output_name = + out_filename(sess, crate_type, &outputs, &*crate_name.as_str()); + let mut out_file = ::std::fs::File::create(output_name).unwrap(); + write!(out_file, "This has been \"compiled\" successfully.").unwrap(); + } + Ok(()) + } +} + +/// This is the entrypoint for a hot plugged rustc_trans +#[no_mangle] +pub fn __rustc_codegen_backend() -> Box { + Box::new(TheBackend(MetadataOnlyTransCrate::new())) +} diff --git a/src/test/run-make-fulldeps/include_bytes_deps/Makefile b/src/test/run-make-fulldeps/include_bytes_deps/Makefile new file mode 100644 index 00000000000..1293695b799 --- /dev/null +++ b/src/test/run-make-fulldeps/include_bytes_deps/Makefile @@ -0,0 +1,20 @@ +-include ../tools.mk + +# FIXME: ignore freebsd/windows +# on windows `rustc --dep-info` produces Makefile dependency with +# windows native paths (e.g. `c:\path\to\libfoo.a`) +# but msys make seems to fail to recognize such paths, so test fails. +ifneq ($(shell uname),FreeBSD) +ifndef IS_WINDOWS +all: + $(RUSTC) --emit dep-info main.rs + $(CGREP) "input.txt" "input.bin" "input.md" < $(TMPDIR)/main.d +else +all: + +endif + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/include_bytes_deps/input.bin b/src/test/run-make-fulldeps/include_bytes_deps/input.bin new file mode 100644 index 00000000000..cd0875583aa --- /dev/null +++ b/src/test/run-make-fulldeps/include_bytes_deps/input.bin @@ -0,0 +1 @@ +Hello world! diff --git a/src/test/run-make-fulldeps/include_bytes_deps/input.md b/src/test/run-make-fulldeps/include_bytes_deps/input.md new file mode 100644 index 00000000000..2a19b7405f7 --- /dev/null +++ b/src/test/run-make-fulldeps/include_bytes_deps/input.md @@ -0,0 +1 @@ +# Hello, world! diff --git a/src/test/run-make-fulldeps/include_bytes_deps/input.txt b/src/test/run-make-fulldeps/include_bytes_deps/input.txt new file mode 100644 index 00000000000..cd0875583aa --- /dev/null +++ b/src/test/run-make-fulldeps/include_bytes_deps/input.txt @@ -0,0 +1 @@ +Hello world! diff --git a/src/test/run-make-fulldeps/include_bytes_deps/main.rs b/src/test/run-make-fulldeps/include_bytes_deps/main.rs new file mode 100644 index 00000000000..27ca1a46a50 --- /dev/null +++ b/src/test/run-make-fulldeps/include_bytes_deps/main.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(external_doc)] + +#[doc(include="input.md")] +pub struct SomeStruct; + +pub fn main() { + const INPUT_TXT: &'static str = include_str!("input.txt"); + const INPUT_BIN: &'static [u8] = include_bytes!("input.bin"); + + println!("{}", INPUT_TXT); + println!("{:?}", INPUT_BIN); +} diff --git a/src/test/run-make-fulldeps/inline-always-many-cgu/Makefile b/src/test/run-make-fulldeps/inline-always-many-cgu/Makefile new file mode 100644 index 00000000000..0cab955f644 --- /dev/null +++ b/src/test/run-make-fulldeps/inline-always-many-cgu/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs --emit llvm-ir -C codegen-units=2 + if cat $(TMPDIR)/*.ll | $(CGREP) -e '\bcall\b'; then \ + echo "found call instruction when one wasn't expected"; \ + exit 1; \ + fi diff --git a/src/test/run-make-fulldeps/inline-always-many-cgu/foo.rs b/src/test/run-make-fulldeps/inline-always-many-cgu/foo.rs new file mode 100644 index 00000000000..539dcdfa9b3 --- /dev/null +++ b/src/test/run-make-fulldeps/inline-always-many-cgu/foo.rs @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +pub mod a { + #[inline(always)] + pub fn foo() { + } + + pub fn bar() { + } +} + +#[no_mangle] +pub fn bar() { + a::foo(); +} diff --git a/src/test/run-make-fulldeps/interdependent-c-libraries/Makefile b/src/test/run-make-fulldeps/interdependent-c-libraries/Makefile new file mode 100644 index 00000000000..1268022e37b --- /dev/null +++ b/src/test/run-make-fulldeps/interdependent-c-libraries/Makefile @@ -0,0 +1,14 @@ +-include ../tools.mk + +# The rust crate foo will link to the native library foo, while the rust crate +# bar will link to the native library bar. There is also a dependency between +# the native library bar to the natibe library foo. +# +# This test ensures that the ordering of -lfoo and -lbar on the command line is +# correct to complete the linkage. If passed as "-lfoo -lbar", then the 'foo' +# library will be stripped out, and the linkage will fail. + +all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar) + $(RUSTC) foo.rs + $(RUSTC) bar.rs + $(RUSTC) main.rs -Z print-link-args diff --git a/src/test/run-make-fulldeps/interdependent-c-libraries/bar.c b/src/test/run-make-fulldeps/interdependent-c-libraries/bar.c new file mode 100644 index 00000000000..c761f029eff --- /dev/null +++ b/src/test/run-make-fulldeps/interdependent-c-libraries/bar.c @@ -0,0 +1,4 @@ +// ignore-license +void foo(); + +void bar() { foo(); } diff --git a/src/test/run-make-fulldeps/interdependent-c-libraries/bar.rs b/src/test/run-make-fulldeps/interdependent-c-libraries/bar.rs new file mode 100644 index 00000000000..1963976b4b0 --- /dev/null +++ b/src/test/run-make-fulldeps/interdependent-c-libraries/bar.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +extern crate foo; + +#[link(name = "bar", kind = "static")] +extern { + fn bar(); +} + +pub fn doit() { + unsafe { bar(); } +} diff --git a/src/test/run-make-fulldeps/interdependent-c-libraries/foo.c b/src/test/run-make-fulldeps/interdependent-c-libraries/foo.c new file mode 100644 index 00000000000..2895ad473bf --- /dev/null +++ b/src/test/run-make-fulldeps/interdependent-c-libraries/foo.c @@ -0,0 +1,2 @@ +// ignore-license +void foo() {} diff --git a/src/test/run-make-fulldeps/interdependent-c-libraries/foo.rs b/src/test/run-make-fulldeps/interdependent-c-libraries/foo.rs new file mode 100644 index 00000000000..7a0fe6bb18f --- /dev/null +++ b/src/test/run-make-fulldeps/interdependent-c-libraries/foo.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[link(name = "foo", kind = "static")] +extern { + fn foo(); +} + +pub fn doit() { + unsafe { foo(); } +} diff --git a/src/test/run-make-fulldeps/interdependent-c-libraries/main.rs b/src/test/run-make-fulldeps/interdependent-c-libraries/main.rs new file mode 100644 index 00000000000..f42e3dd44a9 --- /dev/null +++ b/src/test/run-make-fulldeps/interdependent-c-libraries/main.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; +extern crate bar; + +fn main() { + bar::doit(); +} diff --git a/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile b/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile new file mode 100644 index 00000000000..305e8a7ddc9 --- /dev/null +++ b/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile @@ -0,0 +1,15 @@ +-include ../tools.mk + +ifndef IS_WINDOWS +# The assembly for exit-unreachable.rs should be shorter because it's missing +# (at minimum) a return instruction. + +all: + $(RUSTC) -O --emit asm exit-ret.rs + $(RUSTC) -O --emit asm exit-unreachable.rs + test `wc -l < $(TMPDIR)/exit-unreachable.s` -lt `wc -l < $(TMPDIR)/exit-ret.s` +else +# Because of Windows exception handling, the code is not necessarily any shorter. +# https://github.com/llvm-mirror/llvm/commit/64b2297786f7fd6f5fa24cdd4db0298fbf211466 +all: +endif diff --git a/src/test/run-make-fulldeps/intrinsic-unreachable/exit-ret.rs b/src/test/run-make-fulldeps/intrinsic-unreachable/exit-ret.rs new file mode 100644 index 00000000000..1b8b644dd78 --- /dev/null +++ b/src/test/run-make-fulldeps/intrinsic-unreachable/exit-ret.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(asm)] +#![crate_type="lib"] + +#[deny(unreachable_code)] +pub fn exit(n: usize) -> i32 { + unsafe { + // Pretend this asm is an exit() syscall. + asm!("" :: "r"(n) :: "volatile"); + // Can't actually reach this point, but rustc doesn't know that. + } + // This return value is just here to generate some extra code for a return + // value, making it easier for the test script to detect whether the + // compiler deleted it. + 42 +} diff --git a/src/test/run-make-fulldeps/intrinsic-unreachable/exit-unreachable.rs b/src/test/run-make-fulldeps/intrinsic-unreachable/exit-unreachable.rs new file mode 100644 index 00000000000..de63809ab66 --- /dev/null +++ b/src/test/run-make-fulldeps/intrinsic-unreachable/exit-unreachable.rs @@ -0,0 +1,27 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(asm, core_intrinsics)] +#![crate_type="lib"] + +use std::intrinsics; + +#[allow(unreachable_code)] +pub fn exit(n: usize) -> i32 { + unsafe { + // Pretend this asm is an exit() syscall. + asm!("" :: "r"(n) :: "volatile"); + intrinsics::unreachable() + } + // This return value is just here to generate some extra code for a return + // value, making it easier for the test script to detect whether the + // compiler deleted it. + 42 +} diff --git a/src/test/run-make-fulldeps/invalid-library/Makefile b/src/test/run-make-fulldeps/invalid-library/Makefile new file mode 100644 index 00000000000..b6fb122d98b --- /dev/null +++ b/src/test/run-make-fulldeps/invalid-library/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + touch $(TMPDIR)/rust.metadata.bin + $(AR) crus $(TMPDIR)/libfoo-ffffffff-1.0.rlib $(TMPDIR)/rust.metadata.bin + $(RUSTC) foo.rs 2>&1 | $(CGREP) "can't find crate for" diff --git a/src/test/run-make-fulldeps/invalid-library/foo.rs b/src/test/run-make-fulldeps/invalid-library/foo.rs new file mode 100644 index 00000000000..6316cfa3bba --- /dev/null +++ b/src/test/run-make-fulldeps/invalid-library/foo.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() {} diff --git a/src/test/run-make-fulldeps/invalid-staticlib/Makefile b/src/test/run-make-fulldeps/invalid-staticlib/Makefile new file mode 100644 index 00000000000..3a91902ccce --- /dev/null +++ b/src/test/run-make-fulldeps/invalid-staticlib/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + touch $(TMPDIR)/libfoo.a + echo | $(RUSTC) - --crate-type=rlib -lstatic=foo 2>&1 | $(CGREP) "failed to add native library" diff --git a/src/test/run-make-fulldeps/issue-11908/Makefile b/src/test/run-make-fulldeps/issue-11908/Makefile new file mode 100644 index 00000000000..cf6572c27ad --- /dev/null +++ b/src/test/run-make-fulldeps/issue-11908/Makefile @@ -0,0 +1,21 @@ +# This test ensures that if you have the same rlib or dylib at two locations +# in the same path that you don't hit an assertion in the compiler. +# +# Note that this relies on `liburl` to be in the path somewhere else, +# and then our aux-built libraries will collide with liburl (they have +# the same version listed) + +-include ../tools.mk + +all: + mkdir $(TMPDIR)/other + $(RUSTC) foo.rs --crate-type=dylib -C prefer-dynamic + mv $(call DYLIB,foo) $(TMPDIR)/other + $(RUSTC) foo.rs --crate-type=dylib -C prefer-dynamic + $(RUSTC) bar.rs -L $(TMPDIR)/other + rm -rf $(TMPDIR) + mkdir -p $(TMPDIR)/other + $(RUSTC) foo.rs --crate-type=rlib + mv $(TMPDIR)/libfoo.rlib $(TMPDIR)/other + $(RUSTC) foo.rs --crate-type=rlib + $(RUSTC) bar.rs -L $(TMPDIR)/other diff --git a/src/test/run-make-fulldeps/issue-11908/bar.rs b/src/test/run-make-fulldeps/issue-11908/bar.rs new file mode 100644 index 00000000000..6316cfa3bba --- /dev/null +++ b/src/test/run-make-fulldeps/issue-11908/bar.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() {} diff --git a/src/test/run-make-fulldeps/issue-11908/foo.rs b/src/test/run-make-fulldeps/issue-11908/foo.rs new file mode 100644 index 00000000000..0858d3c4e47 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-11908/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] diff --git a/src/test/run-make-fulldeps/issue-14500/Makefile b/src/test/run-make-fulldeps/issue-14500/Makefile new file mode 100644 index 00000000000..bd94db09520 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-14500/Makefile @@ -0,0 +1,17 @@ +-include ../tools.mk + +# Test to make sure that reachable extern fns are always available in final +# productcs, including when LTO is used. In this test, the `foo` crate has a +# reahable symbol, and is a dependency of the `bar` crate. When the `bar` crate +# is compiled with LTO, it shouldn't strip the symbol from `foo`, and that's the +# only way that `foo.c` will successfully compile. + +ifeq ($(UNAME),Bitrig) + EXTRACFLAGS := -lc $(EXTRACFLAGS) $(EXTRACXXFLAGS) +endif + +all: + $(RUSTC) foo.rs --crate-type=rlib + $(RUSTC) bar.rs --crate-type=staticlib -C lto -L. -o $(TMPDIR)/libbar.a + $(CC) foo.c $(TMPDIR)/libbar.a $(EXTRACFLAGS) $(call OUT_EXE,foo) + $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/issue-14500/bar.rs b/src/test/run-make-fulldeps/issue-14500/bar.rs new file mode 100644 index 00000000000..4b4916fe96d --- /dev/null +++ b/src/test/run-make-fulldeps/issue-14500/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; diff --git a/src/test/run-make-fulldeps/issue-14500/foo.c b/src/test/run-make-fulldeps/issue-14500/foo.c new file mode 100644 index 00000000000..e84b5509c50 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-14500/foo.c @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern void foo(); +extern char FOO_STATIC; + +int main() { + foo(); + return (int)FOO_STATIC; +} diff --git a/src/test/run-make-fulldeps/issue-14500/foo.rs b/src/test/run-make-fulldeps/issue-14500/foo.rs new file mode 100644 index 00000000000..a91d8d6a21d --- /dev/null +++ b/src/test/run-make-fulldeps/issue-14500/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern fn foo() {} + +#[no_mangle] +pub static FOO_STATIC: u8 = 0; diff --git a/src/test/run-make-fulldeps/issue-14698/Makefile b/src/test/run-make-fulldeps/issue-14698/Makefile new file mode 100644 index 00000000000..dbe8317dbc4 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-14698/Makefile @@ -0,0 +1,4 @@ +-include ../tools.mk + +all: + TMP=fake TMPDIR=fake $(RUSTC) foo.rs 2>&1 | $(CGREP) "couldn't create a temp dir:" diff --git a/src/test/run-make-fulldeps/issue-14698/foo.rs b/src/test/run-make-fulldeps/issue-14698/foo.rs new file mode 100644 index 00000000000..7dc79f2043b --- /dev/null +++ b/src/test/run-make-fulldeps/issue-14698/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/issue-15460/Makefile b/src/test/run-make-fulldeps/issue-15460/Makefile new file mode 100644 index 00000000000..846805686a1 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-15460/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,foo) + $(RUSTC) foo.rs -C extra-filename=-383hf8 -C prefer-dynamic + $(RUSTC) bar.rs + $(call RUN,bar) diff --git a/src/test/run-make-fulldeps/issue-15460/bar.rs b/src/test/run-make-fulldeps/issue-15460/bar.rs new file mode 100644 index 00000000000..46777f7fbd2 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-15460/bar.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; +fn main() { + unsafe { foo::foo() } +} diff --git a/src/test/run-make-fulldeps/issue-15460/foo.c b/src/test/run-make-fulldeps/issue-15460/foo.c new file mode 100644 index 00000000000..fdf595b574e --- /dev/null +++ b/src/test/run-make-fulldeps/issue-15460/foo.c @@ -0,0 +1,6 @@ +// ignore-license + +#ifdef _WIN32 +__declspec(dllexport) +#endif +void foo() {} diff --git a/src/test/run-make-fulldeps/issue-15460/foo.rs b/src/test/run-make-fulldeps/issue-15460/foo.rs new file mode 100644 index 00000000000..6917fa55579 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-15460/foo.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +#[link(name = "foo", kind = "static")] +extern { + pub fn foo(); +} diff --git a/src/test/run-make-fulldeps/issue-18943/Makefile b/src/test/run-make-fulldeps/issue-18943/Makefile new file mode 100644 index 00000000000..bef70a0edaa --- /dev/null +++ b/src/test/run-make-fulldeps/issue-18943/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +# Regression test for ICE #18943 when compiling as lib + +all: + $(RUSTC) foo.rs --crate-type lib + $(call REMOVE_RLIBS,foo) && exit 0 || exit 1 diff --git a/src/test/run-make-fulldeps/issue-18943/foo.rs b/src/test/run-make-fulldeps/issue-18943/foo.rs new file mode 100644 index 00000000000..aadf0f593e7 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-18943/foo.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Foo { } + +trait Bar { } + +impl<'a> Foo for Bar + 'a { } + diff --git a/src/test/run-make-fulldeps/issue-19371/Makefile b/src/test/run-make-fulldeps/issue-19371/Makefile new file mode 100644 index 00000000000..9f3ec78465b --- /dev/null +++ b/src/test/run-make-fulldeps/issue-19371/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +# This test ensures that rustc compile_input can be called twice in one task +# without causing a panic. +# The program needs the path to rustc to get sysroot. + +all: + $(RUSTC) foo.rs + $(call RUN,foo $(TMPDIR) $(RUSTC)) diff --git a/src/test/run-make-fulldeps/issue-19371/foo.rs b/src/test/run-make-fulldeps/issue-19371/foo.rs new file mode 100644 index 00000000000..e0db2627d85 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-19371/foo.rs @@ -0,0 +1,88 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_private)] + +extern crate rustc; +extern crate rustc_driver; +extern crate rustc_lint; +extern crate rustc_metadata; +extern crate rustc_errors; +extern crate rustc_trans_utils; +extern crate syntax; + +use rustc::session::{build_session, Session}; +use rustc::session::config::{basic_options, Input, + OutputType, OutputTypes}; +use rustc_driver::driver::{compile_input, CompileController}; +use rustc_metadata::cstore::CStore; +use rustc_errors::registry::Registry; +use syntax::codemap::FileName; +use rustc_trans_utils::trans_crate::TransCrate; + +use std::path::PathBuf; +use std::rc::Rc; + +fn main() { + let src = r#" + fn main() {} + "#; + + let args: Vec = std::env::args().collect(); + + if args.len() < 4 { + panic!("expected rustc path"); + } + + let tmpdir = PathBuf::from(&args[1]); + + let mut sysroot = PathBuf::from(&args[3]); + sysroot.pop(); + sysroot.pop(); + + compile(src.to_string(), tmpdir.join("out"), sysroot.clone()); + + compile(src.to_string(), tmpdir.join("out"), sysroot.clone()); +} + +fn basic_sess(sysroot: PathBuf) -> (Session, Rc, Box) { + let mut opts = basic_options(); + opts.output_types = OutputTypes::new(&[(OutputType::Exe, None)]); + opts.maybe_sysroot = Some(sysroot); + if let Ok(linker) = std::env::var("RUSTC_LINKER") { + opts.cg.linker = Some(linker.into()); + } + + let descriptions = Registry::new(&rustc::DIAGNOSTICS); + let sess = build_session(opts, None, descriptions); + let trans = rustc_driver::get_trans(&sess); + let cstore = Rc::new(CStore::new(trans.metadata_loader())); + rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); + (sess, cstore, trans) +} + +fn compile(code: String, output: PathBuf, sysroot: PathBuf) { + syntax::with_globals(|| { + let (sess, cstore, trans) = basic_sess(sysroot); + let control = CompileController::basic(); + let input = Input::Str { name: FileName::Anon, input: code }; + let _ = compile_input( + trans, + &sess, + &cstore, + &None, + &input, + &None, + &Some(output), + None, + &control + ); + }); +} diff --git a/src/test/run-make-fulldeps/issue-20626/Makefile b/src/test/run-make-fulldeps/issue-20626/Makefile new file mode 100644 index 00000000000..0487b240400 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-20626/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +# Test output to be four +# The original error only occurred when printing, not when comparing using assert! + +all: + $(RUSTC) foo.rs -O + [ `$(call RUN,foo)` = "4" ] diff --git a/src/test/run-make-fulldeps/issue-20626/foo.rs b/src/test/run-make-fulldeps/issue-20626/foo.rs new file mode 100644 index 00000000000..9f727607e4e --- /dev/null +++ b/src/test/run-make-fulldeps/issue-20626/foo.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn identity(a: &u32) -> &u32 { a } + +fn print_foo(f: &fn(&u32) -> &u32, x: &u32) { + print!("{}", (*f)(x)); +} + +fn main() { + let x = &4; + let f: fn(&u32) -> &u32 = identity; + + // Didn't print 4 on optimized builds + print_foo(&f, x); +} diff --git a/src/test/run-make-fulldeps/issue-22131/Makefile b/src/test/run-make-fulldeps/issue-22131/Makefile new file mode 100644 index 00000000000..6db737a9e72 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-22131/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: foo.rs + $(RUSTC) --cfg 'feature="bar"' --crate-type lib foo.rs + $(RUSTDOC) --test --cfg 'feature="bar"' \ + -L $(TMPDIR) foo.rs |\ + $(CGREP) 'foo.rs - foo (line 11) ... ok' diff --git a/src/test/run-make-fulldeps/issue-22131/foo.rs b/src/test/run-make-fulldeps/issue-22131/foo.rs new file mode 100644 index 00000000000..50c63abc0d4 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-22131/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +/// ```rust +/// assert_eq!(foo::foo(), 1); +/// ``` +#[cfg(feature = "bar")] +pub fn foo() -> i32 { 1 } diff --git a/src/test/run-make-fulldeps/issue-24445/Makefile b/src/test/run-make-fulldeps/issue-24445/Makefile new file mode 100644 index 00000000000..2ed971bf7d9 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-24445/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +ifeq ($(UNAME),Linux) +all: + $(RUSTC) foo.rs + $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -o $(TMPDIR)/foo + $(call RUN,foo) + $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -pie -fPIC -o $(TMPDIR)/foo + $(call RUN,foo) +else +all: +endif diff --git a/src/test/run-make-fulldeps/issue-24445/foo.c b/src/test/run-make-fulldeps/issue-24445/foo.c new file mode 100644 index 00000000000..775e151f236 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-24445/foo.c @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void foo(); + +int main() { + foo(); + return 0; +} diff --git a/src/test/run-make-fulldeps/issue-24445/foo.rs b/src/test/run-make-fulldeps/issue-24445/foo.rs new file mode 100644 index 00000000000..65e505df5ef --- /dev/null +++ b/src/test/run-make-fulldeps/issue-24445/foo.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "staticlib"] + +struct Destroy; +impl Drop for Destroy { + fn drop(&mut self) { println!("drop"); } +} + +thread_local! { + static X: Destroy = Destroy +} + +#[no_mangle] +pub extern "C" fn foo() { + X.with(|_| ()); +} diff --git a/src/test/run-make-fulldeps/issue-25581/Makefile b/src/test/run-make-fulldeps/issue-25581/Makefile new file mode 100644 index 00000000000..042048ec25f --- /dev/null +++ b/src/test/run-make-fulldeps/issue-25581/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,test) + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/src/test/run-make-fulldeps/issue-25581/test.c b/src/test/run-make-fulldeps/issue-25581/test.c new file mode 100644 index 00000000000..5736b173021 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-25581/test.c @@ -0,0 +1,16 @@ +// ignore-license +#include +#include + +struct ByteSlice { + uint8_t *data; + size_t len; +}; + +size_t slice_len(struct ByteSlice bs) { + return bs.len; +} + +uint8_t slice_elem(struct ByteSlice bs, size_t idx) { + return bs.data[idx]; +} diff --git a/src/test/run-make-fulldeps/issue-25581/test.rs b/src/test/run-make-fulldeps/issue-25581/test.rs new file mode 100644 index 00000000000..6717d16cb7c --- /dev/null +++ b/src/test/run-make-fulldeps/issue-25581/test.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(libc)] + +extern crate libc; + +#[link(name = "test", kind = "static")] +extern { + fn slice_len(s: &[u8]) -> libc::size_t; + fn slice_elem(s: &[u8], idx: libc::size_t) -> u8; +} + +fn main() { + let data = [1,2,3,4,5]; + + unsafe { + assert_eq!(data.len(), slice_len(&data) as usize); + assert_eq!(data[0], slice_elem(&data, 0)); + assert_eq!(data[1], slice_elem(&data, 1)); + assert_eq!(data[2], slice_elem(&data, 2)); + assert_eq!(data[3], slice_elem(&data, 3)); + assert_eq!(data[4], slice_elem(&data, 4)); + } +} diff --git a/src/test/run-make-fulldeps/issue-26006/Makefile b/src/test/run-make-fulldeps/issue-26006/Makefile new file mode 100644 index 00000000000..66aa78d5386 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-26006/Makefile @@ -0,0 +1,18 @@ +-include ../tools.mk + +OUT := $(TMPDIR)/out + +ifndef IS_WINDOWS +all: time + +time: libc + mkdir -p $(OUT)/time $(OUT)/time/deps + ln -sf $(OUT)/libc/liblibc.rlib $(OUT)/time/deps/ + $(RUSTC) in/time/lib.rs -Ldependency=$(OUT)/time/deps/ + +libc: + mkdir -p $(OUT)/libc + $(RUSTC) in/libc/lib.rs --crate-name=libc -Cmetadata=foo -o $(OUT)/libc/liblibc.rlib +else +all: +endif diff --git a/src/test/run-make-fulldeps/issue-26006/in/libc/lib.rs b/src/test/run-make-fulldeps/issue-26006/in/libc/lib.rs new file mode 100644 index 00000000000..177ffdce062 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-26006/in/libc/lib.rs @@ -0,0 +1,12 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![crate_type="rlib"] + +pub fn something(){} diff --git a/src/test/run-make-fulldeps/issue-26006/in/time/lib.rs b/src/test/run-make-fulldeps/issue-26006/in/time/lib.rs new file mode 100644 index 00000000000..b1d07d57337 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-26006/in/time/lib.rs @@ -0,0 +1,13 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![feature(libc)] +extern crate libc; + +fn main(){} diff --git a/src/test/run-make-fulldeps/issue-26092/Makefile b/src/test/run-make-fulldeps/issue-26092/Makefile new file mode 100644 index 00000000000..27631c31c4a --- /dev/null +++ b/src/test/run-make-fulldeps/issue-26092/Makefile @@ -0,0 +1,4 @@ +-include ../tools.mk + +all: + $(RUSTC) -o "" blank.rs 2>&1 | $(CGREP) -i 'No such file or directory' diff --git a/src/test/run-make-fulldeps/issue-26092/blank.rs b/src/test/run-make-fulldeps/issue-26092/blank.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-26092/blank.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/issue-28595/Makefile b/src/test/run-make-fulldeps/issue-28595/Makefile new file mode 100644 index 00000000000..61e9d0c6547 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28595/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,a) $(call NATIVE_STATICLIB,b) + $(RUSTC) a.rs + $(RUSTC) b.rs + $(call RUN,b) diff --git a/src/test/run-make-fulldeps/issue-28595/a.c b/src/test/run-make-fulldeps/issue-28595/a.c new file mode 100644 index 00000000000..feacd7bc313 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28595/a.c @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void a(void) {} diff --git a/src/test/run-make-fulldeps/issue-28595/a.rs b/src/test/run-make-fulldeps/issue-28595/a.rs new file mode 100644 index 00000000000..7377a9f3416 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28595/a.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[link(name = "a", kind = "static")] +extern { + pub fn a(); +} diff --git a/src/test/run-make-fulldeps/issue-28595/b.c b/src/test/run-make-fulldeps/issue-28595/b.c new file mode 100644 index 00000000000..de81fbcaa60 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28595/b.c @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern void a(void); + +void b(void) { + a(); +} + diff --git a/src/test/run-make-fulldeps/issue-28595/b.rs b/src/test/run-make-fulldeps/issue-28595/b.rs new file mode 100644 index 00000000000..37ff346c3f3 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28595/b.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate a; + +#[link(name = "b", kind = "static")] +extern { + pub fn b(); +} + + +fn main() { + unsafe { b(); } +} diff --git a/src/test/run-make-fulldeps/issue-28766/Makefile b/src/test/run-make-fulldeps/issue-28766/Makefile new file mode 100644 index 00000000000..1f47ef15b27 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28766/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) -O foo.rs + $(RUSTC) -O -L $(TMPDIR) main.rs diff --git a/src/test/run-make-fulldeps/issue-28766/foo.rs b/src/test/run-make-fulldeps/issue-28766/foo.rs new file mode 100644 index 00000000000..3ed0a6bfc74 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28766/foo.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] +pub struct Foo(()); + +impl Foo { + pub fn new() -> Foo { + Foo(()) + } +} diff --git a/src/test/run-make-fulldeps/issue-28766/main.rs b/src/test/run-make-fulldeps/issue-28766/main.rs new file mode 100644 index 00000000000..d1dadbdc7ad --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28766/main.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] +extern crate foo; +use foo::Foo; + +pub fn crash() -> Box { + Box::new(Foo::new()) +} diff --git a/src/test/run-make-fulldeps/issue-30063/Makefile b/src/test/run-make-fulldeps/issue-30063/Makefile new file mode 100644 index 00000000000..a76051dc81e --- /dev/null +++ b/src/test/run-make-fulldeps/issue-30063/Makefile @@ -0,0 +1,35 @@ +-include ../tools.mk + +all: + rm -f $(TMPDIR)/foo-output + $(RUSTC) -C codegen-units=4 -o $(TMPDIR)/foo-output foo.rs + rm $(TMPDIR)/foo-output + + rm -f $(TMPDIR)/asm-output + $(RUSTC) -C codegen-units=4 --emit=asm -o $(TMPDIR)/asm-output foo.rs + rm $(TMPDIR)/asm-output + + rm -f $(TMPDIR)/bc-output + $(RUSTC) -C codegen-units=4 --emit=llvm-bc -o $(TMPDIR)/bc-output foo.rs + rm $(TMPDIR)/bc-output + + rm -f $(TMPDIR)/ir-output + $(RUSTC) -C codegen-units=4 --emit=llvm-ir -o $(TMPDIR)/ir-output foo.rs + rm $(TMPDIR)/ir-output + + rm -f $(TMPDIR)/link-output + $(RUSTC) -C codegen-units=4 --emit=link -o $(TMPDIR)/link-output foo.rs + rm $(TMPDIR)/link-output + + rm -f $(TMPDIR)/obj-output + $(RUSTC) -C codegen-units=4 --emit=obj -o $(TMPDIR)/obj-output foo.rs + rm $(TMPDIR)/obj-output + + rm -f $(TMPDIR)/dep-output + $(RUSTC) -C codegen-units=4 --emit=dep-info -o $(TMPDIR)/dep-output foo.rs + rm $(TMPDIR)/dep-output + +# # (This case doesn't work yet, and may be fundamentally wrong-headed anyway.) +# rm -f $(TMPDIR)/multi-output +# $(RUSTC) -C codegen-units=4 --emit=asm,obj -o $(TMPDIR)/multi-output foo.rs +# rm $(TMPDIR)/multi-output diff --git a/src/test/run-make-fulldeps/issue-30063/foo.rs b/src/test/run-make-fulldeps/issue-30063/foo.rs new file mode 100644 index 00000000000..45f7a2c2aa6 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-30063/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { } diff --git a/src/test/run-make-fulldeps/issue-33329/Makefile b/src/test/run-make-fulldeps/issue-33329/Makefile new file mode 100644 index 00000000000..591e4e3dda3 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-33329/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) --target x86_64_unknown-linux-musl main.rs 2>&1 | $(CGREP) \ + "error: Error loading target specification: Could not find specification for target" diff --git a/src/test/run-make-fulldeps/issue-33329/main.rs b/src/test/run-make-fulldeps/issue-33329/main.rs new file mode 100644 index 00000000000..e06c0a5ec2a --- /dev/null +++ b/src/test/run-make-fulldeps/issue-33329/main.rs @@ -0,0 +1,11 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/issue-35164/Makefile b/src/test/run-make-fulldeps/issue-35164/Makefile new file mode 100644 index 00000000000..6a451656dcb --- /dev/null +++ b/src/test/run-make-fulldeps/issue-35164/Makefile @@ -0,0 +1,4 @@ +-include ../tools.mk + +all: + $(RUSTC) main.rs --error-format json 2>&1 | $(CGREP) -e '"byte_start":490\b' '"byte_end":496\b' diff --git a/src/test/run-make-fulldeps/issue-35164/main.rs b/src/test/run-make-fulldeps/issue-35164/main.rs new file mode 100644 index 00000000000..24322a2484f --- /dev/null +++ b/src/test/run-make-fulldeps/issue-35164/main.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod submodule; + +fn main() { + submodule::foo(); +} diff --git a/src/test/run-make-fulldeps/issue-35164/submodule/mod.rs b/src/test/run-make-fulldeps/issue-35164/submodule/mod.rs new file mode 100644 index 00000000000..7847c13af78 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-35164/submodule/mod.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() { + let _MyFoo = 2; +} diff --git a/src/test/run-make-fulldeps/issue-37839/Makefile b/src/test/run-make-fulldeps/issue-37839/Makefile new file mode 100644 index 00000000000..8b3355b9622 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37839/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) +# ignore stage1 +all: + +else +all: + $(RUSTC) a.rs && $(RUSTC) b.rs + $(BARE_RUSTC) c.rs -L dependency=$(TMPDIR) --extern b=$(TMPDIR)/libb.rlib \ + --out-dir=$(TMPDIR) +endif diff --git a/src/test/run-make-fulldeps/issue-37839/a.rs b/src/test/run-make-fulldeps/issue-37839/a.rs new file mode 100644 index 00000000000..052317438c2 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37839/a.rs @@ -0,0 +1,12 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] +#![crate_type = "proc-macro"] diff --git a/src/test/run-make-fulldeps/issue-37839/b.rs b/src/test/run-make-fulldeps/issue-37839/b.rs new file mode 100644 index 00000000000..82f48f6d8d6 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37839/b.rs @@ -0,0 +1,12 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#[macro_use] extern crate a; diff --git a/src/test/run-make-fulldeps/issue-37839/c.rs b/src/test/run-make-fulldeps/issue-37839/c.rs new file mode 100644 index 00000000000..85bece51427 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37839/c.rs @@ -0,0 +1,12 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +extern crate b; diff --git a/src/test/run-make-fulldeps/issue-37893/Makefile b/src/test/run-make-fulldeps/issue-37893/Makefile new file mode 100644 index 00000000000..c7732cc2682 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37893/Makefile @@ -0,0 +1,10 @@ +-include ../tools.mk + +ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) +# ignore stage1 +all: + +else +all: + $(RUSTC) a.rs && $(RUSTC) b.rs && $(RUSTC) c.rs +endif diff --git a/src/test/run-make-fulldeps/issue-37893/a.rs b/src/test/run-make-fulldeps/issue-37893/a.rs new file mode 100644 index 00000000000..052317438c2 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37893/a.rs @@ -0,0 +1,12 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] +#![crate_type = "proc-macro"] diff --git a/src/test/run-make-fulldeps/issue-37893/b.rs b/src/test/run-make-fulldeps/issue-37893/b.rs new file mode 100644 index 00000000000..82f48f6d8d6 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37893/b.rs @@ -0,0 +1,12 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#[macro_use] extern crate a; diff --git a/src/test/run-make-fulldeps/issue-37893/c.rs b/src/test/run-make-fulldeps/issue-37893/c.rs new file mode 100644 index 00000000000..eee55cc2369 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37893/c.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "staticlib"] +extern crate b; +extern crate a; diff --git a/src/test/run-make-fulldeps/issue-38237/Makefile b/src/test/run-make-fulldeps/issue-38237/Makefile new file mode 100644 index 00000000000..855d958b344 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-38237/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) +# ignore stage1 +all: + +else +all: + $(RUSTC) foo.rs; $(RUSTC) bar.rs + $(RUSTDOC) baz.rs -L $(TMPDIR) -o $(TMPDIR) +endif diff --git a/src/test/run-make-fulldeps/issue-38237/bar.rs b/src/test/run-make-fulldeps/issue-38237/bar.rs new file mode 100644 index 00000000000..794e08c2fe3 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-38237/bar.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +#[derive(Debug)] +pub struct S; diff --git a/src/test/run-make-fulldeps/issue-38237/baz.rs b/src/test/run-make-fulldeps/issue-38237/baz.rs new file mode 100644 index 00000000000..c2a2c89db01 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-38237/baz.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; +extern crate bar; + +pub struct Bar; +impl ::std::ops::Deref for Bar { + type Target = bar::S; + fn deref(&self) -> &Self::Target { unimplemented!() } +} diff --git a/src/test/run-make-fulldeps/issue-38237/foo.rs b/src/test/run-make-fulldeps/issue-38237/foo.rs new file mode 100644 index 00000000000..6fb315731de --- /dev/null +++ b/src/test/run-make-fulldeps/issue-38237/foo.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +#[proc_macro_derive(A)] +pub fn derive(ts: proc_macro::TokenStream) -> proc_macro::TokenStream { ts } + +#[derive(Debug)] +struct S; diff --git a/src/test/run-make-fulldeps/issue-40535/Makefile b/src/test/run-make-fulldeps/issue-40535/Makefile new file mode 100644 index 00000000000..49db1d43e47 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-40535/Makefile @@ -0,0 +1,13 @@ +-include ../tools.mk + +# The ICE occurred in the following situation: +# * `foo` declares `extern crate bar, baz`, depends only on `bar` (forgetting `baz` in `Cargo.toml`) +# * `bar` declares and depends on `extern crate baz` +# * All crates built in metadata-only mode (`cargo check`) +all: + # cc https://github.com/rust-lang/rust/issues/40623 + $(RUSTC) baz.rs --emit=metadata + $(RUSTC) bar.rs --emit=metadata --extern baz=$(TMPDIR)/libbaz.rmeta + $(RUSTC) foo.rs --emit=metadata --extern bar=$(TMPDIR)/libbar.rmeta 2>&1 | \ + $(CGREP) -v "unexpectedly panicked" + # ^ Succeeds if it doesn't find the ICE message diff --git a/src/test/run-make-fulldeps/issue-40535/bar.rs b/src/test/run-make-fulldeps/issue-40535/bar.rs new file mode 100644 index 00000000000..4c22f181975 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-40535/bar.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +extern crate baz; diff --git a/src/test/run-make-fulldeps/issue-40535/baz.rs b/src/test/run-make-fulldeps/issue-40535/baz.rs new file mode 100644 index 00000000000..737a918a039 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-40535/baz.rs @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] diff --git a/src/test/run-make-fulldeps/issue-40535/foo.rs b/src/test/run-make-fulldeps/issue-40535/foo.rs new file mode 100644 index 00000000000..53a8c8636b1 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-40535/foo.rs @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +extern crate bar; +extern crate baz; diff --git a/src/test/run-make-fulldeps/issue-46239/Makefile b/src/test/run-make-fulldeps/issue-46239/Makefile new file mode 100644 index 00000000000..698a605f7e9 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-46239/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) main.rs -C opt-level=1 + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/issue-46239/main.rs b/src/test/run-make-fulldeps/issue-46239/main.rs new file mode 100644 index 00000000000..3b3289168ab --- /dev/null +++ b/src/test/run-make-fulldeps/issue-46239/main.rs @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn project(x: &(T,)) -> &T { &x.0 } + +fn dummy() {} + +fn main() { + let f = (dummy as fn(),); + (*project(&f))(); +} diff --git a/src/test/run-make-fulldeps/issue-7349/Makefile b/src/test/run-make-fulldeps/issue-7349/Makefile new file mode 100644 index 00000000000..50dc63b1deb --- /dev/null +++ b/src/test/run-make-fulldeps/issue-7349/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +# Test to make sure that inner functions within a polymorphic outer function +# don't get re-translated when the outer function is monomorphized. The test +# code monomorphizes the outer functions several times, but the magic constants +# used in the inner functions should each appear only once in the generated IR. + +all: + $(RUSTC) foo.rs --emit=llvm-ir + [ "$$(grep -c 'ret i32 8675309' "$(TMPDIR)/foo.ll")" -eq "1" ] + [ "$$(grep -c 'ret i32 11235813' "$(TMPDIR)/foo.ll")" -eq "1" ] diff --git a/src/test/run-make-fulldeps/issue-7349/foo.rs b/src/test/run-make-fulldeps/issue-7349/foo.rs new file mode 100644 index 00000000000..b75c82afb53 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-7349/foo.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn outer() { + #[allow(dead_code)] + fn inner() -> u32 { + 8675309 + } + inner(); +} + +extern "C" fn outer_foreign() { + #[allow(dead_code)] + fn inner() -> u32 { + 11235813 + } + inner(); +} + +fn main() { + outer::(); + outer::(); + outer_foreign::(); + outer_foreign::(); +} diff --git a/src/test/run-make-fulldeps/issues-41478-43796/Makefile b/src/test/run-make-fulldeps/issues-41478-43796/Makefile new file mode 100644 index 00000000000..f9735253ab6 --- /dev/null +++ b/src/test/run-make-fulldeps/issues-41478-43796/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: + # Work in /tmp, because we need to create the `save-analysis-temp` folder. + cp a.rs $(TMPDIR)/ + cd $(TMPDIR) && $(RUSTC) -Zsave-analysis $(TMPDIR)/a.rs 2> $(TMPDIR)/stderr.txt || ( cat $(TMPDIR)/stderr.txt && exit 1 ) + [ ! -s $(TMPDIR)/stderr.txt ] || ( cat $(TMPDIR)/stderr.txt && exit 1 ) + [ -f $(TMPDIR)/save-analysis/liba.json ] || ( ls -la $(TMPDIR) && exit 1 ) diff --git a/src/test/run-make-fulldeps/issues-41478-43796/a.rs b/src/test/run-make-fulldeps/issues-41478-43796/a.rs new file mode 100644 index 00000000000..9d95f8b2585 --- /dev/null +++ b/src/test/run-make-fulldeps/issues-41478-43796/a.rs @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +pub struct V(S); +pub trait An { + type U; +} +pub trait F { +} +impl F for V<::U> { +} diff --git a/src/test/run-make-fulldeps/libs-and-bins/Makefile b/src/test/run-make-fulldeps/libs-and-bins/Makefile new file mode 100644 index 00000000000..cc3b257a5c5 --- /dev/null +++ b/src/test/run-make-fulldeps/libs-and-bins/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs + $(call RUN,foo) + rm $(TMPDIR)/$(call DYLIB_GLOB,foo) diff --git a/src/test/run-make-fulldeps/libs-and-bins/foo.rs b/src/test/run-make-fulldeps/libs-and-bins/foo.rs new file mode 100644 index 00000000000..2ebe63928ca --- /dev/null +++ b/src/test/run-make-fulldeps/libs-and-bins/foo.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] +#![crate_type = "bin"] + +fn main() {} diff --git a/src/test/run-make-fulldeps/libs-through-symlinks/Makefile b/src/test/run-make-fulldeps/libs-through-symlinks/Makefile new file mode 100644 index 00000000000..2f425121f66 --- /dev/null +++ b/src/test/run-make-fulldeps/libs-through-symlinks/Makefile @@ -0,0 +1,14 @@ +-include ../tools.mk + +ifdef IS_WINDOWS +all: +else + +NAME := $(shell $(RUSTC) --print file-names foo.rs) + +all: + mkdir -p $(TMPDIR)/outdir + $(RUSTC) foo.rs -o $(TMPDIR)/outdir/$(NAME) + ln -nsf outdir/$(NAME) $(TMPDIR) + RUST_LOG=rustc_metadata::loader $(RUSTC) bar.rs +endif diff --git a/src/test/run-make-fulldeps/libs-through-symlinks/bar.rs b/src/test/run-make-fulldeps/libs-through-symlinks/bar.rs new file mode 100644 index 00000000000..6316cfa3bba --- /dev/null +++ b/src/test/run-make-fulldeps/libs-through-symlinks/bar.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() {} diff --git a/src/test/run-make-fulldeps/libs-through-symlinks/foo.rs b/src/test/run-make-fulldeps/libs-through-symlinks/foo.rs new file mode 100644 index 00000000000..dd818cf8798 --- /dev/null +++ b/src/test/run-make-fulldeps/libs-through-symlinks/foo.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![crate_name = "foo"] diff --git a/src/test/run-make-fulldeps/libtest-json/Makefile b/src/test/run-make-fulldeps/libtest-json/Makefile new file mode 100644 index 00000000000..ec91ddfb9f9 --- /dev/null +++ b/src/test/run-make-fulldeps/libtest-json/Makefile @@ -0,0 +1,14 @@ +-include ../tools.mk + +# Test expected libtest's JSON output + +OUTPUT_FILE := $(TMPDIR)/libtest-json-output.json + +all: + $(RUSTC) --test f.rs + $(call RUN,f) -Z unstable-options --test-threads=1 --format=json > $(OUTPUT_FILE) || true + + cat $(OUTPUT_FILE) | "$(PYTHON)" validate_json.py + + # Compare to output file + diff output.json $(OUTPUT_FILE) diff --git a/src/test/run-make-fulldeps/libtest-json/f.rs b/src/test/run-make-fulldeps/libtest-json/f.rs new file mode 100644 index 00000000000..5cff1f1a5b1 --- /dev/null +++ b/src/test/run-make-fulldeps/libtest-json/f.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[test] +fn a() { + // Should pass +} + +#[test] +fn b() { + assert!(false) +} + +#[test] +#[should_panic] +fn c() { + assert!(false); +} + +#[test] +#[ignore] +fn d() { + assert!(false); +} + diff --git a/src/test/run-make-fulldeps/libtest-json/output.json b/src/test/run-make-fulldeps/libtest-json/output.json new file mode 100644 index 00000000000..235f8cd7c72 --- /dev/null +++ b/src/test/run-make-fulldeps/libtest-json/output.json @@ -0,0 +1,10 @@ +{ "type": "suite", "event": "started", "test_count": "4" } +{ "type": "test", "event": "started", "name": "a" } +{ "type": "test", "name": "a", "event": "ok" } +{ "type": "test", "event": "started", "name": "b" } +{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at 'assertion failed: false', f.rs:18:5\nnote: Run with `RUST_BACKTRACE=1` for a backtrace.\n" } +{ "type": "test", "event": "started", "name": "c" } +{ "type": "test", "name": "c", "event": "ok" } +{ "type": "test", "event": "started", "name": "d" } +{ "type": "test", "name": "d", "event": "ignored" } +{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "allowed_fail": 0, "ignored": 1, "measured": 0, "filtered_out": "0" } diff --git a/src/test/run-make-fulldeps/libtest-json/validate_json.py b/src/test/run-make-fulldeps/libtest-json/validate_json.py new file mode 100755 index 00000000000..1e97639b524 --- /dev/null +++ b/src/test/run-make-fulldeps/libtest-json/validate_json.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +# Copyright 2016 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +import sys +import json + +# Try to decode line in order to ensure it is a valid JSON document +for line in sys.stdin: + json.loads(line) diff --git a/src/test/run-make-fulldeps/link-arg/Makefile b/src/test/run-make-fulldeps/link-arg/Makefile new file mode 100644 index 00000000000..d7c9fd27112 --- /dev/null +++ b/src/test/run-make-fulldeps/link-arg/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk +RUSTC_FLAGS = -C link-arg="-lfoo" -C link-arg="-lbar" -Z print-link-args + +all: + $(RUSTC) $(RUSTC_FLAGS) empty.rs | $(CGREP) lfoo lbar diff --git a/src/test/run-make-fulldeps/link-arg/empty.rs b/src/test/run-make-fulldeps/link-arg/empty.rs new file mode 100644 index 00000000000..2b76fb24e5f --- /dev/null +++ b/src/test/run-make-fulldeps/link-arg/empty.rs @@ -0,0 +1,11 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { } diff --git a/src/test/run-make-fulldeps/link-cfg/Makefile b/src/test/run-make-fulldeps/link-cfg/Makefile new file mode 100644 index 00000000000..188cba5fe41 --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/Makefile @@ -0,0 +1,22 @@ +-include ../tools.mk + +all: $(call DYLIB,return1) $(call DYLIB,return2) $(call NATIVE_STATICLIB,return3) + ls $(TMPDIR) + $(RUSTC) --print cfg --target x86_64-unknown-linux-musl | $(CGREP) crt-static + + $(RUSTC) no-deps.rs --cfg foo + $(call RUN,no-deps) + $(RUSTC) no-deps.rs --cfg bar + $(call RUN,no-deps) + + $(RUSTC) dep.rs + $(RUSTC) with-deps.rs --cfg foo + $(call RUN,with-deps) + $(RUSTC) with-deps.rs --cfg bar + $(call RUN,with-deps) + + $(RUSTC) dep-with-staticlib.rs + $(RUSTC) with-staticlib-deps.rs --cfg foo + $(call RUN,with-staticlib-deps) + $(RUSTC) with-staticlib-deps.rs --cfg bar + $(call RUN,with-staticlib-deps) diff --git a/src/test/run-make-fulldeps/link-cfg/dep-with-staticlib.rs b/src/test/run-make-fulldeps/link-cfg/dep-with-staticlib.rs new file mode 100644 index 00000000000..ecc2365ddb0 --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/dep-with-staticlib.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(link_cfg)] +#![crate_type = "rlib"] + +#[link(name = "return1", cfg(foo))] +#[link(name = "return3", kind = "static", cfg(bar))] +extern { + pub fn my_function() -> i32; +} diff --git a/src/test/run-make-fulldeps/link-cfg/dep.rs b/src/test/run-make-fulldeps/link-cfg/dep.rs new file mode 100644 index 00000000000..7da879c2bfa --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/dep.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(link_cfg)] +#![crate_type = "rlib"] + +#[link(name = "return1", cfg(foo))] +#[link(name = "return2", cfg(bar))] +extern { + pub fn my_function() -> i32; +} diff --git a/src/test/run-make-fulldeps/link-cfg/no-deps.rs b/src/test/run-make-fulldeps/link-cfg/no-deps.rs new file mode 100644 index 00000000000..6b114106744 --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/no-deps.rs @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(link_cfg)] + +#[link(name = "return1", cfg(foo))] +#[link(name = "return2", cfg(bar))] +extern { + fn my_function() -> i32; +} + +fn main() { + unsafe { + let v = my_function(); + if cfg!(foo) { + assert_eq!(v, 1); + } else if cfg!(bar) { + assert_eq!(v, 2); + } else { + panic!("unknown"); + } + } +} diff --git a/src/test/run-make-fulldeps/link-cfg/return1.c b/src/test/run-make-fulldeps/link-cfg/return1.c new file mode 100644 index 00000000000..a2a3d051dd1 --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/return1.c @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int my_function() { + return 1; +} diff --git a/src/test/run-make-fulldeps/link-cfg/return2.c b/src/test/run-make-fulldeps/link-cfg/return2.c new file mode 100644 index 00000000000..d6ddcccf2fb --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/return2.c @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int my_function() { + return 2; +} diff --git a/src/test/run-make-fulldeps/link-cfg/return3.c b/src/test/run-make-fulldeps/link-cfg/return3.c new file mode 100644 index 00000000000..6a3b695f208 --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/return3.c @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int my_function() { + return 3; +} diff --git a/src/test/run-make-fulldeps/link-cfg/with-deps.rs b/src/test/run-make-fulldeps/link-cfg/with-deps.rs new file mode 100644 index 00000000000..799555c500a --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/with-deps.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate dep; + +fn main() { + unsafe { + let v = dep::my_function(); + if cfg!(foo) { + assert_eq!(v, 1); + } else if cfg!(bar) { + assert_eq!(v, 2); + } else { + panic!("unknown"); + } + } +} diff --git a/src/test/run-make-fulldeps/link-cfg/with-staticlib-deps.rs b/src/test/run-make-fulldeps/link-cfg/with-staticlib-deps.rs new file mode 100644 index 00000000000..33a9c7720e2 --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/with-staticlib-deps.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate dep_with_staticlib; + +fn main() { + unsafe { + let v = dep_with_staticlib::my_function(); + if cfg!(foo) { + assert_eq!(v, 1); + } else if cfg!(bar) { + assert_eq!(v, 3); + } else { + panic!("unknown"); + } + } +} diff --git a/src/test/run-make-fulldeps/link-path-order/Makefile b/src/test/run-make-fulldeps/link-path-order/Makefile new file mode 100644 index 00000000000..eeea0e3714e --- /dev/null +++ b/src/test/run-make-fulldeps/link-path-order/Makefile @@ -0,0 +1,18 @@ +-include ../tools.mk + +# Verifies that the -L arguments given to the linker is in the same order +# as the -L arguments on the rustc command line. + +CORRECT_DIR=$(TMPDIR)/correct +WRONG_DIR=$(TMPDIR)/wrong + +F := $(call NATIVE_STATICLIB_FILE,foo) + +all: $(call NATIVE_STATICLIB,correct) $(call NATIVE_STATICLIB,wrong) + mkdir -p $(CORRECT_DIR) $(WRONG_DIR) + mv $(call NATIVE_STATICLIB,correct) $(CORRECT_DIR)/$(F) + mv $(call NATIVE_STATICLIB,wrong) $(WRONG_DIR)/$(F) + $(RUSTC) main.rs -o $(TMPDIR)/should_succeed -L $(CORRECT_DIR) -L $(WRONG_DIR) + $(call RUN,should_succeed) + $(RUSTC) main.rs -o $(TMPDIR)/should_fail -L $(WRONG_DIR) -L $(CORRECT_DIR) + $(call FAIL,should_fail) diff --git a/src/test/run-make-fulldeps/link-path-order/correct.c b/src/test/run-make-fulldeps/link-path-order/correct.c new file mode 100644 index 00000000000..a595939f92e --- /dev/null +++ b/src/test/run-make-fulldeps/link-path-order/correct.c @@ -0,0 +1,2 @@ +// ignore-license +int should_return_one() { return 1; } diff --git a/src/test/run-make-fulldeps/link-path-order/main.rs b/src/test/run-make-fulldeps/link-path-order/main.rs new file mode 100644 index 00000000000..aaac3927f1c --- /dev/null +++ b/src/test/run-make-fulldeps/link-path-order/main.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(libc, exit_status)] + +extern crate libc; + +#[link(name="foo", kind = "static")] +extern { + fn should_return_one() -> libc::c_int; +} + +fn main() { + let result = unsafe { + should_return_one() + }; + + if result != 1 { + std::process::exit(255); + } +} diff --git a/src/test/run-make-fulldeps/link-path-order/wrong.c b/src/test/run-make-fulldeps/link-path-order/wrong.c new file mode 100644 index 00000000000..c53e7e3c48c --- /dev/null +++ b/src/test/run-make-fulldeps/link-path-order/wrong.c @@ -0,0 +1,2 @@ +// ignore-license +int should_return_one() { return 0; } diff --git a/src/test/run-make-fulldeps/linkage-attr-on-static/Makefile b/src/test/run-make-fulldeps/linkage-attr-on-static/Makefile new file mode 100644 index 00000000000..4befbe14465 --- /dev/null +++ b/src/test/run-make-fulldeps/linkage-attr-on-static/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,foo) + $(RUSTC) bar.rs + $(call RUN,bar) || exit 1 diff --git a/src/test/run-make-fulldeps/linkage-attr-on-static/bar.rs b/src/test/run-make-fulldeps/linkage-attr-on-static/bar.rs new file mode 100644 index 00000000000..274401c448b --- /dev/null +++ b/src/test/run-make-fulldeps/linkage-attr-on-static/bar.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(linkage)] + +#[no_mangle] +#[linkage = "external"] +static BAZ: i32 = 21; + +#[link(name = "foo", kind = "static")] +extern { + fn what() -> i32; +} + +fn main() { + unsafe { + assert_eq!(what(), BAZ); + } +} diff --git a/src/test/run-make-fulldeps/linkage-attr-on-static/foo.c b/src/test/run-make-fulldeps/linkage-attr-on-static/foo.c new file mode 100644 index 00000000000..d7d33ea12e8 --- /dev/null +++ b/src/test/run-make-fulldeps/linkage-attr-on-static/foo.c @@ -0,0 +1,8 @@ +// ignore-license +#include + +extern int32_t BAZ; + +int32_t what() { + return BAZ; +} diff --git a/src/test/run-make-fulldeps/linker-output-non-utf8/Makefile b/src/test/run-make-fulldeps/linker-output-non-utf8/Makefile new file mode 100644 index 00000000000..5f1577ab44d --- /dev/null +++ b/src/test/run-make-fulldeps/linker-output-non-utf8/Makefile @@ -0,0 +1,32 @@ +-include ../tools.mk + +# Make sure we don't ICE if the linker prints a non-UTF-8 error message. + +# Ignore Windows and Apple + +# This does not work in its current form on windows, possibly due to +# gcc bugs or something about valid Windows paths. See issue #29151 +# for more information. +ifndef IS_WINDOWS + +# This also does not work on Apple APFS due to the filesystem requiring +# valid UTF-8 paths. +ifneq ($(shell uname),Darwin) + +# The zzz it to allow humans to tab complete or glob this thing. +bad_dir := $(TMPDIR)/zzz$$'\xff' + +all: + $(RUSTC) library.rs + mkdir $(bad_dir) + mv $(TMPDIR)/liblibrary.a $(bad_dir) + LIBRARY_PATH=$(bad_dir) $(RUSTC) exec.rs 2>&1 | $(CGREP) this_symbol_not_defined +else +all: + +endif + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/linker-output-non-utf8/exec.rs b/src/test/run-make-fulldeps/linker-output-non-utf8/exec.rs new file mode 100644 index 00000000000..1c03eb479fd --- /dev/null +++ b/src/test/run-make-fulldeps/linker-output-non-utf8/exec.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[link(name="library")] +extern "C" { + fn foo(); +} + +fn main() { unsafe { foo(); } } diff --git a/src/test/run-make-fulldeps/linker-output-non-utf8/library.rs b/src/test/run-make-fulldeps/linker-output-non-utf8/library.rs new file mode 100644 index 00000000000..194be26424a --- /dev/null +++ b/src/test/run-make-fulldeps/linker-output-non-utf8/library.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "staticlib"] + +extern "C" { + fn this_symbol_not_defined(); +} + +#[no_mangle] +pub extern "C" fn foo() { + unsafe { this_symbol_not_defined(); } +} diff --git a/src/test/run-make-fulldeps/llvm-pass/Makefile b/src/test/run-make-fulldeps/llvm-pass/Makefile new file mode 100644 index 00000000000..8a18aadf36a --- /dev/null +++ b/src/test/run-make-fulldeps/llvm-pass/Makefile @@ -0,0 +1,28 @@ +-include ../tools.mk + +ifeq ($(UNAME),Darwin) +PLUGIN_FLAGS := -C link-args=-Wl,-undefined,dynamic_lookup +endif + +ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) +# ignore stage1 +all: + +else +# Windows doesn't correctly handle include statements with escaping paths, +# so this test will not get run on Windows. +ifdef IS_WINDOWS +all: +else +all: $(call NATIVE_STATICLIB,llvm-function-pass) $(call NATIVE_STATICLIB,llvm-module-pass) + $(RUSTC) plugin.rs -C prefer-dynamic $(PLUGIN_FLAGS) + $(RUSTC) main.rs + +$(TMPDIR)/libllvm-function-pass.o: + $(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-function-pass.so.cc -o $(TMPDIR)/libllvm-function-pass.o + +$(TMPDIR)/libllvm-module-pass.o: + $(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-module-pass.so.cc -o $(TMPDIR)/libllvm-module-pass.o +endif + +endif diff --git a/src/test/run-make-fulldeps/llvm-pass/llvm-function-pass.so.cc b/src/test/run-make-fulldeps/llvm-pass/llvm-function-pass.so.cc new file mode 100644 index 00000000000..880c9bce562 --- /dev/null +++ b/src/test/run-make-fulldeps/llvm-pass/llvm-function-pass.so.cc @@ -0,0 +1,61 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#include +#include +#include + +#include "llvm/Pass.h" +#include "llvm/IR/Function.h" + +using namespace llvm; + +namespace { + + class TestLLVMPass : public FunctionPass { + + public: + + static char ID; + TestLLVMPass() : FunctionPass(ID) { } + + bool runOnFunction(Function &F) override; + +#if LLVM_VERSION_MAJOR >= 4 + StringRef +#else + const char * +#endif + getPassName() const override { + return "Some LLVM pass"; + } + + }; + +} + +bool TestLLVMPass::runOnFunction(Function &F) { + // A couple examples of operations that previously caused segmentation faults + // https://github.com/rust-lang/rust/issues/31067 + + for (auto N = F.begin(); N != F.end(); ++N) { + /* code */ + } + + LLVMContext &C = F.getContext(); + IntegerType *Int8Ty = IntegerType::getInt8Ty(C); + PointerType::get(Int8Ty, 0); + return true; +} + +char TestLLVMPass::ID = 0; + +static RegisterPass RegisterAFLPass( + "some-llvm-function-pass", "Some LLVM pass"); diff --git a/src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc b/src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc new file mode 100644 index 00000000000..280eca7e8f0 --- /dev/null +++ b/src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc @@ -0,0 +1,60 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#include +#include +#include + +#include "llvm/IR/Module.h" + +using namespace llvm; + +namespace { + + class TestLLVMPass : public ModulePass { + + public: + + static char ID; + TestLLVMPass() : ModulePass(ID) { } + + bool runOnModule(Module &M) override; + +#if LLVM_VERSION_MAJOR >= 4 + StringRef +#else + const char * +#endif + getPassName() const override { + return "Some LLVM pass"; + } + + }; + +} + +bool TestLLVMPass::runOnModule(Module &M) { + // A couple examples of operations that previously caused segmentation faults + // https://github.com/rust-lang/rust/issues/31067 + + for (auto F = M.begin(); F != M.end(); ++F) { + /* code */ + } + + LLVMContext &C = M.getContext(); + IntegerType *Int8Ty = IntegerType::getInt8Ty(C); + PointerType::get(Int8Ty, 0); + return true; +} + +char TestLLVMPass::ID = 0; + +static RegisterPass RegisterAFLPass( + "some-llvm-module-pass", "Some LLVM pass"); diff --git a/src/test/run-make-fulldeps/llvm-pass/main.rs b/src/test/run-make-fulldeps/llvm-pass/main.rs new file mode 100644 index 00000000000..5b5ab94bcef --- /dev/null +++ b/src/test/run-make-fulldeps/llvm-pass/main.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(plugin)] +#![plugin(some_plugin)] + +fn main() {} diff --git a/src/test/run-make-fulldeps/llvm-pass/plugin.rs b/src/test/run-make-fulldeps/llvm-pass/plugin.rs new file mode 100644 index 00000000000..f77b2fca857 --- /dev/null +++ b/src/test/run-make-fulldeps/llvm-pass/plugin.rs @@ -0,0 +1,28 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(plugin_registrar, rustc_private)] +#![crate_type = "dylib"] +#![crate_name = "some_plugin"] + +extern crate rustc; +extern crate rustc_plugin; + +#[link(name = "llvm-function-pass", kind = "static")] +#[link(name = "llvm-module-pass", kind = "static")] +extern {} + +use rustc_plugin::registry::Registry; + +#[plugin_registrar] +pub fn plugin_registrar(reg: &mut Registry) { + reg.register_llvm_pass("some-llvm-function-pass"); + reg.register_llvm_pass("some-llvm-module-pass"); +} diff --git a/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/Makefile new file mode 100644 index 00000000000..debe9e93824 --- /dev/null +++ b/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs -g + cp foo.bat $(TMPDIR)/ + OUT_DIR="$(TMPDIR)" RUSTC="$(RUSTC_ORIGINAL)" $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.bat b/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.bat new file mode 100644 index 00000000000..a9350f12bbb --- /dev/null +++ b/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.bat @@ -0,0 +1 @@ +%MY_LINKER% %* diff --git a/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.rs b/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.rs new file mode 100644 index 00000000000..67d8ad0b672 --- /dev/null +++ b/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.rs @@ -0,0 +1,111 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Like the `long-linker-command-lines` test this test attempts to blow +// a command line limit for running the linker. Unlike that test, however, +// this test is testing `cmd.exe` specifically rather than the OS. +// +// Unfortunately `cmd.exe` has a 8192 limit which is relatively small +// in the grand scheme of things and anyone sripting rustc's linker +// is probably using a `*.bat` script and is likely to hit this limit. +// +// This test uses a `foo.bat` script as the linker which just simply +// delegates back to this program. The compiler should use a lower +// limit for arguments before passing everything via `@`, which +// means that everything should still succeed here. + +use std::env; +use std::fs::{self, File}; +use std::io::{BufWriter, Write, Read}; +use std::path::PathBuf; +use std::process::Command; + +fn main() { + if !cfg!(windows) { + return + } + + let tmpdir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); + let ok = tmpdir.join("ok"); + let not_ok = tmpdir.join("not_ok"); + if env::var("YOU_ARE_A_LINKER").is_ok() { + match env::args_os().find(|a| a.to_string_lossy().contains("@")) { + Some(file) => { + let file = file.to_str().unwrap(); + fs::copy(&file[1..], &ok).unwrap(); + } + None => { File::create(¬_ok).unwrap(); } + } + return + } + + let rustc = env::var_os("RUSTC").unwrap_or("rustc".into()); + let me = env::current_exe().unwrap(); + let bat = me.parent() + .unwrap() + .join("foo.bat"); + let bat_linker = format!("linker={}", bat.display()); + for i in (1..).map(|i| i * 10) { + println!("attempt: {}", i); + + let file = tmpdir.join("bar.rs"); + let mut f = BufWriter::new(File::create(&file).unwrap()); + let mut lib_name = String::new(); + for _ in 0..i { + lib_name.push_str("foo"); + } + for j in 0..i { + writeln!(f, "#[link(name = \"{}{}\")]", lib_name, j).unwrap(); + } + writeln!(f, "extern {{}}\nfn main() {{}}").unwrap(); + f.into_inner().unwrap(); + + drop(fs::remove_file(&ok)); + drop(fs::remove_file(¬_ok)); + let status = Command::new(&rustc) + .arg(&file) + .arg("-C").arg(&bat_linker) + .arg("--out-dir").arg(&tmpdir) + .env("YOU_ARE_A_LINKER", "1") + .env("MY_LINKER", &me) + .status() + .unwrap(); + + if !status.success() { + panic!("rustc didn't succeed: {}", status); + } + + if !ok.exists() { + assert!(not_ok.exists()); + continue + } + + let mut contents = Vec::new(); + File::open(&ok).unwrap().read_to_end(&mut contents).unwrap(); + + for j in 0..i { + let exp = format!("{}{}", lib_name, j); + let exp = if cfg!(target_env = "msvc") { + let mut out = Vec::with_capacity(exp.len() * 2); + for c in exp.encode_utf16() { + // encode in little endian + out.push(c as u8); + out.push((c >> 8) as u8); + } + out + } else { + exp.into_bytes() + }; + assert!(contents.windows(exp.len()).any(|w| w == &exp[..])); + } + + break + } +} diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile new file mode 100644 index 00000000000..5876fbc94bc --- /dev/null +++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs -g -O + RUSTC="$(RUSTC_ORIGINAL)" $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/foo.rs b/src/test/run-make-fulldeps/long-linker-command-lines/foo.rs new file mode 100644 index 00000000000..2ac240982af --- /dev/null +++ b/src/test/run-make-fulldeps/long-linker-command-lines/foo.rs @@ -0,0 +1,101 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This is a test which attempts to blow out the system limit with how many +// arguments can be passed to a process. This'll successively call rustc with +// larger and larger argument lists in an attempt to find one that's way too +// big for the system at hand. This file itself is then used as a "linker" to +// detect when the process creation succeeds. +// +// Eventually we should see an argument that looks like `@` as we switch from +// passing literal arguments to passing everything in the file. + +use std::env; +use std::fs::{self, File}; +use std::io::{BufWriter, Write, Read}; +use std::path::PathBuf; +use std::process::Command; + +fn main() { + let tmpdir = PathBuf::from(env::var_os("TMPDIR").unwrap()); + let ok = tmpdir.join("ok"); + if env::var("YOU_ARE_A_LINKER").is_ok() { + if let Some(file) = env::args_os().find(|a| a.to_string_lossy().contains("@")) { + let file = file.to_str().expect("non-utf8 file argument"); + fs::copy(&file[1..], &ok).unwrap(); + } + return + } + + let rustc = env::var_os("RUSTC").unwrap_or("rustc".into()); + let me_as_linker = format!("linker={}", env::current_exe().unwrap().display()); + for i in (1..).map(|i| i * 100) { + println!("attempt: {}", i); + let file = tmpdir.join("bar.rs"); + let mut f = BufWriter::new(File::create(&file).unwrap()); + let mut lib_name = String::new(); + for _ in 0..i { + lib_name.push_str("foo"); + } + for j in 0..i { + writeln!(f, "#[link(name = \"{}{}\")]", lib_name, j).unwrap(); + } + writeln!(f, "extern {{}}\nfn main() {{}}").unwrap(); + f.into_inner().unwrap(); + + drop(fs::remove_file(&ok)); + let output = Command::new(&rustc) + .arg(&file) + .arg("-C").arg(&me_as_linker) + .arg("--out-dir").arg(&tmpdir) + .env("YOU_ARE_A_LINKER", "1") + .output() + .unwrap(); + + if !output.status.success() { + let stderr = String::from_utf8_lossy(&output.stderr); + panic!("status: {}\nstdout:\n{}\nstderr:\n{}", + output.status, + String::from_utf8_lossy(&output.stdout), + stderr.lines().map(|l| { + if l.len() > 200 { + format!("{}...\n", &l[..200]) + } else { + format!("{}\n", l) + } + }).collect::()); + } + + if !ok.exists() { + continue + } + + let mut contents = Vec::new(); + File::open(&ok).unwrap().read_to_end(&mut contents).unwrap(); + + for j in 0..i { + let exp = format!("{}{}", lib_name, j); + let exp = if cfg!(target_env = "msvc") { + let mut out = Vec::with_capacity(exp.len() * 2); + for c in exp.encode_utf16() { + // encode in little endian + out.push(c as u8); + out.push((c >> 8) as u8); + } + out + } else { + exp.into_bytes() + }; + assert!(contents.windows(exp.len()).any(|w| w == &exp[..])); + } + + break + } +} diff --git a/src/test/run-make-fulldeps/longjmp-across-rust/Makefile b/src/test/run-make-fulldeps/longjmp-across-rust/Makefile new file mode 100644 index 00000000000..9d71ed8fcf3 --- /dev/null +++ b/src/test/run-make-fulldeps/longjmp-across-rust/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,foo) + $(RUSTC) main.rs + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/longjmp-across-rust/foo.c b/src/test/run-make-fulldeps/longjmp-across-rust/foo.c new file mode 100644 index 00000000000..eb993957674 --- /dev/null +++ b/src/test/run-make-fulldeps/longjmp-across-rust/foo.c @@ -0,0 +1,28 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#include +#include + +static jmp_buf ENV; + +extern void test_middle(); + +void test_start(void(*f)()) { + if (setjmp(ENV) != 0) + return; + f(); + assert(0); +} + +void test_end() { + longjmp(ENV, 1); + assert(0); +} diff --git a/src/test/run-make-fulldeps/longjmp-across-rust/main.rs b/src/test/run-make-fulldeps/longjmp-across-rust/main.rs new file mode 100644 index 00000000000..c420473a560 --- /dev/null +++ b/src/test/run-make-fulldeps/longjmp-across-rust/main.rs @@ -0,0 +1,40 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[link(name = "foo", kind = "static")] +extern { + fn test_start(f: extern fn()); + fn test_end(); +} + +fn main() { + unsafe { + test_start(test_middle); + } +} + +struct A; + +impl Drop for A { + fn drop(&mut self) { + } +} + +extern fn test_middle() { + let _a = A; + foo(); +} + +fn foo() { + let _a = A; + unsafe { + test_end(); + } +} diff --git a/src/test/run-make-fulldeps/ls-metadata/Makefile b/src/test/run-make-fulldeps/ls-metadata/Makefile new file mode 100644 index 00000000000..fc3f5bce0cd --- /dev/null +++ b/src/test/run-make-fulldeps/ls-metadata/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs + $(RUSTC) -Z ls $(TMPDIR)/foo + touch $(TMPDIR)/bar + $(RUSTC) -Z ls $(TMPDIR)/bar diff --git a/src/test/run-make-fulldeps/ls-metadata/foo.rs b/src/test/run-make-fulldeps/ls-metadata/foo.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/ls-metadata/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/lto-no-link-whole-rlib/Makefile b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/Makefile new file mode 100644 index 00000000000..1d45cb413c5 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/Makefile @@ -0,0 +1,18 @@ +# Copyright 2016 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar) + $(RUSTC) lib1.rs + $(RUSTC) lib2.rs + $(RUSTC) main.rs -Clto + $(call RUN,main) + diff --git a/src/test/run-make-fulldeps/lto-no-link-whole-rlib/bar.c b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/bar.c new file mode 100644 index 00000000000..716d1abcf34 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/bar.c @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +int foo() { + return 2; +} diff --git a/src/test/run-make-fulldeps/lto-no-link-whole-rlib/foo.c b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/foo.c new file mode 100644 index 00000000000..1b36874581a --- /dev/null +++ b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/foo.c @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +int foo() { + return 1; +} diff --git a/src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib1.rs b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib1.rs new file mode 100644 index 00000000000..0a87c8e4725 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib1.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[link(name = "foo", kind = "static")] +extern { + fn foo() -> i32; +} + +pub fn foo1() -> i32 { + unsafe { foo() } +} diff --git a/src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib2.rs b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib2.rs new file mode 100644 index 00000000000..6e3f382b3fd --- /dev/null +++ b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib2.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +extern crate lib1; + +#[link(name = "bar", kind = "static")] +extern { + fn foo() -> i32; +} + +pub fn foo2() -> i32 { + unsafe { foo() } +} + diff --git a/src/test/run-make-fulldeps/lto-no-link-whole-rlib/main.rs b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/main.rs new file mode 100644 index 00000000000..8417af63be9 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/main.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate lib1; +extern crate lib2; + +fn main() { + assert_eq!(lib1::foo1(), 2); + assert_eq!(lib2::foo2(), 2); +} diff --git a/src/test/run-make-fulldeps/lto-readonly-lib/Makefile b/src/test/run-make-fulldeps/lto-readonly-lib/Makefile new file mode 100644 index 00000000000..0afbbc3450a --- /dev/null +++ b/src/test/run-make-fulldeps/lto-readonly-lib/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +all: + $(RUSTC) lib.rs + + # the compiler needs to copy and modify the rlib file when performing + # LTO, so we should ensure that it can cope with the original rlib + # being read-only. + chmod 444 $(TMPDIR)/*.rlib + + $(RUSTC) main.rs -C lto + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/lto-readonly-lib/lib.rs b/src/test/run-make-fulldeps/lto-readonly-lib/lib.rs new file mode 100644 index 00000000000..04d3ae67207 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-readonly-lib/lib.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/lto-readonly-lib/main.rs b/src/test/run-make-fulldeps/lto-readonly-lib/main.rs new file mode 100644 index 00000000000..e12ac9e01dc --- /dev/null +++ b/src/test/run-make-fulldeps/lto-readonly-lib/main.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate lib; + +fn main() {} diff --git a/src/test/run-make-fulldeps/lto-smoke-c/Makefile b/src/test/run-make-fulldeps/lto-smoke-c/Makefile new file mode 100644 index 00000000000..0f61f5de938 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-smoke-c/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +# Apparently older versions of GCC segfault if -g is passed... +CC := $(CC:-g=) + +all: + $(RUSTC) foo.rs -C lto + $(CC) bar.c $(call STATICLIB,foo) \ + $(call OUT_EXE,bar) \ + $(EXTRACFLAGS) $(EXTRACXXFLAGS) + $(call RUN,bar) diff --git a/src/test/run-make-fulldeps/lto-smoke-c/bar.c b/src/test/run-make-fulldeps/lto-smoke-c/bar.c new file mode 100644 index 00000000000..5729d411c5b --- /dev/null +++ b/src/test/run-make-fulldeps/lto-smoke-c/bar.c @@ -0,0 +1,7 @@ +// ignore-license +void foo(); + +int main() { + foo(); + return 0; +} diff --git a/src/test/run-make-fulldeps/lto-smoke-c/foo.rs b/src/test/run-make-fulldeps/lto-smoke-c/foo.rs new file mode 100644 index 00000000000..1bb19016700 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-smoke-c/foo.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "staticlib"] + +#[no_mangle] +pub extern "C" fn foo() {} diff --git a/src/test/run-make-fulldeps/lto-smoke/Makefile b/src/test/run-make-fulldeps/lto-smoke/Makefile new file mode 100644 index 00000000000..020252e1f8c --- /dev/null +++ b/src/test/run-make-fulldeps/lto-smoke/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) lib.rs + $(RUSTC) main.rs -C lto + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/lto-smoke/lib.rs b/src/test/run-make-fulldeps/lto-smoke/lib.rs new file mode 100644 index 00000000000..04d3ae67207 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-smoke/lib.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/lto-smoke/main.rs b/src/test/run-make-fulldeps/lto-smoke/main.rs new file mode 100644 index 00000000000..e12ac9e01dc --- /dev/null +++ b/src/test/run-make-fulldeps/lto-smoke/main.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate lib; + +fn main() {} diff --git a/src/test/run-make-fulldeps/manual-crate-name/Makefile b/src/test/run-make-fulldeps/manual-crate-name/Makefile new file mode 100644 index 00000000000..1d1419997a2 --- /dev/null +++ b/src/test/run-make-fulldeps/manual-crate-name/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) --crate-name foo bar.rs + rm $(TMPDIR)/libfoo.rlib diff --git a/src/test/run-make-fulldeps/manual-crate-name/bar.rs b/src/test/run-make-fulldeps/manual-crate-name/bar.rs new file mode 100644 index 00000000000..04d3ae67207 --- /dev/null +++ b/src/test/run-make-fulldeps/manual-crate-name/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/manual-link/Makefile b/src/test/run-make-fulldeps/manual-link/Makefile new file mode 100644 index 00000000000..dccf0d99b0f --- /dev/null +++ b/src/test/run-make-fulldeps/manual-link/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: $(TMPDIR)/libbar.a + $(RUSTC) foo.rs -lstatic=bar + $(RUSTC) main.rs + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/manual-link/bar.c b/src/test/run-make-fulldeps/manual-link/bar.c new file mode 100644 index 00000000000..3c167b45af9 --- /dev/null +++ b/src/test/run-make-fulldeps/manual-link/bar.c @@ -0,0 +1,2 @@ +// ignore-license +void bar() {} diff --git a/src/test/run-make-fulldeps/manual-link/foo.c b/src/test/run-make-fulldeps/manual-link/foo.c new file mode 100644 index 00000000000..3c167b45af9 --- /dev/null +++ b/src/test/run-make-fulldeps/manual-link/foo.c @@ -0,0 +1,2 @@ +// ignore-license +void bar() {} diff --git a/src/test/run-make-fulldeps/manual-link/foo.rs b/src/test/run-make-fulldeps/manual-link/foo.rs new file mode 100644 index 00000000000..d67a4057afb --- /dev/null +++ b/src/test/run-make-fulldeps/manual-link/foo.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +extern { + fn bar(); +} + +pub fn foo() { + unsafe { bar(); } +} diff --git a/src/test/run-make-fulldeps/manual-link/main.rs b/src/test/run-make-fulldeps/manual-link/main.rs new file mode 100644 index 00000000000..756a47f386a --- /dev/null +++ b/src/test/run-make-fulldeps/manual-link/main.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::foo(); +} diff --git a/src/test/run-make-fulldeps/many-crates-but-no-match/Makefile b/src/test/run-make-fulldeps/many-crates-but-no-match/Makefile new file mode 100644 index 00000000000..03a797d95f9 --- /dev/null +++ b/src/test/run-make-fulldeps/many-crates-but-no-match/Makefile @@ -0,0 +1,36 @@ +-include ../tools.mk + +# Modelled after compile-fail/changing-crates test, but this one puts +# more than one (mismatching) candidate crate into the search path, +# which did not appear directly expressible in compile-fail/aux-build +# infrastructure. +# +# Note that we move the built libraries into target direcrtories rather than +# use the `--out-dir` option because the `../tools.mk` file already bakes a +# use of `--out-dir` into the definition of $(RUSTC). + +A1=$(TMPDIR)/a1 +A2=$(TMPDIR)/a2 +A3=$(TMPDIR)/a3 + +# A hack to match distinct lines of output from a single run. +LOG=$(TMPDIR)/log.txt + +all: + mkdir -p $(A1) $(A2) $(A3) + $(RUSTC) --crate-type=rlib crateA1.rs + mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A1) + $(RUSTC) --crate-type=rlib -L $(A1) crateB.rs + $(RUSTC) --crate-type=rlib crateA2.rs + mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A2) + $(RUSTC) --crate-type=rlib crateA3.rs + mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A3) + # Ensure crateC fails to compile since A1 is "missing" and A2/A3 hashes do not match + $(RUSTC) -L $(A2) -L $(A3) crateC.rs >$(LOG) 2>&1 || true + $(CGREP) \ + 'found possibly newer version of crate `crateA` which `crateB` depends on' \ + 'note: perhaps that crate needs to be recompiled?' \ + 'crate `crateA`:' \ + 'crate `crateB`:' \ + < $(LOG) + # the 'crate `crateA`' will match two entries. \ No newline at end of file diff --git a/src/test/run-make-fulldeps/many-crates-but-no-match/crateA1.rs b/src/test/run-make-fulldeps/many-crates-but-no-match/crateA1.rs new file mode 100644 index 00000000000..dbfe920c85b --- /dev/null +++ b/src/test/run-make-fulldeps/many-crates-but-no-match/crateA1.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="crateA"] + +// Base crate +pub fn func() {} diff --git a/src/test/run-make-fulldeps/many-crates-but-no-match/crateA2.rs b/src/test/run-make-fulldeps/many-crates-but-no-match/crateA2.rs new file mode 100644 index 00000000000..857c36aee60 --- /dev/null +++ b/src/test/run-make-fulldeps/many-crates-but-no-match/crateA2.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="crateA"] + +// Base crate +pub fn func() { println!("hello"); } diff --git a/src/test/run-make-fulldeps/many-crates-but-no-match/crateA3.rs b/src/test/run-make-fulldeps/many-crates-but-no-match/crateA3.rs new file mode 100644 index 00000000000..8b8dac5e862 --- /dev/null +++ b/src/test/run-make-fulldeps/many-crates-but-no-match/crateA3.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="crateA"] + +// Base crate +pub fn foo() { println!("world!"); } diff --git a/src/test/run-make-fulldeps/many-crates-but-no-match/crateB.rs b/src/test/run-make-fulldeps/many-crates-but-no-match/crateB.rs new file mode 100644 index 00000000000..bf55017c646 --- /dev/null +++ b/src/test/run-make-fulldeps/many-crates-but-no-match/crateB.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate crateA; diff --git a/src/test/run-make-fulldeps/many-crates-but-no-match/crateC.rs b/src/test/run-make-fulldeps/many-crates-but-no-match/crateC.rs new file mode 100644 index 00000000000..174d9382b76 --- /dev/null +++ b/src/test/run-make-fulldeps/many-crates-but-no-match/crateC.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate crateB; + +fn main() {} diff --git a/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/Makefile b/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/Makefile new file mode 100644 index 00000000000..09e6ae0bbf7 --- /dev/null +++ b/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/Makefile @@ -0,0 +1,10 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs -C metadata=a -C extra-filename=-a + $(RUSTC) foo.rs -C metadata=b -C extra-filename=-b + $(RUSTC) bar.rs \ + --extern foo1=$(TMPDIR)/libfoo-a.rlib \ + --extern foo2=$(TMPDIR)/libfoo-b.rlib \ + -Z print-link-args + $(call RUN,bar) diff --git a/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/bar.rs b/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/bar.rs new file mode 100644 index 00000000000..44b9e2f874a --- /dev/null +++ b/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/bar.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo1; +extern crate foo2; + +fn main() { + let a = foo1::foo(); + let b = foo2::foo(); + assert!(a as *const _ != b as *const _); +} diff --git a/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/foo.rs b/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/foo.rs new file mode 100644 index 00000000000..baabdc9ad7b --- /dev/null +++ b/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/foo.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] +#![crate_type = "rlib"] + +static FOO: usize = 3; + +pub fn foo() -> &'static usize { &FOO } diff --git a/src/test/run-make-fulldeps/min-global-align/Makefile b/src/test/run-make-fulldeps/min-global-align/Makefile new file mode 100644 index 00000000000..2eacc36f380 --- /dev/null +++ b/src/test/run-make-fulldeps/min-global-align/Makefile @@ -0,0 +1,22 @@ +-include ../tools.mk + +# This tests ensure that global variables respect the target minimum alignment. +# The three bools `STATIC_BOOL`, `STATIC_MUT_BOOL`, and `CONST_BOOL` all have +# type-alignment of 1, but some targets require greater global alignment. + +SRC = min_global_align.rs +LL = $(TMPDIR)/min_global_align.ll + +all: +ifeq ($(UNAME),Linux) +# Most targets are happy with default alignment -- take i686 for example. +ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86) + $(RUSTC) --target=i686-unknown-linux-gnu --emit=llvm-ir $(SRC) + [ "$$(grep -c 'align 1' "$(LL)")" -eq "3" ] +endif +# SystemZ requires even alignment for PC-relative addressing. +ifeq ($(filter systemz,$(LLVM_COMPONENTS)),systemz) + $(RUSTC) --target=s390x-unknown-linux-gnu --emit=llvm-ir $(SRC) + [ "$$(grep -c 'align 2' "$(LL)")" -eq "3" ] +endif +endif diff --git a/src/test/run-make-fulldeps/min-global-align/min_global_align.rs b/src/test/run-make-fulldeps/min-global-align/min_global_align.rs new file mode 100644 index 00000000000..3d4f9001a74 --- /dev/null +++ b/src/test/run-make-fulldeps/min-global-align/min_global_align.rs @@ -0,0 +1,38 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(no_core, lang_items)] +#![crate_type="rlib"] +#![no_core] + +pub static STATIC_BOOL: bool = true; + +pub static mut STATIC_MUT_BOOL: bool = true; + +const CONST_BOOL: bool = true; +pub static CONST_BOOL_REF: &'static bool = &CONST_BOOL; + + +#[lang = "sized"] +trait Sized {} + +#[lang = "copy"] +trait Copy {} + +#[lang = "freeze"] +trait Freeze {} + +#[lang = "sync"] +trait Sync {} +impl Sync for bool {} +impl Sync for &'static bool {} + +#[lang="drop_in_place"] +pub unsafe fn drop_in_place(_: *mut T) { } diff --git a/src/test/run-make-fulldeps/mismatching-target-triples/Makefile b/src/test/run-make-fulldeps/mismatching-target-triples/Makefile new file mode 100644 index 00000000000..1636e41b056 --- /dev/null +++ b/src/test/run-make-fulldeps/mismatching-target-triples/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +# Issue #10814 +# +# these are no_std to avoid having to have the standard library or any +# linkers/assemblers for the relevant platform + +all: + $(RUSTC) foo.rs --target=i686-unknown-linux-gnu + $(RUSTC) bar.rs --target=x86_64-unknown-linux-gnu 2>&1 \ + | $(CGREP) 'couldn'"'"'t find crate `foo` with expected target triple x86_64-unknown-linux-gnu' diff --git a/src/test/run-make-fulldeps/mismatching-target-triples/bar.rs b/src/test/run-make-fulldeps/mismatching-target-triples/bar.rs new file mode 100644 index 00000000000..0dc5c0a3a8e --- /dev/null +++ b/src/test/run-make-fulldeps/mismatching-target-triples/bar.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(no_core)] +#![no_core] +extern crate foo; diff --git a/src/test/run-make-fulldeps/mismatching-target-triples/foo.rs b/src/test/run-make-fulldeps/mismatching-target-triples/foo.rs new file mode 100644 index 00000000000..a2169d0c631 --- /dev/null +++ b/src/test/run-make-fulldeps/mismatching-target-triples/foo.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(no_core)] +#![no_core] +#![crate_type = "lib"] diff --git a/src/test/run-make-fulldeps/missing-crate-dependency/Makefile b/src/test/run-make-fulldeps/missing-crate-dependency/Makefile new file mode 100644 index 00000000000..b5a5bf492ab --- /dev/null +++ b/src/test/run-make-fulldeps/missing-crate-dependency/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +all: + $(RUSTC) --crate-type=rlib crateA.rs + $(RUSTC) --crate-type=rlib crateB.rs + $(call REMOVE_RLIBS,crateA) + # Ensure crateC fails to compile since dependency crateA is missing + $(RUSTC) crateC.rs 2>&1 | \ + $(CGREP) 'can'"'"'t find crate for `crateA` which `crateB` depends on' diff --git a/src/test/run-make-fulldeps/missing-crate-dependency/crateA.rs b/src/test/run-make-fulldeps/missing-crate-dependency/crateA.rs new file mode 100644 index 00000000000..4e111f29e8a --- /dev/null +++ b/src/test/run-make-fulldeps/missing-crate-dependency/crateA.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Base crate +pub fn func() {} diff --git a/src/test/run-make-fulldeps/missing-crate-dependency/crateB.rs b/src/test/run-make-fulldeps/missing-crate-dependency/crateB.rs new file mode 100644 index 00000000000..bf55017c646 --- /dev/null +++ b/src/test/run-make-fulldeps/missing-crate-dependency/crateB.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate crateA; diff --git a/src/test/run-make-fulldeps/missing-crate-dependency/crateC.rs b/src/test/run-make-fulldeps/missing-crate-dependency/crateC.rs new file mode 100644 index 00000000000..174d9382b76 --- /dev/null +++ b/src/test/run-make-fulldeps/missing-crate-dependency/crateC.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate crateB; + +fn main() {} diff --git a/src/test/run-make-fulldeps/mixing-deps/Makefile b/src/test/run-make-fulldeps/mixing-deps/Makefile new file mode 100644 index 00000000000..0e52d4a8bef --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-deps/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: + $(RUSTC) both.rs -C prefer-dynamic + $(RUSTC) dylib.rs -C prefer-dynamic + $(RUSTC) prog.rs + $(call RUN,prog) diff --git a/src/test/run-make-fulldeps/mixing-deps/both.rs b/src/test/run-make-fulldeps/mixing-deps/both.rs new file mode 100644 index 00000000000..c44335e2bbc --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-deps/both.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![crate_type = "dylib"] + +pub static foo: isize = 4; diff --git a/src/test/run-make-fulldeps/mixing-deps/dylib.rs b/src/test/run-make-fulldeps/mixing-deps/dylib.rs new file mode 100644 index 00000000000..78af525f386 --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-deps/dylib.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] +extern crate both; + +use std::mem; + +pub fn addr() -> usize { unsafe { mem::transmute(&both::foo) } } diff --git a/src/test/run-make-fulldeps/mixing-deps/prog.rs b/src/test/run-make-fulldeps/mixing-deps/prog.rs new file mode 100644 index 00000000000..c3d88016fda --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-deps/prog.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate dylib; +extern crate both; + +use std::mem; + +fn main() { + assert_eq!(unsafe { mem::transmute::<&isize, usize>(&both::foo) }, + dylib::addr()); +} diff --git a/src/test/run-make-fulldeps/mixing-formats/Makefile b/src/test/run-make-fulldeps/mixing-formats/Makefile new file mode 100644 index 00000000000..48257669baf --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-formats/Makefile @@ -0,0 +1,74 @@ +-include ../tools.mk + +# Testing various mixings of rlibs and dylibs. Makes sure that it's possible to +# link an rlib to a dylib. The dependency tree among the file looks like: +# +# foo +# / \ +# bar1 bar2 +# / \ / +# baz baz2 +# +# This is generally testing the permutations of the foo/bar1/bar2 layer against +# the baz/baz2 layer + +all: + # Building just baz + $(RUSTC) --crate-type=rlib foo.rs + $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic + $(RUSTC) --crate-type=bin baz.rs + rm $(TMPDIR)/* + $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic + $(RUSTC) --crate-type=rlib bar1.rs + $(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic + $(RUSTC) --crate-type=bin baz.rs + rm $(TMPDIR)/* + # Building baz2 + $(RUSTC) --crate-type=rlib foo.rs + $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib baz2.rs && exit 1 || exit 0 + $(RUSTC) --crate-type=bin baz2.rs && exit 1 || exit 0 + rm $(TMPDIR)/* + $(RUSTC) --crate-type=rlib foo.rs + $(RUSTC) --crate-type=rlib bar1.rs + $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib,rlib baz2.rs + $(RUSTC) --crate-type=bin baz2.rs + rm $(TMPDIR)/* + $(RUSTC) --crate-type=rlib foo.rs + $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic + $(RUSTC) --crate-type=rlib bar2.rs + $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic + $(RUSTC) --crate-type=bin baz2.rs + rm $(TMPDIR)/* + $(RUSTC) --crate-type=rlib foo.rs + $(RUSTC) --crate-type=rlib bar1.rs + $(RUSTC) --crate-type=rlib bar2.rs + $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic + $(RUSTC) --crate-type=bin baz2.rs + rm $(TMPDIR)/* + $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic + $(RUSTC) --crate-type=rlib bar1.rs + $(RUSTC) --crate-type=rlib bar2.rs + $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic + $(RUSTC) --crate-type=bin baz2.rs + rm $(TMPDIR)/* + $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic + $(RUSTC) --crate-type=rlib bar2.rs + $(RUSTC) --crate-type=dylib,rlib baz2.rs + $(RUSTC) --crate-type=bin baz2.rs + rm $(TMPDIR)/* + $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic + $(RUSTC) --crate-type=rlib bar1.rs + $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib,rlib baz2.rs + $(RUSTC) --crate-type=bin baz2.rs + rm $(TMPDIR)/* + $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib,rlib baz2.rs + $(RUSTC) --crate-type=bin baz2.rs diff --git a/src/test/run-make-fulldeps/mixing-formats/bar1.rs b/src/test/run-make-fulldeps/mixing-formats/bar1.rs new file mode 100644 index 00000000000..4b4916fe96d --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-formats/bar1.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; diff --git a/src/test/run-make-fulldeps/mixing-formats/bar2.rs b/src/test/run-make-fulldeps/mixing-formats/bar2.rs new file mode 100644 index 00000000000..4b4916fe96d --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-formats/bar2.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; diff --git a/src/test/run-make-fulldeps/mixing-formats/baz.rs b/src/test/run-make-fulldeps/mixing-formats/baz.rs new file mode 100644 index 00000000000..3fb90f6a854 --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-formats/baz.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar1; + +fn main() {} diff --git a/src/test/run-make-fulldeps/mixing-formats/baz2.rs b/src/test/run-make-fulldeps/mixing-formats/baz2.rs new file mode 100644 index 00000000000..c5066ccd656 --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-formats/baz2.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar1; +extern crate bar2; + +fn main() {} diff --git a/src/test/run-make-fulldeps/mixing-formats/foo.rs b/src/test/run-make-fulldeps/mixing-formats/foo.rs new file mode 100644 index 00000000000..e6c76025738 --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-formats/foo.rs @@ -0,0 +1,9 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/run-make-fulldeps/mixing-libs/Makefile b/src/test/run-make-fulldeps/mixing-libs/Makefile new file mode 100644 index 00000000000..babeeef164d --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-libs/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +all: + $(RUSTC) rlib.rs + $(RUSTC) dylib.rs + $(RUSTC) rlib.rs --crate-type=dylib + $(RUSTC) dylib.rs + $(call REMOVE_DYLIBS,rlib) + $(RUSTC) prog.rs && exit 1 || exit 0 diff --git a/src/test/run-make-fulldeps/mixing-libs/dylib.rs b/src/test/run-make-fulldeps/mixing-libs/dylib.rs new file mode 100644 index 00000000000..1a5bd658cd9 --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-libs/dylib.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] +extern crate rlib; + +pub fn dylib() { rlib::rlib() } diff --git a/src/test/run-make-fulldeps/mixing-libs/prog.rs b/src/test/run-make-fulldeps/mixing-libs/prog.rs new file mode 100644 index 00000000000..5e1a4274756 --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-libs/prog.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate dylib; +extern crate rlib; + +fn main() { + dylib::dylib(); + rlib::rlib(); +} diff --git a/src/test/run-make-fulldeps/mixing-libs/rlib.rs b/src/test/run-make-fulldeps/mixing-libs/rlib.rs new file mode 100644 index 00000000000..ad0ea67b9ab --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-libs/rlib.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +pub fn rlib() {} diff --git a/src/test/run-make-fulldeps/msvc-opt-minsize/Makefile b/src/test/run-make-fulldeps/msvc-opt-minsize/Makefile new file mode 100644 index 00000000000..1095a047dd1 --- /dev/null +++ b/src/test/run-make-fulldeps/msvc-opt-minsize/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs -Copt-level=z 2>&1 + $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/msvc-opt-minsize/foo.rs b/src/test/run-make-fulldeps/msvc-opt-minsize/foo.rs new file mode 100644 index 00000000000..30b12691afe --- /dev/null +++ b/src/test/run-make-fulldeps/msvc-opt-minsize/foo.rs @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(test)] +extern crate test; + +fn foo(x: i32, y: i32) -> i64 { + (x + y) as i64 +} + +#[inline(never)] +fn bar() { + let _f = Box::new(0); + // This call used to trigger an LLVM bug in opt-level z where the base + // pointer gets corrupted, see issue #45034 + let y: fn(i32, i32) -> i64 = test::black_box(foo); + test::black_box(y(1, 2)); +} + +fn main() { + bar(); +} diff --git a/src/test/run-make-fulldeps/multiple-emits/Makefile b/src/test/run-make-fulldeps/multiple-emits/Makefile new file mode 100644 index 00000000000..e126422835c --- /dev/null +++ b/src/test/run-make-fulldeps/multiple-emits/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs --emit=asm,llvm-ir -o $(TMPDIR)/out 2>&1 + rm $(TMPDIR)/out.ll $(TMPDIR)/out.s + $(RUSTC) foo.rs --emit=asm,llvm-ir -o $(TMPDIR)/out2.ext 2>&1 + rm $(TMPDIR)/out2.ll $(TMPDIR)/out2.s diff --git a/src/test/run-make-fulldeps/multiple-emits/foo.rs b/src/test/run-make-fulldeps/multiple-emits/foo.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/multiple-emits/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/no-builtins-lto/Makefile b/src/test/run-make-fulldeps/no-builtins-lto/Makefile new file mode 100644 index 00000000000..b9688f16c64 --- /dev/null +++ b/src/test/run-make-fulldeps/no-builtins-lto/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +all: + # Compile a `#![no_builtins]` rlib crate + $(RUSTC) no_builtins.rs + # Build an executable that depends on that crate using LTO. The no_builtins crate doesn't + # participate in LTO, so its rlib must be explicitly linked into the final binary. Verify this by + # grepping the linker arguments. + $(RUSTC) main.rs -C lto -Z print-link-args | $(CGREP) 'libno_builtins.rlib' diff --git a/src/test/run-make-fulldeps/no-builtins-lto/main.rs b/src/test/run-make-fulldeps/no-builtins-lto/main.rs new file mode 100644 index 00000000000..e960c726a98 --- /dev/null +++ b/src/test/run-make-fulldeps/no-builtins-lto/main.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate no_builtins; + +fn main() {} diff --git a/src/test/run-make-fulldeps/no-builtins-lto/no_builtins.rs b/src/test/run-make-fulldeps/no-builtins-lto/no_builtins.rs new file mode 100644 index 00000000000..be95e7c5521 --- /dev/null +++ b/src/test/run-make-fulldeps/no-builtins-lto/no_builtins.rs @@ -0,0 +1,12 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#![no_builtins] diff --git a/src/test/run-make-fulldeps/no-duplicate-libs/Makefile b/src/test/run-make-fulldeps/no-duplicate-libs/Makefile new file mode 100644 index 00000000000..13d8366c60a --- /dev/null +++ b/src/test/run-make-fulldeps/no-duplicate-libs/Makefile @@ -0,0 +1,10 @@ +-include ../tools.mk + +ifdef IS_MSVC +# FIXME(#27979) +all: +else +all: $(call STATICLIB,foo) $(call STATICLIB,bar) + $(RUSTC) main.rs + $(call RUN,main) +endif diff --git a/src/test/run-make-fulldeps/no-duplicate-libs/bar.c b/src/test/run-make-fulldeps/no-duplicate-libs/bar.c new file mode 100644 index 00000000000..b9dcd0f5e5e --- /dev/null +++ b/src/test/run-make-fulldeps/no-duplicate-libs/bar.c @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern void foo(); + +void bar() { + foo(); +} diff --git a/src/test/run-make-fulldeps/no-duplicate-libs/foo.c b/src/test/run-make-fulldeps/no-duplicate-libs/foo.c new file mode 100644 index 00000000000..906cd5682b8 --- /dev/null +++ b/src/test/run-make-fulldeps/no-duplicate-libs/foo.c @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void foo() {} diff --git a/src/test/run-make-fulldeps/no-duplicate-libs/main.rs b/src/test/run-make-fulldeps/no-duplicate-libs/main.rs new file mode 100644 index 00000000000..824946fe9c2 --- /dev/null +++ b/src/test/run-make-fulldeps/no-duplicate-libs/main.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[link(name = "foo")] // linker should drop this library, no symbols used +#[link(name = "bar")] // symbol comes from this library +#[link(name = "foo")] // now linker picks up `foo` b/c `bar` library needs it +extern { + fn bar(); +} + +fn main() { + unsafe { bar() } +} diff --git a/src/test/run-make-fulldeps/no-integrated-as/Makefile b/src/test/run-make-fulldeps/no-integrated-as/Makefile new file mode 100644 index 00000000000..78e3025b99a --- /dev/null +++ b/src/test/run-make-fulldeps/no-integrated-as/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: +ifeq ($(TARGET),x86_64-unknown-linux-gnu) + $(RUSTC) hello.rs -C no_integrated_as + $(call RUN,hello) +endif diff --git a/src/test/run-make-fulldeps/no-integrated-as/hello.rs b/src/test/run-make-fulldeps/no-integrated-as/hello.rs new file mode 100644 index 00000000000..68e7f6d94d1 --- /dev/null +++ b/src/test/run-make-fulldeps/no-integrated-as/hello.rs @@ -0,0 +1,13 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("Hello, world!"); +} diff --git a/src/test/run-make-fulldeps/no-intermediate-extras/Makefile b/src/test/run-make-fulldeps/no-intermediate-extras/Makefile new file mode 100644 index 00000000000..258cbf04c61 --- /dev/null +++ b/src/test/run-make-fulldeps/no-intermediate-extras/Makefile @@ -0,0 +1,7 @@ +# Regression test for issue #10973 + +-include ../tools.mk + +all: + $(RUSTC) --crate-type=rlib --test foo.rs + rm $(TMPDIR)/foo.bc && exit 1 || exit 0 diff --git a/src/test/run-make-fulldeps/no-intermediate-extras/foo.rs b/src/test/run-make-fulldeps/no-intermediate-extras/foo.rs new file mode 100644 index 00000000000..e6c76025738 --- /dev/null +++ b/src/test/run-make-fulldeps/no-intermediate-extras/foo.rs @@ -0,0 +1,9 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/run-make-fulldeps/obey-crate-type-flag/Makefile b/src/test/run-make-fulldeps/obey-crate-type-flag/Makefile new file mode 100644 index 00000000000..903349152df --- /dev/null +++ b/src/test/run-make-fulldeps/obey-crate-type-flag/Makefile @@ -0,0 +1,13 @@ +-include ../tools.mk + +# check that rustc builds all crate_type attributes +# delete rlib +# delete whatever dylib is made for this system +# check that rustc only builds --crate-type flags, ignoring attributes +# fail if an rlib was built +all: + $(RUSTC) test.rs + $(call REMOVE_RLIBS,test) + $(call REMOVE_DYLIBS,test) + $(RUSTC) --crate-type dylib test.rs + $(call REMOVE_RLIBS,test) && exit 1 || exit 0 diff --git a/src/test/run-make-fulldeps/obey-crate-type-flag/test.rs b/src/test/run-make-fulldeps/obey-crate-type-flag/test.rs new file mode 100644 index 00000000000..e6c8b8eb179 --- /dev/null +++ b/src/test/run-make-fulldeps/obey-crate-type-flag/test.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![crate_type = "dylib"] diff --git a/src/test/run-make-fulldeps/output-filename-conflicts-with-directory/Makefile b/src/test/run-make-fulldeps/output-filename-conflicts-with-directory/Makefile new file mode 100644 index 00000000000..74e5dcfcf36 --- /dev/null +++ b/src/test/run-make-fulldeps/output-filename-conflicts-with-directory/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: + cp foo.rs $(TMPDIR)/foo.rs + mkdir $(TMPDIR)/foo + $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo 2>&1 \ + | $(CGREP) -e "the generated executable for the input file \".*foo\.rs\" conflicts with the existing directory \".*foo\"" diff --git a/src/test/run-make-fulldeps/output-filename-conflicts-with-directory/foo.rs b/src/test/run-make-fulldeps/output-filename-conflicts-with-directory/foo.rs new file mode 100644 index 00000000000..3f07b46791d --- /dev/null +++ b/src/test/run-make-fulldeps/output-filename-conflicts-with-directory/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/output-filename-overwrites-input/Makefile b/src/test/run-make-fulldeps/output-filename-overwrites-input/Makefile new file mode 100644 index 00000000000..6377038b7be --- /dev/null +++ b/src/test/run-make-fulldeps/output-filename-overwrites-input/Makefile @@ -0,0 +1,13 @@ +-include ../tools.mk + +all: + cp foo.rs $(TMPDIR)/foo + $(RUSTC) $(TMPDIR)/foo -o $(TMPDIR)/foo 2>&1 \ + | $(CGREP) -e "the input file \".*foo\" would be overwritten by the generated executable" + cp bar.rs $(TMPDIR)/bar.rlib + $(RUSTC) $(TMPDIR)/bar.rlib -o $(TMPDIR)/bar.rlib 2>&1 \ + | $(CGREP) -e "the input file \".*bar.rlib\" would be overwritten by the generated executable" + $(RUSTC) foo.rs 2>&1 && $(RUSTC) -Z ls $(TMPDIR)/foo 2>&1 + cp foo.rs $(TMPDIR)/foo.rs + $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo.rs 2>&1 \ + | $(CGREP) -e "the input file \".*foo.rs\" would be overwritten by the generated executable" diff --git a/src/test/run-make-fulldeps/output-filename-overwrites-input/bar.rs b/src/test/run-make-fulldeps/output-filename-overwrites-input/bar.rs new file mode 100644 index 00000000000..8e4e35fdee6 --- /dev/null +++ b/src/test/run-make-fulldeps/output-filename-overwrites-input/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] diff --git a/src/test/run-make-fulldeps/output-filename-overwrites-input/foo.rs b/src/test/run-make-fulldeps/output-filename-overwrites-input/foo.rs new file mode 100644 index 00000000000..3f07b46791d --- /dev/null +++ b/src/test/run-make-fulldeps/output-filename-overwrites-input/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/output-type-permutations/Makefile b/src/test/run-make-fulldeps/output-type-permutations/Makefile new file mode 100644 index 00000000000..c2715027bc1 --- /dev/null +++ b/src/test/run-make-fulldeps/output-type-permutations/Makefile @@ -0,0 +1,146 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs --crate-type=rlib,dylib,staticlib + $(call REMOVE_RLIBS,bar) + $(call REMOVE_DYLIBS,bar) + rm $(call STATICLIB,bar) + rm -f $(TMPDIR)/bar.{dll.exp,dll.lib,pdb} + # Check that $(TMPDIR) is empty. + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --crate-type=bin + rm $(TMPDIR)/$(call BIN,bar) + rm -f $(TMPDIR)/bar.pdb + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit=asm,llvm-ir,llvm-bc,obj,link + rm $(TMPDIR)/bar.ll + rm $(TMPDIR)/bar.bc + rm $(TMPDIR)/bar.s + rm $(TMPDIR)/bar.o + rm $(TMPDIR)/$(call BIN,bar) + rm -f $(TMPDIR)/bar.pdb + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit asm -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit asm=$(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=asm=$(TMPDIR)/foo + rm $(TMPDIR)/foo + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit llvm-bc -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit llvm-bc=$(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=llvm-bc=$(TMPDIR)/foo + rm $(TMPDIR)/foo + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit llvm-ir -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit llvm-ir=$(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=llvm-ir=$(TMPDIR)/foo + rm $(TMPDIR)/foo + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit obj -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit obj=$(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=obj=$(TMPDIR)/foo + rm $(TMPDIR)/foo + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit link -o $(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --emit link=$(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --emit=link=$(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + rm -f $(TMPDIR)/foo.pdb + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --crate-type=rlib -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --crate-type=rlib --emit link=$(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --crate-type=rlib --emit=link=$(TMPDIR)/foo + rm $(TMPDIR)/foo + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --crate-type=dylib -o $(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --crate-type=dylib --emit link=$(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --crate-type=dylib --emit=link=$(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + rm -f $(TMPDIR)/foo.{dll.exp,dll.lib,pdb} + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --crate-type=staticlib -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --crate-type=staticlib --emit link=$(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --crate-type=staticlib --emit=link=$(TMPDIR)/foo + rm $(TMPDIR)/foo + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --crate-type=bin -o $(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --crate-type=bin --emit link=$(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --crate-type=bin --emit=link=$(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + rm -f $(TMPDIR)/foo.pdb + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit llvm-ir=$(TMPDIR)/ir \ + --emit link \ + --crate-type=rlib + rm $(TMPDIR)/ir + rm $(TMPDIR)/libbar.rlib + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit asm=$(TMPDIR)/asm \ + --emit llvm-ir=$(TMPDIR)/ir \ + --emit llvm-bc=$(TMPDIR)/bc \ + --emit obj=$(TMPDIR)/obj \ + --emit link=$(TMPDIR)/link \ + --crate-type=staticlib + rm $(TMPDIR)/asm + rm $(TMPDIR)/ir + rm $(TMPDIR)/bc + rm $(TMPDIR)/obj + rm $(TMPDIR)/link + $(RUSTC) foo.rs --emit=asm=$(TMPDIR)/asm \ + --emit llvm-ir=$(TMPDIR)/ir \ + --emit=llvm-bc=$(TMPDIR)/bc \ + --emit obj=$(TMPDIR)/obj \ + --emit=link=$(TMPDIR)/link \ + --crate-type=staticlib + rm $(TMPDIR)/asm + rm $(TMPDIR)/ir + rm $(TMPDIR)/bc + rm $(TMPDIR)/obj + rm $(TMPDIR)/link + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit=asm,llvm-ir,llvm-bc,obj,link --crate-type=staticlib + rm $(TMPDIR)/bar.ll + rm $(TMPDIR)/bar.s + rm $(TMPDIR)/bar.o + rm $(call STATICLIB,bar) + mv $(TMPDIR)/bar.bc $(TMPDIR)/foo.bc + # Don't check that the $(TMPDIR) is empty - we left `foo.bc` for later + # comparison. + + $(RUSTC) foo.rs --emit=llvm-bc,link --crate-type=rlib + cmp $(TMPDIR)/foo.bc $(TMPDIR)/bar.bc + rm $(TMPDIR)/bar.bc + rm $(TMPDIR)/foo.bc + $(call REMOVE_RLIBS,bar) + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] diff --git a/src/test/run-make-fulldeps/output-type-permutations/foo.rs b/src/test/run-make-fulldeps/output-type-permutations/foo.rs new file mode 100644 index 00000000000..bb5796bd873 --- /dev/null +++ b/src/test/run-make-fulldeps/output-type-permutations/foo.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "bar"] + +fn main() {} diff --git a/src/test/run-make-fulldeps/output-with-hyphens/Makefile b/src/test/run-make-fulldeps/output-with-hyphens/Makefile new file mode 100644 index 00000000000..783d826a53d --- /dev/null +++ b/src/test/run-make-fulldeps/output-with-hyphens/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) foo-bar.rs + [ -f $(TMPDIR)/$(call BIN,foo-bar) ] + [ -f $(TMPDIR)/libfoo_bar.rlib ] diff --git a/src/test/run-make-fulldeps/output-with-hyphens/foo-bar.rs b/src/test/run-make-fulldeps/output-with-hyphens/foo-bar.rs new file mode 100644 index 00000000000..2f93b2d1ead --- /dev/null +++ b/src/test/run-make-fulldeps/output-with-hyphens/foo-bar.rs @@ -0,0 +1,14 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#![crate_type = "bin"] + +fn main() {} diff --git a/src/test/run-make-fulldeps/prefer-dylib/Makefile b/src/test/run-make-fulldeps/prefer-dylib/Makefile new file mode 100644 index 00000000000..bd44feecf2a --- /dev/null +++ b/src/test/run-make-fulldeps/prefer-dylib/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: + $(RUSTC) bar.rs --crate-type=dylib --crate-type=rlib -C prefer-dynamic + $(RUSTC) foo.rs -C prefer-dynamic + $(call RUN,foo) + rm $(TMPDIR)/*bar* + $(call FAIL,foo) diff --git a/src/test/run-make-fulldeps/prefer-dylib/bar.rs b/src/test/run-make-fulldeps/prefer-dylib/bar.rs new file mode 100644 index 00000000000..4c79f7e2855 --- /dev/null +++ b/src/test/run-make-fulldeps/prefer-dylib/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/prefer-dylib/foo.rs b/src/test/run-make-fulldeps/prefer-dylib/foo.rs new file mode 100644 index 00000000000..858ef492ace --- /dev/null +++ b/src/test/run-make-fulldeps/prefer-dylib/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar; + +fn main() { + bar::bar(); +} diff --git a/src/test/run-make-fulldeps/prefer-rlib/Makefile b/src/test/run-make-fulldeps/prefer-rlib/Makefile new file mode 100644 index 00000000000..c6a239eef08 --- /dev/null +++ b/src/test/run-make-fulldeps/prefer-rlib/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: + $(RUSTC) bar.rs --crate-type=dylib --crate-type=rlib + ls $(TMPDIR)/$(call RLIB_GLOB,bar) + $(RUSTC) foo.rs + rm $(TMPDIR)/*bar* + $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/prefer-rlib/bar.rs b/src/test/run-make-fulldeps/prefer-rlib/bar.rs new file mode 100644 index 00000000000..4c79f7e2855 --- /dev/null +++ b/src/test/run-make-fulldeps/prefer-rlib/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/prefer-rlib/foo.rs b/src/test/run-make-fulldeps/prefer-rlib/foo.rs new file mode 100644 index 00000000000..858ef492ace --- /dev/null +++ b/src/test/run-make-fulldeps/prefer-rlib/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar; + +fn main() { + bar::bar(); +} diff --git a/src/test/run-make-fulldeps/pretty-expanded-hygiene/Makefile b/src/test/run-make-fulldeps/pretty-expanded-hygiene/Makefile new file mode 100644 index 00000000000..136d7643ade --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-expanded-hygiene/Makefile @@ -0,0 +1,21 @@ +-include ../tools.mk + +REPLACEMENT := s/[0-9][0-9]*\#[0-9][0-9]*/$(shell date)/g + +all: + $(RUSTC) -o $(TMPDIR)/input.out -Z unstable-options \ + --pretty expanded,hygiene input.rs + + # the name/ctxt numbers are very internals-dependent and thus + # change relatively frequently, and testing for their exact values + # them will fail annoyingly, so we just check their positions + # (using a non-constant replacement like this will make it less + # likely the compiler matches whatever other dummy value we + # choose). + # + # (These need to be out-of-place because OSX/BSD & GNU sed + # differ.) + sed "$(REPLACEMENT)" input.pp.rs > $(TMPDIR)/input.pp.rs + sed "$(REPLACEMENT)" $(TMPDIR)/input.out > $(TMPDIR)/input.out.replaced + + diff -u $(TMPDIR)/input.out.replaced $(TMPDIR)/input.pp.rs diff --git a/src/test/run-make-fulldeps/pretty-expanded-hygiene/input.pp.rs b/src/test/run-make-fulldeps/pretty-expanded-hygiene/input.pp.rs new file mode 100644 index 00000000000..3d2dd380e48 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-expanded-hygiene/input.pp.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// minimal junk +#![feature(no_core)] +#![no_core] + +macro_rules! foo /* 60#0 */(( $ x : ident ) => { y + $ x }); + +fn bar /* 62#0 */() { let x /* 59#2 */ = 1; y /* 61#4 */ + x /* 59#5 */ } + +fn y /* 61#0 */() { } diff --git a/src/test/run-make-fulldeps/pretty-expanded-hygiene/input.rs b/src/test/run-make-fulldeps/pretty-expanded-hygiene/input.rs new file mode 100644 index 00000000000..422fbdb0884 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-expanded-hygiene/input.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// minimal junk +#![feature(no_core)] +#![no_core] + +macro_rules! foo { + ($x: ident) => { y + $x } +} + +fn bar() { + let x = 1; + foo!(x) +} + +fn y() {} diff --git a/src/test/run-make-fulldeps/pretty-expanded/Makefile b/src/test/run-make-fulldeps/pretty-expanded/Makefile new file mode 100644 index 00000000000..7a8dc8d871c --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-expanded/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) -o $(TMPDIR)/input.expanded.rs -Z unstable-options \ + --pretty=expanded input.rs diff --git a/src/test/run-make-fulldeps/pretty-expanded/input.rs b/src/test/run-make-fulldeps/pretty-expanded/input.rs new file mode 100644 index 00000000000..04bf17dc28a --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-expanded/input.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[crate_type="lib"] + +// #13544 + +extern crate serialize; + +#[derive(Encodable)] pub struct A; +#[derive(Encodable)] pub struct B(isize); +#[derive(Encodable)] pub struct C { x: isize } +#[derive(Encodable)] pub enum D {} +#[derive(Encodable)] pub enum E { y } +#[derive(Encodable)] pub enum F { z(isize) } diff --git a/src/test/run-make-fulldeps/pretty-print-path-suffix/Makefile b/src/test/run-make-fulldeps/pretty-print-path-suffix/Makefile new file mode 100644 index 00000000000..899457fc748 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-path-suffix/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +all: + $(RUSTC) -o $(TMPDIR)/foo.out -Z unpretty=hir=foo input.rs + $(RUSTC) -o $(TMPDIR)/nest_foo.out -Z unpretty=hir=nest::foo input.rs + $(RUSTC) -o $(TMPDIR)/foo_method.out -Z unpretty=hir=foo_method input.rs + diff -u $(TMPDIR)/foo.out foo.pp + diff -u $(TMPDIR)/nest_foo.out nest_foo.pp + diff -u $(TMPDIR)/foo_method.out foo_method.pp diff --git a/src/test/run-make-fulldeps/pretty-print-path-suffix/foo.pp b/src/test/run-make-fulldeps/pretty-print-path-suffix/foo.pp new file mode 100644 index 00000000000..f3130a8044a --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-path-suffix/foo.pp @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +pub fn foo() -> i32 { 45 } /* foo */ + + +pub fn foo() -> &'static str { "i am a foo." } /* nest::foo */ diff --git a/src/test/run-make-fulldeps/pretty-print-path-suffix/foo_method.pp b/src/test/run-make-fulldeps/pretty-print-path-suffix/foo_method.pp new file mode 100644 index 00000000000..fae13498687 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-path-suffix/foo_method.pp @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + + + + +fn foo_method(self: &Self) + -> &'static str { return "i am very similar to foo."; } /* +nest::{{impl}}::foo_method */ diff --git a/src/test/run-make-fulldeps/pretty-print-path-suffix/input.rs b/src/test/run-make-fulldeps/pretty-print-path-suffix/input.rs new file mode 100644 index 00000000000..8ea86a94f93 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-path-suffix/input.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub fn +foo() -> i32 +{ 45 } + +pub fn bar() -> &'static str { "i am not a foo." } + +pub mod nest { + pub fn foo() -> &'static str { "i am a foo." } + + struct S; + impl S { + fn foo_method(&self) -> &'static str { + return "i am very similar to foo."; + } + } +} diff --git a/src/test/run-make-fulldeps/pretty-print-path-suffix/nest_foo.pp b/src/test/run-make-fulldeps/pretty-print-path-suffix/nest_foo.pp new file mode 100644 index 00000000000..88eaa062b03 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-path-suffix/nest_foo.pp @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + + + +pub fn foo() -> &'static str { "i am a foo." } /* nest::foo */ diff --git a/src/test/run-make-fulldeps/pretty-print-to-file/Makefile b/src/test/run-make-fulldeps/pretty-print-to-file/Makefile new file mode 100644 index 00000000000..8909dee11f0 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-to-file/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) -o $(TMPDIR)/input.out --pretty=normal -Z unstable-options input.rs + diff -u $(TMPDIR)/input.out input.pp diff --git a/src/test/run-make-fulldeps/pretty-print-to-file/input.pp b/src/test/run-make-fulldeps/pretty-print-to-file/input.pp new file mode 100644 index 00000000000..a6dd6b6778e --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-to-file/input.pp @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#[crate_type = "lib"] +pub fn foo() -> i32 { 45 } diff --git a/src/test/run-make-fulldeps/pretty-print-to-file/input.rs b/src/test/run-make-fulldeps/pretty-print-to-file/input.rs new file mode 100644 index 00000000000..8e3ec363187 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-to-file/input.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[crate_type="lib"] + +pub fn +foo() -> i32 +{ 45 } diff --git a/src/test/run-make-fulldeps/print-cfg/Makefile b/src/test/run-make-fulldeps/print-cfg/Makefile new file mode 100644 index 00000000000..08303a46d19 --- /dev/null +++ b/src/test/run-make-fulldeps/print-cfg/Makefile @@ -0,0 +1,16 @@ +-include ../tools.mk + +all: default + $(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) windows + $(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) x86_64 + $(RUSTC) --target i686-pc-windows-msvc --print cfg | $(CGREP) msvc + $(RUSTC) --target i686-apple-darwin --print cfg | $(CGREP) macos + $(RUSTC) --target i686-unknown-linux-gnu --print cfg | $(CGREP) gnu + +ifdef IS_WINDOWS +default: + $(RUSTC) --print cfg | $(CGREP) windows +else +default: + $(RUSTC) --print cfg | $(CGREP) unix +endif diff --git a/src/test/run-make-fulldeps/print-target-list/Makefile b/src/test/run-make-fulldeps/print-target-list/Makefile new file mode 100644 index 00000000000..144c5ba10cc --- /dev/null +++ b/src/test/run-make-fulldeps/print-target-list/Makefile @@ -0,0 +1,15 @@ +-include ../tools.mk + +# Checks that all the targets returned by `rustc --print target-list` are valid +# target specifications +# TODO remove the '*ios*' case when rust-lang/rust#29812 is fixed +all: + for target in $(shell $(BARE_RUSTC) --print target-list); do \ + case $$target in \ + *ios*) \ + ;; \ + *) \ + $(BARE_RUSTC) --target $$target --print sysroot \ + ;; \ + esac \ + done diff --git a/src/test/run-make-fulldeps/profile/Makefile b/src/test/run-make-fulldeps/profile/Makefile new file mode 100644 index 00000000000..7300bfc9553 --- /dev/null +++ b/src/test/run-make-fulldeps/profile/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +all: +ifeq ($(PROFILER_SUPPORT),1) + $(RUSTC) -g -Z profile test.rs + $(call RUN,test) || exit 1 + [ -e "$(TMPDIR)/test.gcno" ] || (echo "No .gcno file"; exit 1) + [ -e "$(TMPDIR)/test.gcda" ] || (echo "No .gcda file"; exit 1) +endif diff --git a/src/test/run-make-fulldeps/profile/test.rs b/src/test/run-make-fulldeps/profile/test.rs new file mode 100644 index 00000000000..046d27a9f0f --- /dev/null +++ b/src/test/run-make-fulldeps/profile/test.rs @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/prune-link-args/Makefile b/src/test/run-make-fulldeps/prune-link-args/Makefile new file mode 100644 index 00000000000..a6e219873df --- /dev/null +++ b/src/test/run-make-fulldeps/prune-link-args/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk +ifdef IS_WINDOWS +# ignore windows +RUSTC_FLAGS = +else +# Notice the space in the end, this emulates the output of pkg-config +RUSTC_FLAGS = -C link-args="-lc " +endif + +all: + $(RUSTC) $(RUSTC_FLAGS) empty.rs diff --git a/src/test/run-make-fulldeps/prune-link-args/empty.rs b/src/test/run-make-fulldeps/prune-link-args/empty.rs new file mode 100644 index 00000000000..a9e231b0ea8 --- /dev/null +++ b/src/test/run-make-fulldeps/prune-link-args/empty.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { } diff --git a/src/test/run-make-fulldeps/relocation-model/Makefile b/src/test/run-make-fulldeps/relocation-model/Makefile new file mode 100644 index 00000000000..485ecbb4b5a --- /dev/null +++ b/src/test/run-make-fulldeps/relocation-model/Makefile @@ -0,0 +1,19 @@ +-include ../tools.mk + +all: others + $(RUSTC) -C relocation-model=dynamic-no-pic foo.rs + $(call RUN,foo) + + $(RUSTC) -C relocation-model=default foo.rs + $(call RUN,foo) + + $(RUSTC) -C relocation-model=dynamic-no-pic --crate-type=dylib foo.rs --emit=link,obj + +ifdef IS_MSVC +# FIXME(#28026) +others: +else +others: + $(RUSTC) -C relocation-model=static foo.rs + $(call RUN,foo) +endif diff --git a/src/test/run-make-fulldeps/relocation-model/foo.rs b/src/test/run-make-fulldeps/relocation-model/foo.rs new file mode 100644 index 00000000000..e06d81cd60b --- /dev/null +++ b/src/test/run-make-fulldeps/relocation-model/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main() {} diff --git a/src/test/run-make-fulldeps/relro-levels/Makefile b/src/test/run-make-fulldeps/relro-levels/Makefile new file mode 100644 index 00000000000..673ba9a9a02 --- /dev/null +++ b/src/test/run-make-fulldeps/relro-levels/Makefile @@ -0,0 +1,21 @@ +-include ../tools.mk + +# This tests the different -Zrelro-level values, and makes sure that they they work properly. + +all: +ifeq ($(UNAME),Linux) + # Ensure that binaries built with the full relro level links them with both + # RELRO and BIND_NOW for doing eager symbol resolving. + $(RUSTC) -Zrelro-level=full hello.rs + readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO + readelf -d $(TMPDIR)/hello | grep -q BIND_NOW + + $(RUSTC) -Zrelro-level=partial hello.rs + readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO + + # Ensure that we're *not* built with RELRO when setting it to off. We do + # not want to check for BIND_NOW however, as the linker might have that + # enabled by default. + $(RUSTC) -Zrelro-level=off hello.rs + ! readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO +endif diff --git a/src/test/run-make-fulldeps/relro-levels/hello.rs b/src/test/run-make-fulldeps/relro-levels/hello.rs new file mode 100644 index 00000000000..41782851a1a --- /dev/null +++ b/src/test/run-make-fulldeps/relro-levels/hello.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("Hello, world!"); +} diff --git a/src/test/run-make-fulldeps/reproducible-build/Makefile b/src/test/run-make-fulldeps/reproducible-build/Makefile new file mode 100644 index 00000000000..ca76a5e5d77 --- /dev/null +++ b/src/test/run-make-fulldeps/reproducible-build/Makefile @@ -0,0 +1,74 @@ +-include ../tools.mk +all: \ + smoke \ + debug \ + opt \ + link_paths \ + remap_paths \ + different_source_dirs \ + extern_flags + +smoke: + rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) linker.rs -O + $(RUSTC) reproducible-build-aux.rs + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) + diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2" + +debug: + rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) linker.rs -O + $(RUSTC) reproducible-build-aux.rs -g + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -g + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -g + diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2" + +opt: + rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) linker.rs -O + $(RUSTC) reproducible-build-aux.rs -O + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -O + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -O + diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2" + +link_paths: + rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) reproducible-build-aux.rs + $(RUSTC) reproducible-build.rs --crate-type rlib -L /b + cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib + $(RUSTC) reproducible-build.rs --crate-type rlib -L /a + cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 + +remap_paths: + rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) reproducible-build-aux.rs + $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=/a=/c + cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib + $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=/b=/c + cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 + +different_source_dirs: + rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) reproducible-build-aux.rs + mkdir $(TMPDIR)/test + cp reproducible-build.rs $(TMPDIR)/test + $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=$$PWD=/b + cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib + (cd $(TMPDIR)/test && $(RUSTC) reproducible-build.rs \ + --remap-path-prefix=$(TMPDIR)/test=/b \ + --crate-type rlib) + cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 + +extern_flags: + rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) reproducible-build-aux.rs + $(RUSTC) reproducible-build.rs \ + --extern reproducible_build_aux=$(TMPDIR)/libreproducible_build_aux.rlib \ + --crate-type rlib + cp $(TMPDIR)/libreproducible_build_aux.rlib $(TMPDIR)/libbar.rlib + cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib + $(RUSTC) reproducible-build.rs \ + --extern reproducible_build_aux=$(TMPDIR)/libbar.rlib \ + --crate-type rlib + cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 diff --git a/src/test/run-make-fulldeps/reproducible-build/linker.rs b/src/test/run-make-fulldeps/reproducible-build/linker.rs new file mode 100644 index 00000000000..fd8946708bf --- /dev/null +++ b/src/test/run-make-fulldeps/reproducible-build/linker.rs @@ -0,0 +1,54 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::env; +use std::path::Path; +use std::fs::File; +use std::io::{Read, Write}; + +fn main() { + let mut dst = env::current_exe().unwrap(); + dst.pop(); + dst.push("linker-arguments1"); + if dst.exists() { + dst.pop(); + dst.push("linker-arguments2"); + assert!(!dst.exists()); + } + + let mut out = String::new(); + for arg in env::args().skip(1) { + let path = Path::new(&arg); + if !path.is_file() { + out.push_str(&arg); + out.push_str("\n"); + continue + } + + let mut contents = Vec::new(); + File::open(path).unwrap().read_to_end(&mut contents).unwrap(); + + out.push_str(&format!("{}: {}\n", arg, hash(&contents))); + } + + File::create(dst).unwrap().write_all(out.as_bytes()).unwrap(); +} + +// fnv hash for now +fn hash(contents: &[u8]) -> u64 { + let mut hash = 0xcbf29ce484222325; + + for byte in contents { + hash = hash ^ (*byte as u64); + hash = hash.wrapping_mul(0x100000001b3); + } + + hash +} diff --git a/src/test/run-make-fulldeps/reproducible-build/reproducible-build-aux.rs b/src/test/run-make-fulldeps/reproducible-build/reproducible-build-aux.rs new file mode 100644 index 00000000000..9ef853e7996 --- /dev/null +++ b/src/test/run-make-fulldeps/reproducible-build/reproducible-build-aux.rs @@ -0,0 +1,38 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub static STATIC: i32 = 1234; + +pub struct Struct { + _t1: std::marker::PhantomData, + _t2: std::marker::PhantomData, +} + +pub fn regular_fn(_: i32) {} + +pub fn generic_fn() {} + +impl Drop for Struct { + fn drop(&mut self) {} +} + +pub enum Enum { + Variant1, + Variant2(u32), + Variant3 { x: u32 } +} + +pub struct TupleStruct(pub i8, pub i16, pub i32, pub i64); + +pub trait Trait { + fn foo(&self); +} diff --git a/src/test/run-make-fulldeps/reproducible-build/reproducible-build.rs b/src/test/run-make-fulldeps/reproducible-build/reproducible-build.rs new file mode 100644 index 00000000000..a040c0f858d --- /dev/null +++ b/src/test/run-make-fulldeps/reproducible-build/reproducible-build.rs @@ -0,0 +1,126 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This test case makes sure that two identical invocations of the compiler +// (i.e. same code base, same compile-flags, same compiler-versions, etc.) +// produce the same output. In the past, symbol names of monomorphized functions +// were not deterministic (which we want to avoid). +// +// The test tries to exercise as many different paths into symbol name +// generation as possible: +// +// - regular functions +// - generic functions +// - methods +// - statics +// - closures +// - enum variant constructors +// - tuple struct constructors +// - drop glue +// - FnOnce adapters +// - Trait object shims +// - Fn Pointer shims + +#![allow(dead_code, warnings)] + +extern crate reproducible_build_aux; + +static STATIC: i32 = 1234; + +pub struct Struct { + x: T1, + y: T2, +} + +fn regular_fn(_: i32) {} + +fn generic_fn() {} + +impl Drop for Struct { + fn drop(&mut self) {} +} + +pub enum Enum { + Variant1, + Variant2(u32), + Variant3 { x: u32 } +} + +struct TupleStruct(i8, i16, i32, i64); + +impl TupleStruct { + pub fn bar(&self) {} +} + +trait Trait { + fn foo(&self); +} + +impl Trait for u64 { + fn foo(&self) {} +} + +impl reproducible_build_aux::Trait for TupleStruct { + fn foo(&self) {} +} + +fn main() { + regular_fn(STATIC); + generic_fn::(); + generic_fn::>(); + generic_fn::, reproducible_build_aux::Struct>(); + + let dropped = Struct { + x: "", + y: 'a', + }; + + let _ = Enum::Variant1; + let _ = Enum::Variant2(0); + let _ = Enum::Variant3 { x: 0 }; + let _ = TupleStruct(1, 2, 3, 4); + + let closure = |x| { + x + 1i32 + }; + + fn inner i32>(f: F) -> i32 { + f(STATIC) + } + + println!("{}", inner(closure)); + + let object_shim: &Trait = &0u64; + object_shim.foo(); + + fn with_fn_once_adapter(f: F) { + f(0); + } + + with_fn_once_adapter(|_:i32| { }); + + reproducible_build_aux::regular_fn(STATIC); + reproducible_build_aux::generic_fn::(); + reproducible_build_aux::generic_fn::>(); + reproducible_build_aux::generic_fn::, + reproducible_build_aux::Struct>(); + + let _ = reproducible_build_aux::Enum::Variant1; + let _ = reproducible_build_aux::Enum::Variant2(0); + let _ = reproducible_build_aux::Enum::Variant3 { x: 0 }; + let _ = reproducible_build_aux::TupleStruct(1, 2, 3, 4); + + let object_shim: &reproducible_build_aux::Trait = &TupleStruct(0, 1, 2, 3); + object_shim.foo(); + + let pointer_shim: &Fn(i32) = ®ular_fn; + + TupleStruct(1, 2, 3, 4).bar(); +} diff --git a/src/test/run-make-fulldeps/rlib-chain/Makefile b/src/test/run-make-fulldeps/rlib-chain/Makefile new file mode 100644 index 00000000000..30b6811a388 --- /dev/null +++ b/src/test/run-make-fulldeps/rlib-chain/Makefile @@ -0,0 +1,10 @@ +-include ../tools.mk + +all: + $(RUSTC) m1.rs + $(RUSTC) m2.rs + $(RUSTC) m3.rs + $(RUSTC) m4.rs + $(call RUN,m4) + rm $(TMPDIR)/*lib + $(call RUN,m4) diff --git a/src/test/run-make-fulldeps/rlib-chain/m1.rs b/src/test/run-make-fulldeps/rlib-chain/m1.rs new file mode 100644 index 00000000000..e3afa352938 --- /dev/null +++ b/src/test/run-make-fulldeps/rlib-chain/m1.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +pub fn m1() {} diff --git a/src/test/run-make-fulldeps/rlib-chain/m2.rs b/src/test/run-make-fulldeps/rlib-chain/m2.rs new file mode 100644 index 00000000000..2b4c181134b --- /dev/null +++ b/src/test/run-make-fulldeps/rlib-chain/m2.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +extern crate m1; + +pub fn m2() { m1::m1() } diff --git a/src/test/run-make-fulldeps/rlib-chain/m3.rs b/src/test/run-make-fulldeps/rlib-chain/m3.rs new file mode 100644 index 00000000000..6323a9e65aa --- /dev/null +++ b/src/test/run-make-fulldeps/rlib-chain/m3.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +extern crate m2; + +pub fn m3() { m2::m2() } diff --git a/src/test/run-make-fulldeps/rlib-chain/m4.rs b/src/test/run-make-fulldeps/rlib-chain/m4.rs new file mode 100644 index 00000000000..6c2a6685802 --- /dev/null +++ b/src/test/run-make-fulldeps/rlib-chain/m4.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate m3; + +fn main() { m3::m3() } diff --git a/src/test/run-make-fulldeps/rustc-macro-dep-files/Makefile b/src/test/run-make-fulldeps/rustc-macro-dep-files/Makefile new file mode 100644 index 00000000000..d2c8e7fd043 --- /dev/null +++ b/src/test/run-make-fulldeps/rustc-macro-dep-files/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) +# ignore stage1 +all: + +else +all: + $(RUSTC) foo.rs + $(RUSTC) bar.rs --emit dep-info + $(CGREP) -v "proc-macro source" < $(TMPDIR)/bar.d +endif diff --git a/src/test/run-make-fulldeps/rustc-macro-dep-files/bar.rs b/src/test/run-make-fulldeps/rustc-macro-dep-files/bar.rs new file mode 100644 index 00000000000..03330c3d170 --- /dev/null +++ b/src/test/run-make-fulldeps/rustc-macro-dep-files/bar.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_use] +extern crate foo; + +#[derive(A)] +struct A; + +fn main() { + let _b = B; +} diff --git a/src/test/run-make-fulldeps/rustc-macro-dep-files/foo.rs b/src/test/run-make-fulldeps/rustc-macro-dep-files/foo.rs new file mode 100644 index 00000000000..2f2524f6ef1 --- /dev/null +++ b/src/test/run-make-fulldeps/rustc-macro-dep-files/foo.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(A)] +pub fn derive(input: TokenStream) -> TokenStream { + let input = input.to_string(); + assert!(input.contains("struct A;")); + "struct B;".parse().unwrap() +} diff --git a/src/test/run-make-fulldeps/rustdoc-error-lines/Makefile b/src/test/run-make-fulldeps/rustdoc-error-lines/Makefile new file mode 100644 index 00000000000..0019e5ee794 --- /dev/null +++ b/src/test/run-make-fulldeps/rustdoc-error-lines/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +# Test that hir-tree output doens't crash and includes +# the string constant we would expect to see. + +all: + $(RUSTDOC) --test input.rs > $(TMPDIR)/output || true + $(CGREP) 'input.rs:17:15' < $(TMPDIR)/output diff --git a/src/test/run-make-fulldeps/rustdoc-error-lines/input.rs b/src/test/run-make-fulldeps/rustdoc-error-lines/input.rs new file mode 100644 index 00000000000..6dc7060bc48 --- /dev/null +++ b/src/test/run-make-fulldeps/rustdoc-error-lines/input.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test for #45868 + +// random #![feature] to ensure that crate attrs +// do not offset things +/// ```rust +/// #![feature(nll)] +/// let x: char = 1; +/// ``` +pub fn foo() { + +} diff --git a/src/test/run-make-fulldeps/rustdoc-output-path/Makefile b/src/test/run-make-fulldeps/rustdoc-output-path/Makefile new file mode 100644 index 00000000000..8ce1c699526 --- /dev/null +++ b/src/test/run-make-fulldeps/rustdoc-output-path/Makefile @@ -0,0 +1,4 @@ +-include ../tools.mk + +all: + $(RUSTDOC) -o "$(TMPDIR)/foo/bar/doc" foo.rs diff --git a/src/test/run-make-fulldeps/rustdoc-output-path/foo.rs b/src/test/run-make-fulldeps/rustdoc-output-path/foo.rs new file mode 100644 index 00000000000..11fc2cd2b8d --- /dev/null +++ b/src/test/run-make-fulldeps/rustdoc-output-path/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Foo; diff --git a/src/test/run-make-fulldeps/sanitizer-address/Makefile b/src/test/run-make-fulldeps/sanitizer-address/Makefile new file mode 100644 index 00000000000..207615bfbd5 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-address/Makefile @@ -0,0 +1,29 @@ +-include ../tools.mk + +LOG := $(TMPDIR)/log.txt + +# NOTE the address sanitizer only supports x86_64 linux and macOS + +ifeq ($(TARGET),x86_64-apple-darwin) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) +EXTRA_RUSTFLAG=-C rpath +else +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) + +# Apparently there are very specific Linux kernels, notably the one that's +# currently on Travis CI, which contain a buggy commit that triggers failures in +# the ASan implementation, detailed at google/sanitizers#837. As noted in +# google/sanitizers#856 the "fix" is to avoid using PIE binaries, so we pass a +# different relocation model to avoid generating a PIE binary. Once Travis is no +# longer running kernel 4.4.0-93 we can remove this and pass an empty set of +# flags again. +EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic +endif +endif + +all: +ifeq ($(ASAN_SUPPORT),1) + $(RUSTC) -g -Z sanitizer=address -Z print-link-args $(EXTRA_RUSTFLAG) overflow.rs | $(CGREP) librustc_asan + $(TMPDIR)/overflow 2>&1 | $(CGREP) stack-buffer-overflow +endif diff --git a/src/test/run-make-fulldeps/sanitizer-address/overflow.rs b/src/test/run-make-fulldeps/sanitizer-address/overflow.rs new file mode 100644 index 00000000000..1f3c64c8c32 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-address/overflow.rs @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let xs = [0, 1, 2, 3]; + let _y = unsafe { *xs.as_ptr().offset(4) }; +} diff --git a/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile b/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile new file mode 100644 index 00000000000..bea5519ec5f --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile @@ -0,0 +1,22 @@ +-include ../tools.mk + +LOG := $(TMPDIR)/log.txt + +# This test builds a shared object, then an executable that links it as a native +# rust library (constrast to an rlib). The shared library and executable both +# are compiled with address sanitizer, and we assert that a fault in the cdylib +# is correctly detected. + +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) + +# See comment in sanitizer-address/Makefile for why this is here +EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic +endif + +all: +ifeq ($(ASAN_SUPPORT),1) + $(RUSTC) -g -Z sanitizer=address --crate-type cdylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs + $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs + LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow +endif diff --git a/src/test/run-make-fulldeps/sanitizer-cdylib-link/library.rs b/src/test/run-make-fulldeps/sanitizer-cdylib-link/library.rs new file mode 100644 index 00000000000..4ceef5d3f52 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-cdylib-link/library.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern fn overflow() { + let xs = [0, 1, 2, 3]; + let _y = unsafe { *xs.as_ptr().offset(4) }; +} diff --git a/src/test/run-make-fulldeps/sanitizer-cdylib-link/program.rs b/src/test/run-make-fulldeps/sanitizer-cdylib-link/program.rs new file mode 100644 index 00000000000..9f52817c851 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-cdylib-link/program.rs @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern { + fn overflow(); +} + +fn main() { + unsafe { overflow() } +} diff --git a/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile b/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile new file mode 100644 index 00000000000..0cc8f73da8b --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile @@ -0,0 +1,22 @@ +-include ../tools.mk + +LOG := $(TMPDIR)/log.txt + +# This test builds a shared object, then an executable that links it as a native +# rust library (constrast to an rlib). The shared library and executable both +# are compiled with address sanitizer, and we assert that a fault in the dylib +# is correctly detected. + +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) + +# See comment in sanitizer-address/Makefile for why this is here +EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic +endif + +all: +ifeq ($(ASAN_SUPPORT),1) + $(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs + $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs + LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow +endif diff --git a/src/test/run-make-fulldeps/sanitizer-dylib-link/library.rs b/src/test/run-make-fulldeps/sanitizer-dylib-link/library.rs new file mode 100644 index 00000000000..4ceef5d3f52 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-dylib-link/library.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern fn overflow() { + let xs = [0, 1, 2, 3]; + let _y = unsafe { *xs.as_ptr().offset(4) }; +} diff --git a/src/test/run-make-fulldeps/sanitizer-dylib-link/program.rs b/src/test/run-make-fulldeps/sanitizer-dylib-link/program.rs new file mode 100644 index 00000000000..9f52817c851 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-dylib-link/program.rs @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern { + fn overflow(); +} + +fn main() { + unsafe { overflow() } +} diff --git a/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile b/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile new file mode 100644 index 00000000000..dc37c0d0bc9 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile @@ -0,0 +1,18 @@ +-include ../tools.mk + +# NOTE the address sanitizer only supports x86_64 linux and macOS + +ifeq ($(TARGET),x86_64-apple-darwin) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) +EXTRA_RUSTFLAG=-C rpath +else +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) +EXTRA_RUSTFLAG= +endif +endif + +all: +ifeq ($(ASAN_SUPPORT),1) + $(RUSTC) -Z sanitizer=address --crate-type proc-macro --target $(TARGET) hello.rs 2>&1 | $(CGREP) '-Z sanitizer' +endif diff --git a/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/hello.rs b/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/hello.rs new file mode 100644 index 00000000000..41782851a1a --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/hello.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("Hello, world!"); +} diff --git a/src/test/run-make-fulldeps/sanitizer-invalid-target/Makefile b/src/test/run-make-fulldeps/sanitizer-invalid-target/Makefile new file mode 100644 index 00000000000..df8afee15ce --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-invalid-target/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) -Z sanitizer=leak --target i686-unknown-linux-gnu hello.rs 2>&1 | \ + $(CGREP) 'LeakSanitizer only works with the `x86_64-unknown-linux-gnu` target' diff --git a/src/test/run-make-fulldeps/sanitizer-invalid-target/hello.rs b/src/test/run-make-fulldeps/sanitizer-invalid-target/hello.rs new file mode 100644 index 00000000000..e9e46b7702a --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-invalid-target/hello.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(no_core)] +#![no_core] +#![no_main] diff --git a/src/test/run-make-fulldeps/sanitizer-leak/Makefile b/src/test/run-make-fulldeps/sanitizer-leak/Makefile new file mode 100644 index 00000000000..ab43fac2e99 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-leak/Makefile @@ -0,0 +1,16 @@ +-include ../tools.mk + +# FIXME(#46126) ThinLTO for libstd broke this test +ifeq (1,0) +all: +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ifdef SANITIZER_SUPPORT + $(RUSTC) -C opt-level=1 -g -Z sanitizer=leak -Z print-link-args leak.rs | $(CGREP) librustc_lsan + $(TMPDIR)/leak 2>&1 | $(CGREP) 'detected memory leaks' +endif +endif + +else +all: +endif + diff --git a/src/test/run-make-fulldeps/sanitizer-leak/leak.rs b/src/test/run-make-fulldeps/sanitizer-leak/leak.rs new file mode 100644 index 00000000000..279da6aaae7 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-leak/leak.rs @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::mem; + +fn main() { + let xs = vec![1, 2, 3, 4]; + mem::forget(xs); +} diff --git a/src/test/run-make-fulldeps/sanitizer-memory/Makefile b/src/test/run-make-fulldeps/sanitizer-memory/Makefile new file mode 100644 index 00000000000..3507ca2bef2 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-memory/Makefile @@ -0,0 +1,10 @@ +-include ../tools.mk + +all: +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ifdef SANITIZER_SUPPORT + $(RUSTC) -g -Z sanitizer=memory -Z print-link-args uninit.rs | $(CGREP) librustc_msan + $(TMPDIR)/uninit 2>&1 | $(CGREP) use-of-uninitialized-value +endif +endif + diff --git a/src/test/run-make-fulldeps/sanitizer-memory/uninit.rs b/src/test/run-make-fulldeps/sanitizer-memory/uninit.rs new file mode 100644 index 00000000000..8350c7de3ac --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-memory/uninit.rs @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::mem; + +fn main() { + let xs: [u8; 4] = unsafe { mem::uninitialized() }; + let y = xs[0] + xs[1]; +} diff --git a/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile b/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile new file mode 100644 index 00000000000..2b444d667bf --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile @@ -0,0 +1,18 @@ +-include ../tools.mk + +# This test builds a staticlib, then an executable that links to it. +# The staticlib and executable both are compiled with address sanitizer, +# and we assert that a fault in the staticlib is correctly detected. + +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) +EXTRA_RUSTFLAG= +endif + +all: +ifeq ($(ASAN_SUPPORT),1) + $(RUSTC) -g -Z sanitizer=address --crate-type staticlib --target $(TARGET) library.rs + $(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) $(EXTRACFLAGS) $(EXTRACXXFLAGS) + LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow +endif + diff --git a/src/test/run-make-fulldeps/sanitizer-staticlib-link/library.rs b/src/test/run-make-fulldeps/sanitizer-staticlib-link/library.rs new file mode 100644 index 00000000000..4ceef5d3f52 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-staticlib-link/library.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern fn overflow() { + let xs = [0, 1, 2, 3]; + let _y = unsafe { *xs.as_ptr().offset(4) }; +} diff --git a/src/test/run-make-fulldeps/sanitizer-staticlib-link/program.c b/src/test/run-make-fulldeps/sanitizer-staticlib-link/program.c new file mode 100644 index 00000000000..abd5d508e72 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-staticlib-link/program.c @@ -0,0 +1,8 @@ +// ignore-license +void overflow(); + +int main() { + overflow(); + return 0; +} + diff --git a/src/test/run-make-fulldeps/save-analysis-fail/Makefile b/src/test/run-make-fulldeps/save-analysis-fail/Makefile new file mode 100644 index 00000000000..f29f907cf38 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis-fail/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk +all: code +krate2: krate2.rs + $(RUSTC) $< +code: foo.rs krate2 + $(RUSTC) foo.rs -Zsave-analysis || exit 0 diff --git a/src/test/run-make-fulldeps/save-analysis-fail/SameDir.rs b/src/test/run-make-fulldeps/save-analysis-fail/SameDir.rs new file mode 100644 index 00000000000..fe70ac1edef --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis-fail/SameDir.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// sub-module in the same directory as the main crate file + +pub struct SameStruct { + pub name: String +} diff --git a/src/test/run-make-fulldeps/save-analysis-fail/SameDir3.rs b/src/test/run-make-fulldeps/save-analysis-fail/SameDir3.rs new file mode 100644 index 00000000000..315f900868b --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis-fail/SameDir3.rs @@ -0,0 +1,13 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn hello(x: isize) { + println!("macro {} :-(", x); +} diff --git a/src/test/run-make-fulldeps/save-analysis-fail/SubDir/mod.rs b/src/test/run-make-fulldeps/save-analysis-fail/SubDir/mod.rs new file mode 100644 index 00000000000..fe84db08da9 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis-fail/SubDir/mod.rs @@ -0,0 +1,37 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// sub-module in a sub-directory + +use sub::sub2 as msalias; +use sub::sub2; + +static yy: usize = 25; + +mod sub { + pub mod sub2 { + pub mod sub3 { + pub fn hello() { + println!("hello from module 3"); + } + } + pub fn hello() { + println!("hello from a module"); + } + + pub struct nested_struct { + pub field2: u32, + } + } +} + +pub struct SubStruct { + pub name: String +} diff --git a/src/test/run-make-fulldeps/save-analysis-fail/foo.rs b/src/test/run-make-fulldeps/save-analysis-fail/foo.rs new file mode 100644 index 00000000000..b844f2e49e7 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis-fail/foo.rs @@ -0,0 +1,468 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![ crate_name = "test" ] +#![feature(box_syntax)] +#![feature(rustc_private)] + +extern crate graphviz; +// A simple rust project + +extern crate krate2; +extern crate krate2 as krate3; + +use graphviz::RenderOption; +use std::collections::{HashMap,HashSet}; +use std::cell::RefCell; +use std::io::Write; + + +use sub::sub2 as msalias; +use sub::sub2; +use sub::sub2::nested_struct as sub_struct; + +use std::mem::size_of; + +use std::char::from_u32; + +static uni: &'static str = "Les Miséééééééérables"; +static yy: usize = 25; + +static bob: Option = None; + +// buglink test - see issue #1337. + +fn test_alias(i: Option<::Item>) { + let s = sub_struct{ field2: 45u32, }; + + // import tests + fn foo(x: &Write) {} + let _: Option<_> = from_u32(45); + + let x = 42usize; + + krate2::hello(); + krate3::hello(); + + let x = (3isize, 4usize); + let y = x.1; +} + +// Issue #37700 +const LUT_BITS: usize = 3; +pub struct HuffmanTable { + ac_lut: Option<[(i16, u8); 1 << LUT_BITS]>, +} + +struct TupStruct(isize, isize, Box); + +fn test_tup_struct(x: TupStruct) -> isize { + x.1 +} + +fn println(s: &str) { + std::io::stdout().write_all(s.as_bytes()); +} + +mod sub { + pub mod sub2 { + use std::io::Write; + pub mod sub3 { + use std::io::Write; + pub fn hello() { + ::println("hello from module 3"); + } + } + pub fn hello() { + ::println("hello from a module"); + } + + pub struct nested_struct { + pub field2: u32, + } + + pub enum nested_enum { + Nest2 = 2, + Nest3 = 3 + } + } +} + +pub mod SameDir; +pub mod SubDir; + +#[path = "SameDir3.rs"] +pub mod SameDir2; + +struct nofields; + +#[derive(Clone)] +struct some_fields { + field1: u32, +} + +type SF = some_fields; + +trait SuperTrait { + fn qux(&self) { panic!(); } +} + +trait SomeTrait: SuperTrait { + fn Method(&self, x: u32) -> u32; + + fn prov(&self, x: u32) -> u32 { + println(&x.to_string()); + 42 + } + fn provided_method(&self) -> u32 { + 42 + } +} + +trait SubTrait: SomeTrait { + fn stat2(x: &Self) -> u32 { + 32 + } +} + +trait SizedTrait: Sized {} + +fn error(s: &SizedTrait) { + let foo = 42; + println!("Hello world! {}", foo); +} + +impl SomeTrait for some_fields { + fn Method(&self, x: u32) -> u32 { + println(&x.to_string()); + self.field1 + } +} + +impl SuperTrait for some_fields { +} + +impl SubTrait for some_fields {} + +impl some_fields { + fn stat(x: u32) -> u32 { + println(&x.to_string()); + 42 + } + fn stat2(x: &some_fields) -> u32 { + 42 + } + + fn align_to(&mut self) { + + } + + fn test(&mut self) { + self.align_to::(); + } +} + +impl SuperTrait for nofields { +} +impl SomeTrait for nofields { + fn Method(&self, x: u32) -> u32 { + self.Method(x); + 43 + } + + fn provided_method(&self) -> u32 { + 21 + } +} + +impl SubTrait for nofields {} + +impl SuperTrait for (Box, Box) {} + +fn f_with_params(x: &T) { + x.Method(41); +} + +type MyType = Box; + +enum SomeEnum<'a> { + Ints(isize, isize), + Floats(f64, f64), + Strings(&'a str, &'a str, &'a str), + MyTypes(MyType, MyType) +} + +#[derive(Copy, Clone)] +enum SomeOtherEnum { + SomeConst1, + SomeConst2, + SomeConst3 +} + +enum SomeStructEnum { + EnumStruct{a:isize, b:isize}, + EnumStruct2{f1:MyType, f2:MyType}, + EnumStruct3{f1:MyType, f2:MyType, f3:SomeEnum<'static>} +} + +fn matchSomeEnum(val: SomeEnum) { + match val { + SomeEnum::Ints(int1, int2) => { println(&(int1+int2).to_string()); } + SomeEnum::Floats(float1, float2) => { println(&(float2*float1).to_string()); } + SomeEnum::Strings(.., s3) => { println(s3); } + SomeEnum::MyTypes(mt1, mt2) => { println(&(mt1.field1 - mt2.field1).to_string()); } + } +} + +fn matchSomeStructEnum(se: SomeStructEnum) { + match se { + SomeStructEnum::EnumStruct{a:a, ..} => println(&a.to_string()), + SomeStructEnum::EnumStruct2{f1:f1, f2:f_2} => println(&f_2.field1.to_string()), + SomeStructEnum::EnumStruct3{f1, ..} => println(&f1.field1.to_string()), + } +} + + +fn matchSomeStructEnum2(se: SomeStructEnum) { + use SomeStructEnum::*; + match se { + EnumStruct{a: ref aaa, ..} => println(&aaa.to_string()), + EnumStruct2{f1, f2: f2} => println(&f1.field1.to_string()), + EnumStruct3{f1, f3: SomeEnum::Ints(..), f2} => println(&f1.field1.to_string()), + _ => {}, + } +} + +fn matchSomeOtherEnum(val: SomeOtherEnum) { + use SomeOtherEnum::{SomeConst2, SomeConst3}; + match val { + SomeOtherEnum::SomeConst1 => { println("I'm const1."); } + SomeConst2 | SomeConst3 => { println("I'm const2 or const3."); } + } +} + +fn hello((z, a) : (u32, String), ex: X) { + SameDir2::hello(43); + + println(&yy.to_string()); + let (x, y): (u32, u32) = (5, 3); + println(&x.to_string()); + println(&z.to_string()); + let x: u32 = x; + println(&x.to_string()); + let x = "hello"; + println(x); + + let x = 32.0f32; + let _ = (x + ((x * x) + 1.0).sqrt()).ln(); + + let s: Box = box some_fields {field1: 43}; + let s2: Box = box some_fields {field1: 43}; + let s3 = box nofields; + + s.Method(43); + s3.Method(43); + s2.Method(43); + + ex.prov(43); + + let y: u32 = 56; + // static method on struct + let r = some_fields::stat(y); + // trait static method, calls default + let r = SubTrait::stat2(&*s3); + + let s4 = s3 as Box; + s4.Method(43); + + s4.provided_method(); + s2.prov(45); + + let closure = |x: u32, s: &SomeTrait| { + s.Method(23); + return x + y; + }; + + let z = closure(10, &*s); +} + +pub struct blah { + used_link_args: RefCell<[&'static str; 0]>, +} + +#[macro_use] +mod macro_use_test { + macro_rules! test_rec { + (q, $src: expr) => {{ + print!("{}", $src); + test_rec!($src); + }}; + ($src: expr) => { + print!("{}", $src); + }; + } + + macro_rules! internal_vars { + ($src: ident) => {{ + let mut x = $src; + x += 100; + }}; + } +} + +fn main() { // foo + let s = box some_fields {field1: 43}; + hello((43, "a".to_string()), *s); + sub::sub2::hello(); + sub2::sub3::hello(); + + let h = sub2::sub3::hello; + h(); + + // utf8 chars + let ut = "Les Miséééééééérables"; + + // For some reason, this pattern of macro_rules foiled our generated code + // avoiding strategy. + macro_rules! variable_str(($name:expr) => ( + some_fields { + field1: $name, + } + )); + let vs = variable_str!(32); + + let mut candidates: RefCell> = RefCell::new(HashMap::new()); + let _ = blah { + used_link_args: RefCell::new([]), + }; + let s1 = nofields; + let s2 = SF { field1: 55}; + let s3: some_fields = some_fields{ field1: 55}; + let s4: msalias::nested_struct = sub::sub2::nested_struct{ field2: 55}; + let s4: msalias::nested_struct = sub2::nested_struct{ field2: 55}; + println(&s2.field1.to_string()); + let s5: MyType = box some_fields{ field1: 55}; + let s = SameDir::SameStruct{name: "Bob".to_string()}; + let s = SubDir::SubStruct{name:"Bob".to_string()}; + let s6: SomeEnum = SomeEnum::MyTypes(box s2.clone(), s5); + let s7: SomeEnum = SomeEnum::Strings("one", "two", "three"); + matchSomeEnum(s6); + matchSomeEnum(s7); + let s8: SomeOtherEnum = SomeOtherEnum::SomeConst2; + matchSomeOtherEnum(s8); + let s9: SomeStructEnum = SomeStructEnum::EnumStruct2{ f1: box some_fields{ field1:10 }, + f2: box s2 }; + matchSomeStructEnum(s9); + + for x in &vec![1, 2, 3] { + let _y = x; + } + + let s7: SomeEnum = SomeEnum::Strings("one", "two", "three"); + if let SomeEnum::Strings(..) = s7 { + println!("hello!"); + } + + for i in 0..5 { + foo_foo(i); + } + + if let Some(x) = None { + foo_foo(x); + } + + if false { + } else if let Some(y) = None { + foo_foo(y); + } + + while let Some(z) = None { + foo_foo(z); + } + + let mut x = 4; + test_rec!(q, "Hello"); + assert_eq!(x, 4); + internal_vars!(x); +} + +fn foo_foo(_: i32) {} + +impl Iterator for nofields { + type Item = (usize, usize); + + fn next(&mut self) -> Option<(usize, usize)> { + panic!() + } + + fn size_hint(&self) -> (usize, Option) { + panic!() + } +} + +trait Pattern<'a> { + type Searcher; +} + +struct CharEqPattern; + +impl<'a> Pattern<'a> for CharEqPattern { + type Searcher = CharEqPattern; +} + +struct CharSearcher<'a>(>::Searcher); + +pub trait Error { +} + +impl Error + 'static { + pub fn is(&self) -> bool { + panic!() + } +} + +impl Error + 'static + Send { + pub fn is(&self) -> bool { + ::is::(self) + } +} +extern crate serialize; +#[derive(Clone, Copy, Hash, Encodable, Decodable, PartialEq, Eq, PartialOrd, Ord, Debug, Default)] +struct AllDerives(i32); + +fn test_format_args() { + let x = 1; + let y = 2; + let name = "Joe Blogg"; + println!("Hello {}", name); + print!("Hello {0}", name); + print!("{0} + {} = {}", x, y); + print!("x is {}, y is {1}, name is {n}", x, y, n = name); +} + +extern { + static EXTERN_FOO: u8; + fn extern_foo(a: u8, b: i32) -> String; +} + +struct Rls699 { + f: u32, +} + +fn new(f: u32) -> Rls699 { + Rls699 { fs } +} + +fn invalid_tuple_struct_access() { + bar.0; + + struct S; + S.0; +} diff --git a/src/test/run-make-fulldeps/save-analysis-fail/krate2.rs b/src/test/run-make-fulldeps/save-analysis-fail/krate2.rs new file mode 100644 index 00000000000..2c6f517ff38 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis-fail/krate2.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![ crate_name = "krate2" ] +#![ crate_type = "lib" ] + +use std::io::Write; + +pub fn hello() { + std::io::stdout().write_all(b"hello world!\n"); +} diff --git a/src/test/run-make-fulldeps/save-analysis/Makefile b/src/test/run-make-fulldeps/save-analysis/Makefile new file mode 100644 index 00000000000..7296fb9cc59 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk +all: code +krate2: krate2.rs + $(RUSTC) $< +code: foo.rs krate2 + $(RUSTC) foo.rs -Zsave-analysis diff --git a/src/test/run-make-fulldeps/save-analysis/SameDir.rs b/src/test/run-make-fulldeps/save-analysis/SameDir.rs new file mode 100644 index 00000000000..fe70ac1edef --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis/SameDir.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// sub-module in the same directory as the main crate file + +pub struct SameStruct { + pub name: String +} diff --git a/src/test/run-make-fulldeps/save-analysis/SameDir3.rs b/src/test/run-make-fulldeps/save-analysis/SameDir3.rs new file mode 100644 index 00000000000..315f900868b --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis/SameDir3.rs @@ -0,0 +1,13 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn hello(x: isize) { + println!("macro {} :-(", x); +} diff --git a/src/test/run-make-fulldeps/save-analysis/SubDir/mod.rs b/src/test/run-make-fulldeps/save-analysis/SubDir/mod.rs new file mode 100644 index 00000000000..fe84db08da9 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis/SubDir/mod.rs @@ -0,0 +1,37 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// sub-module in a sub-directory + +use sub::sub2 as msalias; +use sub::sub2; + +static yy: usize = 25; + +mod sub { + pub mod sub2 { + pub mod sub3 { + pub fn hello() { + println!("hello from module 3"); + } + } + pub fn hello() { + println!("hello from a module"); + } + + pub struct nested_struct { + pub field2: u32, + } + } +} + +pub struct SubStruct { + pub name: String +} diff --git a/src/test/run-make-fulldeps/save-analysis/extra-docs.md b/src/test/run-make-fulldeps/save-analysis/extra-docs.md new file mode 100644 index 00000000000..0605ca517ff --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis/extra-docs.md @@ -0,0 +1 @@ +Extra docs for this struct. diff --git a/src/test/run-make-fulldeps/save-analysis/foo.rs b/src/test/run-make-fulldeps/save-analysis/foo.rs new file mode 100644 index 00000000000..5b4e4802957 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis/foo.rs @@ -0,0 +1,467 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![ crate_name = "test" ] +#![feature(box_syntax)] +#![feature(rustc_private)] +#![feature(associated_type_defaults)] +#![feature(external_doc)] + +extern crate graphviz; +// A simple rust project + +extern crate krate2; +extern crate krate2 as krate3; + +use graphviz::RenderOption; +use std::collections::{HashMap,HashSet}; +use std::cell::RefCell; +use std::io::Write; + + +use sub::sub2 as msalias; +use sub::sub2; +use sub::sub2::nested_struct as sub_struct; + +use std::mem::size_of; + +use std::char::from_u32; + +static uni: &'static str = "Les Miséééééééérables"; +static yy: usize = 25; + +static bob: Option = None; + +// buglink test - see issue #1337. + +fn test_alias(i: Option<::Item>) { + let s = sub_struct{ field2: 45u32, }; + + // import tests + fn foo(x: &Write) {} + let _: Option<_> = from_u32(45); + + let x = 42usize; + + krate2::hello(); + krate3::hello(); + + let x = (3isize, 4usize); + let y = x.1; +} + +// Issue #37700 +const LUT_BITS: usize = 3; +pub struct HuffmanTable { + ac_lut: Option<[(i16, u8); 1 << LUT_BITS]>, +} + +struct TupStruct(isize, isize, Box); + +fn test_tup_struct(x: TupStruct) -> isize { + x.1 +} + +fn println(s: &str) { + std::io::stdout().write_all(s.as_bytes()); +} + +mod sub { + pub mod sub2 { + use std::io::Write; + pub mod sub3 { + use std::io::Write; + pub fn hello() { + ::println("hello from module 3"); + } + } + pub fn hello() { + ::println("hello from a module"); + } + + pub struct nested_struct { + pub field2: u32, + } + + pub enum nested_enum { + Nest2 = 2, + Nest3 = 3 + } + } +} + +pub mod SameDir; +pub mod SubDir; + +#[path = "SameDir3.rs"] +pub mod SameDir2; + +struct nofields; + +#[derive(Clone)] +struct some_fields { + field1: u32, +} + +type SF = some_fields; + +trait SuperTrait { + fn qux(&self) { panic!(); } +} + +trait SomeTrait: SuperTrait { + fn Method(&self, x: u32) -> u32; + + fn prov(&self, x: u32) -> u32 { + println(&x.to_string()); + 42 + } + fn provided_method(&self) -> u32 { + 42 + } +} + +trait SubTrait: SomeTrait { + fn stat2(x: &Self) -> u32 { + 32 + } +} + +impl SomeTrait for some_fields { + fn Method(&self, x: u32) -> u32 { + println(&x.to_string()); + self.field1 + } +} + +impl SuperTrait for some_fields { +} + +impl SubTrait for some_fields {} + +impl some_fields { + fn stat(x: u32) -> u32 { + println(&x.to_string()); + 42 + } + fn stat2(x: &some_fields) -> u32 { + 42 + } + + fn align_to(&mut self) { + + } + + fn test(&mut self) { + self.align_to::(); + } +} + +impl SuperTrait for nofields { +} +impl SomeTrait for nofields { + fn Method(&self, x: u32) -> u32 { + self.Method(x); + 43 + } + + fn provided_method(&self) -> u32 { + 21 + } +} + +impl SubTrait for nofields {} + +impl SuperTrait for (Box, Box) {} + +fn f_with_params(x: &T) { + x.Method(41); +} + +type MyType = Box; + +enum SomeEnum<'a> { + Ints(isize, isize), + Floats(f64, f64), + Strings(&'a str, &'a str, &'a str), + MyTypes(MyType, MyType) +} + +#[derive(Copy, Clone)] +enum SomeOtherEnum { + SomeConst1, + SomeConst2, + SomeConst3 +} + +enum SomeStructEnum { + EnumStruct{a:isize, b:isize}, + EnumStruct2{f1:MyType, f2:MyType}, + EnumStruct3{f1:MyType, f2:MyType, f3:SomeEnum<'static>} +} + +fn matchSomeEnum(val: SomeEnum) { + match val { + SomeEnum::Ints(int1, int2) => { println(&(int1+int2).to_string()); } + SomeEnum::Floats(float1, float2) => { println(&(float2*float1).to_string()); } + SomeEnum::Strings(.., s3) => { println(s3); } + SomeEnum::MyTypes(mt1, mt2) => { println(&(mt1.field1 - mt2.field1).to_string()); } + } +} + +fn matchSomeStructEnum(se: SomeStructEnum) { + match se { + SomeStructEnum::EnumStruct{a:a, ..} => println(&a.to_string()), + SomeStructEnum::EnumStruct2{f1:f1, f2:f_2} => println(&f_2.field1.to_string()), + SomeStructEnum::EnumStruct3{f1, ..} => println(&f1.field1.to_string()), + } +} + + +fn matchSomeStructEnum2(se: SomeStructEnum) { + use SomeStructEnum::*; + match se { + EnumStruct{a: ref aaa, ..} => println(&aaa.to_string()), + EnumStruct2{f1, f2: f2} => println(&f1.field1.to_string()), + EnumStruct3{f1, f3: SomeEnum::Ints(..), f2} => println(&f1.field1.to_string()), + _ => {}, + } +} + +fn matchSomeOtherEnum(val: SomeOtherEnum) { + use SomeOtherEnum::{SomeConst2, SomeConst3}; + match val { + SomeOtherEnum::SomeConst1 => { println("I'm const1."); } + SomeConst2 | SomeConst3 => { println("I'm const2 or const3."); } + } +} + +fn hello((z, a) : (u32, String), ex: X) { + SameDir2::hello(43); + + println(&yy.to_string()); + let (x, y): (u32, u32) = (5, 3); + println(&x.to_string()); + println(&z.to_string()); + let x: u32 = x; + println(&x.to_string()); + let x = "hello"; + println(x); + + let x = 32.0f32; + let _ = (x + ((x * x) + 1.0).sqrt()).ln(); + + let s: Box = box some_fields {field1: 43}; + let s2: Box = box some_fields {field1: 43}; + let s3 = box nofields; + + s.Method(43); + s3.Method(43); + s2.Method(43); + + ex.prov(43); + + let y: u32 = 56; + // static method on struct + let r = some_fields::stat(y); + // trait static method, calls default + let r = SubTrait::stat2(&*s3); + + let s4 = s3 as Box; + s4.Method(43); + + s4.provided_method(); + s2.prov(45); + + let closure = |x: u32, s: &SomeTrait| { + s.Method(23); + return x + y; + }; + + let z = closure(10, &*s); +} + +pub struct blah { + used_link_args: RefCell<[&'static str; 0]>, +} + +#[macro_use] +mod macro_use_test { + macro_rules! test_rec { + (q, $src: expr) => {{ + print!("{}", $src); + test_rec!($src); + }}; + ($src: expr) => { + print!("{}", $src); + }; + } + + macro_rules! internal_vars { + ($src: ident) => {{ + let mut x = $src; + x += 100; + }}; + } +} + +fn main() { // foo + let s = box some_fields {field1: 43}; + hello((43, "a".to_string()), *s); + sub::sub2::hello(); + sub2::sub3::hello(); + + let h = sub2::sub3::hello; + h(); + + // utf8 chars + let ut = "Les Miséééééééérables"; + + // For some reason, this pattern of macro_rules foiled our generated code + // avoiding strategy. + macro_rules! variable_str(($name:expr) => ( + some_fields { + field1: $name, + } + )); + let vs = variable_str!(32); + + let mut candidates: RefCell> = RefCell::new(HashMap::new()); + let _ = blah { + used_link_args: RefCell::new([]), + }; + let s1 = nofields; + let s2 = SF { field1: 55}; + let s3: some_fields = some_fields{ field1: 55}; + let s4: msalias::nested_struct = sub::sub2::nested_struct{ field2: 55}; + let s4: msalias::nested_struct = sub2::nested_struct{ field2: 55}; + println(&s2.field1.to_string()); + let s5: MyType = box some_fields{ field1: 55}; + let s = SameDir::SameStruct{name: "Bob".to_string()}; + let s = SubDir::SubStruct{name:"Bob".to_string()}; + let s6: SomeEnum = SomeEnum::MyTypes(box s2.clone(), s5); + let s7: SomeEnum = SomeEnum::Strings("one", "two", "three"); + matchSomeEnum(s6); + matchSomeEnum(s7); + let s8: SomeOtherEnum = SomeOtherEnum::SomeConst2; + matchSomeOtherEnum(s8); + let s9: SomeStructEnum = SomeStructEnum::EnumStruct2{ f1: box some_fields{ field1:10 }, + f2: box s2 }; + matchSomeStructEnum(s9); + + for x in &vec![1, 2, 3] { + let _y = x; + } + + let s7: SomeEnum = SomeEnum::Strings("one", "two", "three"); + if let SomeEnum::Strings(..) = s7 { + println!("hello!"); + } + + for i in 0..5 { + foo_foo(i); + } + + if let Some(x) = None { + foo_foo(x); + } + + if false { + } else if let Some(y) = None { + foo_foo(y); + } + + while let Some(z) = None { + foo_foo(z); + } + + let mut x = 4; + test_rec!(q, "Hello"); + assert_eq!(x, 4); + internal_vars!(x); +} + +fn foo_foo(_: i32) {} + +impl Iterator for nofields { + type Item = (usize, usize); + + fn next(&mut self) -> Option<(usize, usize)> { + panic!() + } + + fn size_hint(&self) -> (usize, Option) { + panic!() + } +} + +trait Pattern<'a> { + type Searcher; +} + +struct CharEqPattern; + +impl<'a> Pattern<'a> for CharEqPattern { + type Searcher = CharEqPattern; +} + +struct CharSearcher<'a>(>::Searcher); + +pub trait Error { +} + +impl Error + 'static { + pub fn is(&self) -> bool { + panic!() + } +} + +impl Error + 'static + Send { + pub fn is(&self) -> bool { + ::is::(self) + } +} +extern crate serialize; +#[derive(Clone, Copy, Hash, Encodable, Decodable, PartialEq, Eq, PartialOrd, Ord, Debug, Default)] +struct AllDerives(i32); + +fn test_format_args() { + let x = 1; + let y = 2; + let name = "Joe Blogg"; + println!("Hello {}", name); + print!("Hello {0}", name); + print!("{0} + {} = {}", x, y); + print!("x is {}, y is {1}, name is {n}", x, y, n = name); +} + + +union TestUnion { + f1: u32 +} + +struct FrameBuffer; + +struct SilenceGenerator; + +impl Iterator for SilenceGenerator { + type Item = FrameBuffer; + + fn next(&mut self) -> Option { + panic!(); + } +} + +trait Foo { + type Bar = FrameBuffer; +} + +#[doc(include="extra-docs.md")] +struct StructWithDocs; diff --git a/src/test/run-make-fulldeps/save-analysis/krate2.rs b/src/test/run-make-fulldeps/save-analysis/krate2.rs new file mode 100644 index 00000000000..2c6f517ff38 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis/krate2.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![ crate_name = "krate2" ] +#![ crate_type = "lib" ] + +use std::io::Write; + +pub fn hello() { + std::io::stdout().write_all(b"hello world!\n"); +} diff --git a/src/test/run-make-fulldeps/sepcomp-cci-copies/Makefile b/src/test/run-make-fulldeps/sepcomp-cci-copies/Makefile new file mode 100644 index 00000000000..36f913ff3fa --- /dev/null +++ b/src/test/run-make-fulldeps/sepcomp-cci-copies/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +# Check that cross-crate inlined items are inlined in all compilation units +# that refer to them, and not in any other compilation units. +# Note that we have to pass `-C codegen-units=6` because up to two CGUs may be +# created for each source module (see `rustc_mir::monomorphize::partitioning`). + +all: + $(RUSTC) cci_lib.rs + $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=6 \ + -Z inline-in-all-cgus + [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ .*cci_fn)" -eq "2" ] diff --git a/src/test/run-make-fulldeps/sepcomp-cci-copies/cci_lib.rs b/src/test/run-make-fulldeps/sepcomp-cci-copies/cci_lib.rs new file mode 100644 index 00000000000..62bc3294286 --- /dev/null +++ b/src/test/run-make-fulldeps/sepcomp-cci-copies/cci_lib.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[inline] +pub fn cci_fn() -> usize { + 1234 +} diff --git a/src/test/run-make-fulldeps/sepcomp-cci-copies/foo.rs b/src/test/run-make-fulldeps/sepcomp-cci-copies/foo.rs new file mode 100644 index 00000000000..e00cab20f6b --- /dev/null +++ b/src/test/run-make-fulldeps/sepcomp-cci-copies/foo.rs @@ -0,0 +1,35 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate cci_lib; +use cci_lib::cci_fn; + +fn call1() -> usize { + cci_fn() +} + +mod a { + use cci_lib::cci_fn; + pub fn call2() -> usize { + cci_fn() + } +} + +mod b { + pub fn call3() -> usize { + 0 + } +} + +fn main() { + call1(); + a::call2(); + b::call3(); +} diff --git a/src/test/run-make-fulldeps/sepcomp-inlining/Makefile b/src/test/run-make-fulldeps/sepcomp-inlining/Makefile new file mode 100644 index 00000000000..1d20d940000 --- /dev/null +++ b/src/test/run-make-fulldeps/sepcomp-inlining/Makefile @@ -0,0 +1,15 @@ +-include ../tools.mk + +# Test that #[inline] functions still get inlined across compilation unit +# boundaries. Compilation should produce three IR files, but only the two +# compilation units that have a usage of the #[inline] function should +# contain a definition. Also, the non-#[inline] function should be defined +# in only one compilation unit. + +all: + $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3 \ + -Z inline-in-all-cgus + [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ i32\ .*inlined)" -eq "0" ] + [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ internal\ i32\ .*inlined)" -eq "2" ] + [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ hidden\ i32\ .*normal)" -eq "1" ] + [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c declare\ hidden\ i32\ .*normal)" -eq "2" ] diff --git a/src/test/run-make-fulldeps/sepcomp-inlining/foo.rs b/src/test/run-make-fulldeps/sepcomp-inlining/foo.rs new file mode 100644 index 00000000000..5b62c1b0626 --- /dev/null +++ b/src/test/run-make-fulldeps/sepcomp-inlining/foo.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(start)] + +#[inline] +fn inlined() -> u32 { + 1234 +} + +fn normal() -> u32 { + 2345 +} + +mod a { + pub fn f() -> u32 { + ::inlined() + ::normal() + } +} + +mod b { + pub fn f() -> u32 { + ::inlined() + ::normal() + } +} + +#[start] +fn start(_: isize, _: *const *const u8) -> isize { + a::f(); + b::f(); + + 0 +} diff --git a/src/test/run-make-fulldeps/sepcomp-separate/Makefile b/src/test/run-make-fulldeps/sepcomp-separate/Makefile new file mode 100644 index 00000000000..5b8bdb0fad8 --- /dev/null +++ b/src/test/run-make-fulldeps/sepcomp-separate/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +# Test that separate compilation actually puts code into separate compilation +# units. `foo.rs` defines `magic_fn` in three different modules, which should +# wind up in three different compilation units. + +all: + $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3 + [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ .*magic_fn)" -eq "3" ] diff --git a/src/test/run-make-fulldeps/sepcomp-separate/foo.rs b/src/test/run-make-fulldeps/sepcomp-separate/foo.rs new file mode 100644 index 00000000000..64a76e9e0ed --- /dev/null +++ b/src/test/run-make-fulldeps/sepcomp-separate/foo.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + + +fn magic_fn() -> usize { + 1234 +} + +mod a { + pub fn magic_fn() -> usize { + 2345 + } +} + +mod b { + pub fn magic_fn() -> usize { + 3456 + } +} + +fn main() { + magic_fn(); + a::magic_fn(); + b::magic_fn(); +} diff --git a/src/test/run-make-fulldeps/simd-ffi/Makefile b/src/test/run-make-fulldeps/simd-ffi/Makefile new file mode 100644 index 00000000000..e9c974a0137 --- /dev/null +++ b/src/test/run-make-fulldeps/simd-ffi/Makefile @@ -0,0 +1,47 @@ +-include ../tools.mk + +TARGETS = +ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm) +# construct a fairly exhaustive list of platforms that we +# support. These ones don't follow a pattern +TARGETS += arm-linux-androideabi arm-unknown-linux-gnueabihf arm-unknown-linux-gnueabi +endif + +ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86) +X86_ARCHS = i686 x86_64 +else +X86_ARCHS = +endif + +# these ones do, each OS lists the architectures it supports +LINUX=$(filter aarch64 mips,$(LLVM_COMPONENTS)) $(X86_ARCHS) +ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips) +LINUX += mipsel +endif + +WINDOWS=$(X86_ARCHS) +# fails with: failed to get iphonesimulator SDK path: no such file or directory +#IOS=i386 aarch64 armv7 +DARWIN=$(X86_ARCHS) + +$(foreach arch,$(LINUX),$(eval TARGETS += $(arch)-unknown-linux-gnu)) +$(foreach arch,$(WINDOWS),$(eval TARGETS += $(arch)-pc-windows-gnu)) +#$(foreach arch,$(IOS),$(eval TARGETS += $(arch)-apple-ios)) +$(foreach arch,$(DARWIN),$(eval TARGETS += $(arch)-apple-darwin)) + +all: $(TARGETS) + +define MK_TARGETS +# compile the rust file to the given target, but only to asm and IR +# form, to avoid having to have an appropriate linker. +# +# we need some features because the integer SIMD instructions are not +# enabled by-default for i686 and ARM; these features will be invalid +# on some platforms, but LLVM just prints a warning so that's fine for +# now. +$(1): simd.rs + $$(RUSTC) --target=$(1) --emit=llvm-ir,asm simd.rs \ + -C target-feature='+neon,+sse2' -C extra-filename=-$(1) +endef + +$(foreach targetxxx,$(TARGETS),$(eval $(call MK_TARGETS,$(targetxxx)))) diff --git a/src/test/run-make-fulldeps/simd-ffi/simd.rs b/src/test/run-make-fulldeps/simd-ffi/simd.rs new file mode 100644 index 00000000000..94b91c711cc --- /dev/null +++ b/src/test/run-make-fulldeps/simd-ffi/simd.rs @@ -0,0 +1,83 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ensures that public symbols are not removed completely +#![crate_type = "lib"] +// we can compile to a variety of platforms, because we don't need +// cross-compiled standard libraries. +#![feature(no_core, optin_builtin_traits)] +#![no_core] + +#![feature(repr_simd, simd_ffi, link_llvm_intrinsics, lang_items)] + + +#[repr(C)] +#[derive(Copy)] +#[repr(simd)] +pub struct f32x4(f32, f32, f32, f32); + + +extern { + #[link_name = "llvm.sqrt.v4f32"] + fn vsqrt(x: f32x4) -> f32x4; +} + +pub fn foo(x: f32x4) -> f32x4 { + unsafe {vsqrt(x)} +} + +#[repr(C)] +#[derive(Copy)] +#[repr(simd)] +pub struct i32x4(i32, i32, i32, i32); + + +extern { + // _mm_sll_epi32 + #[cfg(any(target_arch = "x86", + target_arch = "x86-64"))] + #[link_name = "llvm.x86.sse2.psll.d"] + fn integer(a: i32x4, b: i32x4) -> i32x4; + + // vmaxq_s32 + #[cfg(target_arch = "arm")] + #[link_name = "llvm.arm.neon.vmaxs.v4i32"] + fn integer(a: i32x4, b: i32x4) -> i32x4; + // vmaxq_s32 + #[cfg(target_arch = "aarch64")] + #[link_name = "llvm.aarch64.neon.maxs.v4i32"] + fn integer(a: i32x4, b: i32x4) -> i32x4; + + // just some substitute foreign symbol, not an LLVM intrinsic; so + // we still get type checking, but not as detailed as (ab)using + // LLVM. + #[cfg(not(any(target_arch = "x86", + target_arch = "x86-64", + target_arch = "arm", + target_arch = "aarch64")))] + fn integer(a: i32x4, b: i32x4) -> i32x4; +} + +pub fn bar(a: i32x4, b: i32x4) -> i32x4 { + unsafe {integer(a, b)} +} + +#[lang = "sized"] +pub trait Sized { } + +#[lang = "copy"] +pub trait Copy { } + +pub mod marker { + pub use Copy; +} + +#[lang = "freeze"] +auto trait Freeze {} diff --git a/src/test/run-make-fulldeps/simple-dylib/Makefile b/src/test/run-make-fulldeps/simple-dylib/Makefile new file mode 100644 index 00000000000..26730820fea --- /dev/null +++ b/src/test/run-make-fulldeps/simple-dylib/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk +all: + $(RUSTC) bar.rs --crate-type=dylib -C prefer-dynamic + $(RUSTC) foo.rs + $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/simple-dylib/bar.rs b/src/test/run-make-fulldeps/simple-dylib/bar.rs new file mode 100644 index 00000000000..4c79f7e2855 --- /dev/null +++ b/src/test/run-make-fulldeps/simple-dylib/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/simple-dylib/foo.rs b/src/test/run-make-fulldeps/simple-dylib/foo.rs new file mode 100644 index 00000000000..858ef492ace --- /dev/null +++ b/src/test/run-make-fulldeps/simple-dylib/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar; + +fn main() { + bar::bar(); +} diff --git a/src/test/run-make-fulldeps/simple-rlib/Makefile b/src/test/run-make-fulldeps/simple-rlib/Makefile new file mode 100644 index 00000000000..7b156cb8748 --- /dev/null +++ b/src/test/run-make-fulldeps/simple-rlib/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk +all: + $(RUSTC) bar.rs --crate-type=rlib + $(RUSTC) foo.rs + $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/simple-rlib/bar.rs b/src/test/run-make-fulldeps/simple-rlib/bar.rs new file mode 100644 index 00000000000..4c79f7e2855 --- /dev/null +++ b/src/test/run-make-fulldeps/simple-rlib/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/simple-rlib/foo.rs b/src/test/run-make-fulldeps/simple-rlib/foo.rs new file mode 100644 index 00000000000..858ef492ace --- /dev/null +++ b/src/test/run-make-fulldeps/simple-rlib/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar; + +fn main() { + bar::bar(); +} diff --git a/src/test/run-make-fulldeps/stable-symbol-names/Makefile b/src/test/run-make-fulldeps/stable-symbol-names/Makefile new file mode 100644 index 00000000000..3cbc5593ac0 --- /dev/null +++ b/src/test/run-make-fulldeps/stable-symbol-names/Makefile @@ -0,0 +1,40 @@ +-include ../tools.mk + +# The following command will: +# 1. dump the symbols of a library using `nm` +# 2. extract only those lines that we are interested in via `grep` +# 3. from those lines, extract just the symbol name via `sed` +# (symbol names always start with "_ZN" and end with "E") +# 4. sort those symbol names for deterministic comparison +# 5. write the result into a file + +dump-symbols = nm "$(TMPDIR)/lib$(1).rlib" \ + | grep -E "$(2)" \ + | sed "s/.*\(_ZN.*E\).*/\1/" \ + | sort \ + > "$(TMPDIR)/$(1)$(3).nm" + +# This test +# - compiles each of the two crates 2 times and makes sure each time we get +# exactly the same symbol names +# - makes sure that both crates agree on the same symbol names for monomorphic +# functions + +all: + $(RUSTC) stable-symbol-names1.rs + $(call dump-symbols,stable_symbol_names1,generic_|mono_,_v1) + rm $(TMPDIR)/libstable_symbol_names1.rlib + $(RUSTC) stable-symbol-names1.rs + $(call dump-symbols,stable_symbol_names1,generic_|mono_,_v2) + cmp "$(TMPDIR)/stable_symbol_names1_v1.nm" "$(TMPDIR)/stable_symbol_names1_v2.nm" + + $(RUSTC) stable-symbol-names2.rs + $(call dump-symbols,stable_symbol_names2,generic_|mono_,_v1) + rm $(TMPDIR)/libstable_symbol_names2.rlib + $(RUSTC) stable-symbol-names2.rs + $(call dump-symbols,stable_symbol_names2,generic_|mono_,_v2) + cmp "$(TMPDIR)/stable_symbol_names2_v1.nm" "$(TMPDIR)/stable_symbol_names2_v2.nm" + + $(call dump-symbols,stable_symbol_names1,mono_,_cross) + $(call dump-symbols,stable_symbol_names2,mono_,_cross) + cmp "$(TMPDIR)/stable_symbol_names1_cross.nm" "$(TMPDIR)/stable_symbol_names2_cross.nm" diff --git a/src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names1.rs b/src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names1.rs new file mode 100644 index 00000000000..7344bdf49f6 --- /dev/null +++ b/src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names1.rs @@ -0,0 +1,41 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="rlib"] + +pub trait Foo { + fn generic_method(); +} + +pub struct Bar; + +impl Foo for Bar { + fn generic_method() {} +} + +pub fn mono_function() { + Bar::generic_method::(); +} + +pub fn mono_function_lifetime<'a>(x: &'a u64) -> u64 { + *x +} + +pub fn generic_function(t: T) -> T { + t +} + +pub fn user() { + generic_function(0u32); + generic_function("abc"); + let x = 2u64; + generic_function(&x); + let _ = mono_function_lifetime(&x); +} diff --git a/src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names2.rs b/src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names2.rs new file mode 100644 index 00000000000..eacba4ddb25 --- /dev/null +++ b/src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names2.rs @@ -0,0 +1,28 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="rlib"] + +extern crate stable_symbol_names1; + +pub fn user() { + stable_symbol_names1::generic_function(1u32); + stable_symbol_names1::generic_function("def"); + let x = 2u64; + stable_symbol_names1::generic_function(&x); + stable_symbol_names1::mono_function(); + stable_symbol_names1::mono_function_lifetime(&0); +} + +pub fn trait_impl_test_function() { + use stable_symbol_names1::*; + Bar::generic_method::(); +} + diff --git a/src/test/run-make-fulldeps/static-dylib-by-default/Makefile b/src/test/run-make-fulldeps/static-dylib-by-default/Makefile new file mode 100644 index 00000000000..6409aa66ae0 --- /dev/null +++ b/src/test/run-make-fulldeps/static-dylib-by-default/Makefile @@ -0,0 +1,16 @@ +-include ../tools.mk + +TO_LINK := $(call DYLIB,bar) +ifdef IS_MSVC +LINK_ARG = $(TO_LINK:dll=dll.lib) +else +LINK_ARG = $(TO_LINK) +endif + +all: + $(RUSTC) foo.rs + $(RUSTC) bar.rs + $(CC) main.c $(call OUT_EXE,main) $(LINK_ARG) $(EXTRACFLAGS) + rm $(TMPDIR)/*.rlib + rm $(call DYLIB,foo) + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/static-dylib-by-default/bar.rs b/src/test/run-make-fulldeps/static-dylib-by-default/bar.rs new file mode 100644 index 00000000000..63da277dece --- /dev/null +++ b/src/test/run-make-fulldeps/static-dylib-by-default/bar.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +extern crate foo; + +#[no_mangle] +pub extern fn bar() { + foo::foo(); +} diff --git a/src/test/run-make-fulldeps/static-dylib-by-default/foo.rs b/src/test/run-make-fulldeps/static-dylib-by-default/foo.rs new file mode 100644 index 00000000000..341040e653c --- /dev/null +++ b/src/test/run-make-fulldeps/static-dylib-by-default/foo.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![crate_type = "dylib"] + +pub fn foo() {} diff --git a/src/test/run-make-fulldeps/static-dylib-by-default/main.c b/src/test/run-make-fulldeps/static-dylib-by-default/main.c new file mode 100644 index 00000000000..30bb0783edf --- /dev/null +++ b/src/test/run-make-fulldeps/static-dylib-by-default/main.c @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern void bar(); + +int main() { + bar(); + return 0; +} diff --git a/src/test/run-make-fulldeps/static-nobundle/Makefile b/src/test/run-make-fulldeps/static-nobundle/Makefile new file mode 100644 index 00000000000..abc32d4423b --- /dev/null +++ b/src/test/run-make-fulldeps/static-nobundle/Makefile @@ -0,0 +1,21 @@ +-include ../tools.mk + +# aaa is a native static library +# bbb is a rlib +# ccc is a dylib +# ddd is an executable + +all: $(call NATIVE_STATICLIB,aaa) + $(RUSTC) bbb.rs --crate-type=rlib + + # Check that bbb does NOT contain the definition of `native_func` + nm $(TMPDIR)/libbbb.rlib | $(CGREP) -ve "T _*native_func" + nm $(TMPDIR)/libbbb.rlib | $(CGREP) -e "U _*native_func" + + # Check that aaa gets linked (either as `-l aaa` or `aaa.lib`) when building ccc. + $(RUSTC) ccc.rs -C prefer-dynamic --crate-type=dylib -Z print-link-args | $(CGREP) -e '-l[" ]*aaa|aaa\.lib' + + # Check that aaa does NOT get linked when building ddd. + $(RUSTC) ddd.rs -Z print-link-args | $(CGREP) -ve '-l[" ]*aaa|aaa\.lib' + + $(call RUN,ddd) diff --git a/src/test/run-make-fulldeps/static-nobundle/aaa.c b/src/test/run-make-fulldeps/static-nobundle/aaa.c new file mode 100644 index 00000000000..806ef878c70 --- /dev/null +++ b/src/test/run-make-fulldeps/static-nobundle/aaa.c @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void native_func() {} diff --git a/src/test/run-make-fulldeps/static-nobundle/bbb.rs b/src/test/run-make-fulldeps/static-nobundle/bbb.rs new file mode 100644 index 00000000000..2bd69c99327 --- /dev/null +++ b/src/test/run-make-fulldeps/static-nobundle/bbb.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(static_nobundle)] + +#[link(name = "aaa", kind = "static-nobundle")] +extern { + pub fn native_func(); +} + +pub fn wrapped_func() { + unsafe { + native_func(); + } +} diff --git a/src/test/run-make-fulldeps/static-nobundle/ccc.rs b/src/test/run-make-fulldeps/static-nobundle/ccc.rs new file mode 100644 index 00000000000..bd34753a00d --- /dev/null +++ b/src/test/run-make-fulldeps/static-nobundle/ccc.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +extern crate bbb; + +pub fn do_work() { + unsafe { bbb::native_func(); } + bbb::wrapped_func(); +} + +pub fn do_work_generic() { + unsafe { bbb::native_func(); } + bbb::wrapped_func(); +} diff --git a/src/test/run-make-fulldeps/static-nobundle/ddd.rs b/src/test/run-make-fulldeps/static-nobundle/ddd.rs new file mode 100644 index 00000000000..f7d23a899f7 --- /dev/null +++ b/src/test/run-make-fulldeps/static-nobundle/ddd.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate ccc; + +fn main() { + ccc::do_work(); + ccc::do_work_generic::(); + ccc::do_work_generic::(); +} diff --git a/src/test/run-make-fulldeps/static-unwinding/Makefile b/src/test/run-make-fulldeps/static-unwinding/Makefile new file mode 100644 index 00000000000..cb039744265 --- /dev/null +++ b/src/test/run-make-fulldeps/static-unwinding/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) lib.rs + $(RUSTC) main.rs + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/static-unwinding/lib.rs b/src/test/run-make-fulldeps/static-unwinding/lib.rs new file mode 100644 index 00000000000..12c72d54c09 --- /dev/null +++ b/src/test/run-make-fulldeps/static-unwinding/lib.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +pub static mut statik: isize = 0; + +struct A; +impl Drop for A { + fn drop(&mut self) { + unsafe { statik = 1; } + } +} + +pub fn callback(f: F) where F: FnOnce() { + let _a = A; + f(); +} diff --git a/src/test/run-make-fulldeps/static-unwinding/main.rs b/src/test/run-make-fulldeps/static-unwinding/main.rs new file mode 100644 index 00000000000..1cd785334f6 --- /dev/null +++ b/src/test/run-make-fulldeps/static-unwinding/main.rs @@ -0,0 +1,34 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate lib; + +use std::thread; + +static mut statik: isize = 0; + +struct A; +impl Drop for A { + fn drop(&mut self) { + unsafe { statik = 1; } + } +} + +fn main() { + thread::spawn(move|| { + let _a = A; + lib::callback(|| panic!()); + }).join().unwrap_err(); + + unsafe { + assert_eq!(lib::statik, 1); + assert_eq!(statik, 1); + } +} diff --git a/src/test/run-make-fulldeps/staticlib-blank-lib/Makefile b/src/test/run-make-fulldeps/staticlib-blank-lib/Makefile new file mode 100644 index 00000000000..92a278825c2 --- /dev/null +++ b/src/test/run-make-fulldeps/staticlib-blank-lib/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(AR) crus $(TMPDIR)/libfoo.a foo.rs + $(AR) d $(TMPDIR)/libfoo.a foo.rs + $(RUSTC) foo.rs diff --git a/src/test/run-make-fulldeps/staticlib-blank-lib/foo.rs b/src/test/run-make-fulldeps/staticlib-blank-lib/foo.rs new file mode 100644 index 00000000000..6010e60e95c --- /dev/null +++ b/src/test/run-make-fulldeps/staticlib-blank-lib/foo.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "staticlib"] + +#[link(name = "foo", kind = "static")] +extern {} + +fn main() {} diff --git a/src/test/run-make-fulldeps/stdin-non-utf8/Makefile b/src/test/run-make-fulldeps/stdin-non-utf8/Makefile new file mode 100644 index 00000000000..7948c442616 --- /dev/null +++ b/src/test/run-make-fulldeps/stdin-non-utf8/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + cp non-utf8 $(TMPDIR)/non-utf.rs + cat $(TMPDIR)/non-utf.rs | $(RUSTC) - 2>&1 \ + | $(CGREP) "error: couldn't read from stdin, as it did not contain valid UTF-8" diff --git a/src/test/run-make-fulldeps/stdin-non-utf8/non-utf8 b/src/test/run-make-fulldeps/stdin-non-utf8/non-utf8 new file mode 100644 index 00000000000..bc87051a852 --- /dev/null +++ b/src/test/run-make-fulldeps/stdin-non-utf8/non-utf8 @@ -0,0 +1 @@ +Ò diff --git a/src/test/run-make-fulldeps/suspicious-library/Makefile b/src/test/run-make-fulldeps/suspicious-library/Makefile new file mode 100644 index 00000000000..12f437075fb --- /dev/null +++ b/src/test/run-make-fulldeps/suspicious-library/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs -C prefer-dynamic + touch $(call DYLIB,foo-something-special) + touch $(call DYLIB,foo-something-special2) + $(RUSTC) bar.rs diff --git a/src/test/run-make-fulldeps/suspicious-library/bar.rs b/src/test/run-make-fulldeps/suspicious-library/bar.rs new file mode 100644 index 00000000000..ed0e8a7e23e --- /dev/null +++ b/src/test/run-make-fulldeps/suspicious-library/bar.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { foo::foo() } diff --git a/src/test/run-make-fulldeps/suspicious-library/foo.rs b/src/test/run-make-fulldeps/suspicious-library/foo.rs new file mode 100644 index 00000000000..2ec6e3834a1 --- /dev/null +++ b/src/test/run-make-fulldeps/suspicious-library/foo.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +pub fn foo() {} diff --git a/src/test/run-make-fulldeps/symbol-visibility/Makefile b/src/test/run-make-fulldeps/symbol-visibility/Makefile new file mode 100644 index 00000000000..f1ada814bdb --- /dev/null +++ b/src/test/run-make-fulldeps/symbol-visibility/Makefile @@ -0,0 +1,60 @@ +include ../tools.mk + +ifdef IS_WINDOWS +# Do nothing on MSVC. +# On MINGW the --version-script, --dynamic-list, and --retain-symbol args don't +# seem to work reliably. +all: + exit 0 +else + +NM=nm -D +CDYLIB_NAME=liba_cdylib.so +RDYLIB_NAME=liba_rust_dylib.so +EXE_NAME=an_executable +COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.so + +ifeq ($(UNAME),Darwin) +NM=nm -gU +CDYLIB_NAME=liba_cdylib.dylib +RDYLIB_NAME=liba_rust_dylib.dylib +EXE_NAME=an_executable +COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dylib +endif + +all: + $(RUSTC) an_rlib.rs + $(RUSTC) a_cdylib.rs + $(RUSTC) a_rust_dylib.rs + $(RUSTC) an_executable.rs + $(RUSTC) a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib + + # Check that a cdylib exports its public #[no_mangle] functions + [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ] + # Check that a cdylib exports the public #[no_mangle] functions of dependencies + [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] + # Check that a cdylib DOES NOT export any public Rust functions + [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ] + + # Check that a Rust dylib exports its monomorphic functions + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_rust_function_from_rust_dylib.*E)" -eq "1" ] + + # Check that a Rust dylib exports the monomorphic functions from its dependencies + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ] + + # Check that an executable does not export any dynamic symbols + [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ] + [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ] + + + # Check the combined case, where we generate a cdylib and an rlib in the same + # compilation session: + # Check that a cdylib exports its public #[no_mangle] functions + [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ] + # Check that a cdylib exports the public #[no_mangle] functions of dependencies + [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] + # Check that a cdylib DOES NOT export any public Rust functions + [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ] +endif diff --git a/src/test/run-make-fulldeps/symbol-visibility/a_cdylib.rs b/src/test/run-make-fulldeps/symbol-visibility/a_cdylib.rs new file mode 100644 index 00000000000..9a70542c06c --- /dev/null +++ b/src/test/run-make-fulldeps/symbol-visibility/a_cdylib.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="cdylib"] + +extern crate an_rlib; + +// This should not be exported +pub fn public_rust_function_from_cdylib() {} + +// This should be exported +#[no_mangle] +pub extern "C" fn public_c_function_from_cdylib() { + an_rlib::public_c_function_from_rlib(); +} diff --git a/src/test/run-make-fulldeps/symbol-visibility/a_rust_dylib.rs b/src/test/run-make-fulldeps/symbol-visibility/a_rust_dylib.rs new file mode 100644 index 00000000000..b826211c9a4 --- /dev/null +++ b/src/test/run-make-fulldeps/symbol-visibility/a_rust_dylib.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="dylib"] + +extern crate an_rlib; + +// This should be exported +pub fn public_rust_function_from_rust_dylib() {} + +// This should be exported +#[no_mangle] +pub extern "C" fn public_c_function_from_rust_dylib() {} diff --git a/src/test/run-make-fulldeps/symbol-visibility/an_executable.rs b/src/test/run-make-fulldeps/symbol-visibility/an_executable.rs new file mode 100644 index 00000000000..73059c5e374 --- /dev/null +++ b/src/test/run-make-fulldeps/symbol-visibility/an_executable.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="bin"] + +extern crate an_rlib; + +pub fn public_rust_function_from_exe() {} + +fn main() {} diff --git a/src/test/run-make-fulldeps/symbol-visibility/an_rlib.rs b/src/test/run-make-fulldeps/symbol-visibility/an_rlib.rs new file mode 100644 index 00000000000..cd19500d140 --- /dev/null +++ b/src/test/run-make-fulldeps/symbol-visibility/an_rlib.rs @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="rlib"] + +pub fn public_rust_function_from_rlib() {} + +#[no_mangle] +pub extern "C" fn public_c_function_from_rlib() {} diff --git a/src/test/run-make-fulldeps/symbols-are-reasonable/Makefile b/src/test/run-make-fulldeps/symbols-are-reasonable/Makefile new file mode 100644 index 00000000000..a6d294d2a1c --- /dev/null +++ b/src/test/run-make-fulldeps/symbols-are-reasonable/Makefile @@ -0,0 +1,13 @@ +-include ../tools.mk + +# check that the compile generated symbols for strings, binaries, +# vtables, etc. have semisane names (e.g. `str.1234`); it's relatively +# easy to accidentally modify the compiler internals to make them +# become things like `str"str"(1234)`. + +OUT=$(TMPDIR)/lib.s + +all: + $(RUSTC) lib.rs --emit=asm --crate-type=staticlib + # just check for symbol declarations with the names we're expecting. + $(CGREP) -e 'str\.[0-9]+:' 'byte_str\.[0-9]+:' 'vtable\.[0-9]+' < $(OUT) diff --git a/src/test/run-make-fulldeps/symbols-are-reasonable/lib.rs b/src/test/run-make-fulldeps/symbols-are-reasonable/lib.rs new file mode 100644 index 00000000000..b9285b24cd6 --- /dev/null +++ b/src/test/run-make-fulldeps/symbols-are-reasonable/lib.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub static X: &'static str = "foobarbaz"; +pub static Y: &'static [u8] = include_bytes!("lib.rs"); + +trait Foo { fn dummy(&self) { } } +impl Foo for usize {} + +#[no_mangle] +pub extern "C" fn dummy() { + // force the vtable to be created + let _x = &1usize as &Foo; +} diff --git a/src/test/run-make-fulldeps/symbols-include-type-name/Makefile b/src/test/run-make-fulldeps/symbols-include-type-name/Makefile new file mode 100644 index 00000000000..0850a2633e5 --- /dev/null +++ b/src/test/run-make-fulldeps/symbols-include-type-name/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +# Check that symbol names for methods include type names, instead of . + +OUT=$(TMPDIR)/lib.s + +all: + $(RUSTC) --crate-type staticlib --emit asm lib.rs + $(CGREP) Def < $(OUT) diff --git a/src/test/run-make-fulldeps/symbols-include-type-name/lib.rs b/src/test/run-make-fulldeps/symbols-include-type-name/lib.rs new file mode 100644 index 00000000000..d84f1617db5 --- /dev/null +++ b/src/test/run-make-fulldeps/symbols-include-type-name/lib.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Def { + pub id: i32, +} + +impl Def { + pub fn new(id: i32) -> Def { + Def { id: id } + } +} + +#[no_mangle] +pub fn user() { + let _ = Def::new(0); +} diff --git a/src/test/run-make-fulldeps/symlinked-extern/Makefile b/src/test/run-make-fulldeps/symlinked-extern/Makefile new file mode 100644 index 00000000000..88dbad51e48 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-extern/Makefile @@ -0,0 +1,16 @@ +-include ../tools.mk + +# ignore windows: `ln` is actually `cp` on msys. +ifndef IS_WINDOWS + +all: + $(RUSTC) foo.rs + mkdir -p $(TMPDIR)/other + ln -nsf $(TMPDIR)/libfoo.rlib $(TMPDIR)/other + $(RUSTC) bar.rs -L $(TMPDIR) + $(RUSTC) baz.rs --extern foo=$(TMPDIR)/other/libfoo.rlib -L $(TMPDIR) + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/symlinked-extern/bar.rs b/src/test/run-make-fulldeps/symlinked-extern/bar.rs new file mode 100644 index 00000000000..79103f24017 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-extern/bar.rs @@ -0,0 +1,16 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +extern crate foo; + +pub fn bar(_s: foo::S) { +} diff --git a/src/test/run-make-fulldeps/symlinked-extern/baz.rs b/src/test/run-make-fulldeps/symlinked-extern/baz.rs new file mode 100644 index 00000000000..0f6ba254368 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-extern/baz.rs @@ -0,0 +1,16 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar; +extern crate foo; + +fn main() { + bar::bar(foo::foo()); +} diff --git a/src/test/run-make-fulldeps/symlinked-extern/foo.rs b/src/test/run-make-fulldeps/symlinked-extern/foo.rs new file mode 100644 index 00000000000..0b8bb64d375 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-extern/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +pub struct S; + +pub fn foo() -> S { S } diff --git a/src/test/run-make-fulldeps/symlinked-libraries/Makefile b/src/test/run-make-fulldeps/symlinked-libraries/Makefile new file mode 100644 index 00000000000..ac595546aa7 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-libraries/Makefile @@ -0,0 +1,15 @@ +-include ../tools.mk + +# ignore windows: `ln` is actually `cp` on msys. +ifndef IS_WINDOWS + +all: + $(RUSTC) foo.rs -C prefer-dynamic + mkdir -p $(TMPDIR)/other + ln -nsf $(TMPDIR)/$(call DYLIB_GLOB,foo) $(TMPDIR)/other + $(RUSTC) bar.rs -L $(TMPDIR)/other + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/symlinked-libraries/bar.rs b/src/test/run-make-fulldeps/symlinked-libraries/bar.rs new file mode 100644 index 00000000000..73596f93f56 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-libraries/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::bar(); +} diff --git a/src/test/run-make-fulldeps/symlinked-libraries/foo.rs b/src/test/run-make-fulldeps/symlinked-libraries/foo.rs new file mode 100644 index 00000000000..fdb29974cd8 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-libraries/foo.rs @@ -0,0 +1,13 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/symlinked-rlib/Makefile b/src/test/run-make-fulldeps/symlinked-rlib/Makefile new file mode 100644 index 00000000000..2709f786e0a --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-rlib/Makefile @@ -0,0 +1,14 @@ +-include ../tools.mk + +# ignore windows: `ln` is actually `cp` on msys. +ifndef IS_WINDOWS + +all: + $(RUSTC) foo.rs --crate-type=rlib -o $(TMPDIR)/foo.xxx + ln -nsf $(TMPDIR)/foo.xxx $(TMPDIR)/libfoo.rlib + $(RUSTC) bar.rs -L $(TMPDIR) + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/symlinked-rlib/bar.rs b/src/test/run-make-fulldeps/symlinked-rlib/bar.rs new file mode 100644 index 00000000000..e8f06680862 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-rlib/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::bar(); +} diff --git a/src/test/run-make-fulldeps/symlinked-rlib/foo.rs b/src/test/run-make-fulldeps/symlinked-rlib/foo.rs new file mode 100644 index 00000000000..5abbb1dcbce --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-rlib/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile new file mode 100644 index 00000000000..a35174b3c2a --- /dev/null +++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile @@ -0,0 +1,2 @@ +all: + python2.7 test.py diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/test.py b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/test.py new file mode 100644 index 00000000000..210059e1010 --- /dev/null +++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/test.py @@ -0,0 +1,71 @@ +# Copyright 2015 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +import sys +import os +from os import listdir +from os.path import isfile, join +from subprocess import PIPE, Popen + + +# This is a whitelist of files which are stable crates or simply are not crates, +# we don't check for the instability of these crates as they're all stable! +STABLE_CRATES = ['std', 'core', 'proc_macro', 'rsbegin.o', 'rsend.o', 'dllcrt2.o', 'crt2.o', + 'clang_rt'] + + +def convert_to_string(s): + if s.__class__.__name__ == 'bytes': + return s.decode('utf-8') + return s + + +def exec_command(command, to_input=None): + child = None + if to_input is None: + child = Popen(command, stdout=PIPE, stderr=PIPE) + else: + child = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE) + stdout, stderr = child.communicate(input=to_input) + return (convert_to_string(stdout), convert_to_string(stderr)) + + +def check_lib(lib): + if lib['name'] in STABLE_CRATES: + return True + print('verifying if {} is an unstable crate'.format(lib['name'])) + stdout, stderr = exec_command([os.environ['RUSTC'], '-', '--crate-type', 'rlib', + '--extern', '{}={}'.format(lib['name'], lib['path'])], + to_input='extern crate {};'.format(lib['name'])) + if not 'use of unstable library feature' in '{}{}'.format(stdout, stderr): + print('crate {} "{}" is not unstable'.format(lib['name'], lib['path'])) + print('{}{}'.format(stdout, stderr)) + print('') + return False + return True + +# Generate a list of all crates in the sysroot. To do this we list all files in +# rustc's sysroot, look at the filename, strip everything after the `-`, and +# strip the leading `lib` (if present) +def get_all_libs(dir_path): + return [{ 'path': join(dir_path, f), 'name': f[3:].split('-')[0] } + for f in listdir(dir_path) + if isfile(join(dir_path, f)) and f.endswith('.rlib') and f not in STABLE_CRATES] + + +sysroot = exec_command([os.environ['RUSTC'], '--print', 'sysroot'])[0].replace('\n', '') +libs = get_all_libs(join(sysroot, 'lib/rustlib/{}/lib'.format(os.environ['TARGET']))) + +ret = 0 +for lib in libs: + if not check_lib(lib): + # We continue so users can see all the not unstable crates. + ret = 1 +sys.exit(ret) diff --git a/src/test/run-make-fulldeps/target-cpu-native/Makefile b/src/test/run-make-fulldeps/target-cpu-native/Makefile new file mode 100644 index 00000000000..0c9d93ecb2a --- /dev/null +++ b/src/test/run-make-fulldeps/target-cpu-native/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs -C target-cpu=native + $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/target-cpu-native/foo.rs b/src/test/run-make-fulldeps/target-cpu-native/foo.rs new file mode 100644 index 00000000000..f7a9f969060 --- /dev/null +++ b/src/test/run-make-fulldeps/target-cpu-native/foo.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { +} diff --git a/src/test/run-make-fulldeps/target-specs/Makefile b/src/test/run-make-fulldeps/target-specs/Makefile new file mode 100644 index 00000000000..aff15ce38b4 --- /dev/null +++ b/src/test/run-make-fulldeps/target-specs/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk +all: + $(RUSTC) foo.rs --target=my-awesome-platform.json --crate-type=lib --emit=asm + $(CGREP) -v morestack < $(TMPDIR)/foo.s + $(RUSTC) foo.rs --target=my-invalid-platform.json 2>&1 | $(CGREP) "Error loading target specification" + $(RUSTC) foo.rs --target=my-incomplete-platform.json 2>&1 | $(CGREP) 'Field llvm-target' + RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-awesome-platform --crate-type=lib --emit=asm + RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-x86_64-unknown-linux-gnu-platform --crate-type=lib --emit=asm + $(RUSTC) -Z unstable-options --target=my-awesome-platform.json --print target-spec-json > $(TMPDIR)/test-platform.json && $(RUSTC) -Z unstable-options --target=$(TMPDIR)/test-platform.json --print target-spec-json | diff -q $(TMPDIR)/test-platform.json - diff --git a/src/test/run-make-fulldeps/target-specs/foo.rs b/src/test/run-make-fulldeps/target-specs/foo.rs new file mode 100644 index 00000000000..bbd1c5d900f --- /dev/null +++ b/src/test/run-make-fulldeps/target-specs/foo.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(lang_items, no_core, optin_builtin_traits)] +#![no_core] + +#[lang="copy"] +trait Copy { } + +#[lang="sized"] +trait Sized { } + +#[lang = "freeze"] +auto trait Freeze {} + +#[lang="start"] +fn start(_main: *const u8, _argc: isize, _argv: *const *const u8) -> isize { 0 } + +extern { + fn _foo() -> [u8; 16]; +} + +fn _main() { + let _a = unsafe { _foo() }; +} diff --git a/src/test/run-make-fulldeps/target-specs/my-awesome-platform.json b/src/test/run-make-fulldeps/target-specs/my-awesome-platform.json new file mode 100644 index 00000000000..8d028280a8d --- /dev/null +++ b/src/test/run-make-fulldeps/target-specs/my-awesome-platform.json @@ -0,0 +1,11 @@ +{ + "data-layout": "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128", + "linker-flavor": "gcc", + "llvm-target": "i686-unknown-linux-gnu", + "target-endian": "little", + "target-pointer-width": "32", + "target-c-int-width": "32", + "arch": "x86", + "os": "linux", + "morestack": false +} diff --git a/src/test/run-make-fulldeps/target-specs/my-incomplete-platform.json b/src/test/run-make-fulldeps/target-specs/my-incomplete-platform.json new file mode 100644 index 00000000000..ceaa25cdf2f --- /dev/null +++ b/src/test/run-make-fulldeps/target-specs/my-incomplete-platform.json @@ -0,0 +1,10 @@ +{ + "data-layout": "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32", + "linker-flavor": "gcc", + "target-endian": "little", + "target-pointer-width": "32", + "target-c-int-width": "32", + "arch": "x86", + "os": "foo", + "morestack": false +} diff --git a/src/test/run-make-fulldeps/target-specs/my-invalid-platform.json b/src/test/run-make-fulldeps/target-specs/my-invalid-platform.json new file mode 100644 index 00000000000..3feac45b7d6 --- /dev/null +++ b/src/test/run-make-fulldeps/target-specs/my-invalid-platform.json @@ -0,0 +1 @@ +wow this json is really broke! diff --git a/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json b/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json new file mode 100644 index 00000000000..3ae01d72fcc --- /dev/null +++ b/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json @@ -0,0 +1,12 @@ +{ + "pre-link-args": ["-m64"], + "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", + "linker-flavor": "gcc", + "llvm-target": "x86_64-unknown-linux-gnu", + "target-endian": "little", + "target-pointer-width": "64", + "target-c-int-width": "32", + "arch": "x86_64", + "os": "linux", + "morestack": false +} diff --git a/src/test/run-make-fulldeps/target-without-atomics/Makefile b/src/test/run-make-fulldeps/target-without-atomics/Makefile new file mode 100644 index 00000000000..c5f575ddf84 --- /dev/null +++ b/src/test/run-make-fulldeps/target-without-atomics/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +# The target used below doesn't support atomic operations. Verify that's the case +all: + $(RUSTC) --print cfg --target thumbv6m-none-eabi | $(CGREP) -v target_has_atomic diff --git a/src/test/run-make-fulldeps/test-harness/Makefile b/src/test/run-make-fulldeps/test-harness/Makefile new file mode 100644 index 00000000000..39477c07ced --- /dev/null +++ b/src/test/run-make-fulldeps/test-harness/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: + # check that #[cfg_attr(..., ignore)] does the right thing. + $(RUSTC) --test test-ignore-cfg.rs --cfg ignorecfg + $(call RUN,test-ignore-cfg) | $(CGREP) 'shouldnotignore ... ok' 'shouldignore ... ignored' + $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -e "^i\.$$" + $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -v 'should' diff --git a/src/test/run-make-fulldeps/test-harness/test-ignore-cfg.rs b/src/test/run-make-fulldeps/test-harness/test-ignore-cfg.rs new file mode 100644 index 00000000000..990d3d10485 --- /dev/null +++ b/src/test/run-make-fulldeps/test-harness/test-ignore-cfg.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[test] +#[cfg_attr(ignorecfg, ignore)] +fn shouldignore() { +} + +#[test] +#[cfg_attr(noignorecfg, ignore)] +fn shouldnotignore() { +} diff --git a/src/test/run-make-fulldeps/tools.mk b/src/test/run-make-fulldeps/tools.mk new file mode 100644 index 00000000000..af1707de6c0 --- /dev/null +++ b/src/test/run-make-fulldeps/tools.mk @@ -0,0 +1,134 @@ +# These deliberately use `=` and not `:=` so that client makefiles can +# augment HOST_RPATH_DIR / TARGET_RPATH_DIR. +HOST_RPATH_ENV = \ + $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(HOST_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))" +TARGET_RPATH_ENV = \ + $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(TARGET_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))" + +RUSTC_ORIGINAL := $(RUSTC) +BARE_RUSTC := $(HOST_RPATH_ENV) '$(RUSTC)' +BARE_RUSTDOC := $(HOST_RPATH_ENV) '$(RUSTDOC)' +RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR) $(RUSTFLAGS) +RUSTDOC := $(BARE_RUSTDOC) -L $(TARGET_RPATH_DIR) +ifdef RUSTC_LINKER +RUSTC := $(RUSTC) -Clinker=$(RUSTC_LINKER) +RUSTDOC := $(RUSTDOC) --linker $(RUSTC_LINKER) -Z unstable-options +endif +#CC := $(CC) -L $(TMPDIR) +HTMLDOCCK := $(PYTHON) $(S)/src/etc/htmldocck.py +CGREP := "$(S)/src/etc/cat-and-grep.sh" + +# This is the name of the binary we will generate and run; use this +# e.g. for `$(CC) -o $(RUN_BINFILE)`. +RUN_BINFILE = $(TMPDIR)/$(1) + +# RUN and FAIL are basic way we will invoke the generated binary. On +# non-windows platforms, they set the LD_LIBRARY_PATH environment +# variable before running the binary. + +RLIB_GLOB = lib$(1)*.rlib +BIN = $(1) + +UNAME = $(shell uname) + +ifeq ($(UNAME),Darwin) +RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE) +FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0 +DYLIB_GLOB = lib$(1)*.dylib +DYLIB = $(TMPDIR)/lib$(1).dylib +STATICLIB = $(TMPDIR)/lib$(1).a +STATICLIB_GLOB = lib$(1)*.a +else +ifdef IS_WINDOWS +RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) +FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) && exit 1 || exit 0 +DYLIB_GLOB = $(1)*.dll +DYLIB = $(TMPDIR)/$(1).dll +STATICLIB = $(TMPDIR)/$(1).lib +STATICLIB_GLOB = $(1)*.lib +BIN = $(1).exe +else +RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE) +FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0 +DYLIB_GLOB = lib$(1)*.so +DYLIB = $(TMPDIR)/lib$(1).so +STATICLIB = $(TMPDIR)/lib$(1).a +STATICLIB_GLOB = lib$(1)*.a +endif +endif + +ifdef IS_MSVC +COMPILE_OBJ = $(CC) -c -Fo:`cygpath -w $(1)` $(2) +NATIVE_STATICLIB_FILE = $(1).lib +NATIVE_STATICLIB = $(TMPDIR)/$(call NATIVE_STATICLIB_FILE,$(1)) +OUT_EXE=-Fe:`cygpath -w $(TMPDIR)/$(call BIN,$(1))` \ + -Fo:`cygpath -w $(TMPDIR)/$(1).obj` +else +COMPILE_OBJ = $(CC) -c -o $(1) $(2) +NATIVE_STATICLIB_FILE = lib$(1).a +NATIVE_STATICLIB = $(call STATICLIB,$(1)) +OUT_EXE=-o $(TMPDIR)/$(1) +endif + + +# Extra flags needed to compile a working executable with the standard library +ifdef IS_WINDOWS +ifdef IS_MSVC + EXTRACFLAGS := ws2_32.lib userenv.lib shell32.lib advapi32.lib +else + EXTRACFLAGS := -lws2_32 -luserenv +endif +else +ifeq ($(UNAME),Darwin) + EXTRACFLAGS := -lresolv +else +ifeq ($(UNAME),FreeBSD) + EXTRACFLAGS := -lm -lpthread -lgcc_s +else +ifeq ($(UNAME),Bitrig) + EXTRACFLAGS := -lm -lpthread + EXTRACXXFLAGS := -lc++ -lc++abi +else +ifeq ($(UNAME),SunOS) + EXTRACFLAGS := -lm -lpthread -lposix4 -lsocket -lresolv +else +ifeq ($(UNAME),OpenBSD) + EXTRACFLAGS := -lm -lpthread -lc++abi + RUSTC := $(RUSTC) -C linker="$(word 1,$(CC:ccache=))" +else + EXTRACFLAGS := -lm -lrt -ldl -lpthread + EXTRACXXFLAGS := -lstdc++ +endif +endif +endif +endif +endif +endif + +REMOVE_DYLIBS = rm $(TMPDIR)/$(call DYLIB_GLOB,$(1)) +REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1)) + +%.a: %.o + $(AR) crus $@ $< +ifdef IS_MSVC +%.lib: lib%.o + $(MSVC_LIB) -out:`cygpath -w $@` $< +else +%.lib: lib%.o + $(AR) crus $@ $< +endif +%.dylib: %.o + $(CC) -dynamiclib -Wl,-dylib -o $@ $< +%.so: %.o + $(CC) -o $@ $< -shared + +ifdef IS_MSVC +%.dll: lib%.o + $(CC) $< -link -dll -out:`cygpath -w $@` +else +%.dll: lib%.o + $(CC) -o $@ $< -shared +endif + +$(TMPDIR)/lib%.o: %.c + $(call COMPILE_OBJ,$@,$<) diff --git a/src/test/run-make-fulldeps/treat-err-as-bug/Makefile b/src/test/run-make-fulldeps/treat-err-as-bug/Makefile new file mode 100644 index 00000000000..f99e4611174 --- /dev/null +++ b/src/test/run-make-fulldeps/treat-err-as-bug/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) err.rs -Z treat-err-as-bug 2>&1 \ + | $(CGREP) "panicked at 'encountered error with \`-Z treat_err_as_bug'" diff --git a/src/test/run-make-fulldeps/treat-err-as-bug/err.rs b/src/test/run-make-fulldeps/treat-err-as-bug/err.rs new file mode 100644 index 00000000000..078495663ac --- /dev/null +++ b/src/test/run-make-fulldeps/treat-err-as-bug/err.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="rlib"] + +pub static C: u32 = 0-1; diff --git a/src/test/run-make-fulldeps/type-mismatch-same-crate-name/Makefile b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/Makefile new file mode 100644 index 00000000000..9fd1377322b --- /dev/null +++ b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/Makefile @@ -0,0 +1,19 @@ +-include ../tools.mk + +all: + # compile two different versions of crateA + $(RUSTC) --crate-type=rlib crateA.rs -C metadata=-1 -C extra-filename=-1 + $(RUSTC) --crate-type=rlib crateA.rs -C metadata=-2 -C extra-filename=-2 + # make crateB depend on version 1 of crateA + $(RUSTC) --crate-type=rlib crateB.rs --extern crateA=$(TMPDIR)/libcrateA-1.rlib + # make crateC depend on version 2 of crateA + $(RUSTC) crateC.rs --extern crateA=$(TMPDIR)/libcrateA-2.rlib 2>&1 | \ + tr -d '\r\n' | $(CGREP) -e \ + "mismatched types.*\ + crateB::try_foo\(foo2\);.*\ + expected struct \`crateA::foo::Foo\`, found struct \`crateA::Foo\`.*\ + different versions of crate \`crateA\`.*\ + mismatched types.*\ + crateB::try_bar\(bar2\);.*\ + expected trait \`crateA::bar::Bar\`, found trait \`crateA::Bar\`.*\ + different versions of crate \`crateA\`" diff --git a/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateA.rs b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateA.rs new file mode 100644 index 00000000000..e40266bb4cd --- /dev/null +++ b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateA.rs @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { + pub struct Foo; +} + +mod bar { + pub trait Bar{} + + pub fn bar() -> Box { + unimplemented!() + } +} + +// This makes the publicly accessible path +// differ from the internal one. +pub use foo::Foo; +pub use bar::{Bar, bar}; diff --git a/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateB.rs b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateB.rs new file mode 100644 index 00000000000..da4ea1c9387 --- /dev/null +++ b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateB.rs @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate crateA; + +pub fn try_foo(x: crateA::Foo){} +pub fn try_bar(x: Box){} diff --git a/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs new file mode 100644 index 00000000000..210bc4c8320 --- /dev/null +++ b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs @@ -0,0 +1,35 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This tests the extra note reported when a type error deals with +// seemingly identical types. +// The main use case of this error is when there are two crates +// (generally different versions of the same crate) with the same name +// causing a type mismatch. + +// The test is nearly the same as the one in +// compile-fail/type-mismatch-same-crate-name.rs +// but deals with the case where one of the crates +// is only introduced as an indirect dependency. +// and the type is accessed via a re-export. +// This is similar to how the error can be introduced +// when using cargo's automatic dependency resolution. + +extern crate crateA; + +fn main() { + let foo2 = crateA::Foo; + let bar2 = crateA::bar(); + { + extern crate crateB; + crateB::try_foo(foo2); + crateB::try_bar(bar2); + } +} diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile new file mode 100644 index 00000000000..cc7bc176f49 --- /dev/null +++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile @@ -0,0 +1,21 @@ +-include ../tools.mk + +SKIP_OS := 'FreeBSD OpenBSD Bitrig SunOS' + +ifneq ($(UNAME),$(findstring $(UNAME),$(SKIP_OS))) + +HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //') +ifeq ($(findstring i686,$(HOST)),i686) +TARGET := $(subst i686,x86_64,$(HOST)) +else +TARGET := $(subst x86_64,i686,$(HOST)) +endif + +all: + $(RUSTC) foo.rs -C extra-filename=-host + $(RUSTC) bar.rs -C extra-filename=-targ --target $(TARGET) + $(RUSTC) baz.rs --extern a=$(TMPDIR)/liba-targ.rlib --target $(TARGET) +else +# FreeBSD, OpenBSD, and Bitrig support only x86_64 architecture for now +all: +endif diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/bar.rs b/src/test/run-make-fulldeps/use-extern-for-plugins/bar.rs new file mode 100644 index 00000000000..3e99ed60c62 --- /dev/null +++ b/src/test/run-make-fulldeps/use-extern-for-plugins/bar.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(no_core)] +#![no_core] +#![crate_type = "lib"] +#![crate_name = "a"] + +#[macro_export] +macro_rules! bar { + () => () +} diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/baz.rs b/src/test/run-make-fulldeps/use-extern-for-plugins/baz.rs new file mode 100644 index 00000000000..3f15d0e6e05 --- /dev/null +++ b/src/test/run-make-fulldeps/use-extern-for-plugins/baz.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(no_core)] +#![no_core] +#![crate_type = "lib"] + +#[macro_use] +extern crate a; + +bar!(); diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/foo.rs b/src/test/run-make-fulldeps/use-extern-for-plugins/foo.rs new file mode 100644 index 00000000000..0afd3be466d --- /dev/null +++ b/src/test/run-make-fulldeps/use-extern-for-plugins/foo.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![no_std] +#![crate_type = "lib"] +#![crate_name = "a"] + +#[macro_export] +macro_rules! foo { + () => () +} diff --git a/src/test/run-make-fulldeps/used/Makefile b/src/test/run-make-fulldeps/used/Makefile new file mode 100644 index 00000000000..47edcbb5d0a --- /dev/null +++ b/src/test/run-make-fulldeps/used/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +ifdef IS_WINDOWS +# Do nothing on MSVC. +all: + exit 0 +else +all: + $(RUSTC) -C opt-level=3 --emit=obj used.rs + nm $(TMPDIR)/used.o | $(CGREP) FOO +endif diff --git a/src/test/run-make-fulldeps/used/used.rs b/src/test/run-make-fulldeps/used/used.rs new file mode 100644 index 00000000000..186cd0fdf5e --- /dev/null +++ b/src/test/run-make-fulldeps/used/used.rs @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#![feature(used)] + +#[used] +static FOO: u32 = 0; + +static BAR: u32 = 0; diff --git a/src/test/run-make-fulldeps/version/Makefile b/src/test/run-make-fulldeps/version/Makefile new file mode 100644 index 00000000000..23e14a9cb93 --- /dev/null +++ b/src/test/run-make-fulldeps/version/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) -V + $(RUSTC) -vV + $(RUSTC) --version --verbose diff --git a/src/test/run-make-fulldeps/volatile-intrinsics/Makefile b/src/test/run-make-fulldeps/volatile-intrinsics/Makefile new file mode 100644 index 00000000000..acbadbef9fb --- /dev/null +++ b/src/test/run-make-fulldeps/volatile-intrinsics/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +all: + # The tests must pass... + $(RUSTC) main.rs + $(call RUN,main) + # ... and the loads/stores must not be optimized out. + $(RUSTC) main.rs --emit=llvm-ir + $(CGREP) "load volatile" "store volatile" < $(TMPDIR)/main.ll diff --git a/src/test/run-make-fulldeps/volatile-intrinsics/main.rs b/src/test/run-make-fulldeps/volatile-intrinsics/main.rs new file mode 100644 index 00000000000..4d0d7672101 --- /dev/null +++ b/src/test/run-make-fulldeps/volatile-intrinsics/main.rs @@ -0,0 +1,27 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(core_intrinsics, volatile)] + +use std::intrinsics::{volatile_load, volatile_store}; +use std::ptr::{read_volatile, write_volatile}; + +pub fn main() { + unsafe { + let mut i : isize = 1; + volatile_store(&mut i, 2); + assert_eq!(volatile_load(&i), 2); + } + unsafe { + let mut i : isize = 1; + write_volatile(&mut i, 2); + assert_eq!(read_volatile(&i), 2); + } +} diff --git a/src/test/run-make-fulldeps/weird-output-filenames/Makefile b/src/test/run-make-fulldeps/weird-output-filenames/Makefile new file mode 100644 index 00000000000..f161fe9f8e8 --- /dev/null +++ b/src/test/run-make-fulldeps/weird-output-filenames/Makefile @@ -0,0 +1,15 @@ +-include ../tools.mk + +all: + cp foo.rs $(TMPDIR)/.foo.rs + $(RUSTC) $(TMPDIR)/.foo.rs 2>&1 \ + | $(CGREP) -e "invalid character.*in crate name:" + cp foo.rs $(TMPDIR)/.foo.bar + $(RUSTC) $(TMPDIR)/.foo.bar 2>&1 \ + | $(CGREP) -e "invalid character.*in crate name:" + cp foo.rs $(TMPDIR)/+foo+bar.rs + $(RUSTC) $(TMPDIR)/+foo+bar.rs 2>&1 \ + | $(CGREP) -e "invalid character.*in crate name:" + cp foo.rs $(TMPDIR)/-foo.rs + $(RUSTC) $(TMPDIR)/-foo.rs 2>&1 \ + | $(CGREP) 'crate names cannot start with a `-`' diff --git a/src/test/run-make-fulldeps/weird-output-filenames/foo.rs b/src/test/run-make-fulldeps/weird-output-filenames/foo.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/weird-output-filenames/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/windows-spawn/Makefile b/src/test/run-make-fulldeps/windows-spawn/Makefile new file mode 100644 index 00000000000..f0d4242260f --- /dev/null +++ b/src/test/run-make-fulldeps/windows-spawn/Makefile @@ -0,0 +1,14 @@ +-include ../tools.mk + +ifdef IS_WINDOWS + +all: + $(RUSTC) -o "$(TMPDIR)/hopefullydoesntexist bar.exe" hello.rs + $(RUSTC) spawn.rs + $(TMPDIR)/spawn.exe + +else + +all: + +endif diff --git a/src/test/run-make-fulldeps/windows-spawn/hello.rs b/src/test/run-make-fulldeps/windows-spawn/hello.rs new file mode 100644 index 00000000000..b177f41941d --- /dev/null +++ b/src/test/run-make-fulldeps/windows-spawn/hello.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("Hello World!"); +} diff --git a/src/test/run-make-fulldeps/windows-spawn/spawn.rs b/src/test/run-make-fulldeps/windows-spawn/spawn.rs new file mode 100644 index 00000000000..2913cbe2260 --- /dev/null +++ b/src/test/run-make-fulldeps/windows-spawn/spawn.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::io::ErrorKind; +use std::process::Command; + +fn main() { + // Make sure it doesn't try to run "hopefullydoesntexist bar.exe". + assert_eq!(Command::new("hopefullydoesntexist") + .arg("bar") + .spawn() + .unwrap_err() + .kind(), + ErrorKind::NotFound); +} diff --git a/src/test/run-make-fulldeps/windows-subsystem/Makefile b/src/test/run-make-fulldeps/windows-subsystem/Makefile new file mode 100644 index 00000000000..34fb5db32f9 --- /dev/null +++ b/src/test/run-make-fulldeps/windows-subsystem/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) windows.rs + $(RUSTC) console.rs diff --git a/src/test/run-make-fulldeps/windows-subsystem/console.rs b/src/test/run-make-fulldeps/windows-subsystem/console.rs new file mode 100644 index 00000000000..ffad1e35ee6 --- /dev/null +++ b/src/test/run-make-fulldeps/windows-subsystem/console.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![windows_subsystem = "console"] + +fn main() {} + diff --git a/src/test/run-make-fulldeps/windows-subsystem/windows.rs b/src/test/run-make-fulldeps/windows-subsystem/windows.rs new file mode 100644 index 00000000000..33cbe320591 --- /dev/null +++ b/src/test/run-make-fulldeps/windows-subsystem/windows.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![windows_subsystem = "windows"] + +fn main() {} diff --git a/src/test/run-make/a-b-a-linker-guard/Makefile b/src/test/run-make/a-b-a-linker-guard/Makefile deleted file mode 100644 index 0962ebfbff5..00000000000 --- a/src/test/run-make/a-b-a-linker-guard/Makefile +++ /dev/null @@ -1,12 +0,0 @@ --include ../tools.mk - -# Test that if we build `b` against a version of `a` that has one set -# of types, it will not run with a dylib that has a different set of -# types. - -all: - $(RUSTC) a.rs --cfg x -C prefer-dynamic - $(RUSTC) b.rs -C prefer-dynamic - $(call RUN,b) - $(RUSTC) a.rs --cfg y -C prefer-dynamic - $(call FAIL,b) diff --git a/src/test/run-make/a-b-a-linker-guard/a.rs b/src/test/run-make/a-b-a-linker-guard/a.rs deleted file mode 100644 index c6680a78819..00000000000 --- a/src/test/run-make/a-b-a-linker-guard/a.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "a"] -#![crate_type = "dylib"] - -#[cfg(x)] -pub fn foo(x: u32) { } - -#[cfg(y)] -pub fn foo(x: i32) { } diff --git a/src/test/run-make/a-b-a-linker-guard/b.rs b/src/test/run-make/a-b-a-linker-guard/b.rs deleted file mode 100644 index 89fd48de5bb..00000000000 --- a/src/test/run-make/a-b-a-linker-guard/b.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "b"] - -extern crate a; - -fn main() { - a::foo(22_u32); -} diff --git a/src/test/run-make/alloc-extern-crates/Makefile b/src/test/run-make/alloc-extern-crates/Makefile deleted file mode 100644 index 7197f4e17e3..00000000000 --- a/src/test/run-make/alloc-extern-crates/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) fakealloc.rs - $(RUSTC) --crate-type=rlib ../../../liballoc/lib.rs --cfg feature=\"external_crate\" --extern external=$(TMPDIR)/$(shell $(RUSTC) --print file-names fakealloc.rs) diff --git a/src/test/run-make/alloc-extern-crates/fakealloc.rs b/src/test/run-make/alloc-extern-crates/fakealloc.rs deleted file mode 100644 index 43f97489314..00000000000 --- a/src/test/run-make/alloc-extern-crates/fakealloc.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![no_std] - -#[inline] -pub unsafe fn allocate(_size: usize, _align: usize) -> *mut u8 { 0 as *mut u8 } - -#[inline] -pub unsafe fn deallocate(_ptr: *mut u8, _old_size: usize, _align: usize) { } - -#[inline] -pub unsafe fn reallocate(_ptr: *mut u8, _old_size: usize, _size: usize, _align: usize) -> *mut u8 { - 0 as *mut u8 -} - -#[inline] -pub unsafe fn reallocate_inplace(_ptr: *mut u8, old_size: usize, _size: usize, - _align: usize) -> usize { old_size } - -#[inline] -pub fn usable_size(size: usize, _align: usize) -> usize { size } - -#[inline] -pub fn stats_print() { } diff --git a/src/test/run-make/allow-non-lint-warnings-cmdline/Makefile b/src/test/run-make/allow-non-lint-warnings-cmdline/Makefile deleted file mode 100644 index c14006cc2e0..00000000000 --- a/src/test/run-make/allow-non-lint-warnings-cmdline/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -# Test that -A warnings makes the 'empty trait list for derive' warning go away -OUT=$(shell $(RUSTC) foo.rs -A warnings 2>&1 | grep "warning" ) - -all: foo - test -z '$(OUT)' - -# This is just to make sure the above command actually succeeds -foo: - $(RUSTC) foo.rs -A warnings diff --git a/src/test/run-make/allow-non-lint-warnings-cmdline/foo.rs b/src/test/run-make/allow-non-lint-warnings-cmdline/foo.rs deleted file mode 100644 index a9e18f5a8f1..00000000000 --- a/src/test/run-make/allow-non-lint-warnings-cmdline/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive()] -#[derive(Copy, Clone)] -pub struct Foo; - -pub fn main() { } diff --git a/src/test/run-make/allow-warnings-cmdline-stability/Makefile b/src/test/run-make/allow-warnings-cmdline-stability/Makefile deleted file mode 100644 index 3eecaf93142..00000000000 --- a/src/test/run-make/allow-warnings-cmdline-stability/Makefile +++ /dev/null @@ -1,15 +0,0 @@ --include ../tools.mk - -# Test that -A warnings makes the 'empty trait list for derive' warning go away -DEP=$(shell $(RUSTC) bar.rs) -OUT=$(shell $(RUSTC) foo.rs -A warnings 2>&1 | grep "warning" ) - -all: foo bar - test -z '$(OUT)' - -# These are just to ensure that the above commands actually work -bar: - $(RUSTC) bar.rs - -foo: bar - $(RUSTC) foo.rs -A warnings diff --git a/src/test/run-make/allow-warnings-cmdline-stability/bar.rs b/src/test/run-make/allow-warnings-cmdline-stability/bar.rs deleted file mode 100644 index fed1405b7f4..00000000000 --- a/src/test/run-make/allow-warnings-cmdline-stability/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -#![feature(staged_api)] -#![unstable(feature = "test_feature", issue = "0")] - -pub fn baz() { } diff --git a/src/test/run-make/allow-warnings-cmdline-stability/foo.rs b/src/test/run-make/allow-warnings-cmdline-stability/foo.rs deleted file mode 100644 index a36cc474c2b..00000000000 --- a/src/test/run-make/allow-warnings-cmdline-stability/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(test_feature)] - -extern crate bar; - -pub fn main() { bar::baz() } diff --git a/src/test/run-make/archive-duplicate-names/Makefile b/src/test/run-make/archive-duplicate-names/Makefile deleted file mode 100644 index 93711c41d79..00000000000 --- a/src/test/run-make/archive-duplicate-names/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -all: - mkdir $(TMPDIR)/a - mkdir $(TMPDIR)/b - $(call COMPILE_OBJ,$(TMPDIR)/a/foo.o,foo.c) - $(call COMPILE_OBJ,$(TMPDIR)/b/foo.o,bar.c) - $(AR) crus $(TMPDIR)/libfoo.a $(TMPDIR)/a/foo.o $(TMPDIR)/b/foo.o - $(RUSTC) foo.rs - $(RUSTC) bar.rs - $(call RUN,bar) diff --git a/src/test/run-make/archive-duplicate-names/bar.c b/src/test/run-make/archive-duplicate-names/bar.c deleted file mode 100644 index a25fa10f4d3..00000000000 --- a/src/test/run-make/archive-duplicate-names/bar.c +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -void bar() {} diff --git a/src/test/run-make/archive-duplicate-names/bar.rs b/src/test/run-make/archive-duplicate-names/bar.rs deleted file mode 100644 index 1200a6de8e2..00000000000 --- a/src/test/run-make/archive-duplicate-names/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::baz(); -} diff --git a/src/test/run-make/archive-duplicate-names/foo.c b/src/test/run-make/archive-duplicate-names/foo.c deleted file mode 100644 index 61d5d154078..00000000000 --- a/src/test/run-make/archive-duplicate-names/foo.c +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -void foo() {} diff --git a/src/test/run-make/archive-duplicate-names/foo.rs b/src/test/run-make/archive-duplicate-names/foo.rs deleted file mode 100644 index 24b4734f2cd..00000000000 --- a/src/test/run-make/archive-duplicate-names/foo.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[link(name = "foo", kind = "static")] -extern { - fn foo(); - fn bar(); -} - -pub fn baz() { - unsafe { - foo(); - bar(); - } -} diff --git a/src/test/run-make/atomic-lock-free/Makefile b/src/test/run-make/atomic-lock-free/Makefile deleted file mode 100644 index a7df821f92d..00000000000 --- a/src/test/run-make/atomic-lock-free/Makefile +++ /dev/null @@ -1,46 +0,0 @@ --include ../tools.mk - -# This tests ensure that atomic types are never lowered into runtime library calls that are not -# guaranteed to be lock-free. - -all: -ifeq ($(UNAME),Linux) -ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86) - $(RUSTC) --target=i686-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=x86_64-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm) - $(RUSTC) --target=arm-unknown-linux-gnueabi atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=arm-unknown-linux-gnueabihf atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=armv7-unknown-linux-gnueabihf atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -ifeq ($(filter aarch64,$(LLVM_COMPONENTS)),aarch64) - $(RUSTC) --target=aarch64-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips) - $(RUSTC) --target=mips-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=mipsel-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -ifeq ($(filter powerpc,$(LLVM_COMPONENTS)),powerpc) - $(RUSTC) --target=powerpc-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=powerpc-unknown-linux-gnuspe atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=powerpc64-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=powerpc64le-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -ifeq ($(filter systemz,$(LLVM_COMPONENTS)),systemz) - $(RUSTC) --target=s390x-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -endif diff --git a/src/test/run-make/atomic-lock-free/atomic_lock_free.rs b/src/test/run-make/atomic-lock-free/atomic_lock_free.rs deleted file mode 100644 index b41e8e9226b..00000000000 --- a/src/test/run-make/atomic-lock-free/atomic_lock_free.rs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(cfg_target_has_atomic, no_core, intrinsics, lang_items)] -#![crate_type="rlib"] -#![no_core] - -extern "rust-intrinsic" { - fn atomic_xadd(dst: *mut T, src: T) -> T; -} - -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} -#[lang = "freeze"] -trait Freeze {} - -#[cfg(target_has_atomic = "8")] -pub unsafe fn atomic_u8(x: *mut u8) { - atomic_xadd(x, 1); - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "8")] -pub unsafe fn atomic_i8(x: *mut i8) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "16")] -pub unsafe fn atomic_u16(x: *mut u16) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "16")] -pub unsafe fn atomic_i16(x: *mut i16) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "32")] -pub unsafe fn atomic_u32(x: *mut u32) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "32")] -pub unsafe fn atomic_i32(x: *mut i32) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "64")] -pub unsafe fn atomic_u64(x: *mut u64) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "64")] -pub unsafe fn atomic_i64(x: *mut i64) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "ptr")] -pub unsafe fn atomic_usize(x: *mut usize) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "ptr")] -pub unsafe fn atomic_isize(x: *mut isize) { - atomic_xadd(x, 1); -} diff --git a/src/test/run-make/bare-outfile/Makefile b/src/test/run-make/bare-outfile/Makefile deleted file mode 100644 index baa4c1c0237..00000000000 --- a/src/test/run-make/bare-outfile/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - cp foo.rs $(TMPDIR) - cd $(TMPDIR) && $(RUSTC) -o foo foo.rs - $(call RUN,foo) diff --git a/src/test/run-make/bare-outfile/foo.rs b/src/test/run-make/bare-outfile/foo.rs deleted file mode 100644 index 63e747901ae..00000000000 --- a/src/test/run-make/bare-outfile/foo.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { -} diff --git a/src/test/run-make/c-dynamic-dylib/Makefile b/src/test/run-make/c-dynamic-dylib/Makefile deleted file mode 100644 index 83bddd4c73c..00000000000 --- a/src/test/run-make/c-dynamic-dylib/Makefile +++ /dev/null @@ -1,14 +0,0 @@ --include ../tools.mk - -# This hits an assertion in the linker on older versions of osx apparently -ifeq ($(shell uname),Darwin) -all: - echo ignored -else -all: $(call DYLIB,cfoo) - $(RUSTC) foo.rs -C prefer-dynamic - $(RUSTC) bar.rs - $(call RUN,bar) - $(call REMOVE_DYLIBS,cfoo) - $(call FAIL,bar) -endif diff --git a/src/test/run-make/c-dynamic-dylib/bar.rs b/src/test/run-make/c-dynamic-dylib/bar.rs deleted file mode 100644 index 37b120decd1..00000000000 --- a/src/test/run-make/c-dynamic-dylib/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::rsfoo(); -} diff --git a/src/test/run-make/c-dynamic-dylib/cfoo.c b/src/test/run-make/c-dynamic-dylib/cfoo.c deleted file mode 100644 index a9755493541..00000000000 --- a/src/test/run-make/c-dynamic-dylib/cfoo.c +++ /dev/null @@ -1,5 +0,0 @@ -// ignore-license -#ifdef _WIN32 -__declspec(dllexport) -#endif -int foo() { return 0; } diff --git a/src/test/run-make/c-dynamic-dylib/foo.rs b/src/test/run-make/c-dynamic-dylib/foo.rs deleted file mode 100644 index 04253be71d4..00000000000 --- a/src/test/run-make/c-dynamic-dylib/foo.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -#[link(name = "cfoo")] -extern { - fn foo(); -} - -pub fn rsfoo() { - unsafe { foo() } -} diff --git a/src/test/run-make/c-dynamic-rlib/Makefile b/src/test/run-make/c-dynamic-rlib/Makefile deleted file mode 100644 index e15cfd34d6c..00000000000 --- a/src/test/run-make/c-dynamic-rlib/Makefile +++ /dev/null @@ -1,17 +0,0 @@ --include ../tools.mk - -# This overrides the LD_LIBRARY_PATH for RUN -TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR) - -# This hits an assertion in the linker on older versions of osx apparently -ifeq ($(shell uname),Darwin) -all: - echo ignored -else -all: $(call DYLIB,cfoo) - $(RUSTC) foo.rs - $(RUSTC) bar.rs - $(call RUN,bar) - $(call REMOVE_DYLIBS,cfoo) - $(call FAIL,bar) -endif diff --git a/src/test/run-make/c-dynamic-rlib/bar.rs b/src/test/run-make/c-dynamic-rlib/bar.rs deleted file mode 100644 index 37b120decd1..00000000000 --- a/src/test/run-make/c-dynamic-rlib/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::rsfoo(); -} diff --git a/src/test/run-make/c-dynamic-rlib/cfoo.c b/src/test/run-make/c-dynamic-rlib/cfoo.c deleted file mode 100644 index b2849326a75..00000000000 --- a/src/test/run-make/c-dynamic-rlib/cfoo.c +++ /dev/null @@ -1,6 +0,0 @@ -// ignore-license - -#ifdef _WIN32 -__declspec(dllexport) -#endif -int foo() { return 0; } diff --git a/src/test/run-make/c-dynamic-rlib/foo.rs b/src/test/run-make/c-dynamic-rlib/foo.rs deleted file mode 100644 index a1f01bd2b62..00000000000 --- a/src/test/run-make/c-dynamic-rlib/foo.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[link(name = "cfoo")] -extern { - fn foo(); -} - -pub fn rsfoo() { - unsafe { foo() } -} diff --git a/src/test/run-make/c-link-to-rust-dylib/Makefile b/src/test/run-make/c-link-to-rust-dylib/Makefile deleted file mode 100644 index 98e112a3744..00000000000 --- a/src/test/run-make/c-link-to-rust-dylib/Makefile +++ /dev/null @@ -1,17 +0,0 @@ --include ../tools.mk - -all: $(TMPDIR)/$(call BIN,bar) - $(call RUN,bar) - $(call REMOVE_DYLIBS,foo) - $(call FAIL,bar) - -ifdef IS_MSVC -$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo) - $(CC) bar.c $(TMPDIR)/foo.dll.lib $(call OUT_EXE,bar) -else -$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo) - $(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) -L $(TMPDIR) -endif - -$(call DYLIB,foo): foo.rs - $(RUSTC) foo.rs diff --git a/src/test/run-make/c-link-to-rust-dylib/bar.c b/src/test/run-make/c-link-to-rust-dylib/bar.c deleted file mode 100644 index 5729d411c5b..00000000000 --- a/src/test/run-make/c-link-to-rust-dylib/bar.c +++ /dev/null @@ -1,7 +0,0 @@ -// ignore-license -void foo(); - -int main() { - foo(); - return 0; -} diff --git a/src/test/run-make/c-link-to-rust-dylib/foo.rs b/src/test/run-make/c-link-to-rust-dylib/foo.rs deleted file mode 100644 index 32675bcba1e..00000000000 --- a/src/test/run-make/c-link-to-rust-dylib/foo.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -#[no_mangle] -pub extern "C" fn foo() {} diff --git a/src/test/run-make/c-link-to-rust-staticlib/Makefile b/src/test/run-make/c-link-to-rust-staticlib/Makefile deleted file mode 100644 index 47264e82165..00000000000 --- a/src/test/run-make/c-link-to-rust-staticlib/Makefile +++ /dev/null @@ -1,16 +0,0 @@ --include ../tools.mk - -# FIXME: ignore freebsd -ifneq ($(shell uname),FreeBSD) -all: - $(RUSTC) foo.rs - $(CC) bar.c $(call STATICLIB,foo) $(call OUT_EXE,bar) \ - $(EXTRACFLAGS) $(EXTRACXXFLAGS) - $(call RUN,bar) - rm $(call STATICLIB,foo) - $(call RUN,bar) - -else -all: - -endif diff --git a/src/test/run-make/c-link-to-rust-staticlib/bar.c b/src/test/run-make/c-link-to-rust-staticlib/bar.c deleted file mode 100644 index 5729d411c5b..00000000000 --- a/src/test/run-make/c-link-to-rust-staticlib/bar.c +++ /dev/null @@ -1,7 +0,0 @@ -// ignore-license -void foo(); - -int main() { - foo(); - return 0; -} diff --git a/src/test/run-make/c-link-to-rust-staticlib/foo.rs b/src/test/run-make/c-link-to-rust-staticlib/foo.rs deleted file mode 100644 index 1bb19016700..00000000000 --- a/src/test/run-make/c-link-to-rust-staticlib/foo.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "staticlib"] - -#[no_mangle] -pub extern "C" fn foo() {} diff --git a/src/test/run-make/c-static-dylib/Makefile b/src/test/run-make/c-static-dylib/Makefile deleted file mode 100644 index f88786857cc..00000000000 --- a/src/test/run-make/c-static-dylib/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,cfoo) - $(RUSTC) foo.rs -C prefer-dynamic - $(RUSTC) bar.rs - rm $(call NATIVE_STATICLIB,cfoo) - $(call RUN,bar) - $(call REMOVE_DYLIBS,foo) - $(call FAIL,bar) diff --git a/src/test/run-make/c-static-dylib/bar.rs b/src/test/run-make/c-static-dylib/bar.rs deleted file mode 100644 index 37b120decd1..00000000000 --- a/src/test/run-make/c-static-dylib/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::rsfoo(); -} diff --git a/src/test/run-make/c-static-dylib/cfoo.c b/src/test/run-make/c-static-dylib/cfoo.c deleted file mode 100644 index 113717a776a..00000000000 --- a/src/test/run-make/c-static-dylib/cfoo.c +++ /dev/null @@ -1,2 +0,0 @@ -// ignore-license -int foo() { return 0; } diff --git a/src/test/run-make/c-static-dylib/foo.rs b/src/test/run-make/c-static-dylib/foo.rs deleted file mode 100644 index 44be5ac890d..00000000000 --- a/src/test/run-make/c-static-dylib/foo.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -#[link(name = "cfoo", kind = "static")] -extern { - fn foo(); -} - -pub fn rsfoo() { - unsafe { foo() } -} diff --git a/src/test/run-make/c-static-rlib/Makefile b/src/test/run-make/c-static-rlib/Makefile deleted file mode 100644 index be22b2728f0..00000000000 --- a/src/test/run-make/c-static-rlib/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,cfoo) - $(RUSTC) foo.rs - $(RUSTC) bar.rs - $(call REMOVE_RLIBS,foo) - rm $(call NATIVE_STATICLIB,cfoo) - $(call RUN,bar) diff --git a/src/test/run-make/c-static-rlib/bar.rs b/src/test/run-make/c-static-rlib/bar.rs deleted file mode 100644 index 37b120decd1..00000000000 --- a/src/test/run-make/c-static-rlib/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::rsfoo(); -} diff --git a/src/test/run-make/c-static-rlib/cfoo.c b/src/test/run-make/c-static-rlib/cfoo.c deleted file mode 100644 index 113717a776a..00000000000 --- a/src/test/run-make/c-static-rlib/cfoo.c +++ /dev/null @@ -1,2 +0,0 @@ -// ignore-license -int foo() { return 0; } diff --git a/src/test/run-make/c-static-rlib/foo.rs b/src/test/run-make/c-static-rlib/foo.rs deleted file mode 100644 index cbd7b020bd8..00000000000 --- a/src/test/run-make/c-static-rlib/foo.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[link(name = "cfoo", kind = "static")] -extern { - fn foo(); -} - -pub fn rsfoo() { - unsafe { foo() } -} diff --git a/src/test/run-make/cat-and-grep-sanity-check/Makefile b/src/test/run-make/cat-and-grep-sanity-check/Makefile deleted file mode 100644 index fead197ce39..00000000000 --- a/src/test/run-make/cat-and-grep-sanity-check/Makefile +++ /dev/null @@ -1,46 +0,0 @@ --include ../tools.mk - -all: - echo a | $(CGREP) a - ! echo b | $(CGREP) a - echo xyz | $(CGREP) x y z - ! echo abc | $(CGREP) b c d - printf "x\ny\nz" | $(CGREP) x y z - - echo AbCd | $(CGREP) -i a b C D - ! echo AbCd | $(CGREP) a b C D - - true | $(CGREP) -v nothing - ! echo nothing | $(CGREP) -v nothing - ! echo xyz | $(CGREP) -v w x y - ! echo xyz | $(CGREP) -v x y z - echo xyz | $(CGREP) -v a b c - - ! echo 'foo bar baz' | $(CGREP) 'foo baz' - echo 'foo bar baz' | $(CGREP) foo baz - echo 'x a `b` c y z' | $(CGREP) 'a `b` c' - - echo baaac | $(CGREP) -e 'ba*c' - echo bc | $(CGREP) -e 'ba*c' - ! echo aaac | $(CGREP) -e 'ba*c' - - echo aaa | $(CGREP) -e 'a+' - ! echo bbb | $(CGREP) -e 'a+' - - echo abc | $(CGREP) -e 'a|e|i|o|u' - ! echo fgh | $(CGREP) -e 'a|e|i|o|u' - echo abc | $(CGREP) -e '[aeiou]' - ! echo fgh | $(CGREP) -e '[aeiou]' - ! echo abc | $(CGREP) -e '[^aeiou]{3}' - echo fgh | $(CGREP) -e '[^aeiou]{3}' - echo ab cd ef gh | $(CGREP) -e '\bcd\b' - ! echo abcdefgh | $(CGREP) -e '\bcd\b' - echo xyz | $(CGREP) -e '...' - ! echo xy | $(CGREP) -e '...' - ! echo xyz | $(CGREP) -e '\.\.\.' - echo ... | $(CGREP) -e '\.\.\.' - - echo foo bar baz | $(CGREP) -e 'foo.*baz' - ! echo foo bar baz | $(CGREP) -ve 'foo.*baz' - ! echo foo bar baz | $(CGREP) -e 'baz.*foo' - echo foo bar baz | $(CGREP) -ve 'baz.*foo' diff --git a/src/test/run-make/cdylib-fewer-symbols/Makefile b/src/test/run-make/cdylib-fewer-symbols/Makefile deleted file mode 100644 index 1a0664dfafd..00000000000 --- a/src/test/run-make/cdylib-fewer-symbols/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# Test that allocator-related symbols don't show up as exported from a cdylib as -# they're internal to Rust and not part of the public ABI. - --include ../tools.mk - -# FIXME: The __rdl_ and __rust_ symbol still remains, no matter using MSVC or GNU -# See https://github.com/rust-lang/rust/pull/46207#issuecomment-347561753 -ifdef IS_WINDOWS -all: - true -else -all: - $(RUSTC) foo.rs - nm -g "$(call DYLIB,foo)" | $(CGREP) -v __rdl_ __rde_ __rg_ __rust_ -endif diff --git a/src/test/run-make/cdylib-fewer-symbols/foo.rs b/src/test/run-make/cdylib-fewer-symbols/foo.rs deleted file mode 100644 index 4ec8d4ee860..00000000000 --- a/src/test/run-make/cdylib-fewer-symbols/foo.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "cdylib"] - -#[no_mangle] -pub extern fn foo() -> u32 { - 3 -} diff --git a/src/test/run-make/cdylib/Makefile b/src/test/run-make/cdylib/Makefile deleted file mode 100644 index 47ec762b3e9..00000000000 --- a/src/test/run-make/cdylib/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -include ../tools.mk - -all: $(call RUN_BINFILE,foo) - $(call RUN,foo) - rm $(call DYLIB,foo) - $(RUSTC) foo.rs -C lto - $(call RUN,foo) - -ifdef IS_MSVC -$(call RUN_BINFILE,foo): $(call DYLIB,foo) - $(CC) $(CFLAGS) foo.c $(TMPDIR)/foo.dll.lib $(call OUT_EXE,foo) -else -$(call RUN_BINFILE,foo): $(call DYLIB,foo) - $(CC) $(CFLAGS) foo.c -lfoo -o $(call RUN_BINFILE,foo) -L $(TMPDIR) -endif - -$(call DYLIB,foo): - $(RUSTC) bar.rs - $(RUSTC) foo.rs diff --git a/src/test/run-make/cdylib/bar.rs b/src/test/run-make/cdylib/bar.rs deleted file mode 100644 index 2c97298604c..00000000000 --- a/src/test/run-make/cdylib/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -pub fn bar() { - println!("hello!"); -} diff --git a/src/test/run-make/cdylib/foo.c b/src/test/run-make/cdylib/foo.c deleted file mode 100644 index 1c950427c65..00000000000 --- a/src/test/run-make/cdylib/foo.c +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#include - -extern void foo(); -extern unsigned bar(unsigned a, unsigned b); - -int main() { - foo(); - assert(bar(1, 2) == 3); - return 0; -} diff --git a/src/test/run-make/cdylib/foo.rs b/src/test/run-make/cdylib/foo.rs deleted file mode 100644 index cdac6d19035..00000000000 --- a/src/test/run-make/cdylib/foo.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "cdylib"] - -extern crate bar; - -#[no_mangle] -pub extern fn foo() { - bar::bar(); -} - -#[no_mangle] -pub extern fn bar(a: u32, b: u32) -> u32 { - a + b -} diff --git a/src/test/run-make/codegen-options-parsing/Makefile b/src/test/run-make/codegen-options-parsing/Makefile deleted file mode 100644 index fda96a8b1fb..00000000000 --- a/src/test/run-make/codegen-options-parsing/Makefile +++ /dev/null @@ -1,31 +0,0 @@ --include ../tools.mk - -all: - #Option taking a number - $(RUSTC) -C codegen-units dummy.rs 2>&1 | \ - $(CGREP) 'codegen option `codegen-units` requires a number' - $(RUSTC) -C codegen-units= dummy.rs 2>&1 | \ - $(CGREP) 'incorrect value `` for codegen option `codegen-units` - a number was expected' - $(RUSTC) -C codegen-units=foo dummy.rs 2>&1 | \ - $(CGREP) 'incorrect value `foo` for codegen option `codegen-units` - a number was expected' - $(RUSTC) -C codegen-units=1 dummy.rs - #Option taking a string - $(RUSTC) -C extra-filename dummy.rs 2>&1 | \ - $(CGREP) 'codegen option `extra-filename` requires a string' - $(RUSTC) -C extra-filename= dummy.rs 2>&1 - $(RUSTC) -C extra-filename=foo dummy.rs 2>&1 - #Option taking no argument - $(RUSTC) -C lto= dummy.rs 2>&1 | \ - $(CGREP) 'codegen option `lto` - one of `thin`, `fat`, or' - $(RUSTC) -C lto=1 dummy.rs 2>&1 | \ - $(CGREP) 'codegen option `lto` - one of `thin`, `fat`, or' - $(RUSTC) -C lto=foo dummy.rs 2>&1 | \ - $(CGREP) 'codegen option `lto` - one of `thin`, `fat`, or' - $(RUSTC) -C lto dummy.rs - - # Should not link dead code... - $(RUSTC) -Z print-link-args dummy.rs 2>&1 | \ - $(CGREP) -e '--gc-sections|-z[^ ]* [^ ]*|-dead_strip|/OPT:REF' - # ... unless you specifically ask to keep it - $(RUSTC) -Z print-link-args -C link-dead-code dummy.rs 2>&1 | \ - $(CGREP) -ve '--gc-sections|-z[^ ]* [^ ]*|-dead_strip|/OPT:REF' diff --git a/src/test/run-make/codegen-options-parsing/dummy.rs b/src/test/run-make/codegen-options-parsing/dummy.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/codegen-options-parsing/dummy.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/compile-stdin/Makefile b/src/test/run-make/compile-stdin/Makefile deleted file mode 100644 index 1442224cf9a..00000000000 --- a/src/test/run-make/compile-stdin/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - echo 'fn main(){}' | $(RUSTC) - - $(call RUN,rust_out) diff --git a/src/test/run-make/compiler-lookup-paths-2/Makefile b/src/test/run-make/compiler-lookup-paths-2/Makefile deleted file mode 100644 index bd7f62d5c2d..00000000000 --- a/src/test/run-make/compiler-lookup-paths-2/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: - mkdir -p $(TMPDIR)/a $(TMPDIR)/b - $(RUSTC) a.rs && mv $(TMPDIR)/liba.rlib $(TMPDIR)/a - $(RUSTC) b.rs -L $(TMPDIR)/a && mv $(TMPDIR)/libb.rlib $(TMPDIR)/b - $(RUSTC) c.rs -L crate=$(TMPDIR)/b -L dependency=$(TMPDIR)/a \ - && exit 1 || exit 0 diff --git a/src/test/run-make/compiler-lookup-paths-2/a.rs b/src/test/run-make/compiler-lookup-paths-2/a.rs deleted file mode 100644 index e7572a5f615..00000000000 --- a/src/test/run-make/compiler-lookup-paths-2/a.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] diff --git a/src/test/run-make/compiler-lookup-paths-2/b.rs b/src/test/run-make/compiler-lookup-paths-2/b.rs deleted file mode 100644 index fee0da9b4c1..00000000000 --- a/src/test/run-make/compiler-lookup-paths-2/b.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -extern crate a; diff --git a/src/test/run-make/compiler-lookup-paths-2/c.rs b/src/test/run-make/compiler-lookup-paths-2/c.rs deleted file mode 100644 index 66fe51d1099..00000000000 --- a/src/test/run-make/compiler-lookup-paths-2/c.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -extern crate b; -extern crate a; diff --git a/src/test/run-make/compiler-lookup-paths/Makefile b/src/test/run-make/compiler-lookup-paths/Makefile deleted file mode 100644 index e22b937a087..00000000000 --- a/src/test/run-make/compiler-lookup-paths/Makefile +++ /dev/null @@ -1,38 +0,0 @@ --include ../tools.mk - -all: $(TMPDIR)/libnative.a - mkdir -p $(TMPDIR)/crate - mkdir -p $(TMPDIR)/native - mv $(TMPDIR)/libnative.a $(TMPDIR)/native - $(RUSTC) a.rs - mv $(TMPDIR)/liba.rlib $(TMPDIR)/crate - $(RUSTC) b.rs -L native=$(TMPDIR)/crate && exit 1 || exit 0 - $(RUSTC) b.rs -L dependency=$(TMPDIR)/crate && exit 1 || exit 0 - $(RUSTC) b.rs -L crate=$(TMPDIR)/crate - $(RUSTC) b.rs -L all=$(TMPDIR)/crate - $(RUSTC) c.rs -L native=$(TMPDIR)/crate && exit 1 || exit 0 - $(RUSTC) c.rs -L crate=$(TMPDIR)/crate && exit 1 || exit 0 - $(RUSTC) c.rs -L dependency=$(TMPDIR)/crate - $(RUSTC) c.rs -L all=$(TMPDIR)/crate - $(RUSTC) d.rs -L dependency=$(TMPDIR)/native && exit 1 || exit 0 - $(RUSTC) d.rs -L crate=$(TMPDIR)/native && exit 1 || exit 0 - $(RUSTC) d.rs -L native=$(TMPDIR)/native - $(RUSTC) d.rs -L all=$(TMPDIR)/native - # Deduplication tests: - # Same hash, no errors. - mkdir -p $(TMPDIR)/e1 - mkdir -p $(TMPDIR)/e2 - $(RUSTC) e.rs -o $(TMPDIR)/e1/libe.rlib - $(RUSTC) e.rs -o $(TMPDIR)/e2/libe.rlib - $(RUSTC) f.rs -L $(TMPDIR)/e1 -L $(TMPDIR)/e2 - $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L $(TMPDIR)/e2 - $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2 - # Different hash, errors. - $(RUSTC) e2.rs -o $(TMPDIR)/e2/libe.rlib - $(RUSTC) f.rs -L $(TMPDIR)/e1 -L $(TMPDIR)/e2 && exit 1 || exit 0 - $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L $(TMPDIR)/e2 && exit 1 || exit 0 - $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2 && exit 1 || exit 0 - # Native/dependency paths don't cause errors. - $(RUSTC) f.rs -L native=$(TMPDIR)/e1 -L $(TMPDIR)/e2 - $(RUSTC) f.rs -L dependency=$(TMPDIR)/e1 -L $(TMPDIR)/e2 - $(RUSTC) f.rs -L dependency=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2 diff --git a/src/test/run-make/compiler-lookup-paths/a.rs b/src/test/run-make/compiler-lookup-paths/a.rs deleted file mode 100644 index 4ddf231fba2..00000000000 --- a/src/test/run-make/compiler-lookup-paths/a.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] diff --git a/src/test/run-make/compiler-lookup-paths/b.rs b/src/test/run-make/compiler-lookup-paths/b.rs deleted file mode 100644 index c38300f976e..00000000000 --- a/src/test/run-make/compiler-lookup-paths/b.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -extern crate a; diff --git a/src/test/run-make/compiler-lookup-paths/c.rs b/src/test/run-make/compiler-lookup-paths/c.rs deleted file mode 100644 index b5c54558a4f..00000000000 --- a/src/test/run-make/compiler-lookup-paths/c.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -extern crate b; diff --git a/src/test/run-make/compiler-lookup-paths/d.rs b/src/test/run-make/compiler-lookup-paths/d.rs deleted file mode 100644 index 295b6e00e41..00000000000 --- a/src/test/run-make/compiler-lookup-paths/d.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[link(name = "native", kind = "static")] -extern {} diff --git a/src/test/run-make/compiler-lookup-paths/e.rs b/src/test/run-make/compiler-lookup-paths/e.rs deleted file mode 100644 index c0407aba7c9..00000000000 --- a/src/test/run-make/compiler-lookup-paths/e.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "e"] -#![crate_type = "rlib"] diff --git a/src/test/run-make/compiler-lookup-paths/e2.rs b/src/test/run-make/compiler-lookup-paths/e2.rs deleted file mode 100644 index f8c8c029c0b..00000000000 --- a/src/test/run-make/compiler-lookup-paths/e2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "e"] -#![crate_type = "rlib"] - -pub fn f() {} diff --git a/src/test/run-make/compiler-lookup-paths/f.rs b/src/test/run-make/compiler-lookup-paths/f.rs deleted file mode 100644 index e6160422576..00000000000 --- a/src/test/run-make/compiler-lookup-paths/f.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -extern crate e; diff --git a/src/test/run-make/compiler-lookup-paths/native.c b/src/test/run-make/compiler-lookup-paths/native.c deleted file mode 100644 index 30669470522..00000000000 --- a/src/test/run-make/compiler-lookup-paths/native.c +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. diff --git a/src/test/run-make/compiler-rt-works-on-mingw/Makefile b/src/test/run-make/compiler-rt-works-on-mingw/Makefile deleted file mode 100644 index 06d1bb6698e..00000000000 --- a/src/test/run-make/compiler-rt-works-on-mingw/Makefile +++ /dev/null @@ -1,17 +0,0 @@ --include ../tools.mk - -ifneq (,$(findstring MINGW,$(UNAME))) -ifndef IS_MSVC -all: - $(CXX) foo.cpp -c -o $(TMPDIR)/foo.o - $(AR) crus $(TMPDIR)/libfoo.a $(TMPDIR)/foo.o - $(RUSTC) foo.rs -lfoo -lstdc++ - $(call RUN,foo) -else -all: - -endif -else -all: - -endif diff --git a/src/test/run-make/compiler-rt-works-on-mingw/foo.cpp b/src/test/run-make/compiler-rt-works-on-mingw/foo.cpp deleted file mode 100644 index aac3ba42201..00000000000 --- a/src/test/run-make/compiler-rt-works-on-mingw/foo.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// ignore-license -extern "C" void foo() { - int *a = new int(3); - delete a; -} diff --git a/src/test/run-make/compiler-rt-works-on-mingw/foo.rs b/src/test/run-make/compiler-rt-works-on-mingw/foo.rs deleted file mode 100644 index 293f9d58294..00000000000 --- a/src/test/run-make/compiler-rt-works-on-mingw/foo.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern { fn foo(); } - -pub fn main() { - unsafe { foo(); } - assert_eq!(7f32.powi(3), 343f32); -} diff --git a/src/test/run-make/crate-data-smoke/Makefile b/src/test/run-make/crate-data-smoke/Makefile deleted file mode 100644 index 1afda457411..00000000000 --- a/src/test/run-make/crate-data-smoke/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -all: - [ `$(RUSTC) --print crate-name crate.rs` = "foo" ] - [ `$(RUSTC) --print file-names crate.rs` = "$(call BIN,foo)" ] - [ `$(RUSTC) --print file-names --crate-type=lib \ - --test crate.rs` = "$(call BIN,foo)" ] - [ `$(RUSTC) --print file-names --test lib.rs` = "$(call BIN,mylib)" ] - $(RUSTC) --print file-names lib.rs - $(RUSTC) --print file-names rlib.rs diff --git a/src/test/run-make/crate-data-smoke/crate.rs b/src/test/run-make/crate-data-smoke/crate.rs deleted file mode 100644 index 305b3dc70a6..00000000000 --- a/src/test/run-make/crate-data-smoke/crate.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "foo"] - -// Querying about the crate metadata should *not* parse the entire crate, it -// only needs the crate attributes (which are guaranteed to be at the top) be -// sure that if we have an error like a missing module that we can still query -// about the crate id. -mod error; diff --git a/src/test/run-make/crate-data-smoke/lib.rs b/src/test/run-make/crate-data-smoke/lib.rs deleted file mode 100644 index 639a5d0387b..00000000000 --- a/src/test/run-make/crate-data-smoke/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "mylib"] -#![crate_type = "lib"] diff --git a/src/test/run-make/crate-data-smoke/rlib.rs b/src/test/run-make/crate-data-smoke/rlib.rs deleted file mode 100644 index 4e093748600..00000000000 --- a/src/test/run-make/crate-data-smoke/rlib.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "mylib"] -#![crate_type = "rlib"] diff --git a/src/test/run-make/crate-name-priority/Makefile b/src/test/run-make/crate-name-priority/Makefile deleted file mode 100644 index 17ecb33ab28..00000000000 --- a/src/test/run-make/crate-name-priority/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo.rs --crate-name bar - rm $(TMPDIR)/$(call BIN,bar) - $(RUSTC) foo1.rs - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo1.rs -o $(TMPDIR)/$(call BIN,bar1) - rm $(TMPDIR)/$(call BIN,bar1) diff --git a/src/test/run-make/crate-name-priority/foo.rs b/src/test/run-make/crate-name-priority/foo.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/crate-name-priority/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/crate-name-priority/foo1.rs b/src/test/run-make/crate-name-priority/foo1.rs deleted file mode 100644 index a397d6bc749..00000000000 --- a/src/test/run-make/crate-name-priority/foo1.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "foo"] - -fn main() {} diff --git a/src/test/run-make/debug-assertions/Makefile b/src/test/run-make/debug-assertions/Makefile deleted file mode 100644 index 76ada90f1e2..00000000000 --- a/src/test/run-make/debug-assertions/Makefile +++ /dev/null @@ -1,25 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) debug.rs -C debug-assertions=no - $(call RUN,debug) good - $(RUSTC) debug.rs -C opt-level=0 - $(call RUN,debug) bad - $(RUSTC) debug.rs -C opt-level=1 - $(call RUN,debug) good - $(RUSTC) debug.rs -C opt-level=2 - $(call RUN,debug) good - $(RUSTC) debug.rs -C opt-level=3 - $(call RUN,debug) good - $(RUSTC) debug.rs -C opt-level=s - $(call RUN,debug) good - $(RUSTC) debug.rs -C opt-level=z - $(call RUN,debug) good - $(RUSTC) debug.rs -O - $(call RUN,debug) good - $(RUSTC) debug.rs - $(call RUN,debug) bad - $(RUSTC) debug.rs -C debug-assertions=yes -O - $(call RUN,debug) bad - $(RUSTC) debug.rs -C debug-assertions=yes -C opt-level=1 - $(call RUN,debug) bad diff --git a/src/test/run-make/debug-assertions/debug.rs b/src/test/run-make/debug-assertions/debug.rs deleted file mode 100644 index 65682cb86c3..00000000000 --- a/src/test/run-make/debug-assertions/debug.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![deny(warnings)] - -use std::env; -use std::thread; - -fn main() { - let should_fail = env::args().nth(1) == Some("bad".to_string()); - - assert_eq!(thread::spawn(debug_assert_eq).join().is_err(), should_fail); - assert_eq!(thread::spawn(debug_assert).join().is_err(), should_fail); - assert_eq!(thread::spawn(overflow).join().is_err(), should_fail); -} - -fn debug_assert_eq() { - let mut hit1 = false; - let mut hit2 = false; - debug_assert_eq!({ hit1 = true; 1 }, { hit2 = true; 2 }); - assert!(!hit1); - assert!(!hit2); -} - -fn debug_assert() { - let mut hit = false; - debug_assert!({ hit = true; false }); - assert!(!hit); -} - -fn overflow() { - fn add(a: u8, b: u8) -> u8 { a + b } - - add(200u8, 200u8); -} diff --git a/src/test/run-make/dep-info-doesnt-run-much/Makefile b/src/test/run-make/dep-info-doesnt-run-much/Makefile deleted file mode 100644 index 2fd84639f21..00000000000 --- a/src/test/run-make/dep-info-doesnt-run-much/Makefile +++ /dev/null @@ -1,4 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs --emit dep-info diff --git a/src/test/run-make/dep-info-doesnt-run-much/foo.rs b/src/test/run-make/dep-info-doesnt-run-much/foo.rs deleted file mode 100644 index 35911821044..00000000000 --- a/src/test/run-make/dep-info-doesnt-run-much/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// We're only emitting dep info, so we shouldn't be running static analysis to -// figure out that this program is erroneous. -fn main() { - let a: u8 = "a"; -} diff --git a/src/test/run-make/dep-info-spaces/Makefile b/src/test/run-make/dep-info-spaces/Makefile deleted file mode 100644 index 82686ffdd9d..00000000000 --- a/src/test/run-make/dep-info-spaces/Makefile +++ /dev/null @@ -1,28 +0,0 @@ --include ../tools.mk - -# FIXME: ignore freebsd/windows -# (windows: see `../dep-info/Makefile`) -ifneq ($(shell uname),FreeBSD) -ifndef IS_WINDOWS -all: - cp lib.rs $(TMPDIR)/ - cp 'foo foo.rs' $(TMPDIR)/ - cp bar.rs $(TMPDIR)/ - $(RUSTC) --emit link,dep-info --crate-type=lib $(TMPDIR)/lib.rs - sleep 1 - touch $(TMPDIR)/'foo foo.rs' - -rm -f $(TMPDIR)/done - $(MAKE) -drf Makefile.foo - rm $(TMPDIR)/done - pwd - $(MAKE) -drf Makefile.foo - rm $(TMPDIR)/done && exit 1 || exit 0 -else -all: - -endif - -else -all: - -endif diff --git a/src/test/run-make/dep-info-spaces/Makefile.foo b/src/test/run-make/dep-info-spaces/Makefile.foo deleted file mode 100644 index 80a5d4333cd..00000000000 --- a/src/test/run-make/dep-info-spaces/Makefile.foo +++ /dev/null @@ -1,7 +0,0 @@ -LIB := $(shell $(RUSTC) --print file-names --crate-type=lib $(TMPDIR)/lib.rs) - -$(TMPDIR)/$(LIB): - $(RUSTC) --emit link,dep-info --crate-type=lib $(TMPDIR)/lib.rs - touch $(TMPDIR)/done - --include $(TMPDIR)/lib.d diff --git a/src/test/run-make/dep-info-spaces/bar.rs b/src/test/run-make/dep-info-spaces/bar.rs deleted file mode 100644 index 4c79f7e2855..00000000000 --- a/src/test/run-make/dep-info-spaces/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn bar() {} diff --git a/src/test/run-make/dep-info-spaces/foo foo.rs b/src/test/run-make/dep-info-spaces/foo foo.rs deleted file mode 100644 index 2661b1f4eb4..00000000000 --- a/src/test/run-make/dep-info-spaces/foo foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff --git a/src/test/run-make/dep-info-spaces/lib.rs b/src/test/run-make/dep-info-spaces/lib.rs deleted file mode 100644 index bfbe41baeac..00000000000 --- a/src/test/run-make/dep-info-spaces/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[path="foo foo.rs"] -pub mod foo; - -pub mod bar; diff --git a/src/test/run-make/dep-info/Makefile b/src/test/run-make/dep-info/Makefile deleted file mode 100644 index 9b79d1af521..00000000000 --- a/src/test/run-make/dep-info/Makefile +++ /dev/null @@ -1,34 +0,0 @@ --include ../tools.mk - -# FIXME: ignore freebsd/windows -# on windows `rustc --dep-info` produces Makefile dependency with -# windows native paths (e.g. `c:\path\to\libfoo.a`) -# but msys make seems to fail to recognize such paths, so test fails. -ifneq ($(shell uname),FreeBSD) -ifndef IS_WINDOWS -all: - cp *.rs $(TMPDIR) - $(RUSTC) --emit dep-info,link --crate-type=lib $(TMPDIR)/lib.rs - sleep 2 - touch $(TMPDIR)/foo.rs - -rm -f $(TMPDIR)/done - $(MAKE) -drf Makefile.foo - sleep 2 - rm $(TMPDIR)/done - pwd - $(MAKE) -drf Makefile.foo - rm $(TMPDIR)/done && exit 1 || exit 0 - - # When a source file is deleted `make` should still work - rm $(TMPDIR)/bar.rs - cp $(TMPDIR)/lib2.rs $(TMPDIR)/lib.rs - $(MAKE) -drf Makefile.foo -else -all: - -endif - -else -all: - -endif diff --git a/src/test/run-make/dep-info/Makefile.foo b/src/test/run-make/dep-info/Makefile.foo deleted file mode 100644 index e5df31f88c1..00000000000 --- a/src/test/run-make/dep-info/Makefile.foo +++ /dev/null @@ -1,7 +0,0 @@ -LIB := $(shell $(RUSTC) --print file-names --crate-type=lib lib.rs) - -$(TMPDIR)/$(LIB): - $(RUSTC) --emit dep-info,link --crate-type=lib lib.rs - touch $(TMPDIR)/done - --include $(TMPDIR)/foo.d diff --git a/src/test/run-make/dep-info/bar.rs b/src/test/run-make/dep-info/bar.rs deleted file mode 100644 index 4c79f7e2855..00000000000 --- a/src/test/run-make/dep-info/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn bar() {} diff --git a/src/test/run-make/dep-info/foo.rs b/src/test/run-make/dep-info/foo.rs deleted file mode 100644 index 2661b1f4eb4..00000000000 --- a/src/test/run-make/dep-info/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff --git a/src/test/run-make/dep-info/lib.rs b/src/test/run-make/dep-info/lib.rs deleted file mode 100644 index 7c15785bbb2..00000000000 --- a/src/test/run-make/dep-info/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "foo"] - -pub mod foo; -pub mod bar; diff --git a/src/test/run-make/dep-info/lib2.rs b/src/test/run-make/dep-info/lib2.rs deleted file mode 100644 index 1b70fb4eb4b..00000000000 --- a/src/test/run-make/dep-info/lib2.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "foo"] - -pub mod foo; diff --git a/src/test/run-make/duplicate-output-flavors/Makefile b/src/test/run-make/duplicate-output-flavors/Makefile deleted file mode 100644 index e33279966c9..00000000000 --- a/src/test/run-make/duplicate-output-flavors/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../tools.mk - -all: - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=rlib,rlib foo.rs diff --git a/src/test/run-make/duplicate-output-flavors/foo.rs b/src/test/run-make/duplicate-output-flavors/foo.rs deleted file mode 100644 index 04d3ae67207..00000000000 --- a/src/test/run-make/duplicate-output-flavors/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] diff --git a/src/test/run-make/dylib-chain/Makefile b/src/test/run-make/dylib-chain/Makefile deleted file mode 100644 index a33177197b1..00000000000 --- a/src/test/run-make/dylib-chain/Makefile +++ /dev/null @@ -1,12 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) m1.rs -C prefer-dynamic - $(RUSTC) m2.rs -C prefer-dynamic - $(RUSTC) m3.rs -C prefer-dynamic - $(RUSTC) m4.rs - $(call RUN,m4) - $(call REMOVE_DYLIBS,m1) - $(call REMOVE_DYLIBS,m2) - $(call REMOVE_DYLIBS,m3) - $(call FAIL,m4) diff --git a/src/test/run-make/dylib-chain/m1.rs b/src/test/run-make/dylib-chain/m1.rs deleted file mode 100644 index 5437c935c4e..00000000000 --- a/src/test/run-make/dylib-chain/m1.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] -pub fn m1() {} diff --git a/src/test/run-make/dylib-chain/m2.rs b/src/test/run-make/dylib-chain/m2.rs deleted file mode 100644 index b464f32eae2..00000000000 --- a/src/test/run-make/dylib-chain/m2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] -extern crate m1; - -pub fn m2() { m1::m1() } diff --git a/src/test/run-make/dylib-chain/m3.rs b/src/test/run-make/dylib-chain/m3.rs deleted file mode 100644 index bf431cc827b..00000000000 --- a/src/test/run-make/dylib-chain/m3.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] -extern crate m2; - -pub fn m3() { m2::m2() } diff --git a/src/test/run-make/dylib-chain/m4.rs b/src/test/run-make/dylib-chain/m4.rs deleted file mode 100644 index 6c2a6685802..00000000000 --- a/src/test/run-make/dylib-chain/m4.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate m3; - -fn main() { m3::m3() } diff --git a/src/test/run-make/emit/Makefile b/src/test/run-make/emit/Makefile deleted file mode 100644 index e0b57107e5b..00000000000 --- a/src/test/run-make/emit/Makefile +++ /dev/null @@ -1,21 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 - $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 - $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 - $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 - $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 - $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 diff --git a/src/test/run-make/emit/test-24876.rs b/src/test/run-make/emit/test-24876.rs deleted file mode 100644 index ab69decbf00..00000000000 --- a/src/test/run-make/emit/test-24876.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Checks for issue #24876 - -fn main() { - let mut v = 0; - for i in 0..0 { - v += i; - } - println!("{}", v) -} diff --git a/src/test/run-make/emit/test-26235.rs b/src/test/run-make/emit/test-26235.rs deleted file mode 100644 index 97b58a3671b..00000000000 --- a/src/test/run-make/emit/test-26235.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Checks for issue #26235 - -fn main() { - use std::thread; - - type Key = u32; - const NUM_THREADS: usize = 2; - - #[derive(Clone,Copy)] - struct Stats { - upsert: S, - delete: S, - insert: S, - update: S - }; - - impl Stats where S: Copy { - fn dot(self, s: Stats, f: F) -> Stats where F: Fn(S, T) -> B { - let Stats { upsert: u1, delete: d1, insert: i1, update: p1 } = self; - let Stats { upsert: u2, delete: d2, insert: i2, update: p2 } = s; - Stats { upsert: f(u1, u2), delete: f(d1, d2), insert: f(i1, i2), update: f(p1, p2) } - } - - fn new(init: S) -> Self { - Stats { upsert: init, delete: init, insert: init, update: init } - } - } - - fn make_threads() -> Vec> { - let mut t = Vec::with_capacity(NUM_THREADS); - for _ in 0..NUM_THREADS { - t.push(thread::spawn(move || {})); - } - t - } - - let stats = [Stats::new(0); NUM_THREADS]; - make_threads(); - - { - let Stats { ref upsert, ref delete, ref insert, ref update } = stats.iter().fold( - Stats::new(0), |res, &s| res.dot(s, |x: Key, y: Key| x.wrapping_add(y))); - println!("upserts: {}, deletes: {}, inserts: {}, updates: {}", - upsert, delete, insert, update); - } -} diff --git a/src/test/run-make/error-found-staticlib-instead-crate/Makefile b/src/test/run-make/error-found-staticlib-instead-crate/Makefile deleted file mode 100644 index fef12c4da67..00000000000 --- a/src/test/run-make/error-found-staticlib-instead-crate/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs --crate-type staticlib - $(RUSTC) bar.rs 2>&1 | $(CGREP) "found staticlib" diff --git a/src/test/run-make/error-found-staticlib-instead-crate/bar.rs b/src/test/run-make/error-found-staticlib-instead-crate/bar.rs deleted file mode 100644 index 5ab3e5ee99d..00000000000 --- a/src/test/run-make/error-found-staticlib-instead-crate/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::foo(); -} diff --git a/src/test/run-make/error-found-staticlib-instead-crate/foo.rs b/src/test/run-make/error-found-staticlib-instead-crate/foo.rs deleted file mode 100644 index 222d98a12de..00000000000 --- a/src/test/run-make/error-found-staticlib-instead-crate/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff --git a/src/test/run-make/error-writing-dependencies/Makefile b/src/test/run-make/error-writing-dependencies/Makefile deleted file mode 100644 index cbc96901a38..00000000000 --- a/src/test/run-make/error-writing-dependencies/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: - # Let's get a nice error message - $(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | \ - $(CGREP) "error writing dependencies" - # Make sure the filename shows up - $(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | $(CGREP) "baz" diff --git a/src/test/run-make/error-writing-dependencies/foo.rs b/src/test/run-make/error-writing-dependencies/foo.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/error-writing-dependencies/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/extern-diff-internal-name/Makefile b/src/test/run-make/extern-diff-internal-name/Makefile deleted file mode 100644 index b84e930757b..00000000000 --- a/src/test/run-make/extern-diff-internal-name/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) lib.rs - $(RUSTC) test.rs --extern foo=$(TMPDIR)/libbar.rlib diff --git a/src/test/run-make/extern-diff-internal-name/lib.rs b/src/test/run-make/extern-diff-internal-name/lib.rs deleted file mode 100644 index e8779bba13c..00000000000 --- a/src/test/run-make/extern-diff-internal-name/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "bar"] -#![crate_type = "rlib"] diff --git a/src/test/run-make/extern-diff-internal-name/test.rs b/src/test/run-make/extern-diff-internal-name/test.rs deleted file mode 100644 index 11e042c8c4a..00000000000 --- a/src/test/run-make/extern-diff-internal-name/test.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_use] -extern crate foo; - -fn main() { -} diff --git a/src/test/run-make/extern-flag-disambiguates/Makefile b/src/test/run-make/extern-flag-disambiguates/Makefile deleted file mode 100644 index 81930e969a9..00000000000 --- a/src/test/run-make/extern-flag-disambiguates/Makefile +++ /dev/null @@ -1,25 +0,0 @@ --include ../tools.mk - -# Attempt to build this dependency tree: -# -# A.1 A.2 -# |\ | -# | \ | -# B \ C -# \ | / -# \|/ -# D -# -# Note that A.1 and A.2 are crates with the same name. - -all: - $(RUSTC) -C metadata=1 -C extra-filename=-1 a.rs - $(RUSTC) -C metadata=2 -C extra-filename=-2 a.rs - $(RUSTC) b.rs --extern a=$(TMPDIR)/liba-1.rlib - $(RUSTC) c.rs --extern a=$(TMPDIR)/liba-2.rlib - @echo before - $(RUSTC) --cfg before d.rs --extern a=$(TMPDIR)/liba-1.rlib - $(call RUN,d) - @echo after - $(RUSTC) --cfg after d.rs --extern a=$(TMPDIR)/liba-1.rlib - $(call RUN,d) diff --git a/src/test/run-make/extern-flag-disambiguates/a.rs b/src/test/run-make/extern-flag-disambiguates/a.rs deleted file mode 100644 index ac92aede789..00000000000 --- a/src/test/run-make/extern-flag-disambiguates/a.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "a"] -#![crate_type = "rlib"] - -static FOO: usize = 3; - -pub fn token() -> &'static usize { &FOO } diff --git a/src/test/run-make/extern-flag-disambiguates/b.rs b/src/test/run-make/extern-flag-disambiguates/b.rs deleted file mode 100644 index 8ae238f5a48..00000000000 --- a/src/test/run-make/extern-flag-disambiguates/b.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "b"] -#![crate_type = "rlib"] - -extern crate a; - -static FOO: usize = 3; - -pub fn token() -> &'static usize { &FOO } -pub fn a_token() -> &'static usize { a::token() } diff --git a/src/test/run-make/extern-flag-disambiguates/c.rs b/src/test/run-make/extern-flag-disambiguates/c.rs deleted file mode 100644 index 6eccdf7e5c8..00000000000 --- a/src/test/run-make/extern-flag-disambiguates/c.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "c"] -#![crate_type = "rlib"] - -extern crate a; - -static FOO: usize = 3; - -pub fn token() -> &'static usize { &FOO } -pub fn a_token() -> &'static usize { a::token() } diff --git a/src/test/run-make/extern-flag-disambiguates/d.rs b/src/test/run-make/extern-flag-disambiguates/d.rs deleted file mode 100644 index 9923ff83a91..00000000000 --- a/src/test/run-make/extern-flag-disambiguates/d.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[cfg(before)] extern crate a; -extern crate b; -extern crate c; -#[cfg(after)] extern crate a; - -fn t(a: &'static usize) -> usize { a as *const _ as usize } - -fn main() { - assert_eq!(t(a::token()), t(b::a_token())); - assert!(t(a::token()) != t(c::a_token())); -} diff --git a/src/test/run-make/extern-flag-fun/Makefile b/src/test/run-make/extern-flag-fun/Makefile deleted file mode 100644 index a9f25853350..00000000000 --- a/src/test/run-make/extern-flag-fun/Makefile +++ /dev/null @@ -1,17 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) bar.rs --crate-type=rlib - $(RUSTC) bar.rs --crate-type=rlib -C extra-filename=-a - $(RUSTC) bar-alt.rs --crate-type=rlib - $(RUSTC) foo.rs --extern hello && exit 1 || exit 0 - $(RUSTC) foo.rs --extern bar=no-exist && exit 1 || exit 0 - $(RUSTC) foo.rs --extern bar=foo.rs && exit 1 || exit 0 - $(RUSTC) foo.rs \ - --extern bar=$(TMPDIR)/libbar.rlib \ - --extern bar=$(TMPDIR)/libbar-alt.rlib \ - && exit 1 || exit 0 - $(RUSTC) foo.rs \ - --extern bar=$(TMPDIR)/libbar.rlib \ - --extern bar=$(TMPDIR)/libbar-a.rlib - $(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib diff --git a/src/test/run-make/extern-flag-fun/bar-alt.rs b/src/test/run-make/extern-flag-fun/bar-alt.rs deleted file mode 100644 index d6ebd9d896f..00000000000 --- a/src/test/run-make/extern-flag-fun/bar-alt.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn f() {} diff --git a/src/test/run-make/extern-flag-fun/bar.rs b/src/test/run-make/extern-flag-fun/bar.rs deleted file mode 100644 index e6c76025738..00000000000 --- a/src/test/run-make/extern-flag-fun/bar.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. diff --git a/src/test/run-make/extern-flag-fun/foo.rs b/src/test/run-make/extern-flag-fun/foo.rs deleted file mode 100644 index 52741668640..00000000000 --- a/src/test/run-make/extern-flag-fun/foo.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar; - -fn main() {} diff --git a/src/test/run-make/extern-fn-generic/Makefile b/src/test/run-make/extern-fn-generic/Makefile deleted file mode 100644 index cf897dba1f2..00000000000 --- a/src/test/run-make/extern-fn-generic/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) testcrate.rs - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/src/test/run-make/extern-fn-generic/test.c b/src/test/run-make/extern-fn-generic/test.c deleted file mode 100644 index f9faef64afc..00000000000 --- a/src/test/run-make/extern-fn-generic/test.c +++ /dev/null @@ -1,17 +0,0 @@ -// ignore-license -#include - -typedef struct TestStruct { - uint8_t x; - int32_t y; -} TestStruct; - -typedef int callback(TestStruct s); - -uint32_t call(callback *c) { - TestStruct s; - s.x = 'a'; - s.y = 3; - - return c(s); -} diff --git a/src/test/run-make/extern-fn-generic/test.rs b/src/test/run-make/extern-fn-generic/test.rs deleted file mode 100644 index 8f5ff091b3b..00000000000 --- a/src/test/run-make/extern-fn-generic/test.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate testcrate; - -extern "C" fn bar(ts: testcrate::TestStruct) -> T { ts.y } - -#[link(name = "test", kind = "static")] -extern { - fn call(c: extern "C" fn(testcrate::TestStruct) -> i32) -> i32; -} - -fn main() { - // Let's test calling it cross crate - let back = unsafe { - testcrate::call(testcrate::foo::) - }; - assert_eq!(3, back); - - // And just within this crate - let back = unsafe { - call(bar::) - }; - assert_eq!(3, back); -} diff --git a/src/test/run-make/extern-fn-generic/testcrate.rs b/src/test/run-make/extern-fn-generic/testcrate.rs deleted file mode 100644 index d02c05047c0..00000000000 --- a/src/test/run-make/extern-fn-generic/testcrate.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -#[repr(C)] -pub struct TestStruct { - pub x: u8, - pub y: T -} - -pub extern "C" fn foo(ts: TestStruct) -> T { ts.y } - -#[link(name = "test", kind = "static")] -extern { - pub fn call(c: extern "C" fn(TestStruct) -> i32) -> i32; -} diff --git a/src/test/run-make/extern-fn-mangle/Makefile b/src/test/run-make/extern-fn-mangle/Makefile deleted file mode 100644 index 042048ec25f..00000000000 --- a/src/test/run-make/extern-fn-mangle/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/src/test/run-make/extern-fn-mangle/test.c b/src/test/run-make/extern-fn-mangle/test.c deleted file mode 100644 index 1a9855dedec..00000000000 --- a/src/test/run-make/extern-fn-mangle/test.c +++ /dev/null @@ -1,9 +0,0 @@ -// ignore-license -#include - -uint32_t foo(); -uint32_t bar(); - -uint32_t add() { - return foo() + bar(); -} diff --git a/src/test/run-make/extern-fn-mangle/test.rs b/src/test/run-make/extern-fn-mangle/test.rs deleted file mode 100644 index 35b5a9278a4..00000000000 --- a/src/test/run-make/extern-fn-mangle/test.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[no_mangle] -pub extern "C" fn foo() -> i32 { 3 } - -#[no_mangle] -pub extern "C" fn bar() -> i32 { 5 } - -#[link(name = "test", kind = "static")] -extern { - fn add() -> i32; -} - -fn main() { - let back = unsafe { add() }; - assert_eq!(8, back); -} diff --git a/src/test/run-make/extern-fn-reachable/Makefile b/src/test/run-make/extern-fn-reachable/Makefile deleted file mode 100644 index 79a9a3c640f..00000000000 --- a/src/test/run-make/extern-fn-reachable/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -# This overrides the LD_LIBRARY_PATH for RUN -TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR) - -all: - $(RUSTC) dylib.rs -o $(TMPDIR)/libdylib.so -C prefer-dynamic - $(RUSTC) main.rs -C prefer-dynamic - $(call RUN,main) diff --git a/src/test/run-make/extern-fn-reachable/dylib.rs b/src/test/run-make/extern-fn-reachable/dylib.rs deleted file mode 100644 index f24265e7a52..00000000000 --- a/src/test/run-make/extern-fn-reachable/dylib.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] -#![allow(dead_code)] - -#[no_mangle] pub extern "C" fn fun1() {} -#[no_mangle] extern "C" fn fun2() {} - -mod foo { - #[no_mangle] pub extern "C" fn fun3() {} -} -pub mod bar { - #[no_mangle] pub extern "C" fn fun4() {} -} - -#[no_mangle] pub fn fun5() {} diff --git a/src/test/run-make/extern-fn-reachable/main.rs b/src/test/run-make/extern-fn-reachable/main.rs deleted file mode 100644 index 27387332c1c..00000000000 --- a/src/test/run-make/extern-fn-reachable/main.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_private)] - -extern crate rustc_metadata; - -use rustc_metadata::dynamic_lib::DynamicLibrary; -use std::path::Path; - -pub fn main() { - unsafe { - let path = Path::new("libdylib.so"); - let a = DynamicLibrary::open(Some(&path)).unwrap(); - assert!(a.symbol::("fun1").is_ok()); - assert!(a.symbol::("fun2").is_err()); - assert!(a.symbol::("fun3").is_err()); - assert!(a.symbol::("fun4").is_ok()); - assert!(a.symbol::("fun5").is_ok()); - } -} diff --git a/src/test/run-make/extern-fn-struct-passing-abi/Makefile b/src/test/run-make/extern-fn-struct-passing-abi/Makefile deleted file mode 100644 index 042048ec25f..00000000000 --- a/src/test/run-make/extern-fn-struct-passing-abi/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/src/test/run-make/extern-fn-struct-passing-abi/test.c b/src/test/run-make/extern-fn-struct-passing-abi/test.c deleted file mode 100644 index 25cd6da10b8..00000000000 --- a/src/test/run-make/extern-fn-struct-passing-abi/test.c +++ /dev/null @@ -1,324 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#include -#include - -struct Rect { - int32_t a; - int32_t b; - int32_t c; - int32_t d; -}; - -struct BiggerRect { - struct Rect s; - int32_t a; - int32_t b; -}; - -struct FloatRect { - int32_t a; - int32_t b; - double c; -}; - -struct Huge { - int32_t a; - int32_t b; - int32_t c; - int32_t d; - int32_t e; -}; - -struct FloatPoint { - double x; - double y; -}; - -struct FloatOne { - double x; -}; - -struct IntOdd { - int8_t a; - int8_t b; - int8_t c; -}; - -// System V x86_64 ABI: -// a, b, c, d, e should be in registers -// s should be byval pointer -// -// Win64 ABI: -// a, b, c, d should be in registers -// e should be on the stack -// s should be byval pointer -void byval_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(c == 3); - assert(d == 4); - assert(e == 5); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); -} - -// System V x86_64 ABI: -// a, b, c, d, e, f should be in registers -// s should be byval pointer on the stack -// -// Win64 ABI: -// a, b, c, d should be in registers -// e, f should be on the stack -// s should be byval pointer on the stack -void byval_many_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, - int32_t f, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(c == 3); - assert(d == 4); - assert(e == 5); - assert(f == 6); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); -} - -// System V x86_64 ABI: -// a, b, c, d, e, f, g should be in sse registers -// s should be split across 2 registers -// t should be byval pointer -// -// Win64 ABI: -// a, b, c, d should be in sse registers -// e, f, g should be on the stack -// s should be on the stack (treated as 2 i64's) -// t should be on the stack (treated as an i64 and a double) -void byval_rect_floats(float a, float b, double c, float d, float e, - float f, double g, struct Rect s, struct FloatRect t) { - assert(a == 1.); - assert(b == 2.); - assert(c == 3.); - assert(d == 4.); - assert(e == 5.); - assert(f == 6.); - assert(g == 7.); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); - assert(t.a == 3489); - assert(t.b == 3490); - assert(t.c == 8.); -} - -// System V x86_64 ABI: -// a, b, d, e, f should be in registers -// c passed via sse registers -// s should be byval pointer -// -// Win64 ABI: -// a, b, d should be in registers -// c passed via sse registers -// e, f should be on the stack -// s should be byval pointer -void byval_rect_with_float(int32_t a, int32_t b, float c, int32_t d, - int32_t e, int32_t f, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(c == 3.); - assert(d == 4); - assert(e == 5); - assert(f == 6); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); -} - -// System V x86_64 ABI: -// a, b, d, e, f should be byval pointer (on the stack) -// g passed via register (fixes #41375) -// -// Win64 ABI: -// a, b, d, e, f, g should be byval pointer -void byval_rect_with_many_huge(struct Huge a, struct Huge b, struct Huge c, - struct Huge d, struct Huge e, struct Huge f, - struct Rect g) { - assert(g.a == 123); - assert(g.b == 456); - assert(g.c == 789); - assert(g.d == 420); -} - -// System V x86_64 & Win64 ABI: -// a, b should be in registers -// s should be split across 2 integer registers -void split_rect(int32_t a, int32_t b, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); -} - -// System V x86_64 & Win64 ABI: -// a, b should be in sse registers -// s should be split across integer & sse registers -void split_rect_floats(float a, float b, struct FloatRect s) { - assert(a == 1.); - assert(b == 2.); - assert(s.a == 3489); - assert(s.b == 3490); - assert(s.c == 8.); -} - -// System V x86_64 ABI: -// a, b, d, f should be in registers -// c, e passed via sse registers -// s should be split across 2 registers -// -// Win64 ABI: -// a, b, d should be in registers -// c passed via sse registers -// e, f should be on the stack -// s should be on the stack (treated as 2 i64's) -void split_rect_with_floats(int32_t a, int32_t b, float c, - int32_t d, float e, int32_t f, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(c == 3.); - assert(d == 4); - assert(e == 5.); - assert(f == 6); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); -} - -// System V x86_64 & Win64 ABI: -// a, b, c should be in registers -// s should be split across 2 registers -// t should be a byval pointer -void split_and_byval_rect(int32_t a, int32_t b, int32_t c, struct Rect s, struct Rect t) { - assert(a == 1); - assert(b == 2); - assert(c == 3); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); - assert(t.a == 553); - assert(t.b == 554); - assert(t.c == 555); - assert(t.d == 556); -} - -// System V x86_64 & Win64 ABI: -// a, b should in registers -// s and return should be split across 2 registers -struct Rect split_ret_byval_struct(int32_t a, int32_t b, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); - return s; -} - -// System V x86_64 & Win64 ABI: -// a, b, c, d should be in registers -// return should be in a hidden sret pointer -// s should be a byval pointer -struct BiggerRect sret_byval_struct(int32_t a, int32_t b, int32_t c, int32_t d, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(c == 3); - assert(d == 4); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); - - struct BiggerRect t; - t.s = s; t.a = 27834; t.b = 7657; - return t; -} - -// System V x86_64 & Win64 ABI: -// a, b should be in registers -// return should be in a hidden sret pointer -// s should be split across 2 registers -struct BiggerRect sret_split_struct(int32_t a, int32_t b, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); - - struct BiggerRect t; - t.s = s; t.a = 27834; t.b = 7657; - return t; -} - -// System V x86_64 & Win64 ABI: -// s should be byval pointer (since sizeof(s) > 16) -// return should in a hidden sret pointer -struct Huge huge_struct(struct Huge s) { - assert(s.a == 5647); - assert(s.b == 5648); - assert(s.c == 5649); - assert(s.d == 5650); - assert(s.e == 5651); - - return s; -} - -// System V x86_64 ABI: -// p should be in registers -// return should be in registers -// -// Win64 ABI and 64-bit PowerPC ELFv1 ABI: -// p should be a byval pointer -// return should be in a hidden sret pointer -struct FloatPoint float_point(struct FloatPoint p) { - assert(p.x == 5.); - assert(p.y == -3.); - - return p; -} - -// 64-bit PowerPC ELFv1 ABI: -// f1 should be in a register -// return should be in a hidden sret pointer -struct FloatOne float_one(struct FloatOne f1) { - assert(f1.x == 7.); - - return f1; -} - -// 64-bit PowerPC ELFv1 ABI: -// i should be in the least-significant bits of a register -// return should be in a hidden sret pointer -struct IntOdd int_odd(struct IntOdd i) { - assert(i.a == 1); - assert(i.b == 2); - assert(i.c == 3); - - return i; -} diff --git a/src/test/run-make/extern-fn-struct-passing-abi/test.rs b/src/test/run-make/extern-fn-struct-passing-abi/test.rs deleted file mode 100644 index 54a4f868eb4..00000000000 --- a/src/test/run-make/extern-fn-struct-passing-abi/test.rs +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Passing structs via FFI should work regardless of whether -// they get passed in multiple registers, byval pointers or the stack - -#[derive(Clone, Copy, Debug, PartialEq)] -#[repr(C)] -struct Rect { - a: i32, - b: i32, - c: i32, - d: i32 -} - -#[derive(Clone, Copy, Debug, PartialEq)] -#[repr(C)] -struct BiggerRect { - s: Rect, - a: i32, - b: i32 -} - -#[derive(Clone, Copy, Debug, PartialEq)] -#[repr(C)] -struct FloatRect { - a: i32, - b: i32, - c: f64 -} - -#[derive(Clone, Copy, Debug, PartialEq)] -#[repr(C)] -struct Huge { - a: i32, - b: i32, - c: i32, - d: i32, - e: i32 -} - -#[derive(Clone, Copy, Debug, PartialEq)] -#[repr(C)] -struct FloatPoint { - x: f64, - y: f64 -} - -#[derive(Clone, Copy, Debug, PartialEq)] -#[repr(C)] -struct FloatOne { - x: f64, -} - -#[derive(Clone, Copy, Debug, PartialEq)] -#[repr(C)] -struct IntOdd { - a: i8, - b: i8, - c: i8, -} - -#[link(name = "test", kind = "static")] -extern { - fn byval_rect(a: i32, b: i32, c: i32, d: i32, e: i32, s: Rect); - - fn byval_many_rect(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, s: Rect); - - fn byval_rect_floats(a: f32, b: f32, c: f64, d: f32, e: f32, - f: f32, g: f64, s: Rect, t: FloatRect); - - fn byval_rect_with_float(a: i32, b: i32, c: f32, d: i32, e: i32, f: i32, s: Rect); - - fn byval_rect_with_many_huge(a: Huge, b: Huge, c: Huge, d: Huge, e: Huge, f: Huge, g: Rect); - - fn split_rect(a: i32, b: i32, s: Rect); - - fn split_rect_floats(a: f32, b: f32, s: FloatRect); - - fn split_rect_with_floats(a: i32, b: i32, c: f32, d: i32, e: f32, f: i32, s: Rect); - - fn split_and_byval_rect(a: i32, b: i32, c: i32, s: Rect, t: Rect); - - fn split_ret_byval_struct(a: i32, b: i32, s: Rect) -> Rect; - - fn sret_byval_struct(a: i32, b: i32, c: i32, d: i32, s: Rect) -> BiggerRect; - - fn sret_split_struct(a: i32, b: i32, s: Rect) -> BiggerRect; - - fn huge_struct(s: Huge) -> Huge; - - fn float_point(p: FloatPoint) -> FloatPoint; - - fn float_one(f: FloatOne) -> FloatOne; - - fn int_odd(i: IntOdd) -> IntOdd; -} - -fn main() { - let s = Rect { a: 553, b: 554, c: 555, d: 556 }; - let t = BiggerRect { s: s, a: 27834, b: 7657 }; - let u = FloatRect { a: 3489, b: 3490, c: 8. }; - let v = Huge { a: 5647, b: 5648, c: 5649, d: 5650, e: 5651 }; - let p = FloatPoint { x: 5., y: -3. }; - let f1 = FloatOne { x: 7. }; - let i = IntOdd { a: 1, b: 2, c: 3 }; - - unsafe { - byval_rect(1, 2, 3, 4, 5, s); - byval_many_rect(1, 2, 3, 4, 5, 6, s); - byval_rect_floats(1., 2., 3., 4., 5., 6., 7., s, u); - byval_rect_with_float(1, 2, 3.0, 4, 5, 6, s); - byval_rect_with_many_huge(v, v, v, v, v, v, Rect { - a: 123, - b: 456, - c: 789, - d: 420 - }); - split_rect(1, 2, s); - split_rect_floats(1., 2., u); - split_rect_with_floats(1, 2, 3.0, 4, 5.0, 6, s); - split_and_byval_rect(1, 2, 3, s, s); - split_rect(1, 2, s); - assert_eq!(huge_struct(v), v); - assert_eq!(split_ret_byval_struct(1, 2, s), s); - assert_eq!(sret_byval_struct(1, 2, 3, 4, s), t); - assert_eq!(sret_split_struct(1, 2, s), t); - assert_eq!(float_point(p), p); - assert_eq!(int_odd(i), i); - - // MSVC/GCC/Clang are not consistent in the ABI of single-float aggregates. - // x86_64: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82028 - // i686: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82041 - #[cfg(not(all(windows, target_env = "gnu")))] - assert_eq!(float_one(f1), f1); - } -} diff --git a/src/test/run-make/extern-fn-with-extern-types/Makefile b/src/test/run-make/extern-fn-with-extern-types/Makefile deleted file mode 100644 index 8977e14c3ad..00000000000 --- a/src/test/run-make/extern-fn-with-extern-types/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,ctest) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/src/test/run-make/extern-fn-with-extern-types/ctest.c b/src/test/run-make/extern-fn-with-extern-types/ctest.c deleted file mode 100644 index c3d6166fb12..00000000000 --- a/src/test/run-make/extern-fn-with-extern-types/ctest.c +++ /dev/null @@ -1,17 +0,0 @@ -// ignore-license -#include -#include - -typedef struct data { - uint32_t magic; -} data; - -data* data_create(uint32_t magic) { - static data d; - d.magic = magic; - return &d; -} - -uint32_t data_get(data* p) { - return p->magic; -} diff --git a/src/test/run-make/extern-fn-with-extern-types/test.rs b/src/test/run-make/extern-fn-with-extern-types/test.rs deleted file mode 100644 index 9d6c87885b1..00000000000 --- a/src/test/run-make/extern-fn-with-extern-types/test.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(extern_types)] - -#[link(name = "ctest", kind = "static")] -extern { - type data; - - fn data_create(magic: u32) -> *mut data; - fn data_get(data: *mut data) -> u32; -} - -const MAGIC: u32 = 0xdeadbeef; -fn main() { - unsafe { - let data = data_create(MAGIC); - assert_eq!(data_get(data), MAGIC); - } -} diff --git a/src/test/run-make/extern-fn-with-packed-struct/Makefile b/src/test/run-make/extern-fn-with-packed-struct/Makefile deleted file mode 100644 index 042048ec25f..00000000000 --- a/src/test/run-make/extern-fn-with-packed-struct/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/src/test/run-make/extern-fn-with-packed-struct/test.c b/src/test/run-make/extern-fn-with-packed-struct/test.c deleted file mode 100644 index 4124e202c1d..00000000000 --- a/src/test/run-make/extern-fn-with-packed-struct/test.c +++ /dev/null @@ -1,27 +0,0 @@ -// ignore-license -// Pragma needed cause of gcc bug on windows: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991 - -#include - -#ifdef _MSC_VER -#pragma pack(push,1) -struct Foo { - char a; - short b; - char c; -}; -#else -#pragma pack(1) -struct __attribute__((packed)) Foo { - char a; - short b; - char c; -}; -#endif - -struct Foo foo(struct Foo foo) { - assert(foo.a == 1); - assert(foo.b == 2); - assert(foo.c == 3); - return foo; -} diff --git a/src/test/run-make/extern-fn-with-packed-struct/test.rs b/src/test/run-make/extern-fn-with-packed-struct/test.rs deleted file mode 100644 index d2540ad6154..00000000000 --- a/src/test/run-make/extern-fn-with-packed-struct/test.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[repr(C, packed)] -#[derive(Copy, Clone, Debug, PartialEq)] -struct Foo { - a: i8, - b: i16, - c: i8 -} - -#[link(name = "test", kind = "static")] -extern { - fn foo(f: Foo) -> Foo; -} - -fn main() { - unsafe { - let a = Foo { a: 1, b: 2, c: 3 }; - let b = foo(a); - assert_eq!(a, b); - } -} diff --git a/src/test/run-make/extern-fn-with-union/Makefile b/src/test/run-make/extern-fn-with-union/Makefile deleted file mode 100644 index 71a5407e882..00000000000 --- a/src/test/run-make/extern-fn-with-union/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,ctest) - $(RUSTC) testcrate.rs - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/src/test/run-make/extern-fn-with-union/ctest.c b/src/test/run-make/extern-fn-with-union/ctest.c deleted file mode 100644 index 8c87c230693..00000000000 --- a/src/test/run-make/extern-fn-with-union/ctest.c +++ /dev/null @@ -1,11 +0,0 @@ -// ignore-license -#include -#include - -typedef union TestUnion { - uint64_t bits; -} TestUnion; - -uint64_t give_back(TestUnion tu) { - return tu.bits; -} diff --git a/src/test/run-make/extern-fn-with-union/test.rs b/src/test/run-make/extern-fn-with-union/test.rs deleted file mode 100644 index f9277ba11f4..00000000000 --- a/src/test/run-make/extern-fn-with-union/test.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate testcrate; - -use std::mem; - -extern { - fn give_back(tu: testcrate::TestUnion) -> u64; -} - -fn main() { - let magic: u64 = 0xDEADBEEF; - - // Let's test calling it cross crate - let back = unsafe { - testcrate::give_back(mem::transmute(magic)) - }; - assert_eq!(magic, back); - - // And just within this crate - let back = unsafe { - give_back(mem::transmute(magic)) - }; - assert_eq!(magic, back); -} diff --git a/src/test/run-make/extern-fn-with-union/testcrate.rs b/src/test/run-make/extern-fn-with-union/testcrate.rs deleted file mode 100644 index 66978c38511..00000000000 --- a/src/test/run-make/extern-fn-with-union/testcrate.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -#[repr(C)] -pub struct TestUnion { - _val: u64 -} - -#[link(name = "ctest", kind = "static")] -extern { - pub fn give_back(tu: TestUnion) -> u64; -} diff --git a/src/test/run-make/extern-multiple-copies/Makefile b/src/test/run-make/extern-multiple-copies/Makefile deleted file mode 100644 index 1631aa806af..00000000000 --- a/src/test/run-make/extern-multiple-copies/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo1.rs - $(RUSTC) foo2.rs - mkdir $(TMPDIR)/foo - cp $(TMPDIR)/libfoo1.rlib $(TMPDIR)/foo/libfoo1.rlib - $(RUSTC) bar.rs --extern foo1=$(TMPDIR)/libfoo1.rlib -L $(TMPDIR)/foo diff --git a/src/test/run-make/extern-multiple-copies/bar.rs b/src/test/run-make/extern-multiple-copies/bar.rs deleted file mode 100644 index a50f5de384c..00000000000 --- a/src/test/run-make/extern-multiple-copies/bar.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo2; // foo2 first to exhibit the bug -extern crate foo1; - -fn main() { - /* ... */ -} diff --git a/src/test/run-make/extern-multiple-copies/foo1.rs b/src/test/run-make/extern-multiple-copies/foo1.rs deleted file mode 100644 index 0be200ddcd2..00000000000 --- a/src/test/run-make/extern-multiple-copies/foo1.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] diff --git a/src/test/run-make/extern-multiple-copies/foo2.rs b/src/test/run-make/extern-multiple-copies/foo2.rs deleted file mode 100644 index 0be200ddcd2..00000000000 --- a/src/test/run-make/extern-multiple-copies/foo2.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] diff --git a/src/test/run-make/extern-multiple-copies2/Makefile b/src/test/run-make/extern-multiple-copies2/Makefile deleted file mode 100644 index 567d7e78a57..00000000000 --- a/src/test/run-make/extern-multiple-copies2/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo1.rs - $(RUSTC) foo2.rs - mkdir $(TMPDIR)/foo - cp $(TMPDIR)/libfoo1.rlib $(TMPDIR)/foo/libfoo1.rlib - $(RUSTC) bar.rs \ - --extern foo1=$(TMPDIR)/foo/libfoo1.rlib \ - --extern foo2=$(TMPDIR)/libfoo2.rlib diff --git a/src/test/run-make/extern-multiple-copies2/bar.rs b/src/test/run-make/extern-multiple-copies2/bar.rs deleted file mode 100644 index b8ac34aa53e..00000000000 --- a/src/test/run-make/extern-multiple-copies2/bar.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_use] -extern crate foo2; // foo2 first to exhibit the bug -#[macro_use] -extern crate foo1; - -fn main() { - foo2::foo2(foo1::A); -} diff --git a/src/test/run-make/extern-multiple-copies2/foo1.rs b/src/test/run-make/extern-multiple-copies2/foo1.rs deleted file mode 100644 index 1787772053b..00000000000 --- a/src/test/run-make/extern-multiple-copies2/foo1.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -pub struct A; - -pub fn foo1(a: A) { - drop(a); -} diff --git a/src/test/run-make/extern-multiple-copies2/foo2.rs b/src/test/run-make/extern-multiple-copies2/foo2.rs deleted file mode 100644 index bad10304387..00000000000 --- a/src/test/run-make/extern-multiple-copies2/foo2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[macro_use] -extern crate foo1; - -pub fn foo2(a: foo1::A) { - foo1::foo1(a); -} diff --git a/src/test/run-make/extern-overrides-distribution/Makefile b/src/test/run-make/extern-overrides-distribution/Makefile deleted file mode 100644 index 7d063a4c83c..00000000000 --- a/src/test/run-make/extern-overrides-distribution/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) libc.rs -Cmetadata=foo - $(RUSTC) main.rs --extern libc=$(TMPDIR)/liblibc.rlib diff --git a/src/test/run-make/extern-overrides-distribution/libc.rs b/src/test/run-make/extern-overrides-distribution/libc.rs deleted file mode 100644 index a489d834a92..00000000000 --- a/src/test/run-make/extern-overrides-distribution/libc.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -pub fn foo() {} diff --git a/src/test/run-make/extern-overrides-distribution/main.rs b/src/test/run-make/extern-overrides-distribution/main.rs deleted file mode 100644 index 451841e7368..00000000000 --- a/src/test/run-make/extern-overrides-distribution/main.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate libc; - -fn main() { - libc::foo(); -} diff --git a/src/test/run-make/extra-filename-with-temp-outputs/Makefile b/src/test/run-make/extra-filename-with-temp-outputs/Makefile deleted file mode 100644 index 6de4f97df0c..00000000000 --- a/src/test/run-make/extra-filename-with-temp-outputs/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -C extra-filename=bar foo.rs -C save-temps - rm $(TMPDIR)/foobar.foo0.rcgu.o - rm $(TMPDIR)/$(call BIN,foobar) diff --git a/src/test/run-make/extra-filename-with-temp-outputs/foo.rs b/src/test/run-make/extra-filename-with-temp-outputs/foo.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/extra-filename-with-temp-outputs/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/fpic/Makefile b/src/test/run-make/fpic/Makefile deleted file mode 100644 index 6de58c2db18..00000000000 --- a/src/test/run-make/fpic/Makefile +++ /dev/null @@ -1,13 +0,0 @@ --include ../tools.mk - -# Test for #39529. -# `-z text` causes ld to error if there are any non-PIC sections - -ifeq ($(UNAME),Darwin) -all: -else ifdef IS_WINDOWS -all: -else -all: - $(RUSTC) hello.rs -C link-args=-Wl,-z,text -endif diff --git a/src/test/run-make/fpic/hello.rs b/src/test/run-make/fpic/hello.rs deleted file mode 100644 index a9e231b0ea8..00000000000 --- a/src/test/run-make/fpic/hello.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { } diff --git a/src/test/run-make/hir-tree/Makefile b/src/test/run-make/hir-tree/Makefile deleted file mode 100644 index 2e100b269e1..00000000000 --- a/src/test/run-make/hir-tree/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -# Test that hir-tree output doens't crash and includes -# the string constant we would expect to see. - -all: - $(RUSTC) -o $(TMPDIR)/input.hir -Z unpretty=hir-tree input.rs - $(CGREP) '"Hello, Rustaceans!\n"' < $(TMPDIR)/input.hir diff --git a/src/test/run-make/hir-tree/input.rs b/src/test/run-make/hir-tree/input.rs deleted file mode 100644 index 12adc083bcd..00000000000 --- a/src/test/run-make/hir-tree/input.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - println!("Hello, Rustaceans!"); -} diff --git a/src/test/run-make/hotplug_codegen_backend/Makefile b/src/test/run-make/hotplug_codegen_backend/Makefile deleted file mode 100644 index 2ddf3aa5439..00000000000 --- a/src/test/run-make/hotplug_codegen_backend/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -include ../tools.mk - -all: - /bin/echo || exit 0 # This test requires /bin/echo to exist - $(RUSTC) the_backend.rs --crate-name the_backend --crate-type dylib \ - -o $(TMPDIR)/the_backend.dylib - $(RUSTC) some_crate.rs --crate-name some_crate --crate-type bin -o $(TMPDIR)/some_crate \ - -Z codegen-backend=$(TMPDIR)/the_backend.dylib -Z unstable-options - grep -x "This has been \"compiled\" successfully." $(TMPDIR)/some_crate diff --git a/src/test/run-make/hotplug_codegen_backend/some_crate.rs b/src/test/run-make/hotplug_codegen_backend/some_crate.rs deleted file mode 100644 index 26ffce01b2e..00000000000 --- a/src/test/run-make/hotplug_codegen_backend/some_crate.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - ::std::process::exit(1); -} diff --git a/src/test/run-make/hotplug_codegen_backend/the_backend.rs b/src/test/run-make/hotplug_codegen_backend/the_backend.rs deleted file mode 100644 index e266b0f5e83..00000000000 --- a/src/test/run-make/hotplug_codegen_backend/the_backend.rs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_private)] - -extern crate syntax; -extern crate rustc; -extern crate rustc_trans_utils; - -use std::any::Any; -use std::sync::mpsc; -use syntax::symbol::Symbol; -use rustc::session::{Session, CompileIncomplete}; -use rustc::session::config::OutputFilenames; -use rustc::ty::TyCtxt; -use rustc::ty::maps::Providers; -use rustc::middle::cstore::MetadataLoader; -use rustc::dep_graph::DepGraph; -use rustc_trans_utils::trans_crate::{TransCrate, MetadataOnlyTransCrate}; - -struct TheBackend(Box); - -impl TransCrate for TheBackend { - fn metadata_loader(&self) -> Box { - self.0.metadata_loader() - } - - fn provide(&self, providers: &mut Providers) { - self.0.provide(providers); - } - - fn provide_extern(&self, providers: &mut Providers) { - self.0.provide_extern(providers); - } - - fn trans_crate<'a, 'tcx>( - &self, - tcx: TyCtxt<'a, 'tcx, 'tcx>, - _rx: mpsc::Receiver> - ) -> Box { - use rustc::hir::def_id::LOCAL_CRATE; - - Box::new(tcx.crate_name(LOCAL_CRATE) as Symbol) - } - - fn join_trans_and_link( - &self, - trans: Box, - sess: &Session, - _dep_graph: &DepGraph, - outputs: &OutputFilenames, - ) -> Result<(), CompileIncomplete> { - use std::io::Write; - use rustc::session::config::CrateType; - use rustc_trans_utils::link::out_filename; - let crate_name = trans.downcast::() - .expect("in join_trans_and_link: trans is not a Symbol"); - for &crate_type in sess.opts.crate_types.iter() { - if crate_type != CrateType::CrateTypeExecutable { - sess.fatal(&format!("Crate type is {:?}", crate_type)); - } - let output_name = - out_filename(sess, crate_type, &outputs, &*crate_name.as_str()); - let mut out_file = ::std::fs::File::create(output_name).unwrap(); - write!(out_file, "This has been \"compiled\" successfully.").unwrap(); - } - Ok(()) - } -} - -/// This is the entrypoint for a hot plugged rustc_trans -#[no_mangle] -pub fn __rustc_codegen_backend() -> Box { - Box::new(TheBackend(MetadataOnlyTransCrate::new())) -} diff --git a/src/test/run-make/include_bytes_deps/Makefile b/src/test/run-make/include_bytes_deps/Makefile deleted file mode 100644 index 1293695b799..00000000000 --- a/src/test/run-make/include_bytes_deps/Makefile +++ /dev/null @@ -1,20 +0,0 @@ --include ../tools.mk - -# FIXME: ignore freebsd/windows -# on windows `rustc --dep-info` produces Makefile dependency with -# windows native paths (e.g. `c:\path\to\libfoo.a`) -# but msys make seems to fail to recognize such paths, so test fails. -ifneq ($(shell uname),FreeBSD) -ifndef IS_WINDOWS -all: - $(RUSTC) --emit dep-info main.rs - $(CGREP) "input.txt" "input.bin" "input.md" < $(TMPDIR)/main.d -else -all: - -endif - -else -all: - -endif diff --git a/src/test/run-make/include_bytes_deps/input.bin b/src/test/run-make/include_bytes_deps/input.bin deleted file mode 100644 index cd0875583aa..00000000000 --- a/src/test/run-make/include_bytes_deps/input.bin +++ /dev/null @@ -1 +0,0 @@ -Hello world! diff --git a/src/test/run-make/include_bytes_deps/input.md b/src/test/run-make/include_bytes_deps/input.md deleted file mode 100644 index 2a19b7405f7..00000000000 --- a/src/test/run-make/include_bytes_deps/input.md +++ /dev/null @@ -1 +0,0 @@ -# Hello, world! diff --git a/src/test/run-make/include_bytes_deps/input.txt b/src/test/run-make/include_bytes_deps/input.txt deleted file mode 100644 index cd0875583aa..00000000000 --- a/src/test/run-make/include_bytes_deps/input.txt +++ /dev/null @@ -1 +0,0 @@ -Hello world! diff --git a/src/test/run-make/include_bytes_deps/main.rs b/src/test/run-make/include_bytes_deps/main.rs deleted file mode 100644 index 27ca1a46a50..00000000000 --- a/src/test/run-make/include_bytes_deps/main.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(external_doc)] - -#[doc(include="input.md")] -pub struct SomeStruct; - -pub fn main() { - const INPUT_TXT: &'static str = include_str!("input.txt"); - const INPUT_BIN: &'static [u8] = include_bytes!("input.bin"); - - println!("{}", INPUT_TXT); - println!("{:?}", INPUT_BIN); -} diff --git a/src/test/run-make/inline-always-many-cgu/Makefile b/src/test/run-make/inline-always-many-cgu/Makefile deleted file mode 100644 index 0cab955f644..00000000000 --- a/src/test/run-make/inline-always-many-cgu/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs --emit llvm-ir -C codegen-units=2 - if cat $(TMPDIR)/*.ll | $(CGREP) -e '\bcall\b'; then \ - echo "found call instruction when one wasn't expected"; \ - exit 1; \ - fi diff --git a/src/test/run-make/inline-always-many-cgu/foo.rs b/src/test/run-make/inline-always-many-cgu/foo.rs deleted file mode 100644 index 539dcdfa9b3..00000000000 --- a/src/test/run-make/inline-always-many-cgu/foo.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -pub mod a { - #[inline(always)] - pub fn foo() { - } - - pub fn bar() { - } -} - -#[no_mangle] -pub fn bar() { - a::foo(); -} diff --git a/src/test/run-make/interdependent-c-libraries/Makefile b/src/test/run-make/interdependent-c-libraries/Makefile deleted file mode 100644 index 1268022e37b..00000000000 --- a/src/test/run-make/interdependent-c-libraries/Makefile +++ /dev/null @@ -1,14 +0,0 @@ --include ../tools.mk - -# The rust crate foo will link to the native library foo, while the rust crate -# bar will link to the native library bar. There is also a dependency between -# the native library bar to the natibe library foo. -# -# This test ensures that the ordering of -lfoo and -lbar on the command line is -# correct to complete the linkage. If passed as "-lfoo -lbar", then the 'foo' -# library will be stripped out, and the linkage will fail. - -all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar) - $(RUSTC) foo.rs - $(RUSTC) bar.rs - $(RUSTC) main.rs -Z print-link-args diff --git a/src/test/run-make/interdependent-c-libraries/bar.c b/src/test/run-make/interdependent-c-libraries/bar.c deleted file mode 100644 index c761f029eff..00000000000 --- a/src/test/run-make/interdependent-c-libraries/bar.c +++ /dev/null @@ -1,4 +0,0 @@ -// ignore-license -void foo(); - -void bar() { foo(); } diff --git a/src/test/run-make/interdependent-c-libraries/bar.rs b/src/test/run-make/interdependent-c-libraries/bar.rs deleted file mode 100644 index 1963976b4b0..00000000000 --- a/src/test/run-make/interdependent-c-libraries/bar.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -extern crate foo; - -#[link(name = "bar", kind = "static")] -extern { - fn bar(); -} - -pub fn doit() { - unsafe { bar(); } -} diff --git a/src/test/run-make/interdependent-c-libraries/foo.c b/src/test/run-make/interdependent-c-libraries/foo.c deleted file mode 100644 index 2895ad473bf..00000000000 --- a/src/test/run-make/interdependent-c-libraries/foo.c +++ /dev/null @@ -1,2 +0,0 @@ -// ignore-license -void foo() {} diff --git a/src/test/run-make/interdependent-c-libraries/foo.rs b/src/test/run-make/interdependent-c-libraries/foo.rs deleted file mode 100644 index 7a0fe6bb18f..00000000000 --- a/src/test/run-make/interdependent-c-libraries/foo.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[link(name = "foo", kind = "static")] -extern { - fn foo(); -} - -pub fn doit() { - unsafe { foo(); } -} diff --git a/src/test/run-make/interdependent-c-libraries/main.rs b/src/test/run-make/interdependent-c-libraries/main.rs deleted file mode 100644 index f42e3dd44a9..00000000000 --- a/src/test/run-make/interdependent-c-libraries/main.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; -extern crate bar; - -fn main() { - bar::doit(); -} diff --git a/src/test/run-make/intrinsic-unreachable/Makefile b/src/test/run-make/intrinsic-unreachable/Makefile deleted file mode 100644 index 305e8a7ddc9..00000000000 --- a/src/test/run-make/intrinsic-unreachable/Makefile +++ /dev/null @@ -1,15 +0,0 @@ --include ../tools.mk - -ifndef IS_WINDOWS -# The assembly for exit-unreachable.rs should be shorter because it's missing -# (at minimum) a return instruction. - -all: - $(RUSTC) -O --emit asm exit-ret.rs - $(RUSTC) -O --emit asm exit-unreachable.rs - test `wc -l < $(TMPDIR)/exit-unreachable.s` -lt `wc -l < $(TMPDIR)/exit-ret.s` -else -# Because of Windows exception handling, the code is not necessarily any shorter. -# https://github.com/llvm-mirror/llvm/commit/64b2297786f7fd6f5fa24cdd4db0298fbf211466 -all: -endif diff --git a/src/test/run-make/intrinsic-unreachable/exit-ret.rs b/src/test/run-make/intrinsic-unreachable/exit-ret.rs deleted file mode 100644 index 1b8b644dd78..00000000000 --- a/src/test/run-make/intrinsic-unreachable/exit-ret.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(asm)] -#![crate_type="lib"] - -#[deny(unreachable_code)] -pub fn exit(n: usize) -> i32 { - unsafe { - // Pretend this asm is an exit() syscall. - asm!("" :: "r"(n) :: "volatile"); - // Can't actually reach this point, but rustc doesn't know that. - } - // This return value is just here to generate some extra code for a return - // value, making it easier for the test script to detect whether the - // compiler deleted it. - 42 -} diff --git a/src/test/run-make/intrinsic-unreachable/exit-unreachable.rs b/src/test/run-make/intrinsic-unreachable/exit-unreachable.rs deleted file mode 100644 index de63809ab66..00000000000 --- a/src/test/run-make/intrinsic-unreachable/exit-unreachable.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(asm, core_intrinsics)] -#![crate_type="lib"] - -use std::intrinsics; - -#[allow(unreachable_code)] -pub fn exit(n: usize) -> i32 { - unsafe { - // Pretend this asm is an exit() syscall. - asm!("" :: "r"(n) :: "volatile"); - intrinsics::unreachable() - } - // This return value is just here to generate some extra code for a return - // value, making it easier for the test script to detect whether the - // compiler deleted it. - 42 -} diff --git a/src/test/run-make/invalid-library/Makefile b/src/test/run-make/invalid-library/Makefile deleted file mode 100644 index b6fb122d98b..00000000000 --- a/src/test/run-make/invalid-library/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - touch $(TMPDIR)/rust.metadata.bin - $(AR) crus $(TMPDIR)/libfoo-ffffffff-1.0.rlib $(TMPDIR)/rust.metadata.bin - $(RUSTC) foo.rs 2>&1 | $(CGREP) "can't find crate for" diff --git a/src/test/run-make/invalid-library/foo.rs b/src/test/run-make/invalid-library/foo.rs deleted file mode 100644 index 6316cfa3bba..00000000000 --- a/src/test/run-make/invalid-library/foo.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() {} diff --git a/src/test/run-make/invalid-staticlib/Makefile b/src/test/run-make/invalid-staticlib/Makefile deleted file mode 100644 index 3a91902ccce..00000000000 --- a/src/test/run-make/invalid-staticlib/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - touch $(TMPDIR)/libfoo.a - echo | $(RUSTC) - --crate-type=rlib -lstatic=foo 2>&1 | $(CGREP) "failed to add native library" diff --git a/src/test/run-make/issue-11908/Makefile b/src/test/run-make/issue-11908/Makefile deleted file mode 100644 index cf6572c27ad..00000000000 --- a/src/test/run-make/issue-11908/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# This test ensures that if you have the same rlib or dylib at two locations -# in the same path that you don't hit an assertion in the compiler. -# -# Note that this relies on `liburl` to be in the path somewhere else, -# and then our aux-built libraries will collide with liburl (they have -# the same version listed) - --include ../tools.mk - -all: - mkdir $(TMPDIR)/other - $(RUSTC) foo.rs --crate-type=dylib -C prefer-dynamic - mv $(call DYLIB,foo) $(TMPDIR)/other - $(RUSTC) foo.rs --crate-type=dylib -C prefer-dynamic - $(RUSTC) bar.rs -L $(TMPDIR)/other - rm -rf $(TMPDIR) - mkdir -p $(TMPDIR)/other - $(RUSTC) foo.rs --crate-type=rlib - mv $(TMPDIR)/libfoo.rlib $(TMPDIR)/other - $(RUSTC) foo.rs --crate-type=rlib - $(RUSTC) bar.rs -L $(TMPDIR)/other diff --git a/src/test/run-make/issue-11908/bar.rs b/src/test/run-make/issue-11908/bar.rs deleted file mode 100644 index 6316cfa3bba..00000000000 --- a/src/test/run-make/issue-11908/bar.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() {} diff --git a/src/test/run-make/issue-11908/foo.rs b/src/test/run-make/issue-11908/foo.rs deleted file mode 100644 index 0858d3c4e47..00000000000 --- a/src/test/run-make/issue-11908/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "foo"] diff --git a/src/test/run-make/issue-14500/Makefile b/src/test/run-make/issue-14500/Makefile deleted file mode 100644 index bd94db09520..00000000000 --- a/src/test/run-make/issue-14500/Makefile +++ /dev/null @@ -1,17 +0,0 @@ --include ../tools.mk - -# Test to make sure that reachable extern fns are always available in final -# productcs, including when LTO is used. In this test, the `foo` crate has a -# reahable symbol, and is a dependency of the `bar` crate. When the `bar` crate -# is compiled with LTO, it shouldn't strip the symbol from `foo`, and that's the -# only way that `foo.c` will successfully compile. - -ifeq ($(UNAME),Bitrig) - EXTRACFLAGS := -lc $(EXTRACFLAGS) $(EXTRACXXFLAGS) -endif - -all: - $(RUSTC) foo.rs --crate-type=rlib - $(RUSTC) bar.rs --crate-type=staticlib -C lto -L. -o $(TMPDIR)/libbar.a - $(CC) foo.c $(TMPDIR)/libbar.a $(EXTRACFLAGS) $(call OUT_EXE,foo) - $(call RUN,foo) diff --git a/src/test/run-make/issue-14500/bar.rs b/src/test/run-make/issue-14500/bar.rs deleted file mode 100644 index 4b4916fe96d..00000000000 --- a/src/test/run-make/issue-14500/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; diff --git a/src/test/run-make/issue-14500/foo.c b/src/test/run-make/issue-14500/foo.c deleted file mode 100644 index e84b5509c50..00000000000 --- a/src/test/run-make/issue-14500/foo.c +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern void foo(); -extern char FOO_STATIC; - -int main() { - foo(); - return (int)FOO_STATIC; -} diff --git a/src/test/run-make/issue-14500/foo.rs b/src/test/run-make/issue-14500/foo.rs deleted file mode 100644 index a91d8d6a21d..00000000000 --- a/src/test/run-make/issue-14500/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[no_mangle] -pub extern fn foo() {} - -#[no_mangle] -pub static FOO_STATIC: u8 = 0; diff --git a/src/test/run-make/issue-14698/Makefile b/src/test/run-make/issue-14698/Makefile deleted file mode 100644 index dbe8317dbc4..00000000000 --- a/src/test/run-make/issue-14698/Makefile +++ /dev/null @@ -1,4 +0,0 @@ --include ../tools.mk - -all: - TMP=fake TMPDIR=fake $(RUSTC) foo.rs 2>&1 | $(CGREP) "couldn't create a temp dir:" diff --git a/src/test/run-make/issue-14698/foo.rs b/src/test/run-make/issue-14698/foo.rs deleted file mode 100644 index 7dc79f2043b..00000000000 --- a/src/test/run-make/issue-14698/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/issue-15460/Makefile b/src/test/run-make/issue-15460/Makefile deleted file mode 100644 index 846805686a1..00000000000 --- a/src/test/run-make/issue-15460/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,foo) - $(RUSTC) foo.rs -C extra-filename=-383hf8 -C prefer-dynamic - $(RUSTC) bar.rs - $(call RUN,bar) diff --git a/src/test/run-make/issue-15460/bar.rs b/src/test/run-make/issue-15460/bar.rs deleted file mode 100644 index 46777f7fbd2..00000000000 --- a/src/test/run-make/issue-15460/bar.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; -fn main() { - unsafe { foo::foo() } -} diff --git a/src/test/run-make/issue-15460/foo.c b/src/test/run-make/issue-15460/foo.c deleted file mode 100644 index fdf595b574e..00000000000 --- a/src/test/run-make/issue-15460/foo.c +++ /dev/null @@ -1,6 +0,0 @@ -// ignore-license - -#ifdef _WIN32 -__declspec(dllexport) -#endif -void foo() {} diff --git a/src/test/run-make/issue-15460/foo.rs b/src/test/run-make/issue-15460/foo.rs deleted file mode 100644 index 6917fa55579..00000000000 --- a/src/test/run-make/issue-15460/foo.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -#[link(name = "foo", kind = "static")] -extern { - pub fn foo(); -} diff --git a/src/test/run-make/issue-18943/Makefile b/src/test/run-make/issue-18943/Makefile deleted file mode 100644 index bef70a0edaa..00000000000 --- a/src/test/run-make/issue-18943/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -# Regression test for ICE #18943 when compiling as lib - -all: - $(RUSTC) foo.rs --crate-type lib - $(call REMOVE_RLIBS,foo) && exit 0 || exit 1 diff --git a/src/test/run-make/issue-18943/foo.rs b/src/test/run-make/issue-18943/foo.rs deleted file mode 100644 index aadf0f593e7..00000000000 --- a/src/test/run-make/issue-18943/foo.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Foo { } - -trait Bar { } - -impl<'a> Foo for Bar + 'a { } - diff --git a/src/test/run-make/issue-19371/Makefile b/src/test/run-make/issue-19371/Makefile deleted file mode 100644 index 9f3ec78465b..00000000000 --- a/src/test/run-make/issue-19371/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -# This test ensures that rustc compile_input can be called twice in one task -# without causing a panic. -# The program needs the path to rustc to get sysroot. - -all: - $(RUSTC) foo.rs - $(call RUN,foo $(TMPDIR) $(RUSTC)) diff --git a/src/test/run-make/issue-19371/foo.rs b/src/test/run-make/issue-19371/foo.rs deleted file mode 100644 index e0db2627d85..00000000000 --- a/src/test/run-make/issue-19371/foo.rs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_private)] - -extern crate rustc; -extern crate rustc_driver; -extern crate rustc_lint; -extern crate rustc_metadata; -extern crate rustc_errors; -extern crate rustc_trans_utils; -extern crate syntax; - -use rustc::session::{build_session, Session}; -use rustc::session::config::{basic_options, Input, - OutputType, OutputTypes}; -use rustc_driver::driver::{compile_input, CompileController}; -use rustc_metadata::cstore::CStore; -use rustc_errors::registry::Registry; -use syntax::codemap::FileName; -use rustc_trans_utils::trans_crate::TransCrate; - -use std::path::PathBuf; -use std::rc::Rc; - -fn main() { - let src = r#" - fn main() {} - "#; - - let args: Vec = std::env::args().collect(); - - if args.len() < 4 { - panic!("expected rustc path"); - } - - let tmpdir = PathBuf::from(&args[1]); - - let mut sysroot = PathBuf::from(&args[3]); - sysroot.pop(); - sysroot.pop(); - - compile(src.to_string(), tmpdir.join("out"), sysroot.clone()); - - compile(src.to_string(), tmpdir.join("out"), sysroot.clone()); -} - -fn basic_sess(sysroot: PathBuf) -> (Session, Rc, Box) { - let mut opts = basic_options(); - opts.output_types = OutputTypes::new(&[(OutputType::Exe, None)]); - opts.maybe_sysroot = Some(sysroot); - if let Ok(linker) = std::env::var("RUSTC_LINKER") { - opts.cg.linker = Some(linker.into()); - } - - let descriptions = Registry::new(&rustc::DIAGNOSTICS); - let sess = build_session(opts, None, descriptions); - let trans = rustc_driver::get_trans(&sess); - let cstore = Rc::new(CStore::new(trans.metadata_loader())); - rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); - (sess, cstore, trans) -} - -fn compile(code: String, output: PathBuf, sysroot: PathBuf) { - syntax::with_globals(|| { - let (sess, cstore, trans) = basic_sess(sysroot); - let control = CompileController::basic(); - let input = Input::Str { name: FileName::Anon, input: code }; - let _ = compile_input( - trans, - &sess, - &cstore, - &None, - &input, - &None, - &Some(output), - None, - &control - ); - }); -} diff --git a/src/test/run-make/issue-20626/Makefile b/src/test/run-make/issue-20626/Makefile deleted file mode 100644 index 0487b240400..00000000000 --- a/src/test/run-make/issue-20626/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -# Test output to be four -# The original error only occurred when printing, not when comparing using assert! - -all: - $(RUSTC) foo.rs -O - [ `$(call RUN,foo)` = "4" ] diff --git a/src/test/run-make/issue-20626/foo.rs b/src/test/run-make/issue-20626/foo.rs deleted file mode 100644 index 9f727607e4e..00000000000 --- a/src/test/run-make/issue-20626/foo.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn identity(a: &u32) -> &u32 { a } - -fn print_foo(f: &fn(&u32) -> &u32, x: &u32) { - print!("{}", (*f)(x)); -} - -fn main() { - let x = &4; - let f: fn(&u32) -> &u32 = identity; - - // Didn't print 4 on optimized builds - print_foo(&f, x); -} diff --git a/src/test/run-make/issue-22131/Makefile b/src/test/run-make/issue-22131/Makefile deleted file mode 100644 index 6db737a9e72..00000000000 --- a/src/test/run-make/issue-22131/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -all: foo.rs - $(RUSTC) --cfg 'feature="bar"' --crate-type lib foo.rs - $(RUSTDOC) --test --cfg 'feature="bar"' \ - -L $(TMPDIR) foo.rs |\ - $(CGREP) 'foo.rs - foo (line 11) ... ok' diff --git a/src/test/run-make/issue-22131/foo.rs b/src/test/run-make/issue-22131/foo.rs deleted file mode 100644 index 50c63abc0d4..00000000000 --- a/src/test/run-make/issue-22131/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/// ```rust -/// assert_eq!(foo::foo(), 1); -/// ``` -#[cfg(feature = "bar")] -pub fn foo() -> i32 { 1 } diff --git a/src/test/run-make/issue-24445/Makefile b/src/test/run-make/issue-24445/Makefile deleted file mode 100644 index 2ed971bf7d9..00000000000 --- a/src/test/run-make/issue-24445/Makefile +++ /dev/null @@ -1,12 +0,0 @@ --include ../tools.mk - -ifeq ($(UNAME),Linux) -all: - $(RUSTC) foo.rs - $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -o $(TMPDIR)/foo - $(call RUN,foo) - $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -pie -fPIC -o $(TMPDIR)/foo - $(call RUN,foo) -else -all: -endif diff --git a/src/test/run-make/issue-24445/foo.c b/src/test/run-make/issue-24445/foo.c deleted file mode 100644 index 775e151f236..00000000000 --- a/src/test/run-make/issue-24445/foo.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -void foo(); - -int main() { - foo(); - return 0; -} diff --git a/src/test/run-make/issue-24445/foo.rs b/src/test/run-make/issue-24445/foo.rs deleted file mode 100644 index 65e505df5ef..00000000000 --- a/src/test/run-make/issue-24445/foo.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "staticlib"] - -struct Destroy; -impl Drop for Destroy { - fn drop(&mut self) { println!("drop"); } -} - -thread_local! { - static X: Destroy = Destroy -} - -#[no_mangle] -pub extern "C" fn foo() { - X.with(|_| ()); -} diff --git a/src/test/run-make/issue-25581/Makefile b/src/test/run-make/issue-25581/Makefile deleted file mode 100644 index 042048ec25f..00000000000 --- a/src/test/run-make/issue-25581/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/src/test/run-make/issue-25581/test.c b/src/test/run-make/issue-25581/test.c deleted file mode 100644 index 5736b173021..00000000000 --- a/src/test/run-make/issue-25581/test.c +++ /dev/null @@ -1,16 +0,0 @@ -// ignore-license -#include -#include - -struct ByteSlice { - uint8_t *data; - size_t len; -}; - -size_t slice_len(struct ByteSlice bs) { - return bs.len; -} - -uint8_t slice_elem(struct ByteSlice bs, size_t idx) { - return bs.data[idx]; -} diff --git a/src/test/run-make/issue-25581/test.rs b/src/test/run-make/issue-25581/test.rs deleted file mode 100644 index 6717d16cb7c..00000000000 --- a/src/test/run-make/issue-25581/test.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(libc)] - -extern crate libc; - -#[link(name = "test", kind = "static")] -extern { - fn slice_len(s: &[u8]) -> libc::size_t; - fn slice_elem(s: &[u8], idx: libc::size_t) -> u8; -} - -fn main() { - let data = [1,2,3,4,5]; - - unsafe { - assert_eq!(data.len(), slice_len(&data) as usize); - assert_eq!(data[0], slice_elem(&data, 0)); - assert_eq!(data[1], slice_elem(&data, 1)); - assert_eq!(data[2], slice_elem(&data, 2)); - assert_eq!(data[3], slice_elem(&data, 3)); - assert_eq!(data[4], slice_elem(&data, 4)); - } -} diff --git a/src/test/run-make/issue-26006/Makefile b/src/test/run-make/issue-26006/Makefile deleted file mode 100644 index 66aa78d5386..00000000000 --- a/src/test/run-make/issue-26006/Makefile +++ /dev/null @@ -1,18 +0,0 @@ --include ../tools.mk - -OUT := $(TMPDIR)/out - -ifndef IS_WINDOWS -all: time - -time: libc - mkdir -p $(OUT)/time $(OUT)/time/deps - ln -sf $(OUT)/libc/liblibc.rlib $(OUT)/time/deps/ - $(RUSTC) in/time/lib.rs -Ldependency=$(OUT)/time/deps/ - -libc: - mkdir -p $(OUT)/libc - $(RUSTC) in/libc/lib.rs --crate-name=libc -Cmetadata=foo -o $(OUT)/libc/liblibc.rlib -else -all: -endif diff --git a/src/test/run-make/issue-26006/in/libc/lib.rs b/src/test/run-make/issue-26006/in/libc/lib.rs deleted file mode 100644 index 177ffdce062..00000000000 --- a/src/test/run-make/issue-26006/in/libc/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -#![crate_type="rlib"] - -pub fn something(){} diff --git a/src/test/run-make/issue-26006/in/time/lib.rs b/src/test/run-make/issue-26006/in/time/lib.rs deleted file mode 100644 index b1d07d57337..00000000000 --- a/src/test/run-make/issue-26006/in/time/lib.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -#![feature(libc)] -extern crate libc; - -fn main(){} diff --git a/src/test/run-make/issue-26092/Makefile b/src/test/run-make/issue-26092/Makefile deleted file mode 100644 index 27631c31c4a..00000000000 --- a/src/test/run-make/issue-26092/Makefile +++ /dev/null @@ -1,4 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -o "" blank.rs 2>&1 | $(CGREP) -i 'No such file or directory' diff --git a/src/test/run-make/issue-26092/blank.rs b/src/test/run-make/issue-26092/blank.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/issue-26092/blank.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/issue-28595/Makefile b/src/test/run-make/issue-28595/Makefile deleted file mode 100644 index 61e9d0c6547..00000000000 --- a/src/test/run-make/issue-28595/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,a) $(call NATIVE_STATICLIB,b) - $(RUSTC) a.rs - $(RUSTC) b.rs - $(call RUN,b) diff --git a/src/test/run-make/issue-28595/a.c b/src/test/run-make/issue-28595/a.c deleted file mode 100644 index feacd7bc313..00000000000 --- a/src/test/run-make/issue-28595/a.c +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -void a(void) {} diff --git a/src/test/run-make/issue-28595/a.rs b/src/test/run-make/issue-28595/a.rs deleted file mode 100644 index 7377a9f3416..00000000000 --- a/src/test/run-make/issue-28595/a.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[link(name = "a", kind = "static")] -extern { - pub fn a(); -} diff --git a/src/test/run-make/issue-28595/b.c b/src/test/run-make/issue-28595/b.c deleted file mode 100644 index de81fbcaa60..00000000000 --- a/src/test/run-make/issue-28595/b.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern void a(void); - -void b(void) { - a(); -} - diff --git a/src/test/run-make/issue-28595/b.rs b/src/test/run-make/issue-28595/b.rs deleted file mode 100644 index 37ff346c3f3..00000000000 --- a/src/test/run-make/issue-28595/b.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate a; - -#[link(name = "b", kind = "static")] -extern { - pub fn b(); -} - - -fn main() { - unsafe { b(); } -} diff --git a/src/test/run-make/issue-28766/Makefile b/src/test/run-make/issue-28766/Makefile deleted file mode 100644 index 1f47ef15b27..00000000000 --- a/src/test/run-make/issue-28766/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -O foo.rs - $(RUSTC) -O -L $(TMPDIR) main.rs diff --git a/src/test/run-make/issue-28766/foo.rs b/src/test/run-make/issue-28766/foo.rs deleted file mode 100644 index 3ed0a6bfc74..00000000000 --- a/src/test/run-make/issue-28766/foo.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] -pub struct Foo(()); - -impl Foo { - pub fn new() -> Foo { - Foo(()) - } -} diff --git a/src/test/run-make/issue-28766/main.rs b/src/test/run-make/issue-28766/main.rs deleted file mode 100644 index d1dadbdc7ad..00000000000 --- a/src/test/run-make/issue-28766/main.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] -extern crate foo; -use foo::Foo; - -pub fn crash() -> Box { - Box::new(Foo::new()) -} diff --git a/src/test/run-make/issue-30063/Makefile b/src/test/run-make/issue-30063/Makefile deleted file mode 100644 index a76051dc81e..00000000000 --- a/src/test/run-make/issue-30063/Makefile +++ /dev/null @@ -1,35 +0,0 @@ --include ../tools.mk - -all: - rm -f $(TMPDIR)/foo-output - $(RUSTC) -C codegen-units=4 -o $(TMPDIR)/foo-output foo.rs - rm $(TMPDIR)/foo-output - - rm -f $(TMPDIR)/asm-output - $(RUSTC) -C codegen-units=4 --emit=asm -o $(TMPDIR)/asm-output foo.rs - rm $(TMPDIR)/asm-output - - rm -f $(TMPDIR)/bc-output - $(RUSTC) -C codegen-units=4 --emit=llvm-bc -o $(TMPDIR)/bc-output foo.rs - rm $(TMPDIR)/bc-output - - rm -f $(TMPDIR)/ir-output - $(RUSTC) -C codegen-units=4 --emit=llvm-ir -o $(TMPDIR)/ir-output foo.rs - rm $(TMPDIR)/ir-output - - rm -f $(TMPDIR)/link-output - $(RUSTC) -C codegen-units=4 --emit=link -o $(TMPDIR)/link-output foo.rs - rm $(TMPDIR)/link-output - - rm -f $(TMPDIR)/obj-output - $(RUSTC) -C codegen-units=4 --emit=obj -o $(TMPDIR)/obj-output foo.rs - rm $(TMPDIR)/obj-output - - rm -f $(TMPDIR)/dep-output - $(RUSTC) -C codegen-units=4 --emit=dep-info -o $(TMPDIR)/dep-output foo.rs - rm $(TMPDIR)/dep-output - -# # (This case doesn't work yet, and may be fundamentally wrong-headed anyway.) -# rm -f $(TMPDIR)/multi-output -# $(RUSTC) -C codegen-units=4 --emit=asm,obj -o $(TMPDIR)/multi-output foo.rs -# rm $(TMPDIR)/multi-output diff --git a/src/test/run-make/issue-30063/foo.rs b/src/test/run-make/issue-30063/foo.rs deleted file mode 100644 index 45f7a2c2aa6..00000000000 --- a/src/test/run-make/issue-30063/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { } diff --git a/src/test/run-make/issue-33329/Makefile b/src/test/run-make/issue-33329/Makefile deleted file mode 100644 index 591e4e3dda3..00000000000 --- a/src/test/run-make/issue-33329/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) --target x86_64_unknown-linux-musl main.rs 2>&1 | $(CGREP) \ - "error: Error loading target specification: Could not find specification for target" diff --git a/src/test/run-make/issue-33329/main.rs b/src/test/run-make/issue-33329/main.rs deleted file mode 100644 index e06c0a5ec2a..00000000000 --- a/src/test/run-make/issue-33329/main.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/issue-35164/Makefile b/src/test/run-make/issue-35164/Makefile deleted file mode 100644 index 6a451656dcb..00000000000 --- a/src/test/run-make/issue-35164/Makefile +++ /dev/null @@ -1,4 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) main.rs --error-format json 2>&1 | $(CGREP) -e '"byte_start":490\b' '"byte_end":496\b' diff --git a/src/test/run-make/issue-35164/main.rs b/src/test/run-make/issue-35164/main.rs deleted file mode 100644 index 24322a2484f..00000000000 --- a/src/test/run-make/issue-35164/main.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod submodule; - -fn main() { - submodule::foo(); -} diff --git a/src/test/run-make/issue-35164/submodule/mod.rs b/src/test/run-make/issue-35164/submodule/mod.rs deleted file mode 100644 index 7847c13af78..00000000000 --- a/src/test/run-make/issue-35164/submodule/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() { - let _MyFoo = 2; -} diff --git a/src/test/run-make/issue-37839/Makefile b/src/test/run-make/issue-37839/Makefile deleted file mode 100644 index 8b3355b9622..00000000000 --- a/src/test/run-make/issue-37839/Makefile +++ /dev/null @@ -1,12 +0,0 @@ --include ../tools.mk - -ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) -# ignore stage1 -all: - -else -all: - $(RUSTC) a.rs && $(RUSTC) b.rs - $(BARE_RUSTC) c.rs -L dependency=$(TMPDIR) --extern b=$(TMPDIR)/libb.rlib \ - --out-dir=$(TMPDIR) -endif diff --git a/src/test/run-make/issue-37839/a.rs b/src/test/run-make/issue-37839/a.rs deleted file mode 100644 index 052317438c2..00000000000 --- a/src/test/run-make/issue-37839/a.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused)] -#![crate_type = "proc-macro"] diff --git a/src/test/run-make/issue-37839/b.rs b/src/test/run-make/issue-37839/b.rs deleted file mode 100644 index 82f48f6d8d6..00000000000 --- a/src/test/run-make/issue-37839/b.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -#[macro_use] extern crate a; diff --git a/src/test/run-make/issue-37839/c.rs b/src/test/run-make/issue-37839/c.rs deleted file mode 100644 index 85bece51427..00000000000 --- a/src/test/run-make/issue-37839/c.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -extern crate b; diff --git a/src/test/run-make/issue-37893/Makefile b/src/test/run-make/issue-37893/Makefile deleted file mode 100644 index c7732cc2682..00000000000 --- a/src/test/run-make/issue-37893/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) -# ignore stage1 -all: - -else -all: - $(RUSTC) a.rs && $(RUSTC) b.rs && $(RUSTC) c.rs -endif diff --git a/src/test/run-make/issue-37893/a.rs b/src/test/run-make/issue-37893/a.rs deleted file mode 100644 index 052317438c2..00000000000 --- a/src/test/run-make/issue-37893/a.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused)] -#![crate_type = "proc-macro"] diff --git a/src/test/run-make/issue-37893/b.rs b/src/test/run-make/issue-37893/b.rs deleted file mode 100644 index 82f48f6d8d6..00000000000 --- a/src/test/run-make/issue-37893/b.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -#[macro_use] extern crate a; diff --git a/src/test/run-make/issue-37893/c.rs b/src/test/run-make/issue-37893/c.rs deleted file mode 100644 index eee55cc2369..00000000000 --- a/src/test/run-make/issue-37893/c.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "staticlib"] -extern crate b; -extern crate a; diff --git a/src/test/run-make/issue-38237/Makefile b/src/test/run-make/issue-38237/Makefile deleted file mode 100644 index 855d958b344..00000000000 --- a/src/test/run-make/issue-38237/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) -# ignore stage1 -all: - -else -all: - $(RUSTC) foo.rs; $(RUSTC) bar.rs - $(RUSTDOC) baz.rs -L $(TMPDIR) -o $(TMPDIR) -endif diff --git a/src/test/run-make/issue-38237/bar.rs b/src/test/run-make/issue-38237/bar.rs deleted file mode 100644 index 794e08c2fe3..00000000000 --- a/src/test/run-make/issue-38237/bar.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -#[derive(Debug)] -pub struct S; diff --git a/src/test/run-make/issue-38237/baz.rs b/src/test/run-make/issue-38237/baz.rs deleted file mode 100644 index c2a2c89db01..00000000000 --- a/src/test/run-make/issue-38237/baz.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; -extern crate bar; - -pub struct Bar; -impl ::std::ops::Deref for Bar { - type Target = bar::S; - fn deref(&self) -> &Self::Target { unimplemented!() } -} diff --git a/src/test/run-make/issue-38237/foo.rs b/src/test/run-make/issue-38237/foo.rs deleted file mode 100644 index 6fb315731de..00000000000 --- a/src/test/run-make/issue-38237/foo.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -#[proc_macro_derive(A)] -pub fn derive(ts: proc_macro::TokenStream) -> proc_macro::TokenStream { ts } - -#[derive(Debug)] -struct S; diff --git a/src/test/run-make/issue-40535/Makefile b/src/test/run-make/issue-40535/Makefile deleted file mode 100644 index 49db1d43e47..00000000000 --- a/src/test/run-make/issue-40535/Makefile +++ /dev/null @@ -1,13 +0,0 @@ --include ../tools.mk - -# The ICE occurred in the following situation: -# * `foo` declares `extern crate bar, baz`, depends only on `bar` (forgetting `baz` in `Cargo.toml`) -# * `bar` declares and depends on `extern crate baz` -# * All crates built in metadata-only mode (`cargo check`) -all: - # cc https://github.com/rust-lang/rust/issues/40623 - $(RUSTC) baz.rs --emit=metadata - $(RUSTC) bar.rs --emit=metadata --extern baz=$(TMPDIR)/libbaz.rmeta - $(RUSTC) foo.rs --emit=metadata --extern bar=$(TMPDIR)/libbar.rmeta 2>&1 | \ - $(CGREP) -v "unexpectedly panicked" - # ^ Succeeds if it doesn't find the ICE message diff --git a/src/test/run-make/issue-40535/bar.rs b/src/test/run-make/issue-40535/bar.rs deleted file mode 100644 index 4c22f181975..00000000000 --- a/src/test/run-make/issue-40535/bar.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -extern crate baz; diff --git a/src/test/run-make/issue-40535/baz.rs b/src/test/run-make/issue-40535/baz.rs deleted file mode 100644 index 737a918a039..00000000000 --- a/src/test/run-make/issue-40535/baz.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] diff --git a/src/test/run-make/issue-40535/foo.rs b/src/test/run-make/issue-40535/foo.rs deleted file mode 100644 index 53a8c8636b1..00000000000 --- a/src/test/run-make/issue-40535/foo.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -extern crate bar; -extern crate baz; diff --git a/src/test/run-make/issue-46239/Makefile b/src/test/run-make/issue-46239/Makefile deleted file mode 100644 index 698a605f7e9..00000000000 --- a/src/test/run-make/issue-46239/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) main.rs -C opt-level=1 - $(call RUN,main) diff --git a/src/test/run-make/issue-46239/main.rs b/src/test/run-make/issue-46239/main.rs deleted file mode 100644 index 3b3289168ab..00000000000 --- a/src/test/run-make/issue-46239/main.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn project(x: &(T,)) -> &T { &x.0 } - -fn dummy() {} - -fn main() { - let f = (dummy as fn(),); - (*project(&f))(); -} diff --git a/src/test/run-make/issue-7349/Makefile b/src/test/run-make/issue-7349/Makefile deleted file mode 100644 index 50dc63b1deb..00000000000 --- a/src/test/run-make/issue-7349/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -# Test to make sure that inner functions within a polymorphic outer function -# don't get re-translated when the outer function is monomorphized. The test -# code monomorphizes the outer functions several times, but the magic constants -# used in the inner functions should each appear only once in the generated IR. - -all: - $(RUSTC) foo.rs --emit=llvm-ir - [ "$$(grep -c 'ret i32 8675309' "$(TMPDIR)/foo.ll")" -eq "1" ] - [ "$$(grep -c 'ret i32 11235813' "$(TMPDIR)/foo.ll")" -eq "1" ] diff --git a/src/test/run-make/issue-7349/foo.rs b/src/test/run-make/issue-7349/foo.rs deleted file mode 100644 index b75c82afb53..00000000000 --- a/src/test/run-make/issue-7349/foo.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn outer() { - #[allow(dead_code)] - fn inner() -> u32 { - 8675309 - } - inner(); -} - -extern "C" fn outer_foreign() { - #[allow(dead_code)] - fn inner() -> u32 { - 11235813 - } - inner(); -} - -fn main() { - outer::(); - outer::(); - outer_foreign::(); - outer_foreign::(); -} diff --git a/src/test/run-make/issues-41478-43796/Makefile b/src/test/run-make/issues-41478-43796/Makefile deleted file mode 100644 index f9735253ab6..00000000000 --- a/src/test/run-make/issues-41478-43796/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: - # Work in /tmp, because we need to create the `save-analysis-temp` folder. - cp a.rs $(TMPDIR)/ - cd $(TMPDIR) && $(RUSTC) -Zsave-analysis $(TMPDIR)/a.rs 2> $(TMPDIR)/stderr.txt || ( cat $(TMPDIR)/stderr.txt && exit 1 ) - [ ! -s $(TMPDIR)/stderr.txt ] || ( cat $(TMPDIR)/stderr.txt && exit 1 ) - [ -f $(TMPDIR)/save-analysis/liba.json ] || ( ls -la $(TMPDIR) && exit 1 ) diff --git a/src/test/run-make/issues-41478-43796/a.rs b/src/test/run-make/issues-41478-43796/a.rs deleted file mode 100644 index 9d95f8b2585..00000000000 --- a/src/test/run-make/issues-41478-43796/a.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -pub struct V(S); -pub trait An { - type U; -} -pub trait F { -} -impl F for V<::U> { -} diff --git a/src/test/run-make/libs-and-bins/Makefile b/src/test/run-make/libs-and-bins/Makefile deleted file mode 100644 index cc3b257a5c5..00000000000 --- a/src/test/run-make/libs-and-bins/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs - $(call RUN,foo) - rm $(TMPDIR)/$(call DYLIB_GLOB,foo) diff --git a/src/test/run-make/libs-and-bins/foo.rs b/src/test/run-make/libs-and-bins/foo.rs deleted file mode 100644 index 2ebe63928ca..00000000000 --- a/src/test/run-make/libs-and-bins/foo.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] -#![crate_type = "bin"] - -fn main() {} diff --git a/src/test/run-make/libs-through-symlinks/Makefile b/src/test/run-make/libs-through-symlinks/Makefile deleted file mode 100644 index 2f425121f66..00000000000 --- a/src/test/run-make/libs-through-symlinks/Makefile +++ /dev/null @@ -1,14 +0,0 @@ --include ../tools.mk - -ifdef IS_WINDOWS -all: -else - -NAME := $(shell $(RUSTC) --print file-names foo.rs) - -all: - mkdir -p $(TMPDIR)/outdir - $(RUSTC) foo.rs -o $(TMPDIR)/outdir/$(NAME) - ln -nsf outdir/$(NAME) $(TMPDIR) - RUST_LOG=rustc_metadata::loader $(RUSTC) bar.rs -endif diff --git a/src/test/run-make/libs-through-symlinks/bar.rs b/src/test/run-make/libs-through-symlinks/bar.rs deleted file mode 100644 index 6316cfa3bba..00000000000 --- a/src/test/run-make/libs-through-symlinks/bar.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() {} diff --git a/src/test/run-make/libs-through-symlinks/foo.rs b/src/test/run-make/libs-through-symlinks/foo.rs deleted file mode 100644 index dd818cf8798..00000000000 --- a/src/test/run-make/libs-through-symlinks/foo.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![crate_name = "foo"] diff --git a/src/test/run-make/libtest-json/Makefile b/src/test/run-make/libtest-json/Makefile deleted file mode 100644 index ec91ddfb9f9..00000000000 --- a/src/test/run-make/libtest-json/Makefile +++ /dev/null @@ -1,14 +0,0 @@ --include ../tools.mk - -# Test expected libtest's JSON output - -OUTPUT_FILE := $(TMPDIR)/libtest-json-output.json - -all: - $(RUSTC) --test f.rs - $(call RUN,f) -Z unstable-options --test-threads=1 --format=json > $(OUTPUT_FILE) || true - - cat $(OUTPUT_FILE) | "$(PYTHON)" validate_json.py - - # Compare to output file - diff output.json $(OUTPUT_FILE) diff --git a/src/test/run-make/libtest-json/f.rs b/src/test/run-make/libtest-json/f.rs deleted file mode 100644 index 5cff1f1a5b1..00000000000 --- a/src/test/run-make/libtest-json/f.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[test] -fn a() { - // Should pass -} - -#[test] -fn b() { - assert!(false) -} - -#[test] -#[should_panic] -fn c() { - assert!(false); -} - -#[test] -#[ignore] -fn d() { - assert!(false); -} - diff --git a/src/test/run-make/libtest-json/output.json b/src/test/run-make/libtest-json/output.json deleted file mode 100644 index 235f8cd7c72..00000000000 --- a/src/test/run-make/libtest-json/output.json +++ /dev/null @@ -1,10 +0,0 @@ -{ "type": "suite", "event": "started", "test_count": "4" } -{ "type": "test", "event": "started", "name": "a" } -{ "type": "test", "name": "a", "event": "ok" } -{ "type": "test", "event": "started", "name": "b" } -{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at 'assertion failed: false', f.rs:18:5\nnote: Run with `RUST_BACKTRACE=1` for a backtrace.\n" } -{ "type": "test", "event": "started", "name": "c" } -{ "type": "test", "name": "c", "event": "ok" } -{ "type": "test", "event": "started", "name": "d" } -{ "type": "test", "name": "d", "event": "ignored" } -{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "allowed_fail": 0, "ignored": 1, "measured": 0, "filtered_out": "0" } diff --git a/src/test/run-make/libtest-json/validate_json.py b/src/test/run-make/libtest-json/validate_json.py deleted file mode 100755 index 1e97639b524..00000000000 --- a/src/test/run-make/libtest-json/validate_json.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2016 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -import sys -import json - -# Try to decode line in order to ensure it is a valid JSON document -for line in sys.stdin: - json.loads(line) diff --git a/src/test/run-make/link-arg/Makefile b/src/test/run-make/link-arg/Makefile deleted file mode 100644 index d7c9fd27112..00000000000 --- a/src/test/run-make/link-arg/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk -RUSTC_FLAGS = -C link-arg="-lfoo" -C link-arg="-lbar" -Z print-link-args - -all: - $(RUSTC) $(RUSTC_FLAGS) empty.rs | $(CGREP) lfoo lbar diff --git a/src/test/run-make/link-arg/empty.rs b/src/test/run-make/link-arg/empty.rs deleted file mode 100644 index 2b76fb24e5f..00000000000 --- a/src/test/run-make/link-arg/empty.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { } diff --git a/src/test/run-make/link-cfg/Makefile b/src/test/run-make/link-cfg/Makefile deleted file mode 100644 index 188cba5fe41..00000000000 --- a/src/test/run-make/link-cfg/Makefile +++ /dev/null @@ -1,22 +0,0 @@ --include ../tools.mk - -all: $(call DYLIB,return1) $(call DYLIB,return2) $(call NATIVE_STATICLIB,return3) - ls $(TMPDIR) - $(RUSTC) --print cfg --target x86_64-unknown-linux-musl | $(CGREP) crt-static - - $(RUSTC) no-deps.rs --cfg foo - $(call RUN,no-deps) - $(RUSTC) no-deps.rs --cfg bar - $(call RUN,no-deps) - - $(RUSTC) dep.rs - $(RUSTC) with-deps.rs --cfg foo - $(call RUN,with-deps) - $(RUSTC) with-deps.rs --cfg bar - $(call RUN,with-deps) - - $(RUSTC) dep-with-staticlib.rs - $(RUSTC) with-staticlib-deps.rs --cfg foo - $(call RUN,with-staticlib-deps) - $(RUSTC) with-staticlib-deps.rs --cfg bar - $(call RUN,with-staticlib-deps) diff --git a/src/test/run-make/link-cfg/dep-with-staticlib.rs b/src/test/run-make/link-cfg/dep-with-staticlib.rs deleted file mode 100644 index ecc2365ddb0..00000000000 --- a/src/test/run-make/link-cfg/dep-with-staticlib.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(link_cfg)] -#![crate_type = "rlib"] - -#[link(name = "return1", cfg(foo))] -#[link(name = "return3", kind = "static", cfg(bar))] -extern { - pub fn my_function() -> i32; -} diff --git a/src/test/run-make/link-cfg/dep.rs b/src/test/run-make/link-cfg/dep.rs deleted file mode 100644 index 7da879c2bfa..00000000000 --- a/src/test/run-make/link-cfg/dep.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(link_cfg)] -#![crate_type = "rlib"] - -#[link(name = "return1", cfg(foo))] -#[link(name = "return2", cfg(bar))] -extern { - pub fn my_function() -> i32; -} diff --git a/src/test/run-make/link-cfg/no-deps.rs b/src/test/run-make/link-cfg/no-deps.rs deleted file mode 100644 index 6b114106744..00000000000 --- a/src/test/run-make/link-cfg/no-deps.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(link_cfg)] - -#[link(name = "return1", cfg(foo))] -#[link(name = "return2", cfg(bar))] -extern { - fn my_function() -> i32; -} - -fn main() { - unsafe { - let v = my_function(); - if cfg!(foo) { - assert_eq!(v, 1); - } else if cfg!(bar) { - assert_eq!(v, 2); - } else { - panic!("unknown"); - } - } -} diff --git a/src/test/run-make/link-cfg/return1.c b/src/test/run-make/link-cfg/return1.c deleted file mode 100644 index a2a3d051dd1..00000000000 --- a/src/test/run-make/link-cfg/return1.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#ifdef _WIN32 -__declspec(dllexport) -#endif -int my_function() { - return 1; -} diff --git a/src/test/run-make/link-cfg/return2.c b/src/test/run-make/link-cfg/return2.c deleted file mode 100644 index d6ddcccf2fb..00000000000 --- a/src/test/run-make/link-cfg/return2.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#ifdef _WIN32 -__declspec(dllexport) -#endif -int my_function() { - return 2; -} diff --git a/src/test/run-make/link-cfg/return3.c b/src/test/run-make/link-cfg/return3.c deleted file mode 100644 index 6a3b695f208..00000000000 --- a/src/test/run-make/link-cfg/return3.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#ifdef _WIN32 -__declspec(dllexport) -#endif -int my_function() { - return 3; -} diff --git a/src/test/run-make/link-cfg/with-deps.rs b/src/test/run-make/link-cfg/with-deps.rs deleted file mode 100644 index 799555c500a..00000000000 --- a/src/test/run-make/link-cfg/with-deps.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate dep; - -fn main() { - unsafe { - let v = dep::my_function(); - if cfg!(foo) { - assert_eq!(v, 1); - } else if cfg!(bar) { - assert_eq!(v, 2); - } else { - panic!("unknown"); - } - } -} diff --git a/src/test/run-make/link-cfg/with-staticlib-deps.rs b/src/test/run-make/link-cfg/with-staticlib-deps.rs deleted file mode 100644 index 33a9c7720e2..00000000000 --- a/src/test/run-make/link-cfg/with-staticlib-deps.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate dep_with_staticlib; - -fn main() { - unsafe { - let v = dep_with_staticlib::my_function(); - if cfg!(foo) { - assert_eq!(v, 1); - } else if cfg!(bar) { - assert_eq!(v, 3); - } else { - panic!("unknown"); - } - } -} diff --git a/src/test/run-make/link-path-order/Makefile b/src/test/run-make/link-path-order/Makefile deleted file mode 100644 index eeea0e3714e..00000000000 --- a/src/test/run-make/link-path-order/Makefile +++ /dev/null @@ -1,18 +0,0 @@ --include ../tools.mk - -# Verifies that the -L arguments given to the linker is in the same order -# as the -L arguments on the rustc command line. - -CORRECT_DIR=$(TMPDIR)/correct -WRONG_DIR=$(TMPDIR)/wrong - -F := $(call NATIVE_STATICLIB_FILE,foo) - -all: $(call NATIVE_STATICLIB,correct) $(call NATIVE_STATICLIB,wrong) - mkdir -p $(CORRECT_DIR) $(WRONG_DIR) - mv $(call NATIVE_STATICLIB,correct) $(CORRECT_DIR)/$(F) - mv $(call NATIVE_STATICLIB,wrong) $(WRONG_DIR)/$(F) - $(RUSTC) main.rs -o $(TMPDIR)/should_succeed -L $(CORRECT_DIR) -L $(WRONG_DIR) - $(call RUN,should_succeed) - $(RUSTC) main.rs -o $(TMPDIR)/should_fail -L $(WRONG_DIR) -L $(CORRECT_DIR) - $(call FAIL,should_fail) diff --git a/src/test/run-make/link-path-order/correct.c b/src/test/run-make/link-path-order/correct.c deleted file mode 100644 index a595939f92e..00000000000 --- a/src/test/run-make/link-path-order/correct.c +++ /dev/null @@ -1,2 +0,0 @@ -// ignore-license -int should_return_one() { return 1; } diff --git a/src/test/run-make/link-path-order/main.rs b/src/test/run-make/link-path-order/main.rs deleted file mode 100644 index aaac3927f1c..00000000000 --- a/src/test/run-make/link-path-order/main.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(libc, exit_status)] - -extern crate libc; - -#[link(name="foo", kind = "static")] -extern { - fn should_return_one() -> libc::c_int; -} - -fn main() { - let result = unsafe { - should_return_one() - }; - - if result != 1 { - std::process::exit(255); - } -} diff --git a/src/test/run-make/link-path-order/wrong.c b/src/test/run-make/link-path-order/wrong.c deleted file mode 100644 index c53e7e3c48c..00000000000 --- a/src/test/run-make/link-path-order/wrong.c +++ /dev/null @@ -1,2 +0,0 @@ -// ignore-license -int should_return_one() { return 0; } diff --git a/src/test/run-make/linkage-attr-on-static/Makefile b/src/test/run-make/linkage-attr-on-static/Makefile deleted file mode 100644 index 4befbe14465..00000000000 --- a/src/test/run-make/linkage-attr-on-static/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,foo) - $(RUSTC) bar.rs - $(call RUN,bar) || exit 1 diff --git a/src/test/run-make/linkage-attr-on-static/bar.rs b/src/test/run-make/linkage-attr-on-static/bar.rs deleted file mode 100644 index 274401c448b..00000000000 --- a/src/test/run-make/linkage-attr-on-static/bar.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(linkage)] - -#[no_mangle] -#[linkage = "external"] -static BAZ: i32 = 21; - -#[link(name = "foo", kind = "static")] -extern { - fn what() -> i32; -} - -fn main() { - unsafe { - assert_eq!(what(), BAZ); - } -} diff --git a/src/test/run-make/linkage-attr-on-static/foo.c b/src/test/run-make/linkage-attr-on-static/foo.c deleted file mode 100644 index d7d33ea12e8..00000000000 --- a/src/test/run-make/linkage-attr-on-static/foo.c +++ /dev/null @@ -1,8 +0,0 @@ -// ignore-license -#include - -extern int32_t BAZ; - -int32_t what() { - return BAZ; -} diff --git a/src/test/run-make/linker-output-non-utf8/Makefile b/src/test/run-make/linker-output-non-utf8/Makefile deleted file mode 100644 index 5f1577ab44d..00000000000 --- a/src/test/run-make/linker-output-non-utf8/Makefile +++ /dev/null @@ -1,32 +0,0 @@ --include ../tools.mk - -# Make sure we don't ICE if the linker prints a non-UTF-8 error message. - -# Ignore Windows and Apple - -# This does not work in its current form on windows, possibly due to -# gcc bugs or something about valid Windows paths. See issue #29151 -# for more information. -ifndef IS_WINDOWS - -# This also does not work on Apple APFS due to the filesystem requiring -# valid UTF-8 paths. -ifneq ($(shell uname),Darwin) - -# The zzz it to allow humans to tab complete or glob this thing. -bad_dir := $(TMPDIR)/zzz$$'\xff' - -all: - $(RUSTC) library.rs - mkdir $(bad_dir) - mv $(TMPDIR)/liblibrary.a $(bad_dir) - LIBRARY_PATH=$(bad_dir) $(RUSTC) exec.rs 2>&1 | $(CGREP) this_symbol_not_defined -else -all: - -endif - -else -all: - -endif diff --git a/src/test/run-make/linker-output-non-utf8/exec.rs b/src/test/run-make/linker-output-non-utf8/exec.rs deleted file mode 100644 index 1c03eb479fd..00000000000 --- a/src/test/run-make/linker-output-non-utf8/exec.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[link(name="library")] -extern "C" { - fn foo(); -} - -fn main() { unsafe { foo(); } } diff --git a/src/test/run-make/linker-output-non-utf8/library.rs b/src/test/run-make/linker-output-non-utf8/library.rs deleted file mode 100644 index 194be26424a..00000000000 --- a/src/test/run-make/linker-output-non-utf8/library.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "staticlib"] - -extern "C" { - fn this_symbol_not_defined(); -} - -#[no_mangle] -pub extern "C" fn foo() { - unsafe { this_symbol_not_defined(); } -} diff --git a/src/test/run-make/llvm-pass/Makefile b/src/test/run-make/llvm-pass/Makefile deleted file mode 100644 index 8a18aadf36a..00000000000 --- a/src/test/run-make/llvm-pass/Makefile +++ /dev/null @@ -1,28 +0,0 @@ --include ../tools.mk - -ifeq ($(UNAME),Darwin) -PLUGIN_FLAGS := -C link-args=-Wl,-undefined,dynamic_lookup -endif - -ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) -# ignore stage1 -all: - -else -# Windows doesn't correctly handle include statements with escaping paths, -# so this test will not get run on Windows. -ifdef IS_WINDOWS -all: -else -all: $(call NATIVE_STATICLIB,llvm-function-pass) $(call NATIVE_STATICLIB,llvm-module-pass) - $(RUSTC) plugin.rs -C prefer-dynamic $(PLUGIN_FLAGS) - $(RUSTC) main.rs - -$(TMPDIR)/libllvm-function-pass.o: - $(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-function-pass.so.cc -o $(TMPDIR)/libllvm-function-pass.o - -$(TMPDIR)/libllvm-module-pass.o: - $(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-module-pass.so.cc -o $(TMPDIR)/libllvm-module-pass.o -endif - -endif diff --git a/src/test/run-make/llvm-pass/llvm-function-pass.so.cc b/src/test/run-make/llvm-pass/llvm-function-pass.so.cc deleted file mode 100644 index 880c9bce562..00000000000 --- a/src/test/run-make/llvm-pass/llvm-function-pass.so.cc +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#include -#include -#include - -#include "llvm/Pass.h" -#include "llvm/IR/Function.h" - -using namespace llvm; - -namespace { - - class TestLLVMPass : public FunctionPass { - - public: - - static char ID; - TestLLVMPass() : FunctionPass(ID) { } - - bool runOnFunction(Function &F) override; - -#if LLVM_VERSION_MAJOR >= 4 - StringRef -#else - const char * -#endif - getPassName() const override { - return "Some LLVM pass"; - } - - }; - -} - -bool TestLLVMPass::runOnFunction(Function &F) { - // A couple examples of operations that previously caused segmentation faults - // https://github.com/rust-lang/rust/issues/31067 - - for (auto N = F.begin(); N != F.end(); ++N) { - /* code */ - } - - LLVMContext &C = F.getContext(); - IntegerType *Int8Ty = IntegerType::getInt8Ty(C); - PointerType::get(Int8Ty, 0); - return true; -} - -char TestLLVMPass::ID = 0; - -static RegisterPass RegisterAFLPass( - "some-llvm-function-pass", "Some LLVM pass"); diff --git a/src/test/run-make/llvm-pass/llvm-module-pass.so.cc b/src/test/run-make/llvm-pass/llvm-module-pass.so.cc deleted file mode 100644 index 280eca7e8f0..00000000000 --- a/src/test/run-make/llvm-pass/llvm-module-pass.so.cc +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#include -#include -#include - -#include "llvm/IR/Module.h" - -using namespace llvm; - -namespace { - - class TestLLVMPass : public ModulePass { - - public: - - static char ID; - TestLLVMPass() : ModulePass(ID) { } - - bool runOnModule(Module &M) override; - -#if LLVM_VERSION_MAJOR >= 4 - StringRef -#else - const char * -#endif - getPassName() const override { - return "Some LLVM pass"; - } - - }; - -} - -bool TestLLVMPass::runOnModule(Module &M) { - // A couple examples of operations that previously caused segmentation faults - // https://github.com/rust-lang/rust/issues/31067 - - for (auto F = M.begin(); F != M.end(); ++F) { - /* code */ - } - - LLVMContext &C = M.getContext(); - IntegerType *Int8Ty = IntegerType::getInt8Ty(C); - PointerType::get(Int8Ty, 0); - return true; -} - -char TestLLVMPass::ID = 0; - -static RegisterPass RegisterAFLPass( - "some-llvm-module-pass", "Some LLVM pass"); diff --git a/src/test/run-make/llvm-pass/main.rs b/src/test/run-make/llvm-pass/main.rs deleted file mode 100644 index 5b5ab94bcef..00000000000 --- a/src/test/run-make/llvm-pass/main.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(plugin)] -#![plugin(some_plugin)] - -fn main() {} diff --git a/src/test/run-make/llvm-pass/plugin.rs b/src/test/run-make/llvm-pass/plugin.rs deleted file mode 100644 index f77b2fca857..00000000000 --- a/src/test/run-make/llvm-pass/plugin.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(plugin_registrar, rustc_private)] -#![crate_type = "dylib"] -#![crate_name = "some_plugin"] - -extern crate rustc; -extern crate rustc_plugin; - -#[link(name = "llvm-function-pass", kind = "static")] -#[link(name = "llvm-module-pass", kind = "static")] -extern {} - -use rustc_plugin::registry::Registry; - -#[plugin_registrar] -pub fn plugin_registrar(reg: &mut Registry) { - reg.register_llvm_pass("some-llvm-function-pass"); - reg.register_llvm_pass("some-llvm-module-pass"); -} diff --git a/src/test/run-make/long-linker-command-lines-cmd-exe/Makefile b/src/test/run-make/long-linker-command-lines-cmd-exe/Makefile deleted file mode 100644 index debe9e93824..00000000000 --- a/src/test/run-make/long-linker-command-lines-cmd-exe/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs -g - cp foo.bat $(TMPDIR)/ - OUT_DIR="$(TMPDIR)" RUSTC="$(RUSTC_ORIGINAL)" $(call RUN,foo) diff --git a/src/test/run-make/long-linker-command-lines-cmd-exe/foo.bat b/src/test/run-make/long-linker-command-lines-cmd-exe/foo.bat deleted file mode 100644 index a9350f12bbb..00000000000 --- a/src/test/run-make/long-linker-command-lines-cmd-exe/foo.bat +++ /dev/null @@ -1 +0,0 @@ -%MY_LINKER% %* diff --git a/src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs b/src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs deleted file mode 100644 index 67d8ad0b672..00000000000 --- a/src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Like the `long-linker-command-lines` test this test attempts to blow -// a command line limit for running the linker. Unlike that test, however, -// this test is testing `cmd.exe` specifically rather than the OS. -// -// Unfortunately `cmd.exe` has a 8192 limit which is relatively small -// in the grand scheme of things and anyone sripting rustc's linker -// is probably using a `*.bat` script and is likely to hit this limit. -// -// This test uses a `foo.bat` script as the linker which just simply -// delegates back to this program. The compiler should use a lower -// limit for arguments before passing everything via `@`, which -// means that everything should still succeed here. - -use std::env; -use std::fs::{self, File}; -use std::io::{BufWriter, Write, Read}; -use std::path::PathBuf; -use std::process::Command; - -fn main() { - if !cfg!(windows) { - return - } - - let tmpdir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); - let ok = tmpdir.join("ok"); - let not_ok = tmpdir.join("not_ok"); - if env::var("YOU_ARE_A_LINKER").is_ok() { - match env::args_os().find(|a| a.to_string_lossy().contains("@")) { - Some(file) => { - let file = file.to_str().unwrap(); - fs::copy(&file[1..], &ok).unwrap(); - } - None => { File::create(¬_ok).unwrap(); } - } - return - } - - let rustc = env::var_os("RUSTC").unwrap_or("rustc".into()); - let me = env::current_exe().unwrap(); - let bat = me.parent() - .unwrap() - .join("foo.bat"); - let bat_linker = format!("linker={}", bat.display()); - for i in (1..).map(|i| i * 10) { - println!("attempt: {}", i); - - let file = tmpdir.join("bar.rs"); - let mut f = BufWriter::new(File::create(&file).unwrap()); - let mut lib_name = String::new(); - for _ in 0..i { - lib_name.push_str("foo"); - } - for j in 0..i { - writeln!(f, "#[link(name = \"{}{}\")]", lib_name, j).unwrap(); - } - writeln!(f, "extern {{}}\nfn main() {{}}").unwrap(); - f.into_inner().unwrap(); - - drop(fs::remove_file(&ok)); - drop(fs::remove_file(¬_ok)); - let status = Command::new(&rustc) - .arg(&file) - .arg("-C").arg(&bat_linker) - .arg("--out-dir").arg(&tmpdir) - .env("YOU_ARE_A_LINKER", "1") - .env("MY_LINKER", &me) - .status() - .unwrap(); - - if !status.success() { - panic!("rustc didn't succeed: {}", status); - } - - if !ok.exists() { - assert!(not_ok.exists()); - continue - } - - let mut contents = Vec::new(); - File::open(&ok).unwrap().read_to_end(&mut contents).unwrap(); - - for j in 0..i { - let exp = format!("{}{}", lib_name, j); - let exp = if cfg!(target_env = "msvc") { - let mut out = Vec::with_capacity(exp.len() * 2); - for c in exp.encode_utf16() { - // encode in little endian - out.push(c as u8); - out.push((c >> 8) as u8); - } - out - } else { - exp.into_bytes() - }; - assert!(contents.windows(exp.len()).any(|w| w == &exp[..])); - } - - break - } -} diff --git a/src/test/run-make/long-linker-command-lines/Makefile b/src/test/run-make/long-linker-command-lines/Makefile deleted file mode 100644 index 5876fbc94bc..00000000000 --- a/src/test/run-make/long-linker-command-lines/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs -g -O - RUSTC="$(RUSTC_ORIGINAL)" $(call RUN,foo) diff --git a/src/test/run-make/long-linker-command-lines/foo.rs b/src/test/run-make/long-linker-command-lines/foo.rs deleted file mode 100644 index 2ac240982af..00000000000 --- a/src/test/run-make/long-linker-command-lines/foo.rs +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This is a test which attempts to blow out the system limit with how many -// arguments can be passed to a process. This'll successively call rustc with -// larger and larger argument lists in an attempt to find one that's way too -// big for the system at hand. This file itself is then used as a "linker" to -// detect when the process creation succeeds. -// -// Eventually we should see an argument that looks like `@` as we switch from -// passing literal arguments to passing everything in the file. - -use std::env; -use std::fs::{self, File}; -use std::io::{BufWriter, Write, Read}; -use std::path::PathBuf; -use std::process::Command; - -fn main() { - let tmpdir = PathBuf::from(env::var_os("TMPDIR").unwrap()); - let ok = tmpdir.join("ok"); - if env::var("YOU_ARE_A_LINKER").is_ok() { - if let Some(file) = env::args_os().find(|a| a.to_string_lossy().contains("@")) { - let file = file.to_str().expect("non-utf8 file argument"); - fs::copy(&file[1..], &ok).unwrap(); - } - return - } - - let rustc = env::var_os("RUSTC").unwrap_or("rustc".into()); - let me_as_linker = format!("linker={}", env::current_exe().unwrap().display()); - for i in (1..).map(|i| i * 100) { - println!("attempt: {}", i); - let file = tmpdir.join("bar.rs"); - let mut f = BufWriter::new(File::create(&file).unwrap()); - let mut lib_name = String::new(); - for _ in 0..i { - lib_name.push_str("foo"); - } - for j in 0..i { - writeln!(f, "#[link(name = \"{}{}\")]", lib_name, j).unwrap(); - } - writeln!(f, "extern {{}}\nfn main() {{}}").unwrap(); - f.into_inner().unwrap(); - - drop(fs::remove_file(&ok)); - let output = Command::new(&rustc) - .arg(&file) - .arg("-C").arg(&me_as_linker) - .arg("--out-dir").arg(&tmpdir) - .env("YOU_ARE_A_LINKER", "1") - .output() - .unwrap(); - - if !output.status.success() { - let stderr = String::from_utf8_lossy(&output.stderr); - panic!("status: {}\nstdout:\n{}\nstderr:\n{}", - output.status, - String::from_utf8_lossy(&output.stdout), - stderr.lines().map(|l| { - if l.len() > 200 { - format!("{}...\n", &l[..200]) - } else { - format!("{}\n", l) - } - }).collect::()); - } - - if !ok.exists() { - continue - } - - let mut contents = Vec::new(); - File::open(&ok).unwrap().read_to_end(&mut contents).unwrap(); - - for j in 0..i { - let exp = format!("{}{}", lib_name, j); - let exp = if cfg!(target_env = "msvc") { - let mut out = Vec::with_capacity(exp.len() * 2); - for c in exp.encode_utf16() { - // encode in little endian - out.push(c as u8); - out.push((c >> 8) as u8); - } - out - } else { - exp.into_bytes() - }; - assert!(contents.windows(exp.len()).any(|w| w == &exp[..])); - } - - break - } -} diff --git a/src/test/run-make/longjmp-across-rust/Makefile b/src/test/run-make/longjmp-across-rust/Makefile deleted file mode 100644 index 9d71ed8fcf3..00000000000 --- a/src/test/run-make/longjmp-across-rust/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,foo) - $(RUSTC) main.rs - $(call RUN,main) diff --git a/src/test/run-make/longjmp-across-rust/foo.c b/src/test/run-make/longjmp-across-rust/foo.c deleted file mode 100644 index eb993957674..00000000000 --- a/src/test/run-make/longjmp-across-rust/foo.c +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#include -#include - -static jmp_buf ENV; - -extern void test_middle(); - -void test_start(void(*f)()) { - if (setjmp(ENV) != 0) - return; - f(); - assert(0); -} - -void test_end() { - longjmp(ENV, 1); - assert(0); -} diff --git a/src/test/run-make/longjmp-across-rust/main.rs b/src/test/run-make/longjmp-across-rust/main.rs deleted file mode 100644 index c420473a560..00000000000 --- a/src/test/run-make/longjmp-across-rust/main.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[link(name = "foo", kind = "static")] -extern { - fn test_start(f: extern fn()); - fn test_end(); -} - -fn main() { - unsafe { - test_start(test_middle); - } -} - -struct A; - -impl Drop for A { - fn drop(&mut self) { - } -} - -extern fn test_middle() { - let _a = A; - foo(); -} - -fn foo() { - let _a = A; - unsafe { - test_end(); - } -} diff --git a/src/test/run-make/ls-metadata/Makefile b/src/test/run-make/ls-metadata/Makefile deleted file mode 100644 index fc3f5bce0cd..00000000000 --- a/src/test/run-make/ls-metadata/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs - $(RUSTC) -Z ls $(TMPDIR)/foo - touch $(TMPDIR)/bar - $(RUSTC) -Z ls $(TMPDIR)/bar diff --git a/src/test/run-make/ls-metadata/foo.rs b/src/test/run-make/ls-metadata/foo.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/ls-metadata/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/lto-no-link-whole-rlib/Makefile b/src/test/run-make/lto-no-link-whole-rlib/Makefile deleted file mode 100644 index 1d45cb413c5..00000000000 --- a/src/test/run-make/lto-no-link-whole-rlib/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2016 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - --include ../tools.mk - -all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar) - $(RUSTC) lib1.rs - $(RUSTC) lib2.rs - $(RUSTC) main.rs -Clto - $(call RUN,main) - diff --git a/src/test/run-make/lto-no-link-whole-rlib/bar.c b/src/test/run-make/lto-no-link-whole-rlib/bar.c deleted file mode 100644 index 716d1abcf34..00000000000 --- a/src/test/run-make/lto-no-link-whole-rlib/bar.c +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -int foo() { - return 2; -} diff --git a/src/test/run-make/lto-no-link-whole-rlib/foo.c b/src/test/run-make/lto-no-link-whole-rlib/foo.c deleted file mode 100644 index 1b36874581a..00000000000 --- a/src/test/run-make/lto-no-link-whole-rlib/foo.c +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -int foo() { - return 1; -} diff --git a/src/test/run-make/lto-no-link-whole-rlib/lib1.rs b/src/test/run-make/lto-no-link-whole-rlib/lib1.rs deleted file mode 100644 index 0a87c8e4725..00000000000 --- a/src/test/run-make/lto-no-link-whole-rlib/lib1.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[link(name = "foo", kind = "static")] -extern { - fn foo() -> i32; -} - -pub fn foo1() -> i32 { - unsafe { foo() } -} diff --git a/src/test/run-make/lto-no-link-whole-rlib/lib2.rs b/src/test/run-make/lto-no-link-whole-rlib/lib2.rs deleted file mode 100644 index 6e3f382b3fd..00000000000 --- a/src/test/run-make/lto-no-link-whole-rlib/lib2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -extern crate lib1; - -#[link(name = "bar", kind = "static")] -extern { - fn foo() -> i32; -} - -pub fn foo2() -> i32 { - unsafe { foo() } -} - diff --git a/src/test/run-make/lto-no-link-whole-rlib/main.rs b/src/test/run-make/lto-no-link-whole-rlib/main.rs deleted file mode 100644 index 8417af63be9..00000000000 --- a/src/test/run-make/lto-no-link-whole-rlib/main.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate lib1; -extern crate lib2; - -fn main() { - assert_eq!(lib1::foo1(), 2); - assert_eq!(lib2::foo2(), 2); -} diff --git a/src/test/run-make/lto-readonly-lib/Makefile b/src/test/run-make/lto-readonly-lib/Makefile deleted file mode 100644 index 0afbbc3450a..00000000000 --- a/src/test/run-make/lto-readonly-lib/Makefile +++ /dev/null @@ -1,12 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) lib.rs - - # the compiler needs to copy and modify the rlib file when performing - # LTO, so we should ensure that it can cope with the original rlib - # being read-only. - chmod 444 $(TMPDIR)/*.rlib - - $(RUSTC) main.rs -C lto - $(call RUN,main) diff --git a/src/test/run-make/lto-readonly-lib/lib.rs b/src/test/run-make/lto-readonly-lib/lib.rs deleted file mode 100644 index 04d3ae67207..00000000000 --- a/src/test/run-make/lto-readonly-lib/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] diff --git a/src/test/run-make/lto-readonly-lib/main.rs b/src/test/run-make/lto-readonly-lib/main.rs deleted file mode 100644 index e12ac9e01dc..00000000000 --- a/src/test/run-make/lto-readonly-lib/main.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate lib; - -fn main() {} diff --git a/src/test/run-make/lto-smoke-c/Makefile b/src/test/run-make/lto-smoke-c/Makefile deleted file mode 100644 index 0f61f5de938..00000000000 --- a/src/test/run-make/lto-smoke-c/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -# Apparently older versions of GCC segfault if -g is passed... -CC := $(CC:-g=) - -all: - $(RUSTC) foo.rs -C lto - $(CC) bar.c $(call STATICLIB,foo) \ - $(call OUT_EXE,bar) \ - $(EXTRACFLAGS) $(EXTRACXXFLAGS) - $(call RUN,bar) diff --git a/src/test/run-make/lto-smoke-c/bar.c b/src/test/run-make/lto-smoke-c/bar.c deleted file mode 100644 index 5729d411c5b..00000000000 --- a/src/test/run-make/lto-smoke-c/bar.c +++ /dev/null @@ -1,7 +0,0 @@ -// ignore-license -void foo(); - -int main() { - foo(); - return 0; -} diff --git a/src/test/run-make/lto-smoke-c/foo.rs b/src/test/run-make/lto-smoke-c/foo.rs deleted file mode 100644 index 1bb19016700..00000000000 --- a/src/test/run-make/lto-smoke-c/foo.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "staticlib"] - -#[no_mangle] -pub extern "C" fn foo() {} diff --git a/src/test/run-make/lto-smoke/Makefile b/src/test/run-make/lto-smoke/Makefile deleted file mode 100644 index 020252e1f8c..00000000000 --- a/src/test/run-make/lto-smoke/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) lib.rs - $(RUSTC) main.rs -C lto - $(call RUN,main) diff --git a/src/test/run-make/lto-smoke/lib.rs b/src/test/run-make/lto-smoke/lib.rs deleted file mode 100644 index 04d3ae67207..00000000000 --- a/src/test/run-make/lto-smoke/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] diff --git a/src/test/run-make/lto-smoke/main.rs b/src/test/run-make/lto-smoke/main.rs deleted file mode 100644 index e12ac9e01dc..00000000000 --- a/src/test/run-make/lto-smoke/main.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate lib; - -fn main() {} diff --git a/src/test/run-make/manual-crate-name/Makefile b/src/test/run-make/manual-crate-name/Makefile deleted file mode 100644 index 1d1419997a2..00000000000 --- a/src/test/run-make/manual-crate-name/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) --crate-name foo bar.rs - rm $(TMPDIR)/libfoo.rlib diff --git a/src/test/run-make/manual-crate-name/bar.rs b/src/test/run-make/manual-crate-name/bar.rs deleted file mode 100644 index 04d3ae67207..00000000000 --- a/src/test/run-make/manual-crate-name/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] diff --git a/src/test/run-make/manual-link/Makefile b/src/test/run-make/manual-link/Makefile deleted file mode 100644 index dccf0d99b0f..00000000000 --- a/src/test/run-make/manual-link/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: $(TMPDIR)/libbar.a - $(RUSTC) foo.rs -lstatic=bar - $(RUSTC) main.rs - $(call RUN,main) diff --git a/src/test/run-make/manual-link/bar.c b/src/test/run-make/manual-link/bar.c deleted file mode 100644 index 3c167b45af9..00000000000 --- a/src/test/run-make/manual-link/bar.c +++ /dev/null @@ -1,2 +0,0 @@ -// ignore-license -void bar() {} diff --git a/src/test/run-make/manual-link/foo.c b/src/test/run-make/manual-link/foo.c deleted file mode 100644 index 3c167b45af9..00000000000 --- a/src/test/run-make/manual-link/foo.c +++ /dev/null @@ -1,2 +0,0 @@ -// ignore-license -void bar() {} diff --git a/src/test/run-make/manual-link/foo.rs b/src/test/run-make/manual-link/foo.rs deleted file mode 100644 index d67a4057afb..00000000000 --- a/src/test/run-make/manual-link/foo.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -extern { - fn bar(); -} - -pub fn foo() { - unsafe { bar(); } -} diff --git a/src/test/run-make/manual-link/main.rs b/src/test/run-make/manual-link/main.rs deleted file mode 100644 index 756a47f386a..00000000000 --- a/src/test/run-make/manual-link/main.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::foo(); -} diff --git a/src/test/run-make/many-crates-but-no-match/Makefile b/src/test/run-make/many-crates-but-no-match/Makefile deleted file mode 100644 index 03a797d95f9..00000000000 --- a/src/test/run-make/many-crates-but-no-match/Makefile +++ /dev/null @@ -1,36 +0,0 @@ --include ../tools.mk - -# Modelled after compile-fail/changing-crates test, but this one puts -# more than one (mismatching) candidate crate into the search path, -# which did not appear directly expressible in compile-fail/aux-build -# infrastructure. -# -# Note that we move the built libraries into target direcrtories rather than -# use the `--out-dir` option because the `../tools.mk` file already bakes a -# use of `--out-dir` into the definition of $(RUSTC). - -A1=$(TMPDIR)/a1 -A2=$(TMPDIR)/a2 -A3=$(TMPDIR)/a3 - -# A hack to match distinct lines of output from a single run. -LOG=$(TMPDIR)/log.txt - -all: - mkdir -p $(A1) $(A2) $(A3) - $(RUSTC) --crate-type=rlib crateA1.rs - mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A1) - $(RUSTC) --crate-type=rlib -L $(A1) crateB.rs - $(RUSTC) --crate-type=rlib crateA2.rs - mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A2) - $(RUSTC) --crate-type=rlib crateA3.rs - mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A3) - # Ensure crateC fails to compile since A1 is "missing" and A2/A3 hashes do not match - $(RUSTC) -L $(A2) -L $(A3) crateC.rs >$(LOG) 2>&1 || true - $(CGREP) \ - 'found possibly newer version of crate `crateA` which `crateB` depends on' \ - 'note: perhaps that crate needs to be recompiled?' \ - 'crate `crateA`:' \ - 'crate `crateB`:' \ - < $(LOG) - # the 'crate `crateA`' will match two entries. \ No newline at end of file diff --git a/src/test/run-make/many-crates-but-no-match/crateA1.rs b/src/test/run-make/many-crates-but-no-match/crateA1.rs deleted file mode 100644 index dbfe920c85b..00000000000 --- a/src/test/run-make/many-crates-but-no-match/crateA1.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="crateA"] - -// Base crate -pub fn func() {} diff --git a/src/test/run-make/many-crates-but-no-match/crateA2.rs b/src/test/run-make/many-crates-but-no-match/crateA2.rs deleted file mode 100644 index 857c36aee60..00000000000 --- a/src/test/run-make/many-crates-but-no-match/crateA2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="crateA"] - -// Base crate -pub fn func() { println!("hello"); } diff --git a/src/test/run-make/many-crates-but-no-match/crateA3.rs b/src/test/run-make/many-crates-but-no-match/crateA3.rs deleted file mode 100644 index 8b8dac5e862..00000000000 --- a/src/test/run-make/many-crates-but-no-match/crateA3.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="crateA"] - -// Base crate -pub fn foo() { println!("world!"); } diff --git a/src/test/run-make/many-crates-but-no-match/crateB.rs b/src/test/run-make/many-crates-but-no-match/crateB.rs deleted file mode 100644 index bf55017c646..00000000000 --- a/src/test/run-make/many-crates-but-no-match/crateB.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate crateA; diff --git a/src/test/run-make/many-crates-but-no-match/crateC.rs b/src/test/run-make/many-crates-but-no-match/crateC.rs deleted file mode 100644 index 174d9382b76..00000000000 --- a/src/test/run-make/many-crates-but-no-match/crateC.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate crateB; - -fn main() {} diff --git a/src/test/run-make/metadata-flag-frobs-symbols/Makefile b/src/test/run-make/metadata-flag-frobs-symbols/Makefile deleted file mode 100644 index 09e6ae0bbf7..00000000000 --- a/src/test/run-make/metadata-flag-frobs-symbols/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs -C metadata=a -C extra-filename=-a - $(RUSTC) foo.rs -C metadata=b -C extra-filename=-b - $(RUSTC) bar.rs \ - --extern foo1=$(TMPDIR)/libfoo-a.rlib \ - --extern foo2=$(TMPDIR)/libfoo-b.rlib \ - -Z print-link-args - $(call RUN,bar) diff --git a/src/test/run-make/metadata-flag-frobs-symbols/bar.rs b/src/test/run-make/metadata-flag-frobs-symbols/bar.rs deleted file mode 100644 index 44b9e2f874a..00000000000 --- a/src/test/run-make/metadata-flag-frobs-symbols/bar.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo1; -extern crate foo2; - -fn main() { - let a = foo1::foo(); - let b = foo2::foo(); - assert!(a as *const _ != b as *const _); -} diff --git a/src/test/run-make/metadata-flag-frobs-symbols/foo.rs b/src/test/run-make/metadata-flag-frobs-symbols/foo.rs deleted file mode 100644 index baabdc9ad7b..00000000000 --- a/src/test/run-make/metadata-flag-frobs-symbols/foo.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "foo"] -#![crate_type = "rlib"] - -static FOO: usize = 3; - -pub fn foo() -> &'static usize { &FOO } diff --git a/src/test/run-make/min-global-align/Makefile b/src/test/run-make/min-global-align/Makefile deleted file mode 100644 index 2eacc36f380..00000000000 --- a/src/test/run-make/min-global-align/Makefile +++ /dev/null @@ -1,22 +0,0 @@ --include ../tools.mk - -# This tests ensure that global variables respect the target minimum alignment. -# The three bools `STATIC_BOOL`, `STATIC_MUT_BOOL`, and `CONST_BOOL` all have -# type-alignment of 1, but some targets require greater global alignment. - -SRC = min_global_align.rs -LL = $(TMPDIR)/min_global_align.ll - -all: -ifeq ($(UNAME),Linux) -# Most targets are happy with default alignment -- take i686 for example. -ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86) - $(RUSTC) --target=i686-unknown-linux-gnu --emit=llvm-ir $(SRC) - [ "$$(grep -c 'align 1' "$(LL)")" -eq "3" ] -endif -# SystemZ requires even alignment for PC-relative addressing. -ifeq ($(filter systemz,$(LLVM_COMPONENTS)),systemz) - $(RUSTC) --target=s390x-unknown-linux-gnu --emit=llvm-ir $(SRC) - [ "$$(grep -c 'align 2' "$(LL)")" -eq "3" ] -endif -endif diff --git a/src/test/run-make/min-global-align/min_global_align.rs b/src/test/run-make/min-global-align/min_global_align.rs deleted file mode 100644 index 3d4f9001a74..00000000000 --- a/src/test/run-make/min-global-align/min_global_align.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(no_core, lang_items)] -#![crate_type="rlib"] -#![no_core] - -pub static STATIC_BOOL: bool = true; - -pub static mut STATIC_MUT_BOOL: bool = true; - -const CONST_BOOL: bool = true; -pub static CONST_BOOL_REF: &'static bool = &CONST_BOOL; - - -#[lang = "sized"] -trait Sized {} - -#[lang = "copy"] -trait Copy {} - -#[lang = "freeze"] -trait Freeze {} - -#[lang = "sync"] -trait Sync {} -impl Sync for bool {} -impl Sync for &'static bool {} - -#[lang="drop_in_place"] -pub unsafe fn drop_in_place(_: *mut T) { } diff --git a/src/test/run-make/mismatching-target-triples/Makefile b/src/test/run-make/mismatching-target-triples/Makefile deleted file mode 100644 index 1636e41b056..00000000000 --- a/src/test/run-make/mismatching-target-triples/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -# Issue #10814 -# -# these are no_std to avoid having to have the standard library or any -# linkers/assemblers for the relevant platform - -all: - $(RUSTC) foo.rs --target=i686-unknown-linux-gnu - $(RUSTC) bar.rs --target=x86_64-unknown-linux-gnu 2>&1 \ - | $(CGREP) 'couldn'"'"'t find crate `foo` with expected target triple x86_64-unknown-linux-gnu' diff --git a/src/test/run-make/mismatching-target-triples/bar.rs b/src/test/run-make/mismatching-target-triples/bar.rs deleted file mode 100644 index 0dc5c0a3a8e..00000000000 --- a/src/test/run-make/mismatching-target-triples/bar.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(no_core)] -#![no_core] -extern crate foo; diff --git a/src/test/run-make/mismatching-target-triples/foo.rs b/src/test/run-make/mismatching-target-triples/foo.rs deleted file mode 100644 index a2169d0c631..00000000000 --- a/src/test/run-make/mismatching-target-triples/foo.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(no_core)] -#![no_core] -#![crate_type = "lib"] diff --git a/src/test/run-make/missing-crate-dependency/Makefile b/src/test/run-make/missing-crate-dependency/Makefile deleted file mode 100644 index b5a5bf492ab..00000000000 --- a/src/test/run-make/missing-crate-dependency/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) --crate-type=rlib crateA.rs - $(RUSTC) --crate-type=rlib crateB.rs - $(call REMOVE_RLIBS,crateA) - # Ensure crateC fails to compile since dependency crateA is missing - $(RUSTC) crateC.rs 2>&1 | \ - $(CGREP) 'can'"'"'t find crate for `crateA` which `crateB` depends on' diff --git a/src/test/run-make/missing-crate-dependency/crateA.rs b/src/test/run-make/missing-crate-dependency/crateA.rs deleted file mode 100644 index 4e111f29e8a..00000000000 --- a/src/test/run-make/missing-crate-dependency/crateA.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Base crate -pub fn func() {} diff --git a/src/test/run-make/missing-crate-dependency/crateB.rs b/src/test/run-make/missing-crate-dependency/crateB.rs deleted file mode 100644 index bf55017c646..00000000000 --- a/src/test/run-make/missing-crate-dependency/crateB.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate crateA; diff --git a/src/test/run-make/missing-crate-dependency/crateC.rs b/src/test/run-make/missing-crate-dependency/crateC.rs deleted file mode 100644 index 174d9382b76..00000000000 --- a/src/test/run-make/missing-crate-dependency/crateC.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate crateB; - -fn main() {} diff --git a/src/test/run-make/mixing-deps/Makefile b/src/test/run-make/mixing-deps/Makefile deleted file mode 100644 index 0e52d4a8bef..00000000000 --- a/src/test/run-make/mixing-deps/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) both.rs -C prefer-dynamic - $(RUSTC) dylib.rs -C prefer-dynamic - $(RUSTC) prog.rs - $(call RUN,prog) diff --git a/src/test/run-make/mixing-deps/both.rs b/src/test/run-make/mixing-deps/both.rs deleted file mode 100644 index c44335e2bbc..00000000000 --- a/src/test/run-make/mixing-deps/both.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![crate_type = "dylib"] - -pub static foo: isize = 4; diff --git a/src/test/run-make/mixing-deps/dylib.rs b/src/test/run-make/mixing-deps/dylib.rs deleted file mode 100644 index 78af525f386..00000000000 --- a/src/test/run-make/mixing-deps/dylib.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] -extern crate both; - -use std::mem; - -pub fn addr() -> usize { unsafe { mem::transmute(&both::foo) } } diff --git a/src/test/run-make/mixing-deps/prog.rs b/src/test/run-make/mixing-deps/prog.rs deleted file mode 100644 index c3d88016fda..00000000000 --- a/src/test/run-make/mixing-deps/prog.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate dylib; -extern crate both; - -use std::mem; - -fn main() { - assert_eq!(unsafe { mem::transmute::<&isize, usize>(&both::foo) }, - dylib::addr()); -} diff --git a/src/test/run-make/mixing-formats/Makefile b/src/test/run-make/mixing-formats/Makefile deleted file mode 100644 index 48257669baf..00000000000 --- a/src/test/run-make/mixing-formats/Makefile +++ /dev/null @@ -1,74 +0,0 @@ --include ../tools.mk - -# Testing various mixings of rlibs and dylibs. Makes sure that it's possible to -# link an rlib to a dylib. The dependency tree among the file looks like: -# -# foo -# / \ -# bar1 bar2 -# / \ / -# baz baz2 -# -# This is generally testing the permutations of the foo/bar1/bar2 layer against -# the baz/baz2 layer - -all: - # Building just baz - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic - $(RUSTC) --crate-type=bin baz.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic - $(RUSTC) --crate-type=rlib bar1.rs - $(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic - $(RUSTC) --crate-type=bin baz.rs - rm $(TMPDIR)/* - # Building baz2 - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib baz2.rs && exit 1 || exit 0 - $(RUSTC) --crate-type=bin baz2.rs && exit 1 || exit 0 - rm $(TMPDIR)/* - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=rlib bar1.rs - $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib,rlib baz2.rs - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic - $(RUSTC) --crate-type=rlib bar2.rs - $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=rlib bar1.rs - $(RUSTC) --crate-type=rlib bar2.rs - $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic - $(RUSTC) --crate-type=rlib bar1.rs - $(RUSTC) --crate-type=rlib bar2.rs - $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic - $(RUSTC) --crate-type=rlib bar2.rs - $(RUSTC) --crate-type=dylib,rlib baz2.rs - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic - $(RUSTC) --crate-type=rlib bar1.rs - $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib,rlib baz2.rs - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib,rlib baz2.rs - $(RUSTC) --crate-type=bin baz2.rs diff --git a/src/test/run-make/mixing-formats/bar1.rs b/src/test/run-make/mixing-formats/bar1.rs deleted file mode 100644 index 4b4916fe96d..00000000000 --- a/src/test/run-make/mixing-formats/bar1.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; diff --git a/src/test/run-make/mixing-formats/bar2.rs b/src/test/run-make/mixing-formats/bar2.rs deleted file mode 100644 index 4b4916fe96d..00000000000 --- a/src/test/run-make/mixing-formats/bar2.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; diff --git a/src/test/run-make/mixing-formats/baz.rs b/src/test/run-make/mixing-formats/baz.rs deleted file mode 100644 index 3fb90f6a854..00000000000 --- a/src/test/run-make/mixing-formats/baz.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar1; - -fn main() {} diff --git a/src/test/run-make/mixing-formats/baz2.rs b/src/test/run-make/mixing-formats/baz2.rs deleted file mode 100644 index c5066ccd656..00000000000 --- a/src/test/run-make/mixing-formats/baz2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar1; -extern crate bar2; - -fn main() {} diff --git a/src/test/run-make/mixing-formats/foo.rs b/src/test/run-make/mixing-formats/foo.rs deleted file mode 100644 index e6c76025738..00000000000 --- a/src/test/run-make/mixing-formats/foo.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. diff --git a/src/test/run-make/mixing-libs/Makefile b/src/test/run-make/mixing-libs/Makefile deleted file mode 100644 index babeeef164d..00000000000 --- a/src/test/run-make/mixing-libs/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) rlib.rs - $(RUSTC) dylib.rs - $(RUSTC) rlib.rs --crate-type=dylib - $(RUSTC) dylib.rs - $(call REMOVE_DYLIBS,rlib) - $(RUSTC) prog.rs && exit 1 || exit 0 diff --git a/src/test/run-make/mixing-libs/dylib.rs b/src/test/run-make/mixing-libs/dylib.rs deleted file mode 100644 index 1a5bd658cd9..00000000000 --- a/src/test/run-make/mixing-libs/dylib.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] -extern crate rlib; - -pub fn dylib() { rlib::rlib() } diff --git a/src/test/run-make/mixing-libs/prog.rs b/src/test/run-make/mixing-libs/prog.rs deleted file mode 100644 index 5e1a4274756..00000000000 --- a/src/test/run-make/mixing-libs/prog.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate dylib; -extern crate rlib; - -fn main() { - dylib::dylib(); - rlib::rlib(); -} diff --git a/src/test/run-make/mixing-libs/rlib.rs b/src/test/run-make/mixing-libs/rlib.rs deleted file mode 100644 index ad0ea67b9ab..00000000000 --- a/src/test/run-make/mixing-libs/rlib.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -pub fn rlib() {} diff --git a/src/test/run-make/msvc-opt-minsize/Makefile b/src/test/run-make/msvc-opt-minsize/Makefile deleted file mode 100644 index 1095a047dd1..00000000000 --- a/src/test/run-make/msvc-opt-minsize/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs -Copt-level=z 2>&1 - $(call RUN,foo) diff --git a/src/test/run-make/msvc-opt-minsize/foo.rs b/src/test/run-make/msvc-opt-minsize/foo.rs deleted file mode 100644 index 30b12691afe..00000000000 --- a/src/test/run-make/msvc-opt-minsize/foo.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(test)] -extern crate test; - -fn foo(x: i32, y: i32) -> i64 { - (x + y) as i64 -} - -#[inline(never)] -fn bar() { - let _f = Box::new(0); - // This call used to trigger an LLVM bug in opt-level z where the base - // pointer gets corrupted, see issue #45034 - let y: fn(i32, i32) -> i64 = test::black_box(foo); - test::black_box(y(1, 2)); -} - -fn main() { - bar(); -} diff --git a/src/test/run-make/multiple-emits/Makefile b/src/test/run-make/multiple-emits/Makefile deleted file mode 100644 index e126422835c..00000000000 --- a/src/test/run-make/multiple-emits/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs --emit=asm,llvm-ir -o $(TMPDIR)/out 2>&1 - rm $(TMPDIR)/out.ll $(TMPDIR)/out.s - $(RUSTC) foo.rs --emit=asm,llvm-ir -o $(TMPDIR)/out2.ext 2>&1 - rm $(TMPDIR)/out2.ll $(TMPDIR)/out2.s diff --git a/src/test/run-make/multiple-emits/foo.rs b/src/test/run-make/multiple-emits/foo.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/multiple-emits/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/no-builtins-lto/Makefile b/src/test/run-make/no-builtins-lto/Makefile deleted file mode 100644 index b9688f16c64..00000000000 --- a/src/test/run-make/no-builtins-lto/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -all: - # Compile a `#![no_builtins]` rlib crate - $(RUSTC) no_builtins.rs - # Build an executable that depends on that crate using LTO. The no_builtins crate doesn't - # participate in LTO, so its rlib must be explicitly linked into the final binary. Verify this by - # grepping the linker arguments. - $(RUSTC) main.rs -C lto -Z print-link-args | $(CGREP) 'libno_builtins.rlib' diff --git a/src/test/run-make/no-builtins-lto/main.rs b/src/test/run-make/no-builtins-lto/main.rs deleted file mode 100644 index e960c726a98..00000000000 --- a/src/test/run-make/no-builtins-lto/main.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate no_builtins; - -fn main() {} diff --git a/src/test/run-make/no-builtins-lto/no_builtins.rs b/src/test/run-make/no-builtins-lto/no_builtins.rs deleted file mode 100644 index be95e7c5521..00000000000 --- a/src/test/run-make/no-builtins-lto/no_builtins.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -#![no_builtins] diff --git a/src/test/run-make/no-duplicate-libs/Makefile b/src/test/run-make/no-duplicate-libs/Makefile deleted file mode 100644 index 13d8366c60a..00000000000 --- a/src/test/run-make/no-duplicate-libs/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -ifdef IS_MSVC -# FIXME(#27979) -all: -else -all: $(call STATICLIB,foo) $(call STATICLIB,bar) - $(RUSTC) main.rs - $(call RUN,main) -endif diff --git a/src/test/run-make/no-duplicate-libs/bar.c b/src/test/run-make/no-duplicate-libs/bar.c deleted file mode 100644 index b9dcd0f5e5e..00000000000 --- a/src/test/run-make/no-duplicate-libs/bar.c +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern void foo(); - -void bar() { - foo(); -} diff --git a/src/test/run-make/no-duplicate-libs/foo.c b/src/test/run-make/no-duplicate-libs/foo.c deleted file mode 100644 index 906cd5682b8..00000000000 --- a/src/test/run-make/no-duplicate-libs/foo.c +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -void foo() {} diff --git a/src/test/run-make/no-duplicate-libs/main.rs b/src/test/run-make/no-duplicate-libs/main.rs deleted file mode 100644 index 824946fe9c2..00000000000 --- a/src/test/run-make/no-duplicate-libs/main.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[link(name = "foo")] // linker should drop this library, no symbols used -#[link(name = "bar")] // symbol comes from this library -#[link(name = "foo")] // now linker picks up `foo` b/c `bar` library needs it -extern { - fn bar(); -} - -fn main() { - unsafe { bar() } -} diff --git a/src/test/run-make/no-integrated-as/Makefile b/src/test/run-make/no-integrated-as/Makefile deleted file mode 100644 index 78e3025b99a..00000000000 --- a/src/test/run-make/no-integrated-as/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -all: -ifeq ($(TARGET),x86_64-unknown-linux-gnu) - $(RUSTC) hello.rs -C no_integrated_as - $(call RUN,hello) -endif diff --git a/src/test/run-make/no-integrated-as/hello.rs b/src/test/run-make/no-integrated-as/hello.rs deleted file mode 100644 index 68e7f6d94d1..00000000000 --- a/src/test/run-make/no-integrated-as/hello.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - println!("Hello, world!"); -} diff --git a/src/test/run-make/no-intermediate-extras/Makefile b/src/test/run-make/no-intermediate-extras/Makefile deleted file mode 100644 index 258cbf04c61..00000000000 --- a/src/test/run-make/no-intermediate-extras/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# Regression test for issue #10973 - --include ../tools.mk - -all: - $(RUSTC) --crate-type=rlib --test foo.rs - rm $(TMPDIR)/foo.bc && exit 1 || exit 0 diff --git a/src/test/run-make/no-intermediate-extras/foo.rs b/src/test/run-make/no-intermediate-extras/foo.rs deleted file mode 100644 index e6c76025738..00000000000 --- a/src/test/run-make/no-intermediate-extras/foo.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. diff --git a/src/test/run-make/obey-crate-type-flag/Makefile b/src/test/run-make/obey-crate-type-flag/Makefile deleted file mode 100644 index 903349152df..00000000000 --- a/src/test/run-make/obey-crate-type-flag/Makefile +++ /dev/null @@ -1,13 +0,0 @@ --include ../tools.mk - -# check that rustc builds all crate_type attributes -# delete rlib -# delete whatever dylib is made for this system -# check that rustc only builds --crate-type flags, ignoring attributes -# fail if an rlib was built -all: - $(RUSTC) test.rs - $(call REMOVE_RLIBS,test) - $(call REMOVE_DYLIBS,test) - $(RUSTC) --crate-type dylib test.rs - $(call REMOVE_RLIBS,test) && exit 1 || exit 0 diff --git a/src/test/run-make/obey-crate-type-flag/test.rs b/src/test/run-make/obey-crate-type-flag/test.rs deleted file mode 100644 index e6c8b8eb179..00000000000 --- a/src/test/run-make/obey-crate-type-flag/test.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![crate_type = "dylib"] diff --git a/src/test/run-make/output-filename-conflicts-with-directory/Makefile b/src/test/run-make/output-filename-conflicts-with-directory/Makefile deleted file mode 100644 index 74e5dcfcf36..00000000000 --- a/src/test/run-make/output-filename-conflicts-with-directory/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -all: - cp foo.rs $(TMPDIR)/foo.rs - mkdir $(TMPDIR)/foo - $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo 2>&1 \ - | $(CGREP) -e "the generated executable for the input file \".*foo\.rs\" conflicts with the existing directory \".*foo\"" diff --git a/src/test/run-make/output-filename-conflicts-with-directory/foo.rs b/src/test/run-make/output-filename-conflicts-with-directory/foo.rs deleted file mode 100644 index 3f07b46791d..00000000000 --- a/src/test/run-make/output-filename-conflicts-with-directory/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/output-filename-overwrites-input/Makefile b/src/test/run-make/output-filename-overwrites-input/Makefile deleted file mode 100644 index 6377038b7be..00000000000 --- a/src/test/run-make/output-filename-overwrites-input/Makefile +++ /dev/null @@ -1,13 +0,0 @@ --include ../tools.mk - -all: - cp foo.rs $(TMPDIR)/foo - $(RUSTC) $(TMPDIR)/foo -o $(TMPDIR)/foo 2>&1 \ - | $(CGREP) -e "the input file \".*foo\" would be overwritten by the generated executable" - cp bar.rs $(TMPDIR)/bar.rlib - $(RUSTC) $(TMPDIR)/bar.rlib -o $(TMPDIR)/bar.rlib 2>&1 \ - | $(CGREP) -e "the input file \".*bar.rlib\" would be overwritten by the generated executable" - $(RUSTC) foo.rs 2>&1 && $(RUSTC) -Z ls $(TMPDIR)/foo 2>&1 - cp foo.rs $(TMPDIR)/foo.rs - $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo.rs 2>&1 \ - | $(CGREP) -e "the input file \".*foo.rs\" would be overwritten by the generated executable" diff --git a/src/test/run-make/output-filename-overwrites-input/bar.rs b/src/test/run-make/output-filename-overwrites-input/bar.rs deleted file mode 100644 index 8e4e35fdee6..00000000000 --- a/src/test/run-make/output-filename-overwrites-input/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] diff --git a/src/test/run-make/output-filename-overwrites-input/foo.rs b/src/test/run-make/output-filename-overwrites-input/foo.rs deleted file mode 100644 index 3f07b46791d..00000000000 --- a/src/test/run-make/output-filename-overwrites-input/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/output-type-permutations/Makefile b/src/test/run-make/output-type-permutations/Makefile deleted file mode 100644 index c2715027bc1..00000000000 --- a/src/test/run-make/output-type-permutations/Makefile +++ /dev/null @@ -1,146 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs --crate-type=rlib,dylib,staticlib - $(call REMOVE_RLIBS,bar) - $(call REMOVE_DYLIBS,bar) - rm $(call STATICLIB,bar) - rm -f $(TMPDIR)/bar.{dll.exp,dll.lib,pdb} - # Check that $(TMPDIR) is empty. - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --crate-type=bin - rm $(TMPDIR)/$(call BIN,bar) - rm -f $(TMPDIR)/bar.pdb - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit=asm,llvm-ir,llvm-bc,obj,link - rm $(TMPDIR)/bar.ll - rm $(TMPDIR)/bar.bc - rm $(TMPDIR)/bar.s - rm $(TMPDIR)/bar.o - rm $(TMPDIR)/$(call BIN,bar) - rm -f $(TMPDIR)/bar.pdb - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit asm -o $(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit asm=$(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit=asm=$(TMPDIR)/foo - rm $(TMPDIR)/foo - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit llvm-bc -o $(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit llvm-bc=$(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit=llvm-bc=$(TMPDIR)/foo - rm $(TMPDIR)/foo - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit llvm-ir -o $(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit llvm-ir=$(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit=llvm-ir=$(TMPDIR)/foo - rm $(TMPDIR)/foo - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit obj -o $(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit obj=$(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit=obj=$(TMPDIR)/foo - rm $(TMPDIR)/foo - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit link -o $(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo.rs --emit link=$(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo.rs --emit=link=$(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - rm -f $(TMPDIR)/foo.pdb - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --crate-type=rlib -o $(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --crate-type=rlib --emit link=$(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --crate-type=rlib --emit=link=$(TMPDIR)/foo - rm $(TMPDIR)/foo - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --crate-type=dylib -o $(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo.rs --crate-type=dylib --emit link=$(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo.rs --crate-type=dylib --emit=link=$(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - rm -f $(TMPDIR)/foo.{dll.exp,dll.lib,pdb} - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --crate-type=staticlib -o $(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --crate-type=staticlib --emit link=$(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --crate-type=staticlib --emit=link=$(TMPDIR)/foo - rm $(TMPDIR)/foo - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --crate-type=bin -o $(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo.rs --crate-type=bin --emit link=$(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo.rs --crate-type=bin --emit=link=$(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - rm -f $(TMPDIR)/foo.pdb - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit llvm-ir=$(TMPDIR)/ir \ - --emit link \ - --crate-type=rlib - rm $(TMPDIR)/ir - rm $(TMPDIR)/libbar.rlib - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit asm=$(TMPDIR)/asm \ - --emit llvm-ir=$(TMPDIR)/ir \ - --emit llvm-bc=$(TMPDIR)/bc \ - --emit obj=$(TMPDIR)/obj \ - --emit link=$(TMPDIR)/link \ - --crate-type=staticlib - rm $(TMPDIR)/asm - rm $(TMPDIR)/ir - rm $(TMPDIR)/bc - rm $(TMPDIR)/obj - rm $(TMPDIR)/link - $(RUSTC) foo.rs --emit=asm=$(TMPDIR)/asm \ - --emit llvm-ir=$(TMPDIR)/ir \ - --emit=llvm-bc=$(TMPDIR)/bc \ - --emit obj=$(TMPDIR)/obj \ - --emit=link=$(TMPDIR)/link \ - --crate-type=staticlib - rm $(TMPDIR)/asm - rm $(TMPDIR)/ir - rm $(TMPDIR)/bc - rm $(TMPDIR)/obj - rm $(TMPDIR)/link - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit=asm,llvm-ir,llvm-bc,obj,link --crate-type=staticlib - rm $(TMPDIR)/bar.ll - rm $(TMPDIR)/bar.s - rm $(TMPDIR)/bar.o - rm $(call STATICLIB,bar) - mv $(TMPDIR)/bar.bc $(TMPDIR)/foo.bc - # Don't check that the $(TMPDIR) is empty - we left `foo.bc` for later - # comparison. - - $(RUSTC) foo.rs --emit=llvm-bc,link --crate-type=rlib - cmp $(TMPDIR)/foo.bc $(TMPDIR)/bar.bc - rm $(TMPDIR)/bar.bc - rm $(TMPDIR)/foo.bc - $(call REMOVE_RLIBS,bar) - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] diff --git a/src/test/run-make/output-type-permutations/foo.rs b/src/test/run-make/output-type-permutations/foo.rs deleted file mode 100644 index bb5796bd873..00000000000 --- a/src/test/run-make/output-type-permutations/foo.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "bar"] - -fn main() {} diff --git a/src/test/run-make/output-with-hyphens/Makefile b/src/test/run-make/output-with-hyphens/Makefile deleted file mode 100644 index 783d826a53d..00000000000 --- a/src/test/run-make/output-with-hyphens/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo-bar.rs - [ -f $(TMPDIR)/$(call BIN,foo-bar) ] - [ -f $(TMPDIR)/libfoo_bar.rlib ] diff --git a/src/test/run-make/output-with-hyphens/foo-bar.rs b/src/test/run-make/output-with-hyphens/foo-bar.rs deleted file mode 100644 index 2f93b2d1ead..00000000000 --- a/src/test/run-make/output-with-hyphens/foo-bar.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -#![crate_type = "bin"] - -fn main() {} diff --git a/src/test/run-make/prefer-dylib/Makefile b/src/test/run-make/prefer-dylib/Makefile deleted file mode 100644 index bd44feecf2a..00000000000 --- a/src/test/run-make/prefer-dylib/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) bar.rs --crate-type=dylib --crate-type=rlib -C prefer-dynamic - $(RUSTC) foo.rs -C prefer-dynamic - $(call RUN,foo) - rm $(TMPDIR)/*bar* - $(call FAIL,foo) diff --git a/src/test/run-make/prefer-dylib/bar.rs b/src/test/run-make/prefer-dylib/bar.rs deleted file mode 100644 index 4c79f7e2855..00000000000 --- a/src/test/run-make/prefer-dylib/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn bar() {} diff --git a/src/test/run-make/prefer-dylib/foo.rs b/src/test/run-make/prefer-dylib/foo.rs deleted file mode 100644 index 858ef492ace..00000000000 --- a/src/test/run-make/prefer-dylib/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar; - -fn main() { - bar::bar(); -} diff --git a/src/test/run-make/prefer-rlib/Makefile b/src/test/run-make/prefer-rlib/Makefile deleted file mode 100644 index c6a239eef08..00000000000 --- a/src/test/run-make/prefer-rlib/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) bar.rs --crate-type=dylib --crate-type=rlib - ls $(TMPDIR)/$(call RLIB_GLOB,bar) - $(RUSTC) foo.rs - rm $(TMPDIR)/*bar* - $(call RUN,foo) diff --git a/src/test/run-make/prefer-rlib/bar.rs b/src/test/run-make/prefer-rlib/bar.rs deleted file mode 100644 index 4c79f7e2855..00000000000 --- a/src/test/run-make/prefer-rlib/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn bar() {} diff --git a/src/test/run-make/prefer-rlib/foo.rs b/src/test/run-make/prefer-rlib/foo.rs deleted file mode 100644 index 858ef492ace..00000000000 --- a/src/test/run-make/prefer-rlib/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar; - -fn main() { - bar::bar(); -} diff --git a/src/test/run-make/pretty-expanded-hygiene/Makefile b/src/test/run-make/pretty-expanded-hygiene/Makefile deleted file mode 100644 index 136d7643ade..00000000000 --- a/src/test/run-make/pretty-expanded-hygiene/Makefile +++ /dev/null @@ -1,21 +0,0 @@ --include ../tools.mk - -REPLACEMENT := s/[0-9][0-9]*\#[0-9][0-9]*/$(shell date)/g - -all: - $(RUSTC) -o $(TMPDIR)/input.out -Z unstable-options \ - --pretty expanded,hygiene input.rs - - # the name/ctxt numbers are very internals-dependent and thus - # change relatively frequently, and testing for their exact values - # them will fail annoyingly, so we just check their positions - # (using a non-constant replacement like this will make it less - # likely the compiler matches whatever other dummy value we - # choose). - # - # (These need to be out-of-place because OSX/BSD & GNU sed - # differ.) - sed "$(REPLACEMENT)" input.pp.rs > $(TMPDIR)/input.pp.rs - sed "$(REPLACEMENT)" $(TMPDIR)/input.out > $(TMPDIR)/input.out.replaced - - diff -u $(TMPDIR)/input.out.replaced $(TMPDIR)/input.pp.rs diff --git a/src/test/run-make/pretty-expanded-hygiene/input.pp.rs b/src/test/run-make/pretty-expanded-hygiene/input.pp.rs deleted file mode 100644 index 3d2dd380e48..00000000000 --- a/src/test/run-make/pretty-expanded-hygiene/input.pp.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// minimal junk -#![feature(no_core)] -#![no_core] - -macro_rules! foo /* 60#0 */(( $ x : ident ) => { y + $ x }); - -fn bar /* 62#0 */() { let x /* 59#2 */ = 1; y /* 61#4 */ + x /* 59#5 */ } - -fn y /* 61#0 */() { } diff --git a/src/test/run-make/pretty-expanded-hygiene/input.rs b/src/test/run-make/pretty-expanded-hygiene/input.rs deleted file mode 100644 index 422fbdb0884..00000000000 --- a/src/test/run-make/pretty-expanded-hygiene/input.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// minimal junk -#![feature(no_core)] -#![no_core] - -macro_rules! foo { - ($x: ident) => { y + $x } -} - -fn bar() { - let x = 1; - foo!(x) -} - -fn y() {} diff --git a/src/test/run-make/pretty-expanded/Makefile b/src/test/run-make/pretty-expanded/Makefile deleted file mode 100644 index 7a8dc8d871c..00000000000 --- a/src/test/run-make/pretty-expanded/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -o $(TMPDIR)/input.expanded.rs -Z unstable-options \ - --pretty=expanded input.rs diff --git a/src/test/run-make/pretty-expanded/input.rs b/src/test/run-make/pretty-expanded/input.rs deleted file mode 100644 index 04bf17dc28a..00000000000 --- a/src/test/run-make/pretty-expanded/input.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[crate_type="lib"] - -// #13544 - -extern crate serialize; - -#[derive(Encodable)] pub struct A; -#[derive(Encodable)] pub struct B(isize); -#[derive(Encodable)] pub struct C { x: isize } -#[derive(Encodable)] pub enum D {} -#[derive(Encodable)] pub enum E { y } -#[derive(Encodable)] pub enum F { z(isize) } diff --git a/src/test/run-make/pretty-print-path-suffix/Makefile b/src/test/run-make/pretty-print-path-suffix/Makefile deleted file mode 100644 index 899457fc748..00000000000 --- a/src/test/run-make/pretty-print-path-suffix/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -o $(TMPDIR)/foo.out -Z unpretty=hir=foo input.rs - $(RUSTC) -o $(TMPDIR)/nest_foo.out -Z unpretty=hir=nest::foo input.rs - $(RUSTC) -o $(TMPDIR)/foo_method.out -Z unpretty=hir=foo_method input.rs - diff -u $(TMPDIR)/foo.out foo.pp - diff -u $(TMPDIR)/nest_foo.out nest_foo.pp - diff -u $(TMPDIR)/foo_method.out foo_method.pp diff --git a/src/test/run-make/pretty-print-path-suffix/foo.pp b/src/test/run-make/pretty-print-path-suffix/foo.pp deleted file mode 100644 index f3130a8044a..00000000000 --- a/src/test/run-make/pretty-print-path-suffix/foo.pp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -pub fn foo() -> i32 { 45 } /* foo */ - - -pub fn foo() -> &'static str { "i am a foo." } /* nest::foo */ diff --git a/src/test/run-make/pretty-print-path-suffix/foo_method.pp b/src/test/run-make/pretty-print-path-suffix/foo_method.pp deleted file mode 100644 index fae13498687..00000000000 --- a/src/test/run-make/pretty-print-path-suffix/foo_method.pp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - - - - -fn foo_method(self: &Self) - -> &'static str { return "i am very similar to foo."; } /* -nest::{{impl}}::foo_method */ diff --git a/src/test/run-make/pretty-print-path-suffix/input.rs b/src/test/run-make/pretty-print-path-suffix/input.rs deleted file mode 100644 index 8ea86a94f93..00000000000 --- a/src/test/run-make/pretty-print-path-suffix/input.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub fn -foo() -> i32 -{ 45 } - -pub fn bar() -> &'static str { "i am not a foo." } - -pub mod nest { - pub fn foo() -> &'static str { "i am a foo." } - - struct S; - impl S { - fn foo_method(&self) -> &'static str { - return "i am very similar to foo."; - } - } -} diff --git a/src/test/run-make/pretty-print-path-suffix/nest_foo.pp b/src/test/run-make/pretty-print-path-suffix/nest_foo.pp deleted file mode 100644 index 88eaa062b03..00000000000 --- a/src/test/run-make/pretty-print-path-suffix/nest_foo.pp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - - - -pub fn foo() -> &'static str { "i am a foo." } /* nest::foo */ diff --git a/src/test/run-make/pretty-print-to-file/Makefile b/src/test/run-make/pretty-print-to-file/Makefile deleted file mode 100644 index 8909dee11f0..00000000000 --- a/src/test/run-make/pretty-print-to-file/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -o $(TMPDIR)/input.out --pretty=normal -Z unstable-options input.rs - diff -u $(TMPDIR)/input.out input.pp diff --git a/src/test/run-make/pretty-print-to-file/input.pp b/src/test/run-make/pretty-print-to-file/input.pp deleted file mode 100644 index a6dd6b6778e..00000000000 --- a/src/test/run-make/pretty-print-to-file/input.pp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#[crate_type = "lib"] -pub fn foo() -> i32 { 45 } diff --git a/src/test/run-make/pretty-print-to-file/input.rs b/src/test/run-make/pretty-print-to-file/input.rs deleted file mode 100644 index 8e3ec363187..00000000000 --- a/src/test/run-make/pretty-print-to-file/input.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[crate_type="lib"] - -pub fn -foo() -> i32 -{ 45 } diff --git a/src/test/run-make/print-cfg/Makefile b/src/test/run-make/print-cfg/Makefile deleted file mode 100644 index 08303a46d19..00000000000 --- a/src/test/run-make/print-cfg/Makefile +++ /dev/null @@ -1,16 +0,0 @@ --include ../tools.mk - -all: default - $(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) windows - $(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) x86_64 - $(RUSTC) --target i686-pc-windows-msvc --print cfg | $(CGREP) msvc - $(RUSTC) --target i686-apple-darwin --print cfg | $(CGREP) macos - $(RUSTC) --target i686-unknown-linux-gnu --print cfg | $(CGREP) gnu - -ifdef IS_WINDOWS -default: - $(RUSTC) --print cfg | $(CGREP) windows -else -default: - $(RUSTC) --print cfg | $(CGREP) unix -endif diff --git a/src/test/run-make/print-target-list/Makefile b/src/test/run-make/print-target-list/Makefile deleted file mode 100644 index 144c5ba10cc..00000000000 --- a/src/test/run-make/print-target-list/Makefile +++ /dev/null @@ -1,15 +0,0 @@ --include ../tools.mk - -# Checks that all the targets returned by `rustc --print target-list` are valid -# target specifications -# TODO remove the '*ios*' case when rust-lang/rust#29812 is fixed -all: - for target in $(shell $(BARE_RUSTC) --print target-list); do \ - case $$target in \ - *ios*) \ - ;; \ - *) \ - $(BARE_RUSTC) --target $$target --print sysroot \ - ;; \ - esac \ - done diff --git a/src/test/run-make/profile/Makefile b/src/test/run-make/profile/Makefile deleted file mode 100644 index 7300bfc9553..00000000000 --- a/src/test/run-make/profile/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -all: -ifeq ($(PROFILER_SUPPORT),1) - $(RUSTC) -g -Z profile test.rs - $(call RUN,test) || exit 1 - [ -e "$(TMPDIR)/test.gcno" ] || (echo "No .gcno file"; exit 1) - [ -e "$(TMPDIR)/test.gcda" ] || (echo "No .gcda file"; exit 1) -endif diff --git a/src/test/run-make/profile/test.rs b/src/test/run-make/profile/test.rs deleted file mode 100644 index 046d27a9f0f..00000000000 --- a/src/test/run-make/profile/test.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/prune-link-args/Makefile b/src/test/run-make/prune-link-args/Makefile deleted file mode 100644 index a6e219873df..00000000000 --- a/src/test/run-make/prune-link-args/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk -ifdef IS_WINDOWS -# ignore windows -RUSTC_FLAGS = -else -# Notice the space in the end, this emulates the output of pkg-config -RUSTC_FLAGS = -C link-args="-lc " -endif - -all: - $(RUSTC) $(RUSTC_FLAGS) empty.rs diff --git a/src/test/run-make/prune-link-args/empty.rs b/src/test/run-make/prune-link-args/empty.rs deleted file mode 100644 index a9e231b0ea8..00000000000 --- a/src/test/run-make/prune-link-args/empty.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { } diff --git a/src/test/run-make/relocation-model/Makefile b/src/test/run-make/relocation-model/Makefile deleted file mode 100644 index 485ecbb4b5a..00000000000 --- a/src/test/run-make/relocation-model/Makefile +++ /dev/null @@ -1,19 +0,0 @@ --include ../tools.mk - -all: others - $(RUSTC) -C relocation-model=dynamic-no-pic foo.rs - $(call RUN,foo) - - $(RUSTC) -C relocation-model=default foo.rs - $(call RUN,foo) - - $(RUSTC) -C relocation-model=dynamic-no-pic --crate-type=dylib foo.rs --emit=link,obj - -ifdef IS_MSVC -# FIXME(#28026) -others: -else -others: - $(RUSTC) -C relocation-model=static foo.rs - $(call RUN,foo) -endif diff --git a/src/test/run-make/relocation-model/foo.rs b/src/test/run-make/relocation-model/foo.rs deleted file mode 100644 index e06d81cd60b..00000000000 --- a/src/test/run-make/relocation-model/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn main() {} diff --git a/src/test/run-make/relro-levels/Makefile b/src/test/run-make/relro-levels/Makefile deleted file mode 100644 index 673ba9a9a02..00000000000 --- a/src/test/run-make/relro-levels/Makefile +++ /dev/null @@ -1,21 +0,0 @@ --include ../tools.mk - -# This tests the different -Zrelro-level values, and makes sure that they they work properly. - -all: -ifeq ($(UNAME),Linux) - # Ensure that binaries built with the full relro level links them with both - # RELRO and BIND_NOW for doing eager symbol resolving. - $(RUSTC) -Zrelro-level=full hello.rs - readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO - readelf -d $(TMPDIR)/hello | grep -q BIND_NOW - - $(RUSTC) -Zrelro-level=partial hello.rs - readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO - - # Ensure that we're *not* built with RELRO when setting it to off. We do - # not want to check for BIND_NOW however, as the linker might have that - # enabled by default. - $(RUSTC) -Zrelro-level=off hello.rs - ! readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO -endif diff --git a/src/test/run-make/relro-levels/hello.rs b/src/test/run-make/relro-levels/hello.rs deleted file mode 100644 index 41782851a1a..00000000000 --- a/src/test/run-make/relro-levels/hello.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - println!("Hello, world!"); -} diff --git a/src/test/run-make/reproducible-build/Makefile b/src/test/run-make/reproducible-build/Makefile deleted file mode 100644 index ca76a5e5d77..00000000000 --- a/src/test/run-make/reproducible-build/Makefile +++ /dev/null @@ -1,74 +0,0 @@ --include ../tools.mk -all: \ - smoke \ - debug \ - opt \ - link_paths \ - remap_paths \ - different_source_dirs \ - extern_flags - -smoke: - rm -rf $(TMPDIR) && mkdir $(TMPDIR) - $(RUSTC) linker.rs -O - $(RUSTC) reproducible-build-aux.rs - $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) - $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) - diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2" - -debug: - rm -rf $(TMPDIR) && mkdir $(TMPDIR) - $(RUSTC) linker.rs -O - $(RUSTC) reproducible-build-aux.rs -g - $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -g - $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -g - diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2" - -opt: - rm -rf $(TMPDIR) && mkdir $(TMPDIR) - $(RUSTC) linker.rs -O - $(RUSTC) reproducible-build-aux.rs -O - $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -O - $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -O - diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2" - -link_paths: - rm -rf $(TMPDIR) && mkdir $(TMPDIR) - $(RUSTC) reproducible-build-aux.rs - $(RUSTC) reproducible-build.rs --crate-type rlib -L /b - cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib - $(RUSTC) reproducible-build.rs --crate-type rlib -L /a - cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 - -remap_paths: - rm -rf $(TMPDIR) && mkdir $(TMPDIR) - $(RUSTC) reproducible-build-aux.rs - $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=/a=/c - cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib - $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=/b=/c - cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 - -different_source_dirs: - rm -rf $(TMPDIR) && mkdir $(TMPDIR) - $(RUSTC) reproducible-build-aux.rs - mkdir $(TMPDIR)/test - cp reproducible-build.rs $(TMPDIR)/test - $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=$$PWD=/b - cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib - (cd $(TMPDIR)/test && $(RUSTC) reproducible-build.rs \ - --remap-path-prefix=$(TMPDIR)/test=/b \ - --crate-type rlib) - cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 - -extern_flags: - rm -rf $(TMPDIR) && mkdir $(TMPDIR) - $(RUSTC) reproducible-build-aux.rs - $(RUSTC) reproducible-build.rs \ - --extern reproducible_build_aux=$(TMPDIR)/libreproducible_build_aux.rlib \ - --crate-type rlib - cp $(TMPDIR)/libreproducible_build_aux.rlib $(TMPDIR)/libbar.rlib - cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib - $(RUSTC) reproducible-build.rs \ - --extern reproducible_build_aux=$(TMPDIR)/libbar.rlib \ - --crate-type rlib - cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 diff --git a/src/test/run-make/reproducible-build/linker.rs b/src/test/run-make/reproducible-build/linker.rs deleted file mode 100644 index fd8946708bf..00000000000 --- a/src/test/run-make/reproducible-build/linker.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::env; -use std::path::Path; -use std::fs::File; -use std::io::{Read, Write}; - -fn main() { - let mut dst = env::current_exe().unwrap(); - dst.pop(); - dst.push("linker-arguments1"); - if dst.exists() { - dst.pop(); - dst.push("linker-arguments2"); - assert!(!dst.exists()); - } - - let mut out = String::new(); - for arg in env::args().skip(1) { - let path = Path::new(&arg); - if !path.is_file() { - out.push_str(&arg); - out.push_str("\n"); - continue - } - - let mut contents = Vec::new(); - File::open(path).unwrap().read_to_end(&mut contents).unwrap(); - - out.push_str(&format!("{}: {}\n", arg, hash(&contents))); - } - - File::create(dst).unwrap().write_all(out.as_bytes()).unwrap(); -} - -// fnv hash for now -fn hash(contents: &[u8]) -> u64 { - let mut hash = 0xcbf29ce484222325; - - for byte in contents { - hash = hash ^ (*byte as u64); - hash = hash.wrapping_mul(0x100000001b3); - } - - hash -} diff --git a/src/test/run-make/reproducible-build/reproducible-build-aux.rs b/src/test/run-make/reproducible-build/reproducible-build-aux.rs deleted file mode 100644 index 9ef853e7996..00000000000 --- a/src/test/run-make/reproducible-build/reproducible-build-aux.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub static STATIC: i32 = 1234; - -pub struct Struct { - _t1: std::marker::PhantomData, - _t2: std::marker::PhantomData, -} - -pub fn regular_fn(_: i32) {} - -pub fn generic_fn() {} - -impl Drop for Struct { - fn drop(&mut self) {} -} - -pub enum Enum { - Variant1, - Variant2(u32), - Variant3 { x: u32 } -} - -pub struct TupleStruct(pub i8, pub i16, pub i32, pub i64); - -pub trait Trait { - fn foo(&self); -} diff --git a/src/test/run-make/reproducible-build/reproducible-build.rs b/src/test/run-make/reproducible-build/reproducible-build.rs deleted file mode 100644 index a040c0f858d..00000000000 --- a/src/test/run-make/reproducible-build/reproducible-build.rs +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This test case makes sure that two identical invocations of the compiler -// (i.e. same code base, same compile-flags, same compiler-versions, etc.) -// produce the same output. In the past, symbol names of monomorphized functions -// were not deterministic (which we want to avoid). -// -// The test tries to exercise as many different paths into symbol name -// generation as possible: -// -// - regular functions -// - generic functions -// - methods -// - statics -// - closures -// - enum variant constructors -// - tuple struct constructors -// - drop glue -// - FnOnce adapters -// - Trait object shims -// - Fn Pointer shims - -#![allow(dead_code, warnings)] - -extern crate reproducible_build_aux; - -static STATIC: i32 = 1234; - -pub struct Struct { - x: T1, - y: T2, -} - -fn regular_fn(_: i32) {} - -fn generic_fn() {} - -impl Drop for Struct { - fn drop(&mut self) {} -} - -pub enum Enum { - Variant1, - Variant2(u32), - Variant3 { x: u32 } -} - -struct TupleStruct(i8, i16, i32, i64); - -impl TupleStruct { - pub fn bar(&self) {} -} - -trait Trait { - fn foo(&self); -} - -impl Trait for u64 { - fn foo(&self) {} -} - -impl reproducible_build_aux::Trait for TupleStruct { - fn foo(&self) {} -} - -fn main() { - regular_fn(STATIC); - generic_fn::(); - generic_fn::>(); - generic_fn::, reproducible_build_aux::Struct>(); - - let dropped = Struct { - x: "", - y: 'a', - }; - - let _ = Enum::Variant1; - let _ = Enum::Variant2(0); - let _ = Enum::Variant3 { x: 0 }; - let _ = TupleStruct(1, 2, 3, 4); - - let closure = |x| { - x + 1i32 - }; - - fn inner i32>(f: F) -> i32 { - f(STATIC) - } - - println!("{}", inner(closure)); - - let object_shim: &Trait = &0u64; - object_shim.foo(); - - fn with_fn_once_adapter(f: F) { - f(0); - } - - with_fn_once_adapter(|_:i32| { }); - - reproducible_build_aux::regular_fn(STATIC); - reproducible_build_aux::generic_fn::(); - reproducible_build_aux::generic_fn::>(); - reproducible_build_aux::generic_fn::, - reproducible_build_aux::Struct>(); - - let _ = reproducible_build_aux::Enum::Variant1; - let _ = reproducible_build_aux::Enum::Variant2(0); - let _ = reproducible_build_aux::Enum::Variant3 { x: 0 }; - let _ = reproducible_build_aux::TupleStruct(1, 2, 3, 4); - - let object_shim: &reproducible_build_aux::Trait = &TupleStruct(0, 1, 2, 3); - object_shim.foo(); - - let pointer_shim: &Fn(i32) = ®ular_fn; - - TupleStruct(1, 2, 3, 4).bar(); -} diff --git a/src/test/run-make/rlib-chain/Makefile b/src/test/run-make/rlib-chain/Makefile deleted file mode 100644 index 30b6811a388..00000000000 --- a/src/test/run-make/rlib-chain/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) m1.rs - $(RUSTC) m2.rs - $(RUSTC) m3.rs - $(RUSTC) m4.rs - $(call RUN,m4) - rm $(TMPDIR)/*lib - $(call RUN,m4) diff --git a/src/test/run-make/rlib-chain/m1.rs b/src/test/run-make/rlib-chain/m1.rs deleted file mode 100644 index e3afa352938..00000000000 --- a/src/test/run-make/rlib-chain/m1.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -pub fn m1() {} diff --git a/src/test/run-make/rlib-chain/m2.rs b/src/test/run-make/rlib-chain/m2.rs deleted file mode 100644 index 2b4c181134b..00000000000 --- a/src/test/run-make/rlib-chain/m2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -extern crate m1; - -pub fn m2() { m1::m1() } diff --git a/src/test/run-make/rlib-chain/m3.rs b/src/test/run-make/rlib-chain/m3.rs deleted file mode 100644 index 6323a9e65aa..00000000000 --- a/src/test/run-make/rlib-chain/m3.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -extern crate m2; - -pub fn m3() { m2::m2() } diff --git a/src/test/run-make/rlib-chain/m4.rs b/src/test/run-make/rlib-chain/m4.rs deleted file mode 100644 index 6c2a6685802..00000000000 --- a/src/test/run-make/rlib-chain/m4.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate m3; - -fn main() { m3::m3() } diff --git a/src/test/run-make/rustc-macro-dep-files/Makefile b/src/test/run-make/rustc-macro-dep-files/Makefile deleted file mode 100644 index d2c8e7fd043..00000000000 --- a/src/test/run-make/rustc-macro-dep-files/Makefile +++ /dev/null @@ -1,12 +0,0 @@ --include ../tools.mk - -ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) -# ignore stage1 -all: - -else -all: - $(RUSTC) foo.rs - $(RUSTC) bar.rs --emit dep-info - $(CGREP) -v "proc-macro source" < $(TMPDIR)/bar.d -endif diff --git a/src/test/run-make/rustc-macro-dep-files/bar.rs b/src/test/run-make/rustc-macro-dep-files/bar.rs deleted file mode 100644 index 03330c3d170..00000000000 --- a/src/test/run-make/rustc-macro-dep-files/bar.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_use] -extern crate foo; - -#[derive(A)] -struct A; - -fn main() { - let _b = B; -} diff --git a/src/test/run-make/rustc-macro-dep-files/foo.rs b/src/test/run-make/rustc-macro-dep-files/foo.rs deleted file mode 100644 index 2f2524f6ef1..00000000000 --- a/src/test/run-make/rustc-macro-dep-files/foo.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(A)] -pub fn derive(input: TokenStream) -> TokenStream { - let input = input.to_string(); - assert!(input.contains("struct A;")); - "struct B;".parse().unwrap() -} diff --git a/src/test/run-make/rustdoc-error-lines/Makefile b/src/test/run-make/rustdoc-error-lines/Makefile deleted file mode 100644 index 0019e5ee794..00000000000 --- a/src/test/run-make/rustdoc-error-lines/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -# Test that hir-tree output doens't crash and includes -# the string constant we would expect to see. - -all: - $(RUSTDOC) --test input.rs > $(TMPDIR)/output || true - $(CGREP) 'input.rs:17:15' < $(TMPDIR)/output diff --git a/src/test/run-make/rustdoc-error-lines/input.rs b/src/test/run-make/rustdoc-error-lines/input.rs deleted file mode 100644 index 6dc7060bc48..00000000000 --- a/src/test/run-make/rustdoc-error-lines/input.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test for #45868 - -// random #![feature] to ensure that crate attrs -// do not offset things -/// ```rust -/// #![feature(nll)] -/// let x: char = 1; -/// ``` -pub fn foo() { - -} diff --git a/src/test/run-make/rustdoc-output-path/Makefile b/src/test/run-make/rustdoc-output-path/Makefile deleted file mode 100644 index 8ce1c699526..00000000000 --- a/src/test/run-make/rustdoc-output-path/Makefile +++ /dev/null @@ -1,4 +0,0 @@ --include ../tools.mk - -all: - $(RUSTDOC) -o "$(TMPDIR)/foo/bar/doc" foo.rs diff --git a/src/test/run-make/rustdoc-output-path/foo.rs b/src/test/run-make/rustdoc-output-path/foo.rs deleted file mode 100644 index 11fc2cd2b8d..00000000000 --- a/src/test/run-make/rustdoc-output-path/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Foo; diff --git a/src/test/run-make/sanitizer-address/Makefile b/src/test/run-make/sanitizer-address/Makefile deleted file mode 100644 index 207615bfbd5..00000000000 --- a/src/test/run-make/sanitizer-address/Makefile +++ /dev/null @@ -1,29 +0,0 @@ --include ../tools.mk - -LOG := $(TMPDIR)/log.txt - -# NOTE the address sanitizer only supports x86_64 linux and macOS - -ifeq ($(TARGET),x86_64-apple-darwin) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) -EXTRA_RUSTFLAG=-C rpath -else -ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) - -# Apparently there are very specific Linux kernels, notably the one that's -# currently on Travis CI, which contain a buggy commit that triggers failures in -# the ASan implementation, detailed at google/sanitizers#837. As noted in -# google/sanitizers#856 the "fix" is to avoid using PIE binaries, so we pass a -# different relocation model to avoid generating a PIE binary. Once Travis is no -# longer running kernel 4.4.0-93 we can remove this and pass an empty set of -# flags again. -EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic -endif -endif - -all: -ifeq ($(ASAN_SUPPORT),1) - $(RUSTC) -g -Z sanitizer=address -Z print-link-args $(EXTRA_RUSTFLAG) overflow.rs | $(CGREP) librustc_asan - $(TMPDIR)/overflow 2>&1 | $(CGREP) stack-buffer-overflow -endif diff --git a/src/test/run-make/sanitizer-address/overflow.rs b/src/test/run-make/sanitizer-address/overflow.rs deleted file mode 100644 index 1f3c64c8c32..00000000000 --- a/src/test/run-make/sanitizer-address/overflow.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let xs = [0, 1, 2, 3]; - let _y = unsafe { *xs.as_ptr().offset(4) }; -} diff --git a/src/test/run-make/sanitizer-cdylib-link/Makefile b/src/test/run-make/sanitizer-cdylib-link/Makefile deleted file mode 100644 index bea5519ec5f..00000000000 --- a/src/test/run-make/sanitizer-cdylib-link/Makefile +++ /dev/null @@ -1,22 +0,0 @@ --include ../tools.mk - -LOG := $(TMPDIR)/log.txt - -# This test builds a shared object, then an executable that links it as a native -# rust library (constrast to an rlib). The shared library and executable both -# are compiled with address sanitizer, and we assert that a fault in the cdylib -# is correctly detected. - -ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) - -# See comment in sanitizer-address/Makefile for why this is here -EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic -endif - -all: -ifeq ($(ASAN_SUPPORT),1) - $(RUSTC) -g -Z sanitizer=address --crate-type cdylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs - $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs - LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow -endif diff --git a/src/test/run-make/sanitizer-cdylib-link/library.rs b/src/test/run-make/sanitizer-cdylib-link/library.rs deleted file mode 100644 index 4ceef5d3f52..00000000000 --- a/src/test/run-make/sanitizer-cdylib-link/library.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[no_mangle] -pub extern fn overflow() { - let xs = [0, 1, 2, 3]; - let _y = unsafe { *xs.as_ptr().offset(4) }; -} diff --git a/src/test/run-make/sanitizer-cdylib-link/program.rs b/src/test/run-make/sanitizer-cdylib-link/program.rs deleted file mode 100644 index 9f52817c851..00000000000 --- a/src/test/run-make/sanitizer-cdylib-link/program.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern { - fn overflow(); -} - -fn main() { - unsafe { overflow() } -} diff --git a/src/test/run-make/sanitizer-dylib-link/Makefile b/src/test/run-make/sanitizer-dylib-link/Makefile deleted file mode 100644 index 0cc8f73da8b..00000000000 --- a/src/test/run-make/sanitizer-dylib-link/Makefile +++ /dev/null @@ -1,22 +0,0 @@ --include ../tools.mk - -LOG := $(TMPDIR)/log.txt - -# This test builds a shared object, then an executable that links it as a native -# rust library (constrast to an rlib). The shared library and executable both -# are compiled with address sanitizer, and we assert that a fault in the dylib -# is correctly detected. - -ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) - -# See comment in sanitizer-address/Makefile for why this is here -EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic -endif - -all: -ifeq ($(ASAN_SUPPORT),1) - $(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs - $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs - LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow -endif diff --git a/src/test/run-make/sanitizer-dylib-link/library.rs b/src/test/run-make/sanitizer-dylib-link/library.rs deleted file mode 100644 index 4ceef5d3f52..00000000000 --- a/src/test/run-make/sanitizer-dylib-link/library.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[no_mangle] -pub extern fn overflow() { - let xs = [0, 1, 2, 3]; - let _y = unsafe { *xs.as_ptr().offset(4) }; -} diff --git a/src/test/run-make/sanitizer-dylib-link/program.rs b/src/test/run-make/sanitizer-dylib-link/program.rs deleted file mode 100644 index 9f52817c851..00000000000 --- a/src/test/run-make/sanitizer-dylib-link/program.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern { - fn overflow(); -} - -fn main() { - unsafe { overflow() } -} diff --git a/src/test/run-make/sanitizer-invalid-cratetype/Makefile b/src/test/run-make/sanitizer-invalid-cratetype/Makefile deleted file mode 100644 index dc37c0d0bc9..00000000000 --- a/src/test/run-make/sanitizer-invalid-cratetype/Makefile +++ /dev/null @@ -1,18 +0,0 @@ --include ../tools.mk - -# NOTE the address sanitizer only supports x86_64 linux and macOS - -ifeq ($(TARGET),x86_64-apple-darwin) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) -EXTRA_RUSTFLAG=-C rpath -else -ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) -EXTRA_RUSTFLAG= -endif -endif - -all: -ifeq ($(ASAN_SUPPORT),1) - $(RUSTC) -Z sanitizer=address --crate-type proc-macro --target $(TARGET) hello.rs 2>&1 | $(CGREP) '-Z sanitizer' -endif diff --git a/src/test/run-make/sanitizer-invalid-cratetype/hello.rs b/src/test/run-make/sanitizer-invalid-cratetype/hello.rs deleted file mode 100644 index 41782851a1a..00000000000 --- a/src/test/run-make/sanitizer-invalid-cratetype/hello.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - println!("Hello, world!"); -} diff --git a/src/test/run-make/sanitizer-invalid-target/Makefile b/src/test/run-make/sanitizer-invalid-target/Makefile deleted file mode 100644 index df8afee15ce..00000000000 --- a/src/test/run-make/sanitizer-invalid-target/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -Z sanitizer=leak --target i686-unknown-linux-gnu hello.rs 2>&1 | \ - $(CGREP) 'LeakSanitizer only works with the `x86_64-unknown-linux-gnu` target' diff --git a/src/test/run-make/sanitizer-invalid-target/hello.rs b/src/test/run-make/sanitizer-invalid-target/hello.rs deleted file mode 100644 index e9e46b7702a..00000000000 --- a/src/test/run-make/sanitizer-invalid-target/hello.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(no_core)] -#![no_core] -#![no_main] diff --git a/src/test/run-make/sanitizer-leak/Makefile b/src/test/run-make/sanitizer-leak/Makefile deleted file mode 100644 index ab43fac2e99..00000000000 --- a/src/test/run-make/sanitizer-leak/Makefile +++ /dev/null @@ -1,16 +0,0 @@ --include ../tools.mk - -# FIXME(#46126) ThinLTO for libstd broke this test -ifeq (1,0) -all: -ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ifdef SANITIZER_SUPPORT - $(RUSTC) -C opt-level=1 -g -Z sanitizer=leak -Z print-link-args leak.rs | $(CGREP) librustc_lsan - $(TMPDIR)/leak 2>&1 | $(CGREP) 'detected memory leaks' -endif -endif - -else -all: -endif - diff --git a/src/test/run-make/sanitizer-leak/leak.rs b/src/test/run-make/sanitizer-leak/leak.rs deleted file mode 100644 index 279da6aaae7..00000000000 --- a/src/test/run-make/sanitizer-leak/leak.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::mem; - -fn main() { - let xs = vec![1, 2, 3, 4]; - mem::forget(xs); -} diff --git a/src/test/run-make/sanitizer-memory/Makefile b/src/test/run-make/sanitizer-memory/Makefile deleted file mode 100644 index 3507ca2bef2..00000000000 --- a/src/test/run-make/sanitizer-memory/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -all: -ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ifdef SANITIZER_SUPPORT - $(RUSTC) -g -Z sanitizer=memory -Z print-link-args uninit.rs | $(CGREP) librustc_msan - $(TMPDIR)/uninit 2>&1 | $(CGREP) use-of-uninitialized-value -endif -endif - diff --git a/src/test/run-make/sanitizer-memory/uninit.rs b/src/test/run-make/sanitizer-memory/uninit.rs deleted file mode 100644 index 8350c7de3ac..00000000000 --- a/src/test/run-make/sanitizer-memory/uninit.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::mem; - -fn main() { - let xs: [u8; 4] = unsafe { mem::uninitialized() }; - let y = xs[0] + xs[1]; -} diff --git a/src/test/run-make/sanitizer-staticlib-link/Makefile b/src/test/run-make/sanitizer-staticlib-link/Makefile deleted file mode 100644 index 2b444d667bf..00000000000 --- a/src/test/run-make/sanitizer-staticlib-link/Makefile +++ /dev/null @@ -1,18 +0,0 @@ --include ../tools.mk - -# This test builds a staticlib, then an executable that links to it. -# The staticlib and executable both are compiled with address sanitizer, -# and we assert that a fault in the staticlib is correctly detected. - -ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) -EXTRA_RUSTFLAG= -endif - -all: -ifeq ($(ASAN_SUPPORT),1) - $(RUSTC) -g -Z sanitizer=address --crate-type staticlib --target $(TARGET) library.rs - $(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) $(EXTRACFLAGS) $(EXTRACXXFLAGS) - LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow -endif - diff --git a/src/test/run-make/sanitizer-staticlib-link/library.rs b/src/test/run-make/sanitizer-staticlib-link/library.rs deleted file mode 100644 index 4ceef5d3f52..00000000000 --- a/src/test/run-make/sanitizer-staticlib-link/library.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[no_mangle] -pub extern fn overflow() { - let xs = [0, 1, 2, 3]; - let _y = unsafe { *xs.as_ptr().offset(4) }; -} diff --git a/src/test/run-make/sanitizer-staticlib-link/program.c b/src/test/run-make/sanitizer-staticlib-link/program.c deleted file mode 100644 index abd5d508e72..00000000000 --- a/src/test/run-make/sanitizer-staticlib-link/program.c +++ /dev/null @@ -1,8 +0,0 @@ -// ignore-license -void overflow(); - -int main() { - overflow(); - return 0; -} - diff --git a/src/test/run-make/save-analysis-fail/Makefile b/src/test/run-make/save-analysis-fail/Makefile deleted file mode 100644 index f29f907cf38..00000000000 --- a/src/test/run-make/save-analysis-fail/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk -all: code -krate2: krate2.rs - $(RUSTC) $< -code: foo.rs krate2 - $(RUSTC) foo.rs -Zsave-analysis || exit 0 diff --git a/src/test/run-make/save-analysis-fail/SameDir.rs b/src/test/run-make/save-analysis-fail/SameDir.rs deleted file mode 100644 index fe70ac1edef..00000000000 --- a/src/test/run-make/save-analysis-fail/SameDir.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// sub-module in the same directory as the main crate file - -pub struct SameStruct { - pub name: String -} diff --git a/src/test/run-make/save-analysis-fail/SameDir3.rs b/src/test/run-make/save-analysis-fail/SameDir3.rs deleted file mode 100644 index 315f900868b..00000000000 --- a/src/test/run-make/save-analysis-fail/SameDir3.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn hello(x: isize) { - println!("macro {} :-(", x); -} diff --git a/src/test/run-make/save-analysis-fail/SubDir/mod.rs b/src/test/run-make/save-analysis-fail/SubDir/mod.rs deleted file mode 100644 index fe84db08da9..00000000000 --- a/src/test/run-make/save-analysis-fail/SubDir/mod.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// sub-module in a sub-directory - -use sub::sub2 as msalias; -use sub::sub2; - -static yy: usize = 25; - -mod sub { - pub mod sub2 { - pub mod sub3 { - pub fn hello() { - println!("hello from module 3"); - } - } - pub fn hello() { - println!("hello from a module"); - } - - pub struct nested_struct { - pub field2: u32, - } - } -} - -pub struct SubStruct { - pub name: String -} diff --git a/src/test/run-make/save-analysis-fail/foo.rs b/src/test/run-make/save-analysis-fail/foo.rs deleted file mode 100644 index b844f2e49e7..00000000000 --- a/src/test/run-make/save-analysis-fail/foo.rs +++ /dev/null @@ -1,468 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![ crate_name = "test" ] -#![feature(box_syntax)] -#![feature(rustc_private)] - -extern crate graphviz; -// A simple rust project - -extern crate krate2; -extern crate krate2 as krate3; - -use graphviz::RenderOption; -use std::collections::{HashMap,HashSet}; -use std::cell::RefCell; -use std::io::Write; - - -use sub::sub2 as msalias; -use sub::sub2; -use sub::sub2::nested_struct as sub_struct; - -use std::mem::size_of; - -use std::char::from_u32; - -static uni: &'static str = "Les Miséééééééérables"; -static yy: usize = 25; - -static bob: Option = None; - -// buglink test - see issue #1337. - -fn test_alias(i: Option<::Item>) { - let s = sub_struct{ field2: 45u32, }; - - // import tests - fn foo(x: &Write) {} - let _: Option<_> = from_u32(45); - - let x = 42usize; - - krate2::hello(); - krate3::hello(); - - let x = (3isize, 4usize); - let y = x.1; -} - -// Issue #37700 -const LUT_BITS: usize = 3; -pub struct HuffmanTable { - ac_lut: Option<[(i16, u8); 1 << LUT_BITS]>, -} - -struct TupStruct(isize, isize, Box); - -fn test_tup_struct(x: TupStruct) -> isize { - x.1 -} - -fn println(s: &str) { - std::io::stdout().write_all(s.as_bytes()); -} - -mod sub { - pub mod sub2 { - use std::io::Write; - pub mod sub3 { - use std::io::Write; - pub fn hello() { - ::println("hello from module 3"); - } - } - pub fn hello() { - ::println("hello from a module"); - } - - pub struct nested_struct { - pub field2: u32, - } - - pub enum nested_enum { - Nest2 = 2, - Nest3 = 3 - } - } -} - -pub mod SameDir; -pub mod SubDir; - -#[path = "SameDir3.rs"] -pub mod SameDir2; - -struct nofields; - -#[derive(Clone)] -struct some_fields { - field1: u32, -} - -type SF = some_fields; - -trait SuperTrait { - fn qux(&self) { panic!(); } -} - -trait SomeTrait: SuperTrait { - fn Method(&self, x: u32) -> u32; - - fn prov(&self, x: u32) -> u32 { - println(&x.to_string()); - 42 - } - fn provided_method(&self) -> u32 { - 42 - } -} - -trait SubTrait: SomeTrait { - fn stat2(x: &Self) -> u32 { - 32 - } -} - -trait SizedTrait: Sized {} - -fn error(s: &SizedTrait) { - let foo = 42; - println!("Hello world! {}", foo); -} - -impl SomeTrait for some_fields { - fn Method(&self, x: u32) -> u32 { - println(&x.to_string()); - self.field1 - } -} - -impl SuperTrait for some_fields { -} - -impl SubTrait for some_fields {} - -impl some_fields { - fn stat(x: u32) -> u32 { - println(&x.to_string()); - 42 - } - fn stat2(x: &some_fields) -> u32 { - 42 - } - - fn align_to(&mut self) { - - } - - fn test(&mut self) { - self.align_to::(); - } -} - -impl SuperTrait for nofields { -} -impl SomeTrait for nofields { - fn Method(&self, x: u32) -> u32 { - self.Method(x); - 43 - } - - fn provided_method(&self) -> u32 { - 21 - } -} - -impl SubTrait for nofields {} - -impl SuperTrait for (Box, Box) {} - -fn f_with_params(x: &T) { - x.Method(41); -} - -type MyType = Box; - -enum SomeEnum<'a> { - Ints(isize, isize), - Floats(f64, f64), - Strings(&'a str, &'a str, &'a str), - MyTypes(MyType, MyType) -} - -#[derive(Copy, Clone)] -enum SomeOtherEnum { - SomeConst1, - SomeConst2, - SomeConst3 -} - -enum SomeStructEnum { - EnumStruct{a:isize, b:isize}, - EnumStruct2{f1:MyType, f2:MyType}, - EnumStruct3{f1:MyType, f2:MyType, f3:SomeEnum<'static>} -} - -fn matchSomeEnum(val: SomeEnum) { - match val { - SomeEnum::Ints(int1, int2) => { println(&(int1+int2).to_string()); } - SomeEnum::Floats(float1, float2) => { println(&(float2*float1).to_string()); } - SomeEnum::Strings(.., s3) => { println(s3); } - SomeEnum::MyTypes(mt1, mt2) => { println(&(mt1.field1 - mt2.field1).to_string()); } - } -} - -fn matchSomeStructEnum(se: SomeStructEnum) { - match se { - SomeStructEnum::EnumStruct{a:a, ..} => println(&a.to_string()), - SomeStructEnum::EnumStruct2{f1:f1, f2:f_2} => println(&f_2.field1.to_string()), - SomeStructEnum::EnumStruct3{f1, ..} => println(&f1.field1.to_string()), - } -} - - -fn matchSomeStructEnum2(se: SomeStructEnum) { - use SomeStructEnum::*; - match se { - EnumStruct{a: ref aaa, ..} => println(&aaa.to_string()), - EnumStruct2{f1, f2: f2} => println(&f1.field1.to_string()), - EnumStruct3{f1, f3: SomeEnum::Ints(..), f2} => println(&f1.field1.to_string()), - _ => {}, - } -} - -fn matchSomeOtherEnum(val: SomeOtherEnum) { - use SomeOtherEnum::{SomeConst2, SomeConst3}; - match val { - SomeOtherEnum::SomeConst1 => { println("I'm const1."); } - SomeConst2 | SomeConst3 => { println("I'm const2 or const3."); } - } -} - -fn hello((z, a) : (u32, String), ex: X) { - SameDir2::hello(43); - - println(&yy.to_string()); - let (x, y): (u32, u32) = (5, 3); - println(&x.to_string()); - println(&z.to_string()); - let x: u32 = x; - println(&x.to_string()); - let x = "hello"; - println(x); - - let x = 32.0f32; - let _ = (x + ((x * x) + 1.0).sqrt()).ln(); - - let s: Box = box some_fields {field1: 43}; - let s2: Box = box some_fields {field1: 43}; - let s3 = box nofields; - - s.Method(43); - s3.Method(43); - s2.Method(43); - - ex.prov(43); - - let y: u32 = 56; - // static method on struct - let r = some_fields::stat(y); - // trait static method, calls default - let r = SubTrait::stat2(&*s3); - - let s4 = s3 as Box; - s4.Method(43); - - s4.provided_method(); - s2.prov(45); - - let closure = |x: u32, s: &SomeTrait| { - s.Method(23); - return x + y; - }; - - let z = closure(10, &*s); -} - -pub struct blah { - used_link_args: RefCell<[&'static str; 0]>, -} - -#[macro_use] -mod macro_use_test { - macro_rules! test_rec { - (q, $src: expr) => {{ - print!("{}", $src); - test_rec!($src); - }}; - ($src: expr) => { - print!("{}", $src); - }; - } - - macro_rules! internal_vars { - ($src: ident) => {{ - let mut x = $src; - x += 100; - }}; - } -} - -fn main() { // foo - let s = box some_fields {field1: 43}; - hello((43, "a".to_string()), *s); - sub::sub2::hello(); - sub2::sub3::hello(); - - let h = sub2::sub3::hello; - h(); - - // utf8 chars - let ut = "Les Miséééééééérables"; - - // For some reason, this pattern of macro_rules foiled our generated code - // avoiding strategy. - macro_rules! variable_str(($name:expr) => ( - some_fields { - field1: $name, - } - )); - let vs = variable_str!(32); - - let mut candidates: RefCell> = RefCell::new(HashMap::new()); - let _ = blah { - used_link_args: RefCell::new([]), - }; - let s1 = nofields; - let s2 = SF { field1: 55}; - let s3: some_fields = some_fields{ field1: 55}; - let s4: msalias::nested_struct = sub::sub2::nested_struct{ field2: 55}; - let s4: msalias::nested_struct = sub2::nested_struct{ field2: 55}; - println(&s2.field1.to_string()); - let s5: MyType = box some_fields{ field1: 55}; - let s = SameDir::SameStruct{name: "Bob".to_string()}; - let s = SubDir::SubStruct{name:"Bob".to_string()}; - let s6: SomeEnum = SomeEnum::MyTypes(box s2.clone(), s5); - let s7: SomeEnum = SomeEnum::Strings("one", "two", "three"); - matchSomeEnum(s6); - matchSomeEnum(s7); - let s8: SomeOtherEnum = SomeOtherEnum::SomeConst2; - matchSomeOtherEnum(s8); - let s9: SomeStructEnum = SomeStructEnum::EnumStruct2{ f1: box some_fields{ field1:10 }, - f2: box s2 }; - matchSomeStructEnum(s9); - - for x in &vec![1, 2, 3] { - let _y = x; - } - - let s7: SomeEnum = SomeEnum::Strings("one", "two", "three"); - if let SomeEnum::Strings(..) = s7 { - println!("hello!"); - } - - for i in 0..5 { - foo_foo(i); - } - - if let Some(x) = None { - foo_foo(x); - } - - if false { - } else if let Some(y) = None { - foo_foo(y); - } - - while let Some(z) = None { - foo_foo(z); - } - - let mut x = 4; - test_rec!(q, "Hello"); - assert_eq!(x, 4); - internal_vars!(x); -} - -fn foo_foo(_: i32) {} - -impl Iterator for nofields { - type Item = (usize, usize); - - fn next(&mut self) -> Option<(usize, usize)> { - panic!() - } - - fn size_hint(&self) -> (usize, Option) { - panic!() - } -} - -trait Pattern<'a> { - type Searcher; -} - -struct CharEqPattern; - -impl<'a> Pattern<'a> for CharEqPattern { - type Searcher = CharEqPattern; -} - -struct CharSearcher<'a>(>::Searcher); - -pub trait Error { -} - -impl Error + 'static { - pub fn is(&self) -> bool { - panic!() - } -} - -impl Error + 'static + Send { - pub fn is(&self) -> bool { - ::is::(self) - } -} -extern crate serialize; -#[derive(Clone, Copy, Hash, Encodable, Decodable, PartialEq, Eq, PartialOrd, Ord, Debug, Default)] -struct AllDerives(i32); - -fn test_format_args() { - let x = 1; - let y = 2; - let name = "Joe Blogg"; - println!("Hello {}", name); - print!("Hello {0}", name); - print!("{0} + {} = {}", x, y); - print!("x is {}, y is {1}, name is {n}", x, y, n = name); -} - -extern { - static EXTERN_FOO: u8; - fn extern_foo(a: u8, b: i32) -> String; -} - -struct Rls699 { - f: u32, -} - -fn new(f: u32) -> Rls699 { - Rls699 { fs } -} - -fn invalid_tuple_struct_access() { - bar.0; - - struct S; - S.0; -} diff --git a/src/test/run-make/save-analysis-fail/krate2.rs b/src/test/run-make/save-analysis-fail/krate2.rs deleted file mode 100644 index 2c6f517ff38..00000000000 --- a/src/test/run-make/save-analysis-fail/krate2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![ crate_name = "krate2" ] -#![ crate_type = "lib" ] - -use std::io::Write; - -pub fn hello() { - std::io::stdout().write_all(b"hello world!\n"); -} diff --git a/src/test/run-make/save-analysis/Makefile b/src/test/run-make/save-analysis/Makefile deleted file mode 100644 index 7296fb9cc59..00000000000 --- a/src/test/run-make/save-analysis/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk -all: code -krate2: krate2.rs - $(RUSTC) $< -code: foo.rs krate2 - $(RUSTC) foo.rs -Zsave-analysis diff --git a/src/test/run-make/save-analysis/SameDir.rs b/src/test/run-make/save-analysis/SameDir.rs deleted file mode 100644 index fe70ac1edef..00000000000 --- a/src/test/run-make/save-analysis/SameDir.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// sub-module in the same directory as the main crate file - -pub struct SameStruct { - pub name: String -} diff --git a/src/test/run-make/save-analysis/SameDir3.rs b/src/test/run-make/save-analysis/SameDir3.rs deleted file mode 100644 index 315f900868b..00000000000 --- a/src/test/run-make/save-analysis/SameDir3.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn hello(x: isize) { - println!("macro {} :-(", x); -} diff --git a/src/test/run-make/save-analysis/SubDir/mod.rs b/src/test/run-make/save-analysis/SubDir/mod.rs deleted file mode 100644 index fe84db08da9..00000000000 --- a/src/test/run-make/save-analysis/SubDir/mod.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// sub-module in a sub-directory - -use sub::sub2 as msalias; -use sub::sub2; - -static yy: usize = 25; - -mod sub { - pub mod sub2 { - pub mod sub3 { - pub fn hello() { - println!("hello from module 3"); - } - } - pub fn hello() { - println!("hello from a module"); - } - - pub struct nested_struct { - pub field2: u32, - } - } -} - -pub struct SubStruct { - pub name: String -} diff --git a/src/test/run-make/save-analysis/extra-docs.md b/src/test/run-make/save-analysis/extra-docs.md deleted file mode 100644 index 0605ca517ff..00000000000 --- a/src/test/run-make/save-analysis/extra-docs.md +++ /dev/null @@ -1 +0,0 @@ -Extra docs for this struct. diff --git a/src/test/run-make/save-analysis/foo.rs b/src/test/run-make/save-analysis/foo.rs deleted file mode 100644 index 5b4e4802957..00000000000 --- a/src/test/run-make/save-analysis/foo.rs +++ /dev/null @@ -1,467 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![ crate_name = "test" ] -#![feature(box_syntax)] -#![feature(rustc_private)] -#![feature(associated_type_defaults)] -#![feature(external_doc)] - -extern crate graphviz; -// A simple rust project - -extern crate krate2; -extern crate krate2 as krate3; - -use graphviz::RenderOption; -use std::collections::{HashMap,HashSet}; -use std::cell::RefCell; -use std::io::Write; - - -use sub::sub2 as msalias; -use sub::sub2; -use sub::sub2::nested_struct as sub_struct; - -use std::mem::size_of; - -use std::char::from_u32; - -static uni: &'static str = "Les Miséééééééérables"; -static yy: usize = 25; - -static bob: Option = None; - -// buglink test - see issue #1337. - -fn test_alias(i: Option<::Item>) { - let s = sub_struct{ field2: 45u32, }; - - // import tests - fn foo(x: &Write) {} - let _: Option<_> = from_u32(45); - - let x = 42usize; - - krate2::hello(); - krate3::hello(); - - let x = (3isize, 4usize); - let y = x.1; -} - -// Issue #37700 -const LUT_BITS: usize = 3; -pub struct HuffmanTable { - ac_lut: Option<[(i16, u8); 1 << LUT_BITS]>, -} - -struct TupStruct(isize, isize, Box); - -fn test_tup_struct(x: TupStruct) -> isize { - x.1 -} - -fn println(s: &str) { - std::io::stdout().write_all(s.as_bytes()); -} - -mod sub { - pub mod sub2 { - use std::io::Write; - pub mod sub3 { - use std::io::Write; - pub fn hello() { - ::println("hello from module 3"); - } - } - pub fn hello() { - ::println("hello from a module"); - } - - pub struct nested_struct { - pub field2: u32, - } - - pub enum nested_enum { - Nest2 = 2, - Nest3 = 3 - } - } -} - -pub mod SameDir; -pub mod SubDir; - -#[path = "SameDir3.rs"] -pub mod SameDir2; - -struct nofields; - -#[derive(Clone)] -struct some_fields { - field1: u32, -} - -type SF = some_fields; - -trait SuperTrait { - fn qux(&self) { panic!(); } -} - -trait SomeTrait: SuperTrait { - fn Method(&self, x: u32) -> u32; - - fn prov(&self, x: u32) -> u32 { - println(&x.to_string()); - 42 - } - fn provided_method(&self) -> u32 { - 42 - } -} - -trait SubTrait: SomeTrait { - fn stat2(x: &Self) -> u32 { - 32 - } -} - -impl SomeTrait for some_fields { - fn Method(&self, x: u32) -> u32 { - println(&x.to_string()); - self.field1 - } -} - -impl SuperTrait for some_fields { -} - -impl SubTrait for some_fields {} - -impl some_fields { - fn stat(x: u32) -> u32 { - println(&x.to_string()); - 42 - } - fn stat2(x: &some_fields) -> u32 { - 42 - } - - fn align_to(&mut self) { - - } - - fn test(&mut self) { - self.align_to::(); - } -} - -impl SuperTrait for nofields { -} -impl SomeTrait for nofields { - fn Method(&self, x: u32) -> u32 { - self.Method(x); - 43 - } - - fn provided_method(&self) -> u32 { - 21 - } -} - -impl SubTrait for nofields {} - -impl SuperTrait for (Box, Box) {} - -fn f_with_params(x: &T) { - x.Method(41); -} - -type MyType = Box; - -enum SomeEnum<'a> { - Ints(isize, isize), - Floats(f64, f64), - Strings(&'a str, &'a str, &'a str), - MyTypes(MyType, MyType) -} - -#[derive(Copy, Clone)] -enum SomeOtherEnum { - SomeConst1, - SomeConst2, - SomeConst3 -} - -enum SomeStructEnum { - EnumStruct{a:isize, b:isize}, - EnumStruct2{f1:MyType, f2:MyType}, - EnumStruct3{f1:MyType, f2:MyType, f3:SomeEnum<'static>} -} - -fn matchSomeEnum(val: SomeEnum) { - match val { - SomeEnum::Ints(int1, int2) => { println(&(int1+int2).to_string()); } - SomeEnum::Floats(float1, float2) => { println(&(float2*float1).to_string()); } - SomeEnum::Strings(.., s3) => { println(s3); } - SomeEnum::MyTypes(mt1, mt2) => { println(&(mt1.field1 - mt2.field1).to_string()); } - } -} - -fn matchSomeStructEnum(se: SomeStructEnum) { - match se { - SomeStructEnum::EnumStruct{a:a, ..} => println(&a.to_string()), - SomeStructEnum::EnumStruct2{f1:f1, f2:f_2} => println(&f_2.field1.to_string()), - SomeStructEnum::EnumStruct3{f1, ..} => println(&f1.field1.to_string()), - } -} - - -fn matchSomeStructEnum2(se: SomeStructEnum) { - use SomeStructEnum::*; - match se { - EnumStruct{a: ref aaa, ..} => println(&aaa.to_string()), - EnumStruct2{f1, f2: f2} => println(&f1.field1.to_string()), - EnumStruct3{f1, f3: SomeEnum::Ints(..), f2} => println(&f1.field1.to_string()), - _ => {}, - } -} - -fn matchSomeOtherEnum(val: SomeOtherEnum) { - use SomeOtherEnum::{SomeConst2, SomeConst3}; - match val { - SomeOtherEnum::SomeConst1 => { println("I'm const1."); } - SomeConst2 | SomeConst3 => { println("I'm const2 or const3."); } - } -} - -fn hello((z, a) : (u32, String), ex: X) { - SameDir2::hello(43); - - println(&yy.to_string()); - let (x, y): (u32, u32) = (5, 3); - println(&x.to_string()); - println(&z.to_string()); - let x: u32 = x; - println(&x.to_string()); - let x = "hello"; - println(x); - - let x = 32.0f32; - let _ = (x + ((x * x) + 1.0).sqrt()).ln(); - - let s: Box = box some_fields {field1: 43}; - let s2: Box = box some_fields {field1: 43}; - let s3 = box nofields; - - s.Method(43); - s3.Method(43); - s2.Method(43); - - ex.prov(43); - - let y: u32 = 56; - // static method on struct - let r = some_fields::stat(y); - // trait static method, calls default - let r = SubTrait::stat2(&*s3); - - let s4 = s3 as Box; - s4.Method(43); - - s4.provided_method(); - s2.prov(45); - - let closure = |x: u32, s: &SomeTrait| { - s.Method(23); - return x + y; - }; - - let z = closure(10, &*s); -} - -pub struct blah { - used_link_args: RefCell<[&'static str; 0]>, -} - -#[macro_use] -mod macro_use_test { - macro_rules! test_rec { - (q, $src: expr) => {{ - print!("{}", $src); - test_rec!($src); - }}; - ($src: expr) => { - print!("{}", $src); - }; - } - - macro_rules! internal_vars { - ($src: ident) => {{ - let mut x = $src; - x += 100; - }}; - } -} - -fn main() { // foo - let s = box some_fields {field1: 43}; - hello((43, "a".to_string()), *s); - sub::sub2::hello(); - sub2::sub3::hello(); - - let h = sub2::sub3::hello; - h(); - - // utf8 chars - let ut = "Les Miséééééééérables"; - - // For some reason, this pattern of macro_rules foiled our generated code - // avoiding strategy. - macro_rules! variable_str(($name:expr) => ( - some_fields { - field1: $name, - } - )); - let vs = variable_str!(32); - - let mut candidates: RefCell> = RefCell::new(HashMap::new()); - let _ = blah { - used_link_args: RefCell::new([]), - }; - let s1 = nofields; - let s2 = SF { field1: 55}; - let s3: some_fields = some_fields{ field1: 55}; - let s4: msalias::nested_struct = sub::sub2::nested_struct{ field2: 55}; - let s4: msalias::nested_struct = sub2::nested_struct{ field2: 55}; - println(&s2.field1.to_string()); - let s5: MyType = box some_fields{ field1: 55}; - let s = SameDir::SameStruct{name: "Bob".to_string()}; - let s = SubDir::SubStruct{name:"Bob".to_string()}; - let s6: SomeEnum = SomeEnum::MyTypes(box s2.clone(), s5); - let s7: SomeEnum = SomeEnum::Strings("one", "two", "three"); - matchSomeEnum(s6); - matchSomeEnum(s7); - let s8: SomeOtherEnum = SomeOtherEnum::SomeConst2; - matchSomeOtherEnum(s8); - let s9: SomeStructEnum = SomeStructEnum::EnumStruct2{ f1: box some_fields{ field1:10 }, - f2: box s2 }; - matchSomeStructEnum(s9); - - for x in &vec![1, 2, 3] { - let _y = x; - } - - let s7: SomeEnum = SomeEnum::Strings("one", "two", "three"); - if let SomeEnum::Strings(..) = s7 { - println!("hello!"); - } - - for i in 0..5 { - foo_foo(i); - } - - if let Some(x) = None { - foo_foo(x); - } - - if false { - } else if let Some(y) = None { - foo_foo(y); - } - - while let Some(z) = None { - foo_foo(z); - } - - let mut x = 4; - test_rec!(q, "Hello"); - assert_eq!(x, 4); - internal_vars!(x); -} - -fn foo_foo(_: i32) {} - -impl Iterator for nofields { - type Item = (usize, usize); - - fn next(&mut self) -> Option<(usize, usize)> { - panic!() - } - - fn size_hint(&self) -> (usize, Option) { - panic!() - } -} - -trait Pattern<'a> { - type Searcher; -} - -struct CharEqPattern; - -impl<'a> Pattern<'a> for CharEqPattern { - type Searcher = CharEqPattern; -} - -struct CharSearcher<'a>(>::Searcher); - -pub trait Error { -} - -impl Error + 'static { - pub fn is(&self) -> bool { - panic!() - } -} - -impl Error + 'static + Send { - pub fn is(&self) -> bool { - ::is::(self) - } -} -extern crate serialize; -#[derive(Clone, Copy, Hash, Encodable, Decodable, PartialEq, Eq, PartialOrd, Ord, Debug, Default)] -struct AllDerives(i32); - -fn test_format_args() { - let x = 1; - let y = 2; - let name = "Joe Blogg"; - println!("Hello {}", name); - print!("Hello {0}", name); - print!("{0} + {} = {}", x, y); - print!("x is {}, y is {1}, name is {n}", x, y, n = name); -} - - -union TestUnion { - f1: u32 -} - -struct FrameBuffer; - -struct SilenceGenerator; - -impl Iterator for SilenceGenerator { - type Item = FrameBuffer; - - fn next(&mut self) -> Option { - panic!(); - } -} - -trait Foo { - type Bar = FrameBuffer; -} - -#[doc(include="extra-docs.md")] -struct StructWithDocs; diff --git a/src/test/run-make/save-analysis/krate2.rs b/src/test/run-make/save-analysis/krate2.rs deleted file mode 100644 index 2c6f517ff38..00000000000 --- a/src/test/run-make/save-analysis/krate2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![ crate_name = "krate2" ] -#![ crate_type = "lib" ] - -use std::io::Write; - -pub fn hello() { - std::io::stdout().write_all(b"hello world!\n"); -} diff --git a/src/test/run-make/sepcomp-cci-copies/Makefile b/src/test/run-make/sepcomp-cci-copies/Makefile deleted file mode 100644 index 36f913ff3fa..00000000000 --- a/src/test/run-make/sepcomp-cci-copies/Makefile +++ /dev/null @@ -1,12 +0,0 @@ --include ../tools.mk - -# Check that cross-crate inlined items are inlined in all compilation units -# that refer to them, and not in any other compilation units. -# Note that we have to pass `-C codegen-units=6` because up to two CGUs may be -# created for each source module (see `rustc_mir::monomorphize::partitioning`). - -all: - $(RUSTC) cci_lib.rs - $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=6 \ - -Z inline-in-all-cgus - [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ .*cci_fn)" -eq "2" ] diff --git a/src/test/run-make/sepcomp-cci-copies/cci_lib.rs b/src/test/run-make/sepcomp-cci-copies/cci_lib.rs deleted file mode 100644 index 62bc3294286..00000000000 --- a/src/test/run-make/sepcomp-cci-copies/cci_lib.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[inline] -pub fn cci_fn() -> usize { - 1234 -} diff --git a/src/test/run-make/sepcomp-cci-copies/foo.rs b/src/test/run-make/sepcomp-cci-copies/foo.rs deleted file mode 100644 index e00cab20f6b..00000000000 --- a/src/test/run-make/sepcomp-cci-copies/foo.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate cci_lib; -use cci_lib::cci_fn; - -fn call1() -> usize { - cci_fn() -} - -mod a { - use cci_lib::cci_fn; - pub fn call2() -> usize { - cci_fn() - } -} - -mod b { - pub fn call3() -> usize { - 0 - } -} - -fn main() { - call1(); - a::call2(); - b::call3(); -} diff --git a/src/test/run-make/sepcomp-inlining/Makefile b/src/test/run-make/sepcomp-inlining/Makefile deleted file mode 100644 index 1d20d940000..00000000000 --- a/src/test/run-make/sepcomp-inlining/Makefile +++ /dev/null @@ -1,15 +0,0 @@ --include ../tools.mk - -# Test that #[inline] functions still get inlined across compilation unit -# boundaries. Compilation should produce three IR files, but only the two -# compilation units that have a usage of the #[inline] function should -# contain a definition. Also, the non-#[inline] function should be defined -# in only one compilation unit. - -all: - $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3 \ - -Z inline-in-all-cgus - [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ i32\ .*inlined)" -eq "0" ] - [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ internal\ i32\ .*inlined)" -eq "2" ] - [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ hidden\ i32\ .*normal)" -eq "1" ] - [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c declare\ hidden\ i32\ .*normal)" -eq "2" ] diff --git a/src/test/run-make/sepcomp-inlining/foo.rs b/src/test/run-make/sepcomp-inlining/foo.rs deleted file mode 100644 index 5b62c1b0626..00000000000 --- a/src/test/run-make/sepcomp-inlining/foo.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(start)] - -#[inline] -fn inlined() -> u32 { - 1234 -} - -fn normal() -> u32 { - 2345 -} - -mod a { - pub fn f() -> u32 { - ::inlined() + ::normal() - } -} - -mod b { - pub fn f() -> u32 { - ::inlined() + ::normal() - } -} - -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - a::f(); - b::f(); - - 0 -} diff --git a/src/test/run-make/sepcomp-separate/Makefile b/src/test/run-make/sepcomp-separate/Makefile deleted file mode 100644 index 5b8bdb0fad8..00000000000 --- a/src/test/run-make/sepcomp-separate/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -# Test that separate compilation actually puts code into separate compilation -# units. `foo.rs` defines `magic_fn` in three different modules, which should -# wind up in three different compilation units. - -all: - $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3 - [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ .*magic_fn)" -eq "3" ] diff --git a/src/test/run-make/sepcomp-separate/foo.rs b/src/test/run-make/sepcomp-separate/foo.rs deleted file mode 100644 index 64a76e9e0ed..00000000000 --- a/src/test/run-make/sepcomp-separate/foo.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - - -fn magic_fn() -> usize { - 1234 -} - -mod a { - pub fn magic_fn() -> usize { - 2345 - } -} - -mod b { - pub fn magic_fn() -> usize { - 3456 - } -} - -fn main() { - magic_fn(); - a::magic_fn(); - b::magic_fn(); -} diff --git a/src/test/run-make/simd-ffi/Makefile b/src/test/run-make/simd-ffi/Makefile deleted file mode 100644 index e9c974a0137..00000000000 --- a/src/test/run-make/simd-ffi/Makefile +++ /dev/null @@ -1,47 +0,0 @@ --include ../tools.mk - -TARGETS = -ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm) -# construct a fairly exhaustive list of platforms that we -# support. These ones don't follow a pattern -TARGETS += arm-linux-androideabi arm-unknown-linux-gnueabihf arm-unknown-linux-gnueabi -endif - -ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86) -X86_ARCHS = i686 x86_64 -else -X86_ARCHS = -endif - -# these ones do, each OS lists the architectures it supports -LINUX=$(filter aarch64 mips,$(LLVM_COMPONENTS)) $(X86_ARCHS) -ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips) -LINUX += mipsel -endif - -WINDOWS=$(X86_ARCHS) -# fails with: failed to get iphonesimulator SDK path: no such file or directory -#IOS=i386 aarch64 armv7 -DARWIN=$(X86_ARCHS) - -$(foreach arch,$(LINUX),$(eval TARGETS += $(arch)-unknown-linux-gnu)) -$(foreach arch,$(WINDOWS),$(eval TARGETS += $(arch)-pc-windows-gnu)) -#$(foreach arch,$(IOS),$(eval TARGETS += $(arch)-apple-ios)) -$(foreach arch,$(DARWIN),$(eval TARGETS += $(arch)-apple-darwin)) - -all: $(TARGETS) - -define MK_TARGETS -# compile the rust file to the given target, but only to asm and IR -# form, to avoid having to have an appropriate linker. -# -# we need some features because the integer SIMD instructions are not -# enabled by-default for i686 and ARM; these features will be invalid -# on some platforms, but LLVM just prints a warning so that's fine for -# now. -$(1): simd.rs - $$(RUSTC) --target=$(1) --emit=llvm-ir,asm simd.rs \ - -C target-feature='+neon,+sse2' -C extra-filename=-$(1) -endef - -$(foreach targetxxx,$(TARGETS),$(eval $(call MK_TARGETS,$(targetxxx)))) diff --git a/src/test/run-make/simd-ffi/simd.rs b/src/test/run-make/simd-ffi/simd.rs deleted file mode 100644 index 94b91c711cc..00000000000 --- a/src/test/run-make/simd-ffi/simd.rs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ensures that public symbols are not removed completely -#![crate_type = "lib"] -// we can compile to a variety of platforms, because we don't need -// cross-compiled standard libraries. -#![feature(no_core, optin_builtin_traits)] -#![no_core] - -#![feature(repr_simd, simd_ffi, link_llvm_intrinsics, lang_items)] - - -#[repr(C)] -#[derive(Copy)] -#[repr(simd)] -pub struct f32x4(f32, f32, f32, f32); - - -extern { - #[link_name = "llvm.sqrt.v4f32"] - fn vsqrt(x: f32x4) -> f32x4; -} - -pub fn foo(x: f32x4) -> f32x4 { - unsafe {vsqrt(x)} -} - -#[repr(C)] -#[derive(Copy)] -#[repr(simd)] -pub struct i32x4(i32, i32, i32, i32); - - -extern { - // _mm_sll_epi32 - #[cfg(any(target_arch = "x86", - target_arch = "x86-64"))] - #[link_name = "llvm.x86.sse2.psll.d"] - fn integer(a: i32x4, b: i32x4) -> i32x4; - - // vmaxq_s32 - #[cfg(target_arch = "arm")] - #[link_name = "llvm.arm.neon.vmaxs.v4i32"] - fn integer(a: i32x4, b: i32x4) -> i32x4; - // vmaxq_s32 - #[cfg(target_arch = "aarch64")] - #[link_name = "llvm.aarch64.neon.maxs.v4i32"] - fn integer(a: i32x4, b: i32x4) -> i32x4; - - // just some substitute foreign symbol, not an LLVM intrinsic; so - // we still get type checking, but not as detailed as (ab)using - // LLVM. - #[cfg(not(any(target_arch = "x86", - target_arch = "x86-64", - target_arch = "arm", - target_arch = "aarch64")))] - fn integer(a: i32x4, b: i32x4) -> i32x4; -} - -pub fn bar(a: i32x4, b: i32x4) -> i32x4 { - unsafe {integer(a, b)} -} - -#[lang = "sized"] -pub trait Sized { } - -#[lang = "copy"] -pub trait Copy { } - -pub mod marker { - pub use Copy; -} - -#[lang = "freeze"] -auto trait Freeze {} diff --git a/src/test/run-make/simple-dylib/Makefile b/src/test/run-make/simple-dylib/Makefile deleted file mode 100644 index 26730820fea..00000000000 --- a/src/test/run-make/simple-dylib/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk -all: - $(RUSTC) bar.rs --crate-type=dylib -C prefer-dynamic - $(RUSTC) foo.rs - $(call RUN,foo) diff --git a/src/test/run-make/simple-dylib/bar.rs b/src/test/run-make/simple-dylib/bar.rs deleted file mode 100644 index 4c79f7e2855..00000000000 --- a/src/test/run-make/simple-dylib/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn bar() {} diff --git a/src/test/run-make/simple-dylib/foo.rs b/src/test/run-make/simple-dylib/foo.rs deleted file mode 100644 index 858ef492ace..00000000000 --- a/src/test/run-make/simple-dylib/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar; - -fn main() { - bar::bar(); -} diff --git a/src/test/run-make/simple-rlib/Makefile b/src/test/run-make/simple-rlib/Makefile deleted file mode 100644 index 7b156cb8748..00000000000 --- a/src/test/run-make/simple-rlib/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk -all: - $(RUSTC) bar.rs --crate-type=rlib - $(RUSTC) foo.rs - $(call RUN,foo) diff --git a/src/test/run-make/simple-rlib/bar.rs b/src/test/run-make/simple-rlib/bar.rs deleted file mode 100644 index 4c79f7e2855..00000000000 --- a/src/test/run-make/simple-rlib/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn bar() {} diff --git a/src/test/run-make/simple-rlib/foo.rs b/src/test/run-make/simple-rlib/foo.rs deleted file mode 100644 index 858ef492ace..00000000000 --- a/src/test/run-make/simple-rlib/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar; - -fn main() { - bar::bar(); -} diff --git a/src/test/run-make/stable-symbol-names/Makefile b/src/test/run-make/stable-symbol-names/Makefile deleted file mode 100644 index 3cbc5593ac0..00000000000 --- a/src/test/run-make/stable-symbol-names/Makefile +++ /dev/null @@ -1,40 +0,0 @@ --include ../tools.mk - -# The following command will: -# 1. dump the symbols of a library using `nm` -# 2. extract only those lines that we are interested in via `grep` -# 3. from those lines, extract just the symbol name via `sed` -# (symbol names always start with "_ZN" and end with "E") -# 4. sort those symbol names for deterministic comparison -# 5. write the result into a file - -dump-symbols = nm "$(TMPDIR)/lib$(1).rlib" \ - | grep -E "$(2)" \ - | sed "s/.*\(_ZN.*E\).*/\1/" \ - | sort \ - > "$(TMPDIR)/$(1)$(3).nm" - -# This test -# - compiles each of the two crates 2 times and makes sure each time we get -# exactly the same symbol names -# - makes sure that both crates agree on the same symbol names for monomorphic -# functions - -all: - $(RUSTC) stable-symbol-names1.rs - $(call dump-symbols,stable_symbol_names1,generic_|mono_,_v1) - rm $(TMPDIR)/libstable_symbol_names1.rlib - $(RUSTC) stable-symbol-names1.rs - $(call dump-symbols,stable_symbol_names1,generic_|mono_,_v2) - cmp "$(TMPDIR)/stable_symbol_names1_v1.nm" "$(TMPDIR)/stable_symbol_names1_v2.nm" - - $(RUSTC) stable-symbol-names2.rs - $(call dump-symbols,stable_symbol_names2,generic_|mono_,_v1) - rm $(TMPDIR)/libstable_symbol_names2.rlib - $(RUSTC) stable-symbol-names2.rs - $(call dump-symbols,stable_symbol_names2,generic_|mono_,_v2) - cmp "$(TMPDIR)/stable_symbol_names2_v1.nm" "$(TMPDIR)/stable_symbol_names2_v2.nm" - - $(call dump-symbols,stable_symbol_names1,mono_,_cross) - $(call dump-symbols,stable_symbol_names2,mono_,_cross) - cmp "$(TMPDIR)/stable_symbol_names1_cross.nm" "$(TMPDIR)/stable_symbol_names2_cross.nm" diff --git a/src/test/run-make/stable-symbol-names/stable-symbol-names1.rs b/src/test/run-make/stable-symbol-names/stable-symbol-names1.rs deleted file mode 100644 index 7344bdf49f6..00000000000 --- a/src/test/run-make/stable-symbol-names/stable-symbol-names1.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="rlib"] - -pub trait Foo { - fn generic_method(); -} - -pub struct Bar; - -impl Foo for Bar { - fn generic_method() {} -} - -pub fn mono_function() { - Bar::generic_method::(); -} - -pub fn mono_function_lifetime<'a>(x: &'a u64) -> u64 { - *x -} - -pub fn generic_function(t: T) -> T { - t -} - -pub fn user() { - generic_function(0u32); - generic_function("abc"); - let x = 2u64; - generic_function(&x); - let _ = mono_function_lifetime(&x); -} diff --git a/src/test/run-make/stable-symbol-names/stable-symbol-names2.rs b/src/test/run-make/stable-symbol-names/stable-symbol-names2.rs deleted file mode 100644 index eacba4ddb25..00000000000 --- a/src/test/run-make/stable-symbol-names/stable-symbol-names2.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="rlib"] - -extern crate stable_symbol_names1; - -pub fn user() { - stable_symbol_names1::generic_function(1u32); - stable_symbol_names1::generic_function("def"); - let x = 2u64; - stable_symbol_names1::generic_function(&x); - stable_symbol_names1::mono_function(); - stable_symbol_names1::mono_function_lifetime(&0); -} - -pub fn trait_impl_test_function() { - use stable_symbol_names1::*; - Bar::generic_method::(); -} - diff --git a/src/test/run-make/static-dylib-by-default/Makefile b/src/test/run-make/static-dylib-by-default/Makefile deleted file mode 100644 index 6409aa66ae0..00000000000 --- a/src/test/run-make/static-dylib-by-default/Makefile +++ /dev/null @@ -1,16 +0,0 @@ --include ../tools.mk - -TO_LINK := $(call DYLIB,bar) -ifdef IS_MSVC -LINK_ARG = $(TO_LINK:dll=dll.lib) -else -LINK_ARG = $(TO_LINK) -endif - -all: - $(RUSTC) foo.rs - $(RUSTC) bar.rs - $(CC) main.c $(call OUT_EXE,main) $(LINK_ARG) $(EXTRACFLAGS) - rm $(TMPDIR)/*.rlib - rm $(call DYLIB,foo) - $(call RUN,main) diff --git a/src/test/run-make/static-dylib-by-default/bar.rs b/src/test/run-make/static-dylib-by-default/bar.rs deleted file mode 100644 index 63da277dece..00000000000 --- a/src/test/run-make/static-dylib-by-default/bar.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -extern crate foo; - -#[no_mangle] -pub extern fn bar() { - foo::foo(); -} diff --git a/src/test/run-make/static-dylib-by-default/foo.rs b/src/test/run-make/static-dylib-by-default/foo.rs deleted file mode 100644 index 341040e653c..00000000000 --- a/src/test/run-make/static-dylib-by-default/foo.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![crate_type = "dylib"] - -pub fn foo() {} diff --git a/src/test/run-make/static-dylib-by-default/main.c b/src/test/run-make/static-dylib-by-default/main.c deleted file mode 100644 index 30bb0783edf..00000000000 --- a/src/test/run-make/static-dylib-by-default/main.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern void bar(); - -int main() { - bar(); - return 0; -} diff --git a/src/test/run-make/static-nobundle/Makefile b/src/test/run-make/static-nobundle/Makefile deleted file mode 100644 index abc32d4423b..00000000000 --- a/src/test/run-make/static-nobundle/Makefile +++ /dev/null @@ -1,21 +0,0 @@ --include ../tools.mk - -# aaa is a native static library -# bbb is a rlib -# ccc is a dylib -# ddd is an executable - -all: $(call NATIVE_STATICLIB,aaa) - $(RUSTC) bbb.rs --crate-type=rlib - - # Check that bbb does NOT contain the definition of `native_func` - nm $(TMPDIR)/libbbb.rlib | $(CGREP) -ve "T _*native_func" - nm $(TMPDIR)/libbbb.rlib | $(CGREP) -e "U _*native_func" - - # Check that aaa gets linked (either as `-l aaa` or `aaa.lib`) when building ccc. - $(RUSTC) ccc.rs -C prefer-dynamic --crate-type=dylib -Z print-link-args | $(CGREP) -e '-l[" ]*aaa|aaa\.lib' - - # Check that aaa does NOT get linked when building ddd. - $(RUSTC) ddd.rs -Z print-link-args | $(CGREP) -ve '-l[" ]*aaa|aaa\.lib' - - $(call RUN,ddd) diff --git a/src/test/run-make/static-nobundle/aaa.c b/src/test/run-make/static-nobundle/aaa.c deleted file mode 100644 index 806ef878c70..00000000000 --- a/src/test/run-make/static-nobundle/aaa.c +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -void native_func() {} diff --git a/src/test/run-make/static-nobundle/bbb.rs b/src/test/run-make/static-nobundle/bbb.rs deleted file mode 100644 index 2bd69c99327..00000000000 --- a/src/test/run-make/static-nobundle/bbb.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![feature(static_nobundle)] - -#[link(name = "aaa", kind = "static-nobundle")] -extern { - pub fn native_func(); -} - -pub fn wrapped_func() { - unsafe { - native_func(); - } -} diff --git a/src/test/run-make/static-nobundle/ccc.rs b/src/test/run-make/static-nobundle/ccc.rs deleted file mode 100644 index bd34753a00d..00000000000 --- a/src/test/run-make/static-nobundle/ccc.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -extern crate bbb; - -pub fn do_work() { - unsafe { bbb::native_func(); } - bbb::wrapped_func(); -} - -pub fn do_work_generic() { - unsafe { bbb::native_func(); } - bbb::wrapped_func(); -} diff --git a/src/test/run-make/static-nobundle/ddd.rs b/src/test/run-make/static-nobundle/ddd.rs deleted file mode 100644 index f7d23a899f7..00000000000 --- a/src/test/run-make/static-nobundle/ddd.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate ccc; - -fn main() { - ccc::do_work(); - ccc::do_work_generic::(); - ccc::do_work_generic::(); -} diff --git a/src/test/run-make/static-unwinding/Makefile b/src/test/run-make/static-unwinding/Makefile deleted file mode 100644 index cb039744265..00000000000 --- a/src/test/run-make/static-unwinding/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) lib.rs - $(RUSTC) main.rs - $(call RUN,main) diff --git a/src/test/run-make/static-unwinding/lib.rs b/src/test/run-make/static-unwinding/lib.rs deleted file mode 100644 index 12c72d54c09..00000000000 --- a/src/test/run-make/static-unwinding/lib.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -pub static mut statik: isize = 0; - -struct A; -impl Drop for A { - fn drop(&mut self) { - unsafe { statik = 1; } - } -} - -pub fn callback(f: F) where F: FnOnce() { - let _a = A; - f(); -} diff --git a/src/test/run-make/static-unwinding/main.rs b/src/test/run-make/static-unwinding/main.rs deleted file mode 100644 index 1cd785334f6..00000000000 --- a/src/test/run-make/static-unwinding/main.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate lib; - -use std::thread; - -static mut statik: isize = 0; - -struct A; -impl Drop for A { - fn drop(&mut self) { - unsafe { statik = 1; } - } -} - -fn main() { - thread::spawn(move|| { - let _a = A; - lib::callback(|| panic!()); - }).join().unwrap_err(); - - unsafe { - assert_eq!(lib::statik, 1); - assert_eq!(statik, 1); - } -} diff --git a/src/test/run-make/staticlib-blank-lib/Makefile b/src/test/run-make/staticlib-blank-lib/Makefile deleted file mode 100644 index 92a278825c2..00000000000 --- a/src/test/run-make/staticlib-blank-lib/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(AR) crus $(TMPDIR)/libfoo.a foo.rs - $(AR) d $(TMPDIR)/libfoo.a foo.rs - $(RUSTC) foo.rs diff --git a/src/test/run-make/staticlib-blank-lib/foo.rs b/src/test/run-make/staticlib-blank-lib/foo.rs deleted file mode 100644 index 6010e60e95c..00000000000 --- a/src/test/run-make/staticlib-blank-lib/foo.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "staticlib"] - -#[link(name = "foo", kind = "static")] -extern {} - -fn main() {} diff --git a/src/test/run-make/stdin-non-utf8/Makefile b/src/test/run-make/stdin-non-utf8/Makefile deleted file mode 100644 index 7948c442616..00000000000 --- a/src/test/run-make/stdin-non-utf8/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - cp non-utf8 $(TMPDIR)/non-utf.rs - cat $(TMPDIR)/non-utf.rs | $(RUSTC) - 2>&1 \ - | $(CGREP) "error: couldn't read from stdin, as it did not contain valid UTF-8" diff --git a/src/test/run-make/stdin-non-utf8/non-utf8 b/src/test/run-make/stdin-non-utf8/non-utf8 deleted file mode 100644 index bc87051a852..00000000000 --- a/src/test/run-make/stdin-non-utf8/non-utf8 +++ /dev/null @@ -1 +0,0 @@ -Ò diff --git a/src/test/run-make/suspicious-library/Makefile b/src/test/run-make/suspicious-library/Makefile deleted file mode 100644 index 12f437075fb..00000000000 --- a/src/test/run-make/suspicious-library/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs -C prefer-dynamic - touch $(call DYLIB,foo-something-special) - touch $(call DYLIB,foo-something-special2) - $(RUSTC) bar.rs diff --git a/src/test/run-make/suspicious-library/bar.rs b/src/test/run-make/suspicious-library/bar.rs deleted file mode 100644 index ed0e8a7e23e..00000000000 --- a/src/test/run-make/suspicious-library/bar.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { foo::foo() } diff --git a/src/test/run-make/suspicious-library/foo.rs b/src/test/run-make/suspicious-library/foo.rs deleted file mode 100644 index 2ec6e3834a1..00000000000 --- a/src/test/run-make/suspicious-library/foo.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -pub fn foo() {} diff --git a/src/test/run-make/symbol-visibility/Makefile b/src/test/run-make/symbol-visibility/Makefile deleted file mode 100644 index f1ada814bdb..00000000000 --- a/src/test/run-make/symbol-visibility/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -include ../tools.mk - -ifdef IS_WINDOWS -# Do nothing on MSVC. -# On MINGW the --version-script, --dynamic-list, and --retain-symbol args don't -# seem to work reliably. -all: - exit 0 -else - -NM=nm -D -CDYLIB_NAME=liba_cdylib.so -RDYLIB_NAME=liba_rust_dylib.so -EXE_NAME=an_executable -COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.so - -ifeq ($(UNAME),Darwin) -NM=nm -gU -CDYLIB_NAME=liba_cdylib.dylib -RDYLIB_NAME=liba_rust_dylib.dylib -EXE_NAME=an_executable -COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dylib -endif - -all: - $(RUSTC) an_rlib.rs - $(RUSTC) a_cdylib.rs - $(RUSTC) a_rust_dylib.rs - $(RUSTC) an_executable.rs - $(RUSTC) a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib - - # Check that a cdylib exports its public #[no_mangle] functions - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ] - # Check that a cdylib exports the public #[no_mangle] functions of dependencies - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] - # Check that a cdylib DOES NOT export any public Rust functions - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ] - - # Check that a Rust dylib exports its monomorphic functions - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_rust_function_from_rust_dylib.*E)" -eq "1" ] - - # Check that a Rust dylib exports the monomorphic functions from its dependencies - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ] - - # Check that an executable does not export any dynamic symbols - [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ] - [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ] - - - # Check the combined case, where we generate a cdylib and an rlib in the same - # compilation session: - # Check that a cdylib exports its public #[no_mangle] functions - [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ] - # Check that a cdylib exports the public #[no_mangle] functions of dependencies - [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] - # Check that a cdylib DOES NOT export any public Rust functions - [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ] -endif diff --git a/src/test/run-make/symbol-visibility/a_cdylib.rs b/src/test/run-make/symbol-visibility/a_cdylib.rs deleted file mode 100644 index 9a70542c06c..00000000000 --- a/src/test/run-make/symbol-visibility/a_cdylib.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="cdylib"] - -extern crate an_rlib; - -// This should not be exported -pub fn public_rust_function_from_cdylib() {} - -// This should be exported -#[no_mangle] -pub extern "C" fn public_c_function_from_cdylib() { - an_rlib::public_c_function_from_rlib(); -} diff --git a/src/test/run-make/symbol-visibility/a_rust_dylib.rs b/src/test/run-make/symbol-visibility/a_rust_dylib.rs deleted file mode 100644 index b826211c9a4..00000000000 --- a/src/test/run-make/symbol-visibility/a_rust_dylib.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="dylib"] - -extern crate an_rlib; - -// This should be exported -pub fn public_rust_function_from_rust_dylib() {} - -// This should be exported -#[no_mangle] -pub extern "C" fn public_c_function_from_rust_dylib() {} diff --git a/src/test/run-make/symbol-visibility/an_executable.rs b/src/test/run-make/symbol-visibility/an_executable.rs deleted file mode 100644 index 73059c5e374..00000000000 --- a/src/test/run-make/symbol-visibility/an_executable.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="bin"] - -extern crate an_rlib; - -pub fn public_rust_function_from_exe() {} - -fn main() {} diff --git a/src/test/run-make/symbol-visibility/an_rlib.rs b/src/test/run-make/symbol-visibility/an_rlib.rs deleted file mode 100644 index cd19500d140..00000000000 --- a/src/test/run-make/symbol-visibility/an_rlib.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="rlib"] - -pub fn public_rust_function_from_rlib() {} - -#[no_mangle] -pub extern "C" fn public_c_function_from_rlib() {} diff --git a/src/test/run-make/symbols-are-reasonable/Makefile b/src/test/run-make/symbols-are-reasonable/Makefile deleted file mode 100644 index a6d294d2a1c..00000000000 --- a/src/test/run-make/symbols-are-reasonable/Makefile +++ /dev/null @@ -1,13 +0,0 @@ --include ../tools.mk - -# check that the compile generated symbols for strings, binaries, -# vtables, etc. have semisane names (e.g. `str.1234`); it's relatively -# easy to accidentally modify the compiler internals to make them -# become things like `str"str"(1234)`. - -OUT=$(TMPDIR)/lib.s - -all: - $(RUSTC) lib.rs --emit=asm --crate-type=staticlib - # just check for symbol declarations with the names we're expecting. - $(CGREP) -e 'str\.[0-9]+:' 'byte_str\.[0-9]+:' 'vtable\.[0-9]+' < $(OUT) diff --git a/src/test/run-make/symbols-are-reasonable/lib.rs b/src/test/run-make/symbols-are-reasonable/lib.rs deleted file mode 100644 index b9285b24cd6..00000000000 --- a/src/test/run-make/symbols-are-reasonable/lib.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub static X: &'static str = "foobarbaz"; -pub static Y: &'static [u8] = include_bytes!("lib.rs"); - -trait Foo { fn dummy(&self) { } } -impl Foo for usize {} - -#[no_mangle] -pub extern "C" fn dummy() { - // force the vtable to be created - let _x = &1usize as &Foo; -} diff --git a/src/test/run-make/symbols-include-type-name/Makefile b/src/test/run-make/symbols-include-type-name/Makefile deleted file mode 100644 index 0850a2633e5..00000000000 --- a/src/test/run-make/symbols-include-type-name/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -# Check that symbol names for methods include type names, instead of . - -OUT=$(TMPDIR)/lib.s - -all: - $(RUSTC) --crate-type staticlib --emit asm lib.rs - $(CGREP) Def < $(OUT) diff --git a/src/test/run-make/symbols-include-type-name/lib.rs b/src/test/run-make/symbols-include-type-name/lib.rs deleted file mode 100644 index d84f1617db5..00000000000 --- a/src/test/run-make/symbols-include-type-name/lib.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Def { - pub id: i32, -} - -impl Def { - pub fn new(id: i32) -> Def { - Def { id: id } - } -} - -#[no_mangle] -pub fn user() { - let _ = Def::new(0); -} diff --git a/src/test/run-make/symlinked-extern/Makefile b/src/test/run-make/symlinked-extern/Makefile deleted file mode 100644 index 88dbad51e48..00000000000 --- a/src/test/run-make/symlinked-extern/Makefile +++ /dev/null @@ -1,16 +0,0 @@ --include ../tools.mk - -# ignore windows: `ln` is actually `cp` on msys. -ifndef IS_WINDOWS - -all: - $(RUSTC) foo.rs - mkdir -p $(TMPDIR)/other - ln -nsf $(TMPDIR)/libfoo.rlib $(TMPDIR)/other - $(RUSTC) bar.rs -L $(TMPDIR) - $(RUSTC) baz.rs --extern foo=$(TMPDIR)/other/libfoo.rlib -L $(TMPDIR) - -else -all: - -endif diff --git a/src/test/run-make/symlinked-extern/bar.rs b/src/test/run-make/symlinked-extern/bar.rs deleted file mode 100644 index 79103f24017..00000000000 --- a/src/test/run-make/symlinked-extern/bar.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -extern crate foo; - -pub fn bar(_s: foo::S) { -} diff --git a/src/test/run-make/symlinked-extern/baz.rs b/src/test/run-make/symlinked-extern/baz.rs deleted file mode 100644 index 0f6ba254368..00000000000 --- a/src/test/run-make/symlinked-extern/baz.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar; -extern crate foo; - -fn main() { - bar::bar(foo::foo()); -} diff --git a/src/test/run-make/symlinked-extern/foo.rs b/src/test/run-make/symlinked-extern/foo.rs deleted file mode 100644 index 0b8bb64d375..00000000000 --- a/src/test/run-make/symlinked-extern/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -pub struct S; - -pub fn foo() -> S { S } diff --git a/src/test/run-make/symlinked-libraries/Makefile b/src/test/run-make/symlinked-libraries/Makefile deleted file mode 100644 index ac595546aa7..00000000000 --- a/src/test/run-make/symlinked-libraries/Makefile +++ /dev/null @@ -1,15 +0,0 @@ --include ../tools.mk - -# ignore windows: `ln` is actually `cp` on msys. -ifndef IS_WINDOWS - -all: - $(RUSTC) foo.rs -C prefer-dynamic - mkdir -p $(TMPDIR)/other - ln -nsf $(TMPDIR)/$(call DYLIB_GLOB,foo) $(TMPDIR)/other - $(RUSTC) bar.rs -L $(TMPDIR)/other - -else -all: - -endif diff --git a/src/test/run-make/symlinked-libraries/bar.rs b/src/test/run-make/symlinked-libraries/bar.rs deleted file mode 100644 index 73596f93f56..00000000000 --- a/src/test/run-make/symlinked-libraries/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::bar(); -} diff --git a/src/test/run-make/symlinked-libraries/foo.rs b/src/test/run-make/symlinked-libraries/foo.rs deleted file mode 100644 index fdb29974cd8..00000000000 --- a/src/test/run-make/symlinked-libraries/foo.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -pub fn bar() {} diff --git a/src/test/run-make/symlinked-rlib/Makefile b/src/test/run-make/symlinked-rlib/Makefile deleted file mode 100644 index 2709f786e0a..00000000000 --- a/src/test/run-make/symlinked-rlib/Makefile +++ /dev/null @@ -1,14 +0,0 @@ --include ../tools.mk - -# ignore windows: `ln` is actually `cp` on msys. -ifndef IS_WINDOWS - -all: - $(RUSTC) foo.rs --crate-type=rlib -o $(TMPDIR)/foo.xxx - ln -nsf $(TMPDIR)/foo.xxx $(TMPDIR)/libfoo.rlib - $(RUSTC) bar.rs -L $(TMPDIR) - -else -all: - -endif diff --git a/src/test/run-make/symlinked-rlib/bar.rs b/src/test/run-make/symlinked-rlib/bar.rs deleted file mode 100644 index e8f06680862..00000000000 --- a/src/test/run-make/symlinked-rlib/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::bar(); -} diff --git a/src/test/run-make/symlinked-rlib/foo.rs b/src/test/run-make/symlinked-rlib/foo.rs deleted file mode 100644 index 5abbb1dcbce..00000000000 --- a/src/test/run-make/symlinked-rlib/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn bar() {} diff --git a/src/test/run-make/sysroot-crates-are-unstable/Makefile b/src/test/run-make/sysroot-crates-are-unstable/Makefile deleted file mode 100644 index a35174b3c2a..00000000000 --- a/src/test/run-make/sysroot-crates-are-unstable/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -all: - python2.7 test.py diff --git a/src/test/run-make/sysroot-crates-are-unstable/test.py b/src/test/run-make/sysroot-crates-are-unstable/test.py deleted file mode 100644 index 210059e1010..00000000000 --- a/src/test/run-make/sysroot-crates-are-unstable/test.py +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright 2015 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -import sys -import os -from os import listdir -from os.path import isfile, join -from subprocess import PIPE, Popen - - -# This is a whitelist of files which are stable crates or simply are not crates, -# we don't check for the instability of these crates as they're all stable! -STABLE_CRATES = ['std', 'core', 'proc_macro', 'rsbegin.o', 'rsend.o', 'dllcrt2.o', 'crt2.o', - 'clang_rt'] - - -def convert_to_string(s): - if s.__class__.__name__ == 'bytes': - return s.decode('utf-8') - return s - - -def exec_command(command, to_input=None): - child = None - if to_input is None: - child = Popen(command, stdout=PIPE, stderr=PIPE) - else: - child = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE) - stdout, stderr = child.communicate(input=to_input) - return (convert_to_string(stdout), convert_to_string(stderr)) - - -def check_lib(lib): - if lib['name'] in STABLE_CRATES: - return True - print('verifying if {} is an unstable crate'.format(lib['name'])) - stdout, stderr = exec_command([os.environ['RUSTC'], '-', '--crate-type', 'rlib', - '--extern', '{}={}'.format(lib['name'], lib['path'])], - to_input='extern crate {};'.format(lib['name'])) - if not 'use of unstable library feature' in '{}{}'.format(stdout, stderr): - print('crate {} "{}" is not unstable'.format(lib['name'], lib['path'])) - print('{}{}'.format(stdout, stderr)) - print('') - return False - return True - -# Generate a list of all crates in the sysroot. To do this we list all files in -# rustc's sysroot, look at the filename, strip everything after the `-`, and -# strip the leading `lib` (if present) -def get_all_libs(dir_path): - return [{ 'path': join(dir_path, f), 'name': f[3:].split('-')[0] } - for f in listdir(dir_path) - if isfile(join(dir_path, f)) and f.endswith('.rlib') and f not in STABLE_CRATES] - - -sysroot = exec_command([os.environ['RUSTC'], '--print', 'sysroot'])[0].replace('\n', '') -libs = get_all_libs(join(sysroot, 'lib/rustlib/{}/lib'.format(os.environ['TARGET']))) - -ret = 0 -for lib in libs: - if not check_lib(lib): - # We continue so users can see all the not unstable crates. - ret = 1 -sys.exit(ret) diff --git a/src/test/run-make/target-cpu-native/Makefile b/src/test/run-make/target-cpu-native/Makefile deleted file mode 100644 index 0c9d93ecb2a..00000000000 --- a/src/test/run-make/target-cpu-native/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs -C target-cpu=native - $(call RUN,foo) diff --git a/src/test/run-make/target-cpu-native/foo.rs b/src/test/run-make/target-cpu-native/foo.rs deleted file mode 100644 index f7a9f969060..00000000000 --- a/src/test/run-make/target-cpu-native/foo.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { -} diff --git a/src/test/run-make/target-specs/Makefile b/src/test/run-make/target-specs/Makefile deleted file mode 100644 index aff15ce38b4..00000000000 --- a/src/test/run-make/target-specs/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk -all: - $(RUSTC) foo.rs --target=my-awesome-platform.json --crate-type=lib --emit=asm - $(CGREP) -v morestack < $(TMPDIR)/foo.s - $(RUSTC) foo.rs --target=my-invalid-platform.json 2>&1 | $(CGREP) "Error loading target specification" - $(RUSTC) foo.rs --target=my-incomplete-platform.json 2>&1 | $(CGREP) 'Field llvm-target' - RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-awesome-platform --crate-type=lib --emit=asm - RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-x86_64-unknown-linux-gnu-platform --crate-type=lib --emit=asm - $(RUSTC) -Z unstable-options --target=my-awesome-platform.json --print target-spec-json > $(TMPDIR)/test-platform.json && $(RUSTC) -Z unstable-options --target=$(TMPDIR)/test-platform.json --print target-spec-json | diff -q $(TMPDIR)/test-platform.json - diff --git a/src/test/run-make/target-specs/foo.rs b/src/test/run-make/target-specs/foo.rs deleted file mode 100644 index bbd1c5d900f..00000000000 --- a/src/test/run-make/target-specs/foo.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(lang_items, no_core, optin_builtin_traits)] -#![no_core] - -#[lang="copy"] -trait Copy { } - -#[lang="sized"] -trait Sized { } - -#[lang = "freeze"] -auto trait Freeze {} - -#[lang="start"] -fn start(_main: *const u8, _argc: isize, _argv: *const *const u8) -> isize { 0 } - -extern { - fn _foo() -> [u8; 16]; -} - -fn _main() { - let _a = unsafe { _foo() }; -} diff --git a/src/test/run-make/target-specs/my-awesome-platform.json b/src/test/run-make/target-specs/my-awesome-platform.json deleted file mode 100644 index 8d028280a8d..00000000000 --- a/src/test/run-make/target-specs/my-awesome-platform.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data-layout": "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128", - "linker-flavor": "gcc", - "llvm-target": "i686-unknown-linux-gnu", - "target-endian": "little", - "target-pointer-width": "32", - "target-c-int-width": "32", - "arch": "x86", - "os": "linux", - "morestack": false -} diff --git a/src/test/run-make/target-specs/my-incomplete-platform.json b/src/test/run-make/target-specs/my-incomplete-platform.json deleted file mode 100644 index ceaa25cdf2f..00000000000 --- a/src/test/run-make/target-specs/my-incomplete-platform.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "data-layout": "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32", - "linker-flavor": "gcc", - "target-endian": "little", - "target-pointer-width": "32", - "target-c-int-width": "32", - "arch": "x86", - "os": "foo", - "morestack": false -} diff --git a/src/test/run-make/target-specs/my-invalid-platform.json b/src/test/run-make/target-specs/my-invalid-platform.json deleted file mode 100644 index 3feac45b7d6..00000000000 --- a/src/test/run-make/target-specs/my-invalid-platform.json +++ /dev/null @@ -1 +0,0 @@ -wow this json is really broke! diff --git a/src/test/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json b/src/test/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json deleted file mode 100644 index 3ae01d72fcc..00000000000 --- a/src/test/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "pre-link-args": ["-m64"], - "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", - "linker-flavor": "gcc", - "llvm-target": "x86_64-unknown-linux-gnu", - "target-endian": "little", - "target-pointer-width": "64", - "target-c-int-width": "32", - "arch": "x86_64", - "os": "linux", - "morestack": false -} diff --git a/src/test/run-make/target-without-atomics/Makefile b/src/test/run-make/target-without-atomics/Makefile deleted file mode 100644 index c5f575ddf84..00000000000 --- a/src/test/run-make/target-without-atomics/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -# The target used below doesn't support atomic operations. Verify that's the case -all: - $(RUSTC) --print cfg --target thumbv6m-none-eabi | $(CGREP) -v target_has_atomic diff --git a/src/test/run-make/test-harness/Makefile b/src/test/run-make/test-harness/Makefile deleted file mode 100644 index 39477c07ced..00000000000 --- a/src/test/run-make/test-harness/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: - # check that #[cfg_attr(..., ignore)] does the right thing. - $(RUSTC) --test test-ignore-cfg.rs --cfg ignorecfg - $(call RUN,test-ignore-cfg) | $(CGREP) 'shouldnotignore ... ok' 'shouldignore ... ignored' - $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -e "^i\.$$" - $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -v 'should' diff --git a/src/test/run-make/test-harness/test-ignore-cfg.rs b/src/test/run-make/test-harness/test-ignore-cfg.rs deleted file mode 100644 index 990d3d10485..00000000000 --- a/src/test/run-make/test-harness/test-ignore-cfg.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[test] -#[cfg_attr(ignorecfg, ignore)] -fn shouldignore() { -} - -#[test] -#[cfg_attr(noignorecfg, ignore)] -fn shouldnotignore() { -} diff --git a/src/test/run-make/tools.mk b/src/test/run-make/tools.mk deleted file mode 100644 index af1707de6c0..00000000000 --- a/src/test/run-make/tools.mk +++ /dev/null @@ -1,134 +0,0 @@ -# These deliberately use `=` and not `:=` so that client makefiles can -# augment HOST_RPATH_DIR / TARGET_RPATH_DIR. -HOST_RPATH_ENV = \ - $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(HOST_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))" -TARGET_RPATH_ENV = \ - $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(TARGET_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))" - -RUSTC_ORIGINAL := $(RUSTC) -BARE_RUSTC := $(HOST_RPATH_ENV) '$(RUSTC)' -BARE_RUSTDOC := $(HOST_RPATH_ENV) '$(RUSTDOC)' -RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR) $(RUSTFLAGS) -RUSTDOC := $(BARE_RUSTDOC) -L $(TARGET_RPATH_DIR) -ifdef RUSTC_LINKER -RUSTC := $(RUSTC) -Clinker=$(RUSTC_LINKER) -RUSTDOC := $(RUSTDOC) --linker $(RUSTC_LINKER) -Z unstable-options -endif -#CC := $(CC) -L $(TMPDIR) -HTMLDOCCK := $(PYTHON) $(S)/src/etc/htmldocck.py -CGREP := "$(S)/src/etc/cat-and-grep.sh" - -# This is the name of the binary we will generate and run; use this -# e.g. for `$(CC) -o $(RUN_BINFILE)`. -RUN_BINFILE = $(TMPDIR)/$(1) - -# RUN and FAIL are basic way we will invoke the generated binary. On -# non-windows platforms, they set the LD_LIBRARY_PATH environment -# variable before running the binary. - -RLIB_GLOB = lib$(1)*.rlib -BIN = $(1) - -UNAME = $(shell uname) - -ifeq ($(UNAME),Darwin) -RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE) -FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0 -DYLIB_GLOB = lib$(1)*.dylib -DYLIB = $(TMPDIR)/lib$(1).dylib -STATICLIB = $(TMPDIR)/lib$(1).a -STATICLIB_GLOB = lib$(1)*.a -else -ifdef IS_WINDOWS -RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) -FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) && exit 1 || exit 0 -DYLIB_GLOB = $(1)*.dll -DYLIB = $(TMPDIR)/$(1).dll -STATICLIB = $(TMPDIR)/$(1).lib -STATICLIB_GLOB = $(1)*.lib -BIN = $(1).exe -else -RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE) -FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0 -DYLIB_GLOB = lib$(1)*.so -DYLIB = $(TMPDIR)/lib$(1).so -STATICLIB = $(TMPDIR)/lib$(1).a -STATICLIB_GLOB = lib$(1)*.a -endif -endif - -ifdef IS_MSVC -COMPILE_OBJ = $(CC) -c -Fo:`cygpath -w $(1)` $(2) -NATIVE_STATICLIB_FILE = $(1).lib -NATIVE_STATICLIB = $(TMPDIR)/$(call NATIVE_STATICLIB_FILE,$(1)) -OUT_EXE=-Fe:`cygpath -w $(TMPDIR)/$(call BIN,$(1))` \ - -Fo:`cygpath -w $(TMPDIR)/$(1).obj` -else -COMPILE_OBJ = $(CC) -c -o $(1) $(2) -NATIVE_STATICLIB_FILE = lib$(1).a -NATIVE_STATICLIB = $(call STATICLIB,$(1)) -OUT_EXE=-o $(TMPDIR)/$(1) -endif - - -# Extra flags needed to compile a working executable with the standard library -ifdef IS_WINDOWS -ifdef IS_MSVC - EXTRACFLAGS := ws2_32.lib userenv.lib shell32.lib advapi32.lib -else - EXTRACFLAGS := -lws2_32 -luserenv -endif -else -ifeq ($(UNAME),Darwin) - EXTRACFLAGS := -lresolv -else -ifeq ($(UNAME),FreeBSD) - EXTRACFLAGS := -lm -lpthread -lgcc_s -else -ifeq ($(UNAME),Bitrig) - EXTRACFLAGS := -lm -lpthread - EXTRACXXFLAGS := -lc++ -lc++abi -else -ifeq ($(UNAME),SunOS) - EXTRACFLAGS := -lm -lpthread -lposix4 -lsocket -lresolv -else -ifeq ($(UNAME),OpenBSD) - EXTRACFLAGS := -lm -lpthread -lc++abi - RUSTC := $(RUSTC) -C linker="$(word 1,$(CC:ccache=))" -else - EXTRACFLAGS := -lm -lrt -ldl -lpthread - EXTRACXXFLAGS := -lstdc++ -endif -endif -endif -endif -endif -endif - -REMOVE_DYLIBS = rm $(TMPDIR)/$(call DYLIB_GLOB,$(1)) -REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1)) - -%.a: %.o - $(AR) crus $@ $< -ifdef IS_MSVC -%.lib: lib%.o - $(MSVC_LIB) -out:`cygpath -w $@` $< -else -%.lib: lib%.o - $(AR) crus $@ $< -endif -%.dylib: %.o - $(CC) -dynamiclib -Wl,-dylib -o $@ $< -%.so: %.o - $(CC) -o $@ $< -shared - -ifdef IS_MSVC -%.dll: lib%.o - $(CC) $< -link -dll -out:`cygpath -w $@` -else -%.dll: lib%.o - $(CC) -o $@ $< -shared -endif - -$(TMPDIR)/lib%.o: %.c - $(call COMPILE_OBJ,$@,$<) diff --git a/src/test/run-make/treat-err-as-bug/Makefile b/src/test/run-make/treat-err-as-bug/Makefile deleted file mode 100644 index f99e4611174..00000000000 --- a/src/test/run-make/treat-err-as-bug/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) err.rs -Z treat-err-as-bug 2>&1 \ - | $(CGREP) "panicked at 'encountered error with \`-Z treat_err_as_bug'" diff --git a/src/test/run-make/treat-err-as-bug/err.rs b/src/test/run-make/treat-err-as-bug/err.rs deleted file mode 100644 index 078495663ac..00000000000 --- a/src/test/run-make/treat-err-as-bug/err.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="rlib"] - -pub static C: u32 = 0-1; diff --git a/src/test/run-make/type-mismatch-same-crate-name/Makefile b/src/test/run-make/type-mismatch-same-crate-name/Makefile deleted file mode 100644 index 9fd1377322b..00000000000 --- a/src/test/run-make/type-mismatch-same-crate-name/Makefile +++ /dev/null @@ -1,19 +0,0 @@ --include ../tools.mk - -all: - # compile two different versions of crateA - $(RUSTC) --crate-type=rlib crateA.rs -C metadata=-1 -C extra-filename=-1 - $(RUSTC) --crate-type=rlib crateA.rs -C metadata=-2 -C extra-filename=-2 - # make crateB depend on version 1 of crateA - $(RUSTC) --crate-type=rlib crateB.rs --extern crateA=$(TMPDIR)/libcrateA-1.rlib - # make crateC depend on version 2 of crateA - $(RUSTC) crateC.rs --extern crateA=$(TMPDIR)/libcrateA-2.rlib 2>&1 | \ - tr -d '\r\n' | $(CGREP) -e \ - "mismatched types.*\ - crateB::try_foo\(foo2\);.*\ - expected struct \`crateA::foo::Foo\`, found struct \`crateA::Foo\`.*\ - different versions of crate \`crateA\`.*\ - mismatched types.*\ - crateB::try_bar\(bar2\);.*\ - expected trait \`crateA::bar::Bar\`, found trait \`crateA::Bar\`.*\ - different versions of crate \`crateA\`" diff --git a/src/test/run-make/type-mismatch-same-crate-name/crateA.rs b/src/test/run-make/type-mismatch-same-crate-name/crateA.rs deleted file mode 100644 index e40266bb4cd..00000000000 --- a/src/test/run-make/type-mismatch-same-crate-name/crateA.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod foo { - pub struct Foo; -} - -mod bar { - pub trait Bar{} - - pub fn bar() -> Box { - unimplemented!() - } -} - -// This makes the publicly accessible path -// differ from the internal one. -pub use foo::Foo; -pub use bar::{Bar, bar}; diff --git a/src/test/run-make/type-mismatch-same-crate-name/crateB.rs b/src/test/run-make/type-mismatch-same-crate-name/crateB.rs deleted file mode 100644 index da4ea1c9387..00000000000 --- a/src/test/run-make/type-mismatch-same-crate-name/crateB.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate crateA; - -pub fn try_foo(x: crateA::Foo){} -pub fn try_bar(x: Box){} diff --git a/src/test/run-make/type-mismatch-same-crate-name/crateC.rs b/src/test/run-make/type-mismatch-same-crate-name/crateC.rs deleted file mode 100644 index 210bc4c8320..00000000000 --- a/src/test/run-make/type-mismatch-same-crate-name/crateC.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This tests the extra note reported when a type error deals with -// seemingly identical types. -// The main use case of this error is when there are two crates -// (generally different versions of the same crate) with the same name -// causing a type mismatch. - -// The test is nearly the same as the one in -// compile-fail/type-mismatch-same-crate-name.rs -// but deals with the case where one of the crates -// is only introduced as an indirect dependency. -// and the type is accessed via a re-export. -// This is similar to how the error can be introduced -// when using cargo's automatic dependency resolution. - -extern crate crateA; - -fn main() { - let foo2 = crateA::Foo; - let bar2 = crateA::bar(); - { - extern crate crateB; - crateB::try_foo(foo2); - crateB::try_bar(bar2); - } -} diff --git a/src/test/run-make/use-extern-for-plugins/Makefile b/src/test/run-make/use-extern-for-plugins/Makefile deleted file mode 100644 index cc7bc176f49..00000000000 --- a/src/test/run-make/use-extern-for-plugins/Makefile +++ /dev/null @@ -1,21 +0,0 @@ --include ../tools.mk - -SKIP_OS := 'FreeBSD OpenBSD Bitrig SunOS' - -ifneq ($(UNAME),$(findstring $(UNAME),$(SKIP_OS))) - -HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //') -ifeq ($(findstring i686,$(HOST)),i686) -TARGET := $(subst i686,x86_64,$(HOST)) -else -TARGET := $(subst x86_64,i686,$(HOST)) -endif - -all: - $(RUSTC) foo.rs -C extra-filename=-host - $(RUSTC) bar.rs -C extra-filename=-targ --target $(TARGET) - $(RUSTC) baz.rs --extern a=$(TMPDIR)/liba-targ.rlib --target $(TARGET) -else -# FreeBSD, OpenBSD, and Bitrig support only x86_64 architecture for now -all: -endif diff --git a/src/test/run-make/use-extern-for-plugins/bar.rs b/src/test/run-make/use-extern-for-plugins/bar.rs deleted file mode 100644 index 3e99ed60c62..00000000000 --- a/src/test/run-make/use-extern-for-plugins/bar.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(no_core)] -#![no_core] -#![crate_type = "lib"] -#![crate_name = "a"] - -#[macro_export] -macro_rules! bar { - () => () -} diff --git a/src/test/run-make/use-extern-for-plugins/baz.rs b/src/test/run-make/use-extern-for-plugins/baz.rs deleted file mode 100644 index 3f15d0e6e05..00000000000 --- a/src/test/run-make/use-extern-for-plugins/baz.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(no_core)] -#![no_core] -#![crate_type = "lib"] - -#[macro_use] -extern crate a; - -bar!(); diff --git a/src/test/run-make/use-extern-for-plugins/foo.rs b/src/test/run-make/use-extern-for-plugins/foo.rs deleted file mode 100644 index 0afd3be466d..00000000000 --- a/src/test/run-make/use-extern-for-plugins/foo.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![no_std] -#![crate_type = "lib"] -#![crate_name = "a"] - -#[macro_export] -macro_rules! foo { - () => () -} diff --git a/src/test/run-make/used/Makefile b/src/test/run-make/used/Makefile deleted file mode 100644 index 47edcbb5d0a..00000000000 --- a/src/test/run-make/used/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -ifdef IS_WINDOWS -# Do nothing on MSVC. -all: - exit 0 -else -all: - $(RUSTC) -C opt-level=3 --emit=obj used.rs - nm $(TMPDIR)/used.o | $(CGREP) FOO -endif diff --git a/src/test/run-make/used/used.rs b/src/test/run-make/used/used.rs deleted file mode 100644 index 186cd0fdf5e..00000000000 --- a/src/test/run-make/used/used.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -#![feature(used)] - -#[used] -static FOO: u32 = 0; - -static BAR: u32 = 0; diff --git a/src/test/run-make/version/Makefile b/src/test/run-make/version/Makefile deleted file mode 100644 index 23e14a9cb93..00000000000 --- a/src/test/run-make/version/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -V - $(RUSTC) -vV - $(RUSTC) --version --verbose diff --git a/src/test/run-make/volatile-intrinsics/Makefile b/src/test/run-make/volatile-intrinsics/Makefile deleted file mode 100644 index acbadbef9fb..00000000000 --- a/src/test/run-make/volatile-intrinsics/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -all: - # The tests must pass... - $(RUSTC) main.rs - $(call RUN,main) - # ... and the loads/stores must not be optimized out. - $(RUSTC) main.rs --emit=llvm-ir - $(CGREP) "load volatile" "store volatile" < $(TMPDIR)/main.ll diff --git a/src/test/run-make/volatile-intrinsics/main.rs b/src/test/run-make/volatile-intrinsics/main.rs deleted file mode 100644 index 4d0d7672101..00000000000 --- a/src/test/run-make/volatile-intrinsics/main.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(core_intrinsics, volatile)] - -use std::intrinsics::{volatile_load, volatile_store}; -use std::ptr::{read_volatile, write_volatile}; - -pub fn main() { - unsafe { - let mut i : isize = 1; - volatile_store(&mut i, 2); - assert_eq!(volatile_load(&i), 2); - } - unsafe { - let mut i : isize = 1; - write_volatile(&mut i, 2); - assert_eq!(read_volatile(&i), 2); - } -} diff --git a/src/test/run-make/wasm-custom-section/Makefile b/src/test/run-make/wasm-custom-section/Makefile new file mode 100644 index 00000000000..399951e5163 --- /dev/null +++ b/src/test/run-make/wasm-custom-section/Makefile @@ -0,0 +1,10 @@ +-include ../../run-make-fulldeps/tools.mk + +ifeq ($(TARGET),wasm32-unknown-unknown) +all: + $(RUSTC) foo.rs --target wasm32-unknown-unknown + $(RUSTC) bar.rs -C lto -O --target wasm32-unknown-unknown + $(NODE) foo.js $(TMPDIR)/bar.wasm +else +all: +endif diff --git a/src/test/run-make/wasm-custom-section/bar.rs b/src/test/run-make/wasm-custom-section/bar.rs new file mode 100644 index 00000000000..e3db36d6dbd --- /dev/null +++ b/src/test/run-make/wasm-custom-section/bar.rs @@ -0,0 +1,24 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "cdylib"] +#![feature(wasm_custom_section)] +#![deny(warnings)] + +extern crate foo; + +#[wasm_custom_section = "foo"] +const A: [u8; 2] = [5, 6]; + +#[wasm_custom_section = "baz"] +const B: [u8; 2] = [7, 8]; + +#[no_mangle] +pub extern fn foo() {} diff --git a/src/test/run-make/wasm-custom-section/foo.js b/src/test/run-make/wasm-custom-section/foo.js new file mode 100644 index 00000000000..df69354f3a4 --- /dev/null +++ b/src/test/run-make/wasm-custom-section/foo.js @@ -0,0 +1,46 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const fs = require('fs'); +const process = require('process'); +const assert = require('assert'); +const buffer = fs.readFileSync(process.argv[2]); + +let m = new WebAssembly.Module(buffer); +let sections = WebAssembly.Module.customSections(m, "baz"); +console.log('section baz', sections); +assert.strictEqual(sections.length, 1); +let section = new Uint8Array(sections[0]); +console.log('contents', section); +assert.strictEqual(section.length, 2); +assert.strictEqual(section[0], 7); +assert.strictEqual(section[1], 8); + +sections = WebAssembly.Module.customSections(m, "bar"); +console.log('section bar', sections); +assert.strictEqual(sections.length, 1, "didn't pick up `bar` section from dependency"); +section = new Uint8Array(sections[0]); +console.log('contents', section); +assert.strictEqual(section.length, 2); +assert.strictEqual(section[0], 3); +assert.strictEqual(section[1], 4); + +sections = WebAssembly.Module.customSections(m, "foo"); +console.log('section foo', sections); +assert.strictEqual(sections.length, 1, "didn't create `foo` section"); +section = new Uint8Array(sections[0]); +console.log('contents', section); +assert.strictEqual(section.length, 4, "didn't concatenate `foo` sections"); +assert.strictEqual(section[0], 5); +assert.strictEqual(section[1], 6); +assert.strictEqual(section[2], 1); +assert.strictEqual(section[3], 2); + +process.exit(1); diff --git a/src/test/run-make/wasm-custom-section/foo.rs b/src/test/run-make/wasm-custom-section/foo.rs new file mode 100644 index 00000000000..44d1efd7c2d --- /dev/null +++ b/src/test/run-make/wasm-custom-section/foo.rs @@ -0,0 +1,19 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(wasm_custom_section)] +#![deny(warnings)] + +#[wasm_custom_section = "foo"] +const A: [u8; 2] = [1, 2]; + +#[wasm_custom_section = "bar"] +const B: [u8; 2] = [3, 4]; diff --git a/src/test/run-make/weird-output-filenames/Makefile b/src/test/run-make/weird-output-filenames/Makefile deleted file mode 100644 index f161fe9f8e8..00000000000 --- a/src/test/run-make/weird-output-filenames/Makefile +++ /dev/null @@ -1,15 +0,0 @@ --include ../tools.mk - -all: - cp foo.rs $(TMPDIR)/.foo.rs - $(RUSTC) $(TMPDIR)/.foo.rs 2>&1 \ - | $(CGREP) -e "invalid character.*in crate name:" - cp foo.rs $(TMPDIR)/.foo.bar - $(RUSTC) $(TMPDIR)/.foo.bar 2>&1 \ - | $(CGREP) -e "invalid character.*in crate name:" - cp foo.rs $(TMPDIR)/+foo+bar.rs - $(RUSTC) $(TMPDIR)/+foo+bar.rs 2>&1 \ - | $(CGREP) -e "invalid character.*in crate name:" - cp foo.rs $(TMPDIR)/-foo.rs - $(RUSTC) $(TMPDIR)/-foo.rs 2>&1 \ - | $(CGREP) 'crate names cannot start with a `-`' diff --git a/src/test/run-make/weird-output-filenames/foo.rs b/src/test/run-make/weird-output-filenames/foo.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/weird-output-filenames/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/windows-spawn/Makefile b/src/test/run-make/windows-spawn/Makefile deleted file mode 100644 index f0d4242260f..00000000000 --- a/src/test/run-make/windows-spawn/Makefile +++ /dev/null @@ -1,14 +0,0 @@ --include ../tools.mk - -ifdef IS_WINDOWS - -all: - $(RUSTC) -o "$(TMPDIR)/hopefullydoesntexist bar.exe" hello.rs - $(RUSTC) spawn.rs - $(TMPDIR)/spawn.exe - -else - -all: - -endif diff --git a/src/test/run-make/windows-spawn/hello.rs b/src/test/run-make/windows-spawn/hello.rs deleted file mode 100644 index b177f41941d..00000000000 --- a/src/test/run-make/windows-spawn/hello.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - println!("Hello World!"); -} diff --git a/src/test/run-make/windows-spawn/spawn.rs b/src/test/run-make/windows-spawn/spawn.rs deleted file mode 100644 index 2913cbe2260..00000000000 --- a/src/test/run-make/windows-spawn/spawn.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::io::ErrorKind; -use std::process::Command; - -fn main() { - // Make sure it doesn't try to run "hopefullydoesntexist bar.exe". - assert_eq!(Command::new("hopefullydoesntexist") - .arg("bar") - .spawn() - .unwrap_err() - .kind(), - ErrorKind::NotFound); -} diff --git a/src/test/run-make/windows-subsystem/Makefile b/src/test/run-make/windows-subsystem/Makefile deleted file mode 100644 index 34fb5db32f9..00000000000 --- a/src/test/run-make/windows-subsystem/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) windows.rs - $(RUSTC) console.rs diff --git a/src/test/run-make/windows-subsystem/console.rs b/src/test/run-make/windows-subsystem/console.rs deleted file mode 100644 index ffad1e35ee6..00000000000 --- a/src/test/run-make/windows-subsystem/console.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![windows_subsystem = "console"] - -fn main() {} - diff --git a/src/test/run-make/windows-subsystem/windows.rs b/src/test/run-make/windows-subsystem/windows.rs deleted file mode 100644 index 33cbe320591..00000000000 --- a/src/test/run-make/windows-subsystem/windows.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![windows_subsystem = "windows"] - -fn main() {} diff --git a/src/test/ui/feature-gate-wasm_custom_section.rs b/src/test/ui/feature-gate-wasm_custom_section.rs new file mode 100644 index 00000000000..c695ef4ff06 --- /dev/null +++ b/src/test/ui/feature-gate-wasm_custom_section.rs @@ -0,0 +1,14 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[wasm_custom_section = "foo"] //~ ERROR: attribute is currently unstable +const A: [u8; 2] = [1, 2]; + +fn main() {} diff --git a/src/test/ui/feature-gate-wasm_custom_section.stderr b/src/test/ui/feature-gate-wasm_custom_section.stderr new file mode 100644 index 00000000000..5977ec9edad --- /dev/null +++ b/src/test/ui/feature-gate-wasm_custom_section.stderr @@ -0,0 +1,11 @@ +error[E0658]: attribute is currently unstable + --> $DIR/feature-gate-wasm_custom_section.rs:11:1 + | +LL | #[wasm_custom_section = "foo"] //~ ERROR: attribute is currently unstable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(wasm_custom_section)] to the crate attributes to enable + +error: aborting due to previous error + +If you want more information on this error, try using "rustc --explain E0658" diff --git a/src/test/ui/wasm-custom-section/malformed.rs b/src/test/ui/wasm-custom-section/malformed.rs new file mode 100644 index 00000000000..13b1685a480 --- /dev/null +++ b/src/test/ui/wasm-custom-section/malformed.rs @@ -0,0 +1,19 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(wasm_custom_section)] + +#[wasm_custom_section] //~ ERROR: must be of the form +const A: [u8; 1] = [0]; + +#[wasm_custom_section(foo)] //~ ERROR: must be of the form +const B: [u8; 1] = [0]; + +fn main() {} diff --git a/src/test/ui/wasm-custom-section/malformed.stderr b/src/test/ui/wasm-custom-section/malformed.stderr new file mode 100644 index 00000000000..c716c824aeb --- /dev/null +++ b/src/test/ui/wasm-custom-section/malformed.stderr @@ -0,0 +1,14 @@ +error: must be of the form #[wasm_custom_section = "foo"] + --> $DIR/malformed.rs:13:1 + | +LL | #[wasm_custom_section] //~ ERROR: must be of the form + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: must be of the form #[wasm_custom_section = "foo"] + --> $DIR/malformed.rs:16:1 + | +LL | #[wasm_custom_section(foo)] //~ ERROR: must be of the form + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/wasm-custom-section/not-const.rs b/src/test/ui/wasm-custom-section/not-const.rs new file mode 100644 index 00000000000..68077fb2fe4 --- /dev/null +++ b/src/test/ui/wasm-custom-section/not-const.rs @@ -0,0 +1,29 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(wasm_custom_section)] + +#[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts +static A: [u8; 2] = [1, 2]; + +#[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts +struct B {} + +#[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts +enum C {} + +#[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts +impl B {} + +#[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts +mod d {} + +#[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts +fn main() {} diff --git a/src/test/ui/wasm-custom-section/not-const.stderr b/src/test/ui/wasm-custom-section/not-const.stderr new file mode 100644 index 00000000000..17c85b3e848 --- /dev/null +++ b/src/test/ui/wasm-custom-section/not-const.stderr @@ -0,0 +1,38 @@ +error: only allowed on consts + --> $DIR/not-const.rs:13:1 + | +LL | #[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: only allowed on consts + --> $DIR/not-const.rs:16:1 + | +LL | #[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: only allowed on consts + --> $DIR/not-const.rs:19:1 + | +LL | #[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: only allowed on consts + --> $DIR/not-const.rs:22:1 + | +LL | #[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: only allowed on consts + --> $DIR/not-const.rs:25:1 + | +LL | #[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: only allowed on consts + --> $DIR/not-const.rs:28:1 + | +LL | #[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/wasm-custom-section/not-slice.rs b/src/test/ui/wasm-custom-section/not-slice.rs new file mode 100644 index 00000000000..2d91641a5f7 --- /dev/null +++ b/src/test/ui/wasm-custom-section/not-slice.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(wasm_custom_section)] + +#[wasm_custom_section = "foo"] +const A: u8 = 0; //~ ERROR: must be an array of bytes + +#[wasm_custom_section = "foo"] +const B: &[u8] = &[0]; //~ ERROR: must be an array of bytes + +#[wasm_custom_section = "foo"] +const C: &[u8; 1] = &[0]; //~ ERROR: must be an array of bytes + +fn main() {} diff --git a/src/test/ui/wasm-custom-section/not-slice.stderr b/src/test/ui/wasm-custom-section/not-slice.stderr new file mode 100644 index 00000000000..f2563ce0ddd --- /dev/null +++ b/src/test/ui/wasm-custom-section/not-slice.stderr @@ -0,0 +1,20 @@ +error: must be an array of bytes like `[u8; N]` + --> $DIR/not-slice.rs:14:1 + | +LL | const A: u8 = 0; //~ ERROR: must be an array of bytes + | ^^^^^^^^^^^^^^^^ + +error: must be an array of bytes like `[u8; N]` + --> $DIR/not-slice.rs:17:1 + | +LL | const B: &[u8] = &[0]; //~ ERROR: must be an array of bytes + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: must be an array of bytes like `[u8; N]` + --> $DIR/not-slice.rs:20:1 + | +LL | const C: &[u8; 1] = &[0]; //~ ERROR: must be an array of bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 43220af4893..93b1b1f08e6 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2396,13 +2396,6 @@ impl<'test> TestCx<'test> { .env("S", src_root) .env("RUST_BUILD_STAGE", &self.config.stage_id) .env("RUSTC", cwd.join(&self.config.rustc_path)) - .env( - "RUSTDOC", - cwd.join(&self.config - .rustdoc_path - .as_ref() - .expect("--rustdoc-path passed")), - ) .env("TMPDIR", &tmpdir) .env("LD_LIB_PATH_ENVVAR", dylib_env_var()) .env("HOST_RPATH_DIR", cwd.join(&self.config.compile_lib_path)) @@ -2417,6 +2410,14 @@ impl<'test> TestCx<'test> { .env_remove("MFLAGS") .env_remove("CARGO_MAKEFLAGS"); + if let Some(ref rustdoc) = self.config.rustdoc_path { + cmd.env("RUSTDOC", cwd.join(rustdoc)); + } + + if let Some(ref node) = self.config.nodejs { + cmd.env("NODE", node); + } + if let Some(ref linker) = self.config.linker { cmd.env("RUSTC_LINKER", linker); } -- cgit 1.4.1-3-g733a5 From d889957dab5ee0778f9dd64faeafc8872645efed Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 10 Feb 2018 14:28:17 -0800 Subject: rustc: Add a `#[wasm_import_module]` attribute This commit adds a new attribute to the Rust compiler specific to the wasm target (and no other targets). The `#[wasm_import_module]` attribute is used to specify the module that a name is imported from, and is used like so: #[wasm_import_module = "./foo.js"] extern { fn some_js_function(); } Here the import of the symbol `some_js_function` is tagged with the `./foo.js` module in the wasm output file. Wasm-the-format includes two fields on all imports, a module and a field. The field is the symbol name (`some_js_function` above) and the module has historically unconditionally been `"env"`. I'm not sure if this `"env"` convention has asm.js or LLVM roots, but regardless we'd like the ability to configure it! The proposed ES module integration with wasm (aka a wasm module is "just another ES module") requires that the import module of wasm imports is interpreted as an ES module import, meaning that you'll need to encode paths, NPM packages, etc. As a result, we'll need this to be something other than `"env"`! Unfortunately neither our version of LLVM nor LLD supports custom import modules (aka anything not `"env"`). My hope is that by the time LLVM 7 is released both will have support, but in the meantime this commit adds some primitive encoding/decoding of wasm files to the compiler. This way rustc postprocesses the wasm module that LLVM emits to ensure it's got all the imports we'd like to have in it. Eventually I'd ideally like to unconditionally require this attribute to be placed on all `extern { ... }` blocks. For now though it seemed prudent to add it as an unstable attribute, so for now it's not required (as that'd force usage of a feature gate). Hopefully it doesn't take too long to "stabilize" this! cc rust-lang-nursery/rust-wasm#29 --- src/ci/docker/wasm32-unknown/Dockerfile | 1 + src/librustc/dep_graph/dep_node.rs | 3 + src/librustc/hir/check_attr.rs | 43 +++- src/librustc/ich/impls_cstore.rs | 7 +- src/librustc/middle/cstore.rs | 6 + src/librustc/ty/maps/config.rs | 18 ++ src/librustc/ty/maps/mod.rs | 9 +- src/librustc/ty/maps/plumbing.rs | 5 + src/librustc_metadata/creader.rs | 20 +- src/librustc_metadata/cstore.rs | 6 +- src/librustc_metadata/cstore_impl.rs | 22 +- src/librustc_metadata/decoder.rs | 10 +- src/librustc_metadata/encoder.rs | 12 +- src/librustc_metadata/foreign_modules.rs | 48 ++++ src/librustc_metadata/lib.rs | 1 + src/librustc_metadata/native_libs.rs | 7 +- src/librustc_metadata/schema.rs | 3 +- src/librustc_trans/attributes.rs | 46 ++++ src/librustc_trans/back/link.rs | 1 + src/librustc_trans/back/wasm.rs | 249 +++++++++++++++++++-- src/librustc_trans/base.rs | 52 ++++- src/librustc_trans/lib.rs | 3 + src/libsyntax/feature_gate.rs | 7 + src/test/run-make/wasm-custom-section/foo.js | 2 +- src/test/run-make/wasm-import-module/Makefile | 10 + src/test/run-make/wasm-import-module/bar.rs | 29 +++ src/test/run-make/wasm-import-module/foo.js | 28 +++ src/test/run-make/wasm-import-module/foo.rs | 18 ++ .../ui/feature-gate-wasm_custom_section.stderr | 2 +- src/test/ui/feature-gate-wasm_import_module.rs | 15 ++ src/test/ui/feature-gate-wasm_import_module.stderr | 11 + src/test/ui/wasm-import-module.rs | 20 ++ src/test/ui/wasm-import-module.stderr | 14 ++ 33 files changed, 653 insertions(+), 75 deletions(-) create mode 100644 src/librustc_metadata/foreign_modules.rs create mode 100644 src/test/run-make/wasm-import-module/Makefile create mode 100644 src/test/run-make/wasm-import-module/bar.rs create mode 100644 src/test/run-make/wasm-import-module/foo.js create mode 100644 src/test/run-make/wasm-import-module/foo.rs create mode 100644 src/test/ui/feature-gate-wasm_import_module.rs create mode 100644 src/test/ui/feature-gate-wasm_import_module.stderr create mode 100644 src/test/ui/wasm-import-module.rs create mode 100644 src/test/ui/wasm-import-module.stderr (limited to 'src/libsyntax') diff --git a/src/ci/docker/wasm32-unknown/Dockerfile b/src/ci/docker/wasm32-unknown/Dockerfile index 0972eb85191..6c0ec1ad9d4 100644 --- a/src/ci/docker/wasm32-unknown/Dockerfile +++ b/src/ci/docker/wasm32-unknown/Dockerfile @@ -26,6 +26,7 @@ ENV RUST_CONFIGURE_ARGS \ --set rust.lld ENV SCRIPT python2.7 /checkout/x.py test --target $TARGETS \ + src/test/run-make \ src/test/ui \ src/test/run-pass \ src/test/compile-fail \ diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 09d7ce599ab..8bcec79d99f 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -593,6 +593,7 @@ define_dep_nodes!( <'tcx> [] ImplementationsOfTrait { krate: CrateNum, trait_id: DefId }, [] AllTraitImplementations(CrateNum), + [] DllimportForeignItems(CrateNum), [] IsDllimportForeignItem(DefId), [] IsStaticallyIncludedForeignItem(DefId), [] NativeLibraryKind(DefId), @@ -655,6 +656,8 @@ define_dep_nodes!( <'tcx> [input] Features, [] ProgramClausesFor(DefId), + [] WasmImportModuleMap(CrateNum), + [] ForeignModules(CrateNum), ); trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug { diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index f141cac1614..9b2647ad4db 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -26,6 +26,7 @@ enum Target { Union, Enum, Const, + ForeignMod, Other, } @@ -37,6 +38,7 @@ impl Target { hir::ItemUnion(..) => Target::Union, hir::ItemEnum(..) => Target::Enum, hir::ItemConst(..) => Target::Const, + hir::ItemForeignMod(..) => Target::ForeignMod, _ => Target::Other, } } @@ -57,25 +59,42 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> { .emit(); } + let mut has_wasm_import_module = false; for attr in &item.attrs { - if let Some(name) = attr.name() { - if name == "inline" { - self.check_inline(attr, item, target) + if attr.check_name("inline") { + self.check_inline(attr, item, target) + } else if attr.check_name("wasm_import_module") { + has_wasm_import_module = true; + if attr.value_str().is_none() { + self.tcx.sess.span_err(attr.span, "\ + must be of the form #[wasm_import_module = \"...\"]"); + } + if target != Target::ForeignMod { + self.tcx.sess.span_err(attr.span, "\ + must only be attached to foreign modules"); + } + } else if attr.check_name("wasm_custom_section") { + if target != Target::Const { + self.tcx.sess.span_err(attr.span, "only allowed on consts"); } - if name == "wasm_custom_section" { - if target != Target::Const { - self.tcx.sess.span_err(attr.span, "only allowed on consts"); - } - - if attr.value_str().is_none() { - self.tcx.sess.span_err(attr.span, "must be of the form \ - #[wasm_custom_section = \"foo\"]"); - } + if attr.value_str().is_none() { + self.tcx.sess.span_err(attr.span, "must be of the form \ + #[wasm_custom_section = \"foo\"]"); } } } + if target == Target::ForeignMod && + !has_wasm_import_module && + self.tcx.sess.target.target.arch == "wasm32" && + false // FIXME: eventually enable this warning when stable + { + self.tcx.sess.span_warn(item.span, "\ + must have a #[wasm_import_module = \"...\"] attribute, this \ + will become a hard error before too long"); + } + self.check_repr(item, target); } diff --git a/src/librustc/ich/impls_cstore.rs b/src/librustc/ich/impls_cstore.rs index 18a02ff5c58..0071850e105 100644 --- a/src/librustc/ich/impls_cstore.rs +++ b/src/librustc/ich/impls_cstore.rs @@ -33,7 +33,12 @@ impl_stable_hash_for!(struct middle::cstore::NativeLibrary { kind, name, cfg, - foreign_items + foreign_module +}); + +impl_stable_hash_for!(struct middle::cstore::ForeignModule { + foreign_items, + def_id }); impl_stable_hash_for!(enum middle::cstore::LinkagePreference { diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 3c451d7ae46..add9b621596 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -132,7 +132,13 @@ pub struct NativeLibrary { pub kind: NativeLibraryKind, pub name: Symbol, pub cfg: Option, + pub foreign_module: Option, +} + +#[derive(Clone, Hash, RustcEncodable, RustcDecodable)] +pub struct ForeignModule { pub foreign_items: Vec, + pub def_id: DefId, } pub enum LoadedMacro { diff --git a/src/librustc/ty/maps/config.rs b/src/librustc/ty/maps/config.rs index 0b41c3ab2fa..7565e90df98 100644 --- a/src/librustc/ty/maps/config.rs +++ b/src/librustc/ty/maps/config.rs @@ -430,6 +430,12 @@ impl<'tcx> QueryDescription<'tcx> for queries::native_libraries<'tcx> { } } +impl<'tcx> QueryDescription<'tcx> for queries::foreign_modules<'tcx> { + fn describe(_tcx: TyCtxt, _: CrateNum) -> String { + format!("looking up the foreign modules of a linked crate") + } +} + impl<'tcx> QueryDescription<'tcx> for queries::plugin_registrar_fn<'tcx> { fn describe(_tcx: TyCtxt, _: CrateNum) -> String { format!("looking up the plugin registrar for a crate") @@ -705,6 +711,18 @@ impl<'tcx> QueryDescription<'tcx> for queries::program_clauses_for<'tcx> { } } +impl<'tcx> QueryDescription<'tcx> for queries::wasm_import_module_map<'tcx> { + fn describe(_tcx: TyCtxt, _: CrateNum) -> String { + format!("wasm import module map") + } +} + +impl<'tcx> QueryDescription<'tcx> for queries::dllimport_foreign_items<'tcx> { + fn describe(_tcx: TyCtxt, _: CrateNum) -> String { + format!("wasm import module map") + } +} + macro_rules! impl_disk_cacheable_query( ($query_name:ident, |$key:tt| $cond:expr) => { impl<'tcx> QueryDescription<'tcx> for queries::$query_name<'tcx> { diff --git a/src/librustc/ty/maps/mod.rs b/src/librustc/ty/maps/mod.rs index 2b4c1992762..c16ad0d8ca1 100644 --- a/src/librustc/ty/maps/mod.rs +++ b/src/librustc/ty/maps/mod.rs @@ -18,7 +18,7 @@ use infer::canonical::{Canonical, QueryResult}; use lint; use middle::borrowck::BorrowCheckResult; use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, - ExternBodyNestedBodies}; + ExternBodyNestedBodies, ForeignModule}; use middle::cstore::{NativeLibraryKind, DepKind, CrateSource, ExternConstBody}; use middle::privacy::AccessLevels; use middle::reachable::ReachableSet; @@ -320,6 +320,9 @@ define_maps! { <'tcx> [] fn native_libraries: NativeLibraries(CrateNum) -> Lrc>, + + [] fn foreign_modules: ForeignModules(CrateNum) -> Lrc>, + [] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option, [] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option, [] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> CrateDisambiguator, @@ -331,6 +334,8 @@ define_maps! { <'tcx> [] fn all_trait_implementations: AllTraitImplementations(CrateNum) -> Lrc>, + [] fn dllimport_foreign_items: DllimportForeignItems(CrateNum) + -> Lrc>, [] fn is_dllimport_foreign_item: IsDllimportForeignItem(DefId) -> bool, [] fn is_statically_included_foreign_item: IsStaticallyIncludedForeignItem(DefId) -> bool, [] fn native_library_kind: NativeLibraryKind(DefId) @@ -426,6 +431,8 @@ define_maps! { <'tcx> [] fn program_clauses_for: ProgramClausesFor(DefId) -> Lrc>>, [] fn wasm_custom_sections: WasmCustomSections(CrateNum) -> Lrc>, + [] fn wasm_import_module_map: WasmImportModuleMap(CrateNum) + -> Lrc>, } ////////////////////////////////////////////////////////////////////// diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index 910c00b832e..46106d8ec0e 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -886,6 +886,9 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, force!(all_trait_implementations, krate!()); } + DepKind::DllimportForeignItems => { + force!(dllimport_foreign_items, krate!()); + } DepKind::IsDllimportForeignItem => { force!(is_dllimport_foreign_item, def_id!()); } @@ -941,6 +944,8 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, DepKind::ProgramClausesFor => { force!(program_clauses_for, def_id!()); } DepKind::WasmCustomSections => { force!(wasm_custom_sections, krate!()); } + DepKind::WasmImportModuleMap => { force!(wasm_import_module_map, krate!()); } + DepKind::ForeignModules => { force!(foreign_modules, krate!()); } } true diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index a0546b369a8..baaf57c8908 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -12,7 +12,6 @@ use cstore::{self, CStore, CrateSource, MetadataBlob}; use locator::{self, CratePaths}; -use native_libs::relevant_lib; use schema::CrateRoot; use rustc_data_structures::sync::{Lrc, RwLock, Lock}; @@ -230,7 +229,7 @@ impl<'a> CrateLoader<'a> { .map(|trait_impls| (trait_impls.trait_id, trait_impls.impls)) .collect(); - let mut cmeta = cstore::CrateMetadata { + let cmeta = cstore::CrateMetadata { name, extern_crate: Lock::new(None), def_path_table: Lrc::new(def_path_table), @@ -250,25 +249,8 @@ impl<'a> CrateLoader<'a> { rlib, rmeta, }, - // Initialize this with an empty set. The field is populated below - // after we were able to deserialize its contents. - dllimport_foreign_items: FxHashSet(), }; - let dllimports: FxHashSet<_> = cmeta - .root - .native_libraries - .decode((&cmeta, self.sess)) - .filter(|lib| relevant_lib(self.sess, lib) && - lib.kind == cstore::NativeLibraryKind::NativeUnknown) - .flat_map(|lib| { - assert!(lib.foreign_items.iter().all(|def_id| def_id.krate == cnum)); - lib.foreign_items.into_iter().map(|def_id| def_id.index) - }) - .collect(); - - cmeta.dllimport_foreign_items = dllimports; - let cmeta = Lrc::new(cmeta); self.cstore.set_crate_data(cnum, cmeta.clone()); (cnum, cmeta) diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index bd5ad93946e..53986f07410 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -20,7 +20,7 @@ use rustc::middle::cstore::{DepKind, ExternCrate, MetadataLoader}; use rustc::session::{Session, CrateDisambiguator}; use rustc_back::PanicStrategy; use rustc_data_structures::indexed_vec::IndexVec; -use rustc::util::nodemap::{FxHashMap, FxHashSet, NodeMap}; +use rustc::util::nodemap::{FxHashMap, NodeMap}; use rustc_data_structures::sync::{Lrc, RwLock, Lock}; use syntax::{ast, attr}; @@ -30,7 +30,7 @@ use syntax_pos; pub use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind, LinkagePreference}; pub use rustc::middle::cstore::NativeLibraryKind::*; -pub use rustc::middle::cstore::{CrateSource, LibSource}; +pub use rustc::middle::cstore::{CrateSource, LibSource, ForeignModule}; pub use cstore_impl::{provide, provide_extern}; @@ -84,8 +84,6 @@ pub struct CrateMetadata { pub source: CrateSource, pub proc_macros: Option)>>, - // Foreign items imported from a dylib (Windows only) - pub dllimport_foreign_items: FxHashSet, } pub struct CStore { diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 3c2f984ef8b..e911a03bbe2 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -12,6 +12,7 @@ use cstore; use encoder; use link_args; use native_libs; +use foreign_modules; use schema; use rustc::ty::maps::QueryConfig; @@ -197,6 +198,7 @@ provide! { <'tcx> tcx, def_id, other, cdata, Lrc::new(reachable_non_generics) } native_libraries => { Lrc::new(cdata.get_native_libraries(tcx.sess)) } + foreign_modules => { Lrc::new(cdata.get_foreign_modules(tcx.sess)) } plugin_registrar_fn => { cdata.root.plugin_registrar_fn.map(|index| { DefId { krate: def_id.krate, index } @@ -224,9 +226,6 @@ provide! { <'tcx> tcx, def_id, other, cdata, Lrc::new(result) } - is_dllimport_foreign_item => { - cdata.is_dllimport_foreign_item(def_id.index) - } visibility => { cdata.get_visibility(def_id.index) } dep_kind => { let r = *cdata.dep_kind.lock(); @@ -306,13 +305,28 @@ pub fn provide<'tcx>(providers: &mut Providers<'tcx>) { tcx.native_libraries(id.krate) .iter() .filter(|lib| native_libs::relevant_lib(&tcx.sess, lib)) - .find(|l| l.foreign_items.contains(&id)) + .find(|lib| { + let fm_id = match lib.foreign_module { + Some(id) => id, + None => return false, + }; + tcx.foreign_modules(id.krate) + .iter() + .find(|m| m.def_id == fm_id) + .expect("failed to find foreign module") + .foreign_items + .contains(&id) + }) .map(|l| l.kind) }, native_libraries: |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); Lrc::new(native_libs::collect(tcx)) }, + foreign_modules: |tcx, cnum| { + assert_eq!(cnum, LOCAL_CRATE); + Lrc::new(foreign_modules::collect(tcx)) + }, link_args: |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); Lrc::new(link_args::collect(tcx)) diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 0e5df3142af..e72f9ddd82a 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -10,7 +10,7 @@ // Decoding metadata from a single crate's metadata -use cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary}; +use cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary, ForeignModule}; use schema::*; use rustc_data_structures::sync::{Lrc, ReadGuard}; @@ -1031,6 +1031,10 @@ impl<'a, 'tcx> CrateMetadata { self.root.native_libraries.decode((self, sess)).collect() } + pub fn get_foreign_modules(&self, sess: &Session) -> Vec { + self.root.foreign_modules.decode((self, sess)).collect() + } + pub fn get_dylib_dependency_formats(&self) -> Vec<(CrateNum, LinkagePreference)> { self.root .dylib_dependency_formats @@ -1103,10 +1107,6 @@ impl<'a, 'tcx> CrateMetadata { } } - pub fn is_dllimport_foreign_item(&self, id: DefIndex) -> bool { - self.dllimport_foreign_items.contains(&id) - } - pub fn fn_sig(&self, id: DefIndex, tcx: TyCtxt<'a, 'tcx, 'tcx>) diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 56981b8f4a1..39de1ec852e 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -14,7 +14,7 @@ use isolated_encoder::IsolatedEncoder; use schema::*; use rustc::middle::cstore::{LinkMeta, LinkagePreference, NativeLibrary, - EncodedMetadata}; + EncodedMetadata, ForeignModule}; use rustc::hir::def::CtorKind; use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId, LocalDefId, LOCAL_CRATE}; use rustc::hir::map::definitions::DefPathTable; @@ -412,6 +412,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { ()); let native_lib_bytes = self.position() - i; + let foreign_modules = self.tracked( + IsolatedEncoder::encode_foreign_modules, + ()); + // Encode codemap i = self.position(); let codemap = self.encode_codemap(); @@ -480,6 +484,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { lang_items, lang_items_missing, native_libraries, + foreign_modules, codemap, def_path_table, impls, @@ -1337,6 +1342,11 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { self.lazy_seq(used_libraries.iter().cloned()) } + fn encode_foreign_modules(&mut self, _: ()) -> LazySeq { + let foreign_modules = self.tcx.foreign_modules(LOCAL_CRATE); + self.lazy_seq(foreign_modules.iter().cloned()) + } + fn encode_crate_deps(&mut self, _: ()) -> LazySeq { let crates = self.tcx.crates(); diff --git a/src/librustc_metadata/foreign_modules.rs b/src/librustc_metadata/foreign_modules.rs new file mode 100644 index 00000000000..c44d891b7f3 --- /dev/null +++ b/src/librustc_metadata/foreign_modules.rs @@ -0,0 +1,48 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use rustc::hir::itemlikevisit::ItemLikeVisitor; +use rustc::hir; +use rustc::middle::cstore::ForeignModule; +use rustc::ty::TyCtxt; + +pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Vec { + let mut collector = Collector { + tcx, + modules: Vec::new(), + }; + tcx.hir.krate().visit_all_item_likes(&mut collector); + return collector.modules +} + +struct Collector<'a, 'tcx: 'a> { + tcx: TyCtxt<'a, 'tcx, 'tcx>, + modules: Vec, +} + +impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { + fn visit_item(&mut self, it: &'tcx hir::Item) { + let fm = match it.node { + hir::ItemForeignMod(ref fm) => fm, + _ => return, + }; + + let foreign_items = fm.items.iter() + .map(|it| self.tcx.hir.local_def_id(it.id)) + .collect(); + self.modules.push(ForeignModule { + foreign_items, + def_id: self.tcx.hir.local_def_id(it.id), + }); + } + + fn visit_trait_item(&mut self, _it: &'tcx hir::TraitItem) {} + fn visit_impl_item(&mut self, _it: &'tcx hir::ImplItem) {} +} diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index f77c22bd895..85099667449 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -56,6 +56,7 @@ mod isolated_encoder; mod schema; mod native_libs; mod link_args; +mod foreign_modules; pub mod creader; pub mod cstore; diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index 2504f8dc251..4bb6d8fb87c 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -105,14 +105,11 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { } else { None }; - let foreign_items = fm.items.iter() - .map(|it| self.tcx.hir.local_def_id(it.id)) - .collect(); let lib = NativeLibrary { name: n, kind, cfg, - foreign_items, + foreign_module: Some(self.tcx.hir.local_def_id(it.id)), }; self.register_native_lib(Some(m.span), lib); } @@ -218,7 +215,7 @@ impl<'a, 'tcx> Collector<'a, 'tcx> { name: Symbol::intern(new_name.unwrap_or(name)), kind: if let Some(k) = kind { k } else { cstore::NativeUnknown }, cfg: None, - foreign_items: Vec::new(), + foreign_module: None, }; self.register_native_lib(None, lib); } diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index 001772623e7..98327945297 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -15,8 +15,8 @@ use rustc::hir; use rustc::hir::def::{self, CtorKind}; use rustc::hir::def_id::{DefIndex, DefId, CrateNum}; use rustc::ich::StableHashingContext; -use rustc::middle::cstore::{DepKind, LinkagePreference, NativeLibrary}; use rustc::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel}; +use rustc::middle::cstore::{DepKind, LinkagePreference, NativeLibrary, ForeignModule}; use rustc::middle::lang_items; use rustc::mir; use rustc::session::CrateDisambiguator; @@ -200,6 +200,7 @@ pub struct CrateRoot { pub lang_items: LazySeq<(DefIndex, usize)>, pub lang_items_missing: LazySeq, pub native_libraries: LazySeq, + pub foreign_modules: LazySeq, pub codemap: LazySeq, pub def_path_table: Lazy, pub impls: LazySeq, diff --git a/src/librustc_trans/attributes.rs b/src/librustc_trans/attributes.rs index 16253aa92ac..df78ccdd229 100644 --- a/src/librustc_trans/attributes.rs +++ b/src/librustc_trans/attributes.rs @@ -18,6 +18,7 @@ use rustc::session::config::Sanitizer; use rustc::ty::TyCtxt; use rustc::ty::maps::Providers; use rustc_data_structures::sync::Lrc; +use rustc_data_structures::fx::FxHashMap; use llvm::{self, Attribute, ValueRef}; use llvm::AttributePlace::Function; @@ -141,6 +142,20 @@ pub fn from_fn_attrs(cx: &CodegenCx, llfn: ValueRef, id: DefId) { llfn, llvm::AttributePlace::Function, cstr("target-features\0"), &val); } + + // Note that currently the `wasm-import-module` doesn't do anything, but + // eventually LLVM 7 should read this and ferry the appropriate import + // module to the output file. + if cx.tcx.sess.target.target.arch == "wasm32" { + if let Some(module) = wasm_import_module(cx.tcx, id) { + llvm::AddFunctionAttrStringValue( + llfn, + llvm::AttributePlace::Function, + cstr("wasm-import-module\0"), + &module, + ); + } + } } fn cstr(s: &'static str) -> &CStr { @@ -170,6 +185,8 @@ pub fn provide(providers: &mut Providers) { tcx.hir.krate().visit_all_item_likes(&mut finder); Lrc::new(finder.list) }; + + provide_extern(providers); } struct WasmSectionFinder<'a, 'tcx: 'a> { @@ -192,3 +209,32 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for WasmSectionFinder<'a, 'tcx> { fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem) {} } + +pub fn provide_extern(providers: &mut Providers) { + providers.wasm_import_module_map = |tcx, cnum| { + let mut ret = FxHashMap(); + for lib in tcx.foreign_modules(cnum).iter() { + let attrs = tcx.get_attrs(lib.def_id); + let mut module = None; + for attr in attrs.iter().filter(|a| a.check_name("wasm_import_module")) { + module = attr.value_str(); + } + let module = match module { + Some(s) => s, + None => continue, + }; + for id in lib.foreign_items.iter() { + assert_eq!(id.krate, cnum); + ret.insert(*id, module.to_string()); + } + } + + Lrc::new(ret) + } +} + +fn wasm_import_module(tcx: TyCtxt, id: DefId) -> Option { + tcx.wasm_import_module_map(id.krate) + .get(&id) + .map(|s| CString::new(&s[..]).unwrap()) +} diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 8e8ba823b6f..542cdc5baad 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -813,6 +813,7 @@ fn link_natively(sess: &Session, } if sess.opts.target_triple == "wasm32-unknown-unknown" { + wasm::rewrite_imports(&out_filename, &trans.crate_info.wasm_imports); wasm::add_custom_sections(&out_filename, &trans.crate_info.wasm_custom_sections); } diff --git a/src/librustc_trans/back/wasm.rs b/src/librustc_trans/back/wasm.rs index 99f1e4b7e78..d6d386c9fbe 100644 --- a/src/librustc_trans/back/wasm.rs +++ b/src/librustc_trans/back/wasm.rs @@ -8,37 +8,254 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::collections::BTreeMap; use std::fs; use std::path::Path; -use std::collections::BTreeMap; +use std::str; +use rustc_data_structures::fx::FxHashMap; use serialize::leb128; +// https://webassembly.github.io/spec/core/binary/modules.html#binary-importsec +const WASM_IMPORT_SECTION_ID: u8 = 2; + +const WASM_EXTERNAL_KIND_FUNCTION: u8 = 0; +const WASM_EXTERNAL_KIND_TABLE: u8 = 1; +const WASM_EXTERNAL_KIND_MEMORY: u8 = 2; +const WASM_EXTERNAL_KIND_GLOBAL: u8 = 3; + +/// Append all the custom sections listed in `sections` to the wasm binary +/// specified at `path`. +/// +/// LLVM 6 which we're using right now doesn't have the ability to create custom +/// sections in wasm files nor does LLD have the ability to merge these sections +/// into one larger section when linking. It's expected that this will +/// eventually get implemented, however! +/// +/// Until that time though this is a custom implementation in rustc to append +/// all sections to a wasm file to the finished product that LLD produces. +/// +/// Support for this is landing in LLVM in https://reviews.llvm.org/D43097, +/// although after that support will need to be in LLD as well. pub fn add_custom_sections(path: &Path, sections: &BTreeMap>) { - let mut wasm = fs::read(path).expect("failed to read wasm output"); + if sections.len() == 0 { + return + } + + let wasm = fs::read(path).expect("failed to read wasm output"); // see https://webassembly.github.io/spec/core/binary/modules.html#custom-section + let mut wasm = WasmEncoder { data: wasm }; for (section, bytes) in sections { // write the `id` identifier, 0 for a custom section - let len = wasm.len(); - leb128::write_u32_leb128(&mut wasm, len, 0); + wasm.byte(0); // figure out how long our name descriptor will be - let mut name = Vec::new(); - leb128::write_u32_leb128(&mut name, 0, section.len() as u32); - name.extend_from_slice(section.as_bytes()); + let mut name = WasmEncoder::new(); + name.str(section); + + // write the length of the payload followed by all its contents + wasm.u32((bytes.len() + name.data.len()) as u32); + wasm.data.extend_from_slice(&name.data); + wasm.data.extend_from_slice(bytes); + } + + fs::write(path, &wasm.data).expect("failed to write wasm output"); +} + +/// Rewrite the module imports are listed from in a wasm module given the field +/// name to module name mapping in `import_map`. +/// +/// LLVM 6 which we're using right now doesn't have the ability to configure the +/// module a wasm symbol is import from. Rather all imported symbols come from +/// the bland `"env"` module unconditionally. Furthermore we'd *also* need +/// support in LLD for preserving these import modules, which it unfortunately +/// currently does not. +/// +/// This function is intended as a hack for now where we manually rewrite the +/// wasm output by LLVM to have the correct import modules listed. The +/// `#[wasm_import_module]` attribute in Rust translates to the module that each +/// symbol is imported from, so here we manually go through the wasm file, +/// decode it, rewrite imports, and then rewrite the wasm module. +/// +/// Support for this was added to LLVM in +/// https://github.com/llvm-mirror/llvm/commit/0f32e1365, although support still +/// needs to be added (AFAIK at the time of this writing) to LLD +pub fn rewrite_imports(path: &Path, import_map: &FxHashMap) { + if import_map.len() == 0 { + return + } + + let wasm = fs::read(path).expect("failed to read wasm output"); + let mut ret = WasmEncoder::new(); + ret.data.extend(&wasm[..8]); + + // skip the 8 byte wasm/version header + for (id, raw) in WasmSections(WasmDecoder::new(&wasm[8..])) { + ret.byte(id); + if id == WASM_IMPORT_SECTION_ID { + info!("rewriting import section"); + let data = rewrite_import_section( + &mut WasmDecoder::new(raw), + import_map, + ); + ret.bytes(&data); + } else { + info!("carry forward section {}, {} bytes long", id, raw.len()); + ret.bytes(raw); + } + } + + fs::write(path, &ret.data).expect("failed to write wasm output"); + + fn rewrite_import_section( + wasm: &mut WasmDecoder, + import_map: &FxHashMap, + ) + -> Vec + { + let mut dst = WasmEncoder::new(); + let n = wasm.u32(); + dst.u32(n); + info!("rewriting {} imports", n); + for _ in 0..n { + rewrite_import_entry(wasm, &mut dst, import_map); + } + return dst.data + } + + fn rewrite_import_entry(wasm: &mut WasmDecoder, + dst: &mut WasmEncoder, + import_map: &FxHashMap) { + // More info about the binary format here is available at: + // https://webassembly.github.io/spec/core/binary/modules.html#import-section + // + // Note that you can also find the whole point of existence of this + // function here, where we map the `module` name to a different one if + // we've got one listed. + let module = wasm.str(); + let field = wasm.str(); + let new_module = if module == "env" { + import_map.get(field).map(|s| &**s).unwrap_or(module) + } else { + module + }; + info!("import rewrite ({} => {}) / {}", module, new_module, field); + dst.str(new_module); + dst.str(field); + let kind = wasm.byte(); + dst.byte(kind); + match kind { + WASM_EXTERNAL_KIND_FUNCTION => dst.u32(wasm.u32()), + WASM_EXTERNAL_KIND_TABLE => { + dst.byte(wasm.byte()); // element_type + dst.limits(wasm.limits()); + } + WASM_EXTERNAL_KIND_MEMORY => dst.limits(wasm.limits()), + WASM_EXTERNAL_KIND_GLOBAL => { + dst.byte(wasm.byte()); // content_type + dst.bool(wasm.bool()); // mutable + } + b => panic!("unknown kind: {}", b), + } + } +} - // write the length of the payload - let len = wasm.len(); - let total_len = bytes.len() + name.len(); - leb128::write_u32_leb128(&mut wasm, len, total_len as u32); +struct WasmSections<'a>(WasmDecoder<'a>); - // write out the name section - wasm.extend(name); +impl<'a> Iterator for WasmSections<'a> { + type Item = (u8, &'a [u8]); - // and now the payload itself - wasm.extend_from_slice(bytes); + fn next(&mut self) -> Option<(u8, &'a [u8])> { + if self.0.data.len() == 0 { + return None + } + + // see https://webassembly.github.io/spec/core/binary/modules.html#sections + let id = self.0.byte(); + let section_len = self.0.u32(); + info!("new section {} / {} bytes", id, section_len); + let section = self.0.skip(section_len as usize); + Some((id, section)) } +} + +struct WasmDecoder<'a> { + data: &'a [u8], +} - fs::write(path, &wasm).expect("failed to write wasm output"); +impl<'a> WasmDecoder<'a> { + fn new(data: &'a [u8]) -> WasmDecoder<'a> { + WasmDecoder { data } + } + + fn byte(&mut self) -> u8 { + self.skip(1)[0] + } + + fn u32(&mut self) -> u32 { + let (n, l1) = leb128::read_u32_leb128(self.data); + self.data = &self.data[l1..]; + return n + } + + fn skip(&mut self, amt: usize) -> &'a [u8] { + let (data, rest) = self.data.split_at(amt); + self.data = rest; + data + } + + fn str(&mut self) -> &'a str { + let len = self.u32(); + str::from_utf8(self.skip(len as usize)).unwrap() + } + + fn bool(&mut self) -> bool { + self.byte() == 1 + } + + fn limits(&mut self) -> (u32, Option) { + let has_max = self.bool(); + (self.u32(), if has_max { Some(self.u32()) } else { None }) + } +} + +struct WasmEncoder { + data: Vec, +} + +impl WasmEncoder { + fn new() -> WasmEncoder { + WasmEncoder { data: Vec::new() } + } + + fn u32(&mut self, val: u32) { + let at = self.data.len(); + leb128::write_u32_leb128(&mut self.data, at, val); + } + + fn byte(&mut self, val: u8) { + self.data.push(val); + } + + fn bytes(&mut self, val: &[u8]) { + self.u32(val.len() as u32); + self.data.extend_from_slice(val); + } + + fn str(&mut self, val: &str) { + self.bytes(val.as_bytes()) + } + + fn bool(&mut self, b: bool) { + self.byte(b as u8); + } + + fn limits(&mut self, limits: (u32, Option)) { + self.bool(limits.1.is_some()); + self.u32(limits.0); + if let Some(c) = limits.1 { + self.u32(c); + } + } } diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 11f952bc5bc..56eece9f31e 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -72,6 +72,7 @@ use type_::Type; use type_of::LayoutLlvmExt; use rustc::util::nodemap::{FxHashMap, FxHashSet, DefIdSet}; use CrateInfo; +use rustc_data_structures::sync::Lrc; use std::any::Any; use std::collections::BTreeMap; @@ -1072,14 +1073,15 @@ impl CrateInfo { used_crates_static: cstore::used_crates(tcx, LinkagePreference::RequireStatic), used_crate_source: FxHashMap(), wasm_custom_sections: BTreeMap::new(), + wasm_imports: FxHashMap(), }; - let load_wasm_sections = tcx.sess.crate_types.borrow() + let load_wasm_items = tcx.sess.crate_types.borrow() .iter() .any(|c| *c != config::CrateTypeRlib) && tcx.sess.opts.target_triple == "wasm32-unknown-unknown"; - if load_wasm_sections { + if load_wasm_items { info!("attempting to load all wasm sections"); for &id in tcx.wasm_custom_sections(LOCAL_CRATE).iter() { let (name, contents) = fetch_wasm_section(tcx, id); @@ -1087,6 +1089,7 @@ impl CrateInfo { .or_insert(Vec::new()) .extend(contents); } + info.load_wasm_imports(tcx, LOCAL_CRATE); } for &cnum in tcx.crates().iter() { @@ -1108,19 +1111,27 @@ impl CrateInfo { if tcx.is_no_builtins(cnum) { info.is_no_builtins.insert(cnum); } - if load_wasm_sections { + if load_wasm_items { for &id in tcx.wasm_custom_sections(cnum).iter() { let (name, contents) = fetch_wasm_section(tcx, id); info.wasm_custom_sections.entry(name) .or_insert(Vec::new()) .extend(contents); } + info.load_wasm_imports(tcx, cnum); } } - return info } + + fn load_wasm_imports(&mut self, tcx: TyCtxt, cnum: CrateNum) { + for (&id, module) in tcx.wasm_import_module_map(cnum).iter() { + let instance = Instance::mono(tcx, id); + let import_name = tcx.symbol_name(instance); + self.wasm_imports.insert(import_name.to_string(), module.clone()); + } + } } fn is_translated_item(tcx: TyCtxt, id: DefId) -> bool { @@ -1248,6 +1259,39 @@ pub fn provide(providers: &mut Providers) { .expect(&format!("failed to find cgu with name {:?}", name)) }; providers.compile_codegen_unit = compile_codegen_unit; + + provide_extern(providers); +} + +pub fn provide_extern(providers: &mut Providers) { + providers.dllimport_foreign_items = |tcx, krate| { + let module_map = tcx.foreign_modules(krate); + let module_map = module_map.iter() + .map(|lib| (lib.def_id, lib)) + .collect::>(); + + let dllimports = tcx.native_libraries(krate) + .iter() + .filter(|lib| { + if lib.kind != cstore::NativeLibraryKind::NativeUnknown { + return false + } + let cfg = match lib.cfg { + Some(ref cfg) => cfg, + None => return true, + }; + attr::cfg_matches(cfg, &tcx.sess.parse_sess, None) + }) + .filter_map(|lib| lib.foreign_module) + .map(|id| &module_map[&id]) + .flat_map(|module| module.foreign_items.iter().cloned()) + .collect(); + Lrc::new(dllimports) + }; + + providers.is_dllimport_foreign_item = |tcx, def_id| { + tcx.dllimport_foreign_items(def_id.krate).contains(&def_id) + }; } pub fn linkage_to_llvm(linkage: Linkage) -> llvm::Linkage { diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index bb2aeca3748..9f654c8ab29 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -216,6 +216,8 @@ impl TransCrate for LlvmTransCrate { fn provide_extern(&self, providers: &mut ty::maps::Providers) { back::symbol_export::provide_extern(providers); + base::provide_extern(providers); + attributes::provide_extern(providers); } fn trans_crate<'a, 'tcx>( @@ -403,6 +405,7 @@ struct CrateInfo { used_crates_static: Vec<(CrateNum, LibSource)>, used_crates_dynamic: Vec<(CrateNum, LibSource)>, wasm_custom_sections: BTreeMap>, + wasm_imports: FxHashMap, } __build_diagnostic_array! { librustc_trans, DIAGNOSTICS } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index dbcfee208ca..270cee26948 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -454,6 +454,9 @@ declare_features! ( // The #[wasm_custom_section] attribute (active, wasm_custom_section, "1.26.0", None, None), + + // The #![wasm_import_module] attribute + (active, wasm_import_module, "1.26.0", None, None), ); declare_features! ( @@ -920,6 +923,10 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG "the `#[no_debug]` attribute was an experimental feature that has been \ deprecated due to lack of demand", cfg_fn!(no_debug))), + ("wasm_import_module", Normal, Gated(Stability::Unstable, + "wasm_import_module", + "experimental attribute", + cfg_fn!(wasm_import_module))), ("omit_gdb_pretty_printer_section", Whitelisted, Gated(Stability::Unstable, "omit_gdb_pretty_printer_section", "the `#[omit_gdb_pretty_printer_section]` \ diff --git a/src/test/run-make/wasm-custom-section/foo.js b/src/test/run-make/wasm-custom-section/foo.js index df69354f3a4..e7a4cfc344e 100644 --- a/src/test/run-make/wasm-custom-section/foo.js +++ b/src/test/run-make/wasm-custom-section/foo.js @@ -43,4 +43,4 @@ assert.strictEqual(section[1], 6); assert.strictEqual(section[2], 1); assert.strictEqual(section[3], 2); -process.exit(1); +process.exit(0); diff --git a/src/test/run-make/wasm-import-module/Makefile b/src/test/run-make/wasm-import-module/Makefile new file mode 100644 index 00000000000..399951e5163 --- /dev/null +++ b/src/test/run-make/wasm-import-module/Makefile @@ -0,0 +1,10 @@ +-include ../../run-make-fulldeps/tools.mk + +ifeq ($(TARGET),wasm32-unknown-unknown) +all: + $(RUSTC) foo.rs --target wasm32-unknown-unknown + $(RUSTC) bar.rs -C lto -O --target wasm32-unknown-unknown + $(NODE) foo.js $(TMPDIR)/bar.wasm +else +all: +endif diff --git a/src/test/run-make/wasm-import-module/bar.rs b/src/test/run-make/wasm-import-module/bar.rs new file mode 100644 index 00000000000..9e659223c65 --- /dev/null +++ b/src/test/run-make/wasm-import-module/bar.rs @@ -0,0 +1,29 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "cdylib"] +#![feature(wasm_import_module)] +#![deny(warnings)] + +extern crate foo; + +#[wasm_import_module = "./me"] +extern { + #[link_name = "me_in_dep"] + fn dep(); +} + +#[no_mangle] +pub extern fn foo() { + unsafe { + foo::dep(); + dep(); + } +} diff --git a/src/test/run-make/wasm-import-module/foo.js b/src/test/run-make/wasm-import-module/foo.js new file mode 100644 index 00000000000..369962e55b1 --- /dev/null +++ b/src/test/run-make/wasm-import-module/foo.js @@ -0,0 +1,28 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const fs = require('fs'); +const process = require('process'); +const assert = require('assert'); +const buffer = fs.readFileSync(process.argv[2]); + +let m = new WebAssembly.Module(buffer); +let imports = WebAssembly.Module.imports(m); +console.log('imports', imports); +assert.strictEqual(imports.length, 2); + +assert.strictEqual(imports[0].kind, 'function'); +assert.strictEqual(imports[1].kind, 'function'); + +let modules = [imports[0].module, imports[1].module]; +modules.sort(); + +assert.strictEqual(modules[0], './dep'); +assert.strictEqual(modules[1], './me'); diff --git a/src/test/run-make/wasm-import-module/foo.rs b/src/test/run-make/wasm-import-module/foo.rs new file mode 100644 index 00000000000..bcd2ca70bef --- /dev/null +++ b/src/test/run-make/wasm-import-module/foo.rs @@ -0,0 +1,18 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(wasm_import_module)] +#![deny(warnings)] + +#[wasm_import_module = "./dep"] +extern { + pub fn dep(); +} diff --git a/src/test/ui/feature-gate-wasm_custom_section.stderr b/src/test/ui/feature-gate-wasm_custom_section.stderr index 5977ec9edad..1b4415539f4 100644 --- a/src/test/ui/feature-gate-wasm_custom_section.stderr +++ b/src/test/ui/feature-gate-wasm_custom_section.stderr @@ -8,4 +8,4 @@ LL | #[wasm_custom_section = "foo"] //~ ERROR: attribute is currently unstable error: aborting due to previous error -If you want more information on this error, try using "rustc --explain E0658" +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gate-wasm_import_module.rs b/src/test/ui/feature-gate-wasm_import_module.rs new file mode 100644 index 00000000000..c5898a9c126 --- /dev/null +++ b/src/test/ui/feature-gate-wasm_import_module.rs @@ -0,0 +1,15 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[wasm_import_module = "test"] //~ ERROR: experimental +extern { +} + +fn main() {} diff --git a/src/test/ui/feature-gate-wasm_import_module.stderr b/src/test/ui/feature-gate-wasm_import_module.stderr new file mode 100644 index 00000000000..bae5fa9d595 --- /dev/null +++ b/src/test/ui/feature-gate-wasm_import_module.stderr @@ -0,0 +1,11 @@ +error[E0658]: experimental attribute + --> $DIR/feature-gate-wasm_import_module.rs:11:1 + | +LL | #[wasm_import_module = "test"] //~ ERROR: experimental + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(wasm_import_module)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/wasm-import-module.rs b/src/test/ui/wasm-import-module.rs new file mode 100644 index 00000000000..0b743d9e486 --- /dev/null +++ b/src/test/ui/wasm-import-module.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(wasm_import_module)] + +#[wasm_import_module] //~ ERROR: must be of the form +extern {} + +#[wasm_import_module = "foo"] //~ ERROR: must only be attached to +fn foo() {} + +fn main() {} + diff --git a/src/test/ui/wasm-import-module.stderr b/src/test/ui/wasm-import-module.stderr new file mode 100644 index 00000000000..bf301ce5269 --- /dev/null +++ b/src/test/ui/wasm-import-module.stderr @@ -0,0 +1,14 @@ +error: must be of the form #[wasm_import_module = "..."] + --> $DIR/wasm-import-module.rs:13:1 + | +LL | #[wasm_import_module] //~ ERROR: must be of the form + | ^^^^^^^^^^^^^^^^^^^^^ + +error: must only be attached to foreign modules + --> $DIR/wasm-import-module.rs:16:1 + | +LL | #[wasm_import_module = "foo"] //~ ERROR: must only be attached to + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + -- cgit 1.4.1-3-g733a5