Skip to content

Commit 2005a83

Browse files
---
yaml --- r: 147222 b: refs/heads/try2 c: 5de4270 h: refs/heads/master v: v3
1 parent b9a8919 commit 2005a83

29 files changed

+495
-372
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 3d3a663d2530dd49fee235667e98f2767dfd1b57
8+
refs/heads/try2: 5de42701a87cb0e517921cce7bc3a512e513301c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,10 @@ Attributes on the anonymous crate module define important metadata that influenc
609609
the behavior of the compiler.
610610

611611
~~~~
612-
// Package ID
613-
#[ pkgid = "projx#2.5" ];
612+
// Linkage attributes
613+
#[ link(name = "projx",
614+
vers = "2.5",
615+
uuid = "9cccc5d5-aceb-4af5-8285-811211826b82") ];
614616
615617
// Additional metadata attributes
616618
#[ desc = "Project X" ];
@@ -773,24 +775,36 @@ An _`extern mod` declaration_ specifies a dependency on an external crate.
773775
The external crate is then bound into the declaring scope
774776
as the `ident` provided in the `extern_mod_decl`.
775777

776-
The external crate is resolved to a specific `soname` at compile time, and a
777-
runtime linkage requirement to that `soname` is passed to the linker for
778-
loading at runtime. The `soname` is resolved at compile time by scanning the
779-
compiler's library path and matching the optional `pkgid` provided as a string literal
780-
against the `pkgid` attributes that were declared on the external crate when
781-
it was compiled. If no `pkgid` is provided, a default `name` attribute is
782-
assumed, equal to the `ident` given in the `extern_mod_decl`.
778+
The external crate is resolved to a specific `soname` at compile time,
779+
and a runtime linkage requirement to that `soname` is passed to the linker for
780+
loading at runtime.
781+
The `soname` is resolved at compile time by scanning the compiler's library path
782+
and matching the `link_attrs` provided in the `use_decl` against any `#link` attributes that
783+
were declared on the external crate when it was compiled.
784+
If no `link_attrs` are provided,
785+
a default `name` attribute is assumed,
786+
equal to the `ident` given in the `use_decl`.
787+
788+
Optionally, an identifier in an `extern mod` declaration may be followed by an equals sign,
789+
then a string literal denoting a relative path on the filesystem.
790+
This path should exist in one of the directories in the Rust path,
791+
which by default contains the `.rust` subdirectory of the current directory and each of its parents,
792+
as well as any directories in the colon-separated (or semicolon-separated on Windows)
793+
list of paths that is the `RUST_PATH` environment variable.
794+
The meaning of `extern mod a = "b/c/d";`, supposing that `/a` is in the RUST_PATH,
795+
is that the name `a` should be taken as a reference to the crate whose absolute location is
796+
`/a/b/c/d`.
783797

784798
Four examples of `extern mod` declarations:
785799

786800
~~~~ {.xfail-test}
787-
extern mod pcre;
801+
extern mod pcre (uuid = "54aba0f8-a7b1-4beb-92f1-4cf625264841");
788802
789-
extern mod extra; // equivalent to: extern mod extra = "extra";
803+
extern mod extra; // equivalent to: extern mod extra ( name = "extra" );
790804
791-
extern mod rustextra = "extra"; // linking to 'extra' under another name
805+
extern mod rustextra (name = "extra"); // linking to 'extra' under another name
792806
793-
extern mod foo = "some/where/foo#1.0"; // a full package ID for rustpkg
807+
extern mod complicated_mod = "some-file/in/the-rust/path";
794808
~~~~
795809

796810
##### Use declarations
@@ -1728,8 +1742,7 @@ names are effectively reserved. Some significant attributes include:
17281742
* The `doc` attribute, for documenting code in-place.
17291743
* The `cfg` attribute, for conditional-compilation by build-configuration.
17301744
* The `lang` attribute, for custom definitions of traits and functions that are known to the Rust compiler (see [Language items](#language-items)).
1731-
* The `link` attribute, for describing linkage metadata for a extern blocks.
1732-
* The `pkgid` attribute, for describing the package ID of a crate.
1745+
* The `link` attribute, for describing linkage metadata for a crate.
17331746
* The `test` attribute, for marking functions as unit tests.
17341747
* The `allow`, `warn`, `forbid`, and `deny` attributes, for
17351748
controlling lint checks (see [Lint check attributes](#lint-check-attributes)).
@@ -3782,7 +3795,7 @@ specified then log level 4 is assumed. Debug messages can be omitted
37823795
by passing `--cfg ndebug` to `rustc`.
37833796

37843797
As an example, to see all the logs generated by the compiler, you would set
3785-
`RUST_LOG` to `rustc`, which is the crate name (as specified in its `pkgid`
3798+
`RUST_LOG` to `rustc`, which is the crate name (as specified in its `link`
37863799
[attribute](#attributes)). To narrow down the logs to just crate resolution,
37873800
you would set it to `rustc::metadata::creader`. To see just error logging
37883801
use `rustc=0`.

branches/try2/doc/rustdoc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ comments":
1313
~~~
1414
// the "link" crate attribute is currently required for rustdoc, but normally
1515
// isn't needed.
16-
#[pkgid = "universe"];
16+
#[link(name="universe")];
1717
#[crate_type="lib"];
1818
1919
//! Tools for dealing with universes (this is a doc comment, and is shown on

branches/try2/doc/rustpkg.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ as well as `foo/src/bar/extras/baz/lib.rs`,
8989
then both `bar` and `bar/extras/baz` are valid package identifiers
9090
in the workspace `foo`.
9191

92-
Because rustpkg uses generic source file names as the main inputs, you will
93-
need to specify the package identifier in them using the `pkgid` attribute
94-
on the crate.
95-
9692
## Source files
9793

9894
rustpkg searches for four different fixed filenames in order to determine the crates to build:
@@ -112,6 +108,9 @@ When building a package that is not under version control,
112108
or that has no tags, `rustpkg` assumes the intended version is 0.1.
113109

114110
> **Note:** A future version of rustpkg will support semantic versions.
111+
> Also, a future version will add the option to specify a version with a metadata
112+
> attribute like `#[link(vers = "3.1415")]` inside the crate module,
113+
> though this attribute will never be mandatory.
115114
116115
# Dependencies
117116

branches/try2/doc/tutorial.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3070,21 +3070,22 @@ Therefore, if you plan to compile your crate as a library, you should annotate i
30703070
// lib.rs
30713071
30723072
# #[crate_type = "lib"];
3073-
// Package ID
3074-
#[pkgid = "farm#2.5"];
3073+
// Crate linkage metadata
3074+
#[link(name = "farm", vers = "2.5")];
30753075
30763076
// ...
30773077
# fn farm() {}
30783078
~~~~
30793079

3080-
You can also specify package ID information in a `extern mod` statement. For
3081-
example, these `extern mod` statements would both accept and select the
3082-
crate define above:
3080+
You can also in turn require in a `extern mod` statement that certain link metadata items match some criteria.
3081+
For that, Rust currently parses a comma-separated list of name/value pairs that appear after
3082+
it, and ensures that they match the attributes provided in the `link` attribute of a crate file.
3083+
This enables you to, e.g., pick a crate based on its version number, or link a library under a
3084+
different name. For example, these two `mod` statements would both accept and select the crate define above:
30833085

30843086
~~~~ {.xfail-test}
3085-
extern mod farm;
3086-
extern mod farm = "farm#2.5";
3087-
extern mod my_farm = "farm";
3087+
extern mod farm(vers = "2.5");
3088+
extern mod my_farm(name = "farm", vers = "2.5");
30883089
~~~~
30893090

30903091
Other crate settings and metadata include things like enabling/disabling certain errors or warnings,
@@ -3095,18 +3096,21 @@ or setting the crate type (library or executable) explicitly:
30953096
// ...
30963097
30973098
// This crate is a library ("bin" is the default)
3098-
#[pkgid = "farm#2.5"];
30993099
#[crate_type = "lib"];
31003100
31013101
// Turn on a warning
31023102
#[warn(non_camel_case_types)]
31033103
# fn farm() {}
31043104
~~~~
31053105

3106-
> ***Note:*** The rules regarding package IDs, both as attributes and as used
3107-
in `extern mod`, as well as their interaction with `rustpkg` are
3108-
currently not clearly defined and will likely change in the
3109-
future.
3106+
If you're compiling your crate with `rustpkg`,
3107+
link annotations will not be necessary, because they get
3108+
inferred by `rustpkg` based on the Package id and naming conventions.
3109+
3110+
3111+
> ***Note:*** The rules regarding link metadata, both as attributes and on `extern mod`,
3112+
as well as their interaction with `rustpkg`
3113+
are currently not clearly defined and will likely change in the future.
31103114

31113115
## A minimal example
31123116

@@ -3116,7 +3120,7 @@ We define two crates, and use one of them as a library in the other.
31163120

31173121
~~~~
31183122
// world.rs
3119-
#[pkgid = "world#0.42"];
3123+
#[link(name = "world", vers = "0.42")];
31203124
# extern mod extra;
31213125
pub fn explore() -> &'static str { "world" }
31223126
# fn main() {}
@@ -3140,7 +3144,7 @@ Now compile and run like this (adjust to your platform if necessary):
31403144
Notice that the library produced contains the version in the file name
31413145
as well as an inscrutable string of alphanumerics. As explained in the previous paragraph,
31423146
these are both part of Rust's library versioning scheme. The alphanumerics are
3143-
a hash representing the crates package ID.
3147+
a hash representing the crates link metadata.
31443148

31453149
## The standard library and the prelude
31463150

branches/try2/mk/platform.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ CFG_LIB_GLOB_arm-linux-androideabi=lib$(1)-*.so
287287
CFG_LIB_DSYM_GLOB_arm-linux-androideabi=lib$(1)-*.dylib.dSYM
288288
CFG_GCCISH_CFLAGS_arm-linux-androideabi := -Wall -g -fPIC -D__arm__ -DANDROID -D__ANDROID__
289289
CFG_GCCISH_CXXFLAGS_arm-linux-androideabi := -fno-rtti
290-
CFG_GCCISH_LINK_FLAGS_arm-linux-androideabi := -shared -fPIC -ldl -g -lm -lsupc++
290+
CFG_GCCISH_LINK_FLAGS_arm-linux-androideabi := -shared -fPIC -ldl -g -lm -lsupc++ -lgnustl_shared
291291
CFG_GCCISH_DEF_FLAG_arm-linux-androideabi := -Wl,--export-dynamic,--dynamic-list=
292292
CFG_GCCISH_PRE_LIB_FLAGS_arm-linux-androideabi := -Wl,-whole-archive
293293
CFG_GCCISH_POST_LIB_FLAGS_arm-linux-androideabi := -Wl,-no-whole-archive

branches/try2/mk/tests.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ $(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
156156
$(shell adb shell mkdir $(CFG_ADB_TEST_DIR)) \
157157
$(shell adb shell mkdir $(CFG_ADB_TEST_DIR)/tmp) \
158158
$(shell adb push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
159+
$(shell adb push $(CFG_ANDROID_CROSS_PATH)/arm-linux-androideabi/lib/armv7-a/libgnustl_shared.so \
160+
$(CFG_ADB_TEST_DIR) 1>/dev/null) \
159161
$(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD))/$(CFG_RUNTIME_arm-linux-androideabi) \
160162
$(CFG_ADB_TEST_DIR)) \
161163
$(shell adb push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD))/$(STDLIB_GLOB_arm-linux-androideabi) \

branches/try2/src/compiletest/procsrv.rs

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,47 +46,57 @@ pub fn run(lib_path: &str,
4646
prog: &str,
4747
args: &[~str],
4848
env: ~[(~str, ~str)],
49-
input: Option<~str>) -> Result {
49+
input: Option<~str>) -> Option<Result> {
5050

5151
let env = env + target_env(lib_path, prog);
52-
let mut process = run::Process::new(prog, args, run::ProcessOptions {
52+
let mut opt_process = run::Process::new(prog, args, run::ProcessOptions {
5353
env: Some(env),
5454
dir: None,
5555
in_fd: None,
5656
out_fd: None,
5757
err_fd: None
5858
});
5959

60-
for input in input.iter() {
61-
process.input().write(input.as_bytes());
62-
}
63-
let run::ProcessOutput { status, output, error } = process.finish_with_output();
60+
match opt_process {
61+
Some(ref mut process) => {
62+
for input in input.iter() {
63+
process.input().write(input.as_bytes());
64+
}
65+
let run::ProcessOutput { status, output, error } = process.finish_with_output();
6466

65-
Result {
66-
status: status,
67-
out: str::from_utf8_owned(output),
68-
err: str::from_utf8_owned(error)
67+
Some(Result {
68+
status: status,
69+
out: str::from_utf8_owned(output),
70+
err: str::from_utf8_owned(error)
71+
})
72+
},
73+
None => None
6974
}
7075
}
7176

7277
pub fn run_background(lib_path: &str,
7378
prog: &str,
7479
args: &[~str],
7580
env: ~[(~str, ~str)],
76-
input: Option<~str>) -> run::Process {
81+
input: Option<~str>) -> Option<run::Process> {
7782

7883
let env = env + target_env(lib_path, prog);
79-
let mut process = run::Process::new(prog, args, run::ProcessOptions {
84+
let opt_process = run::Process::new(prog, args, run::ProcessOptions {
8085
env: Some(env),
8186
dir: None,
8287
in_fd: None,
8388
out_fd: None,
8489
err_fd: None
8590
});
8691

87-
for input in input.iter() {
88-
process.input().write(input.as_bytes());
89-
}
92+
match opt_process {
93+
Some(mut process) => {
94+
for input in input.iter() {
95+
process.input().write(input.as_bytes());
96+
}
9097

91-
return process;
98+
Some(process)
99+
},
100+
None => None
101+
}
92102
}

0 commit comments

Comments
 (0)