Skip to content

Commit e7a000e

Browse files
committed
Added test for link path ordering
1 parent 61414a9 commit e7a000e

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-include ../tools.mk
2+
3+
# Verifies that the -L arguments given to the linker is in the same order
4+
# as the -L arguments on the rustc command line.
5+
6+
CORRECT_DIR=$(TMPDIR)/correct
7+
WRONG_DIR=$(TMPDIR)/wrong
8+
9+
all: $(TMPDIR)/libcorrect.a $(TMPDIR)/libwrong.a
10+
mkdir -p $(CORRECT_DIR) $(WRONG_DIR)
11+
mv $(TMPDIR)/libcorrect.a $(CORRECT_DIR)/libfoo.a
12+
mv $(TMPDIR)/libwrong.a $(WRONG_DIR)/libfoo.a
13+
$(RUSTC) main.rs -o $(TMPDIR)/should_succeed -L $(CORRECT_DIR) -L $(WRONG_DIR)
14+
$(call RUN,should_succeed)
15+
$(RUSTC) main.rs -o $(TMPDIR)/should_fail -L $(WRONG_DIR) -L $(CORRECT_DIR)
16+
$(call FAIL,should_fail)
17+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int should_return_one() { return 1; }
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern crate libc;
12+
13+
#[link(name="foo")]
14+
extern {
15+
fn should_return_one() -> libc::c_int;
16+
}
17+
18+
fn main() {
19+
let result = unsafe {
20+
should_return_one()
21+
};
22+
23+
if result != 1 {
24+
std::os::set_exit_status(255);
25+
}
26+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int should_return_one() { return 0; }

0 commit comments

Comments
 (0)