Skip to content

Commit aa286c2

Browse files
committed
---
yaml --- r: 147791 b: refs/heads/try2 c: d255d4a h: refs/heads/master i: 147789: ac49069 147787: e021df8 147783: 36dd1cb 147775: a5a6c9b v: v3
1 parent cb73e71 commit aa286c2

File tree

10 files changed

+164
-34
lines changed

10 files changed

+164
-34
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: d459e805df076ace12ed3f7f57f2b1378f0e2403
8+
refs/heads/try2: d255d4a4ff394da96bb669fef7a70871e08498fa
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libextra/getopts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
//!
3232
//! ~~~{.rust}
3333
//! extern mod extra;
34-
//! use extra::getopts::{optopt,optflag,getopts,Opt};
34+
//! use extra::getopts::*;
3535
//! use std::os;
3636
//!
3737
//! fn do_work(inp: &str, out: Option<~str>) {

branches/try2/src/librustc/back/link.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use back::archive::{Archive, METADATA_FILENAME};
1313
use back::rpath;
14+
use back::manifest;
1415
use driver::driver::CrateTranslation;
1516
use driver::session::Session;
1617
use driver::session;
@@ -827,6 +828,12 @@ fn link_binary_output(sess: Session,
827828
}
828829
session::OutputExecutable => {
829830
link_natively(sess, false, obj_filename, &out_filename);
831+
// Windows linker will add an ".exe" extension if there was none
832+
let out_filename = match out_filename.extension() {
833+
Some(_) => out_filename.clone(),
834+
None => out_filename.with_extension(win32::EXE_EXTENSION)
835+
};
836+
manifest::postprocess_executable(sess, &out_filename);
830837
}
831838
session::OutputDylib => {
832839
link_natively(sess, true, obj_filename, &out_filename);
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// Copyright 2013 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+
12+
// To avoid problems with Windows UAC installer detection heuristics,
13+
// Rust-produced executables need an application manifest.
14+
// For details, see issue #10512.
15+
16+
// No-op on other platforms.
17+
18+
use driver::session::Session;
19+
use std::path::Path;
20+
21+
#[cfg(not(windows))]
22+
pub fn postprocess_executable(_sess: Session, _filename: &Path) {}
23+
24+
#[cfg(windows)]
25+
pub fn postprocess_executable(sess: Session, filename: &Path) {
26+
27+
let default_manifest = concat!(
28+
"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>",
29+
"<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>",
30+
" <trustInfo xmlns='urn:schemas-microsoft-com:asm.v3'>",
31+
" <security>",
32+
" <requestedPrivileges>",
33+
" <requestedExecutionLevel level='asInvoker' uiAccess='false' />",
34+
" </requestedPrivileges>",
35+
" </security>",
36+
" </trustInfo>",
37+
"</assembly>");
38+
39+
match windows::embed_manifest(filename, default_manifest) {
40+
Ok(_) => (),
41+
Err(msg) => sess.err(format!("Could not embed application manifest: {}", msg))
42+
}
43+
}
44+
45+
#[cfg(windows)]
46+
mod windows {
47+
use std::libc::types::os::arch::extra::{BOOL,WORD,DWORD,HANDLE,LPCWSTR,LPCVOID};
48+
use std::libc::consts::os::extra::FALSE;
49+
use std::cast::transmute;
50+
use std::os;
51+
52+
// FIXME #9053: should import as_utf16_p from std rather than re-defining here
53+
//use std::os::win32::as_utf16_p;
54+
fn as_utf16_p<T>(s: &str, f: |*u16| -> T) -> T {
55+
let mut t = s.to_utf16();
56+
// Null terminate before passing on.
57+
t.push(0u16);
58+
f(t.as_ptr())
59+
}
60+
61+
#[link_name = "kernel32"]
62+
extern "system" {
63+
pub fn BeginUpdateResourceW(pFileName: LPCWSTR,
64+
bDeleteExistingResources: BOOL) -> HANDLE;
65+
pub fn UpdateResourceW(hUpdate: HANDLE,
66+
lpType: LPCWSTR,
67+
lpName: LPCWSTR,
68+
wLanguage: WORD,
69+
lpData: LPCVOID,
70+
cbData: DWORD) -> BOOL;
71+
pub fn EndUpdateResourceW(hUpdate: HANDLE,
72+
fDiscard: BOOL) -> BOOL;
73+
}
74+
75+
fn MAKEINTRESOURCEW(id: int) -> LPCWSTR {
76+
unsafe{ transmute(id) }
77+
}
78+
79+
pub fn embed_manifest(filename: &Path,
80+
manifest: &str) -> Result<(),~str> {
81+
unsafe {
82+
let hUpdate = as_utf16_p(filename.as_str().unwrap(), |path| {
83+
BeginUpdateResourceW(path, FALSE)
84+
});
85+
if hUpdate.is_null() {
86+
return Err(format!("failure in BeginUpdateResourceW: {}", os::last_os_error()));
87+
}
88+
89+
let ok = UpdateResourceW(hUpdate,
90+
MAKEINTRESOURCEW(24), // RT_MANIFEST
91+
MAKEINTRESOURCEW(1), // CREATEPROCESS_MANIFEST_RESOURCE_ID
92+
0, // LANG_NEUTRAL, SUBLANG_NEUTRAL
93+
manifest.as_ptr() as LPCVOID,
94+
manifest.len() as u32);
95+
if ok == FALSE {
96+
return Err(format!("failure in UpdateResourceW: {}", os::last_os_error()));
97+
}
98+
99+
let ok = EndUpdateResourceW(hUpdate, FALSE);
100+
if ok == FALSE {
101+
return Err(format!("failure in EndUpdateResourceW: {}", os::last_os_error()));
102+
}
103+
Ok(())
104+
}
105+
}
106+
}

branches/try2/src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ pub mod front {
8888
pub mod back {
8989
pub mod archive;
9090
pub mod link;
91+
pub mod manifest;
9192
pub mod abi;
9293
pub mod arm;
9394
pub mod mips;

branches/try2/src/librustdoc/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ fn maketest(s: &str, cratename: &str) -> @str {
138138
let mut prog = ~r"
139139
#[deny(warnings)];
140140
#[allow(unused_variable, dead_assignment, unused_mut, attribute_usage, dead_code)];
141+
#[feature(macro_rules, globs, struct_variant, managed_boxes)];
141142
";
142143
if s.contains("extra") {
143144
prog.push_str("extern mod extra;\n");

branches/try2/src/libstd/rt/logging.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use io::stdio::StdWriter;
1717
use io::buffered::LineBufferedWriter;
1818
use rt::crate_map::{ModEntry, CrateMap, iter_crate_map, get_crate_map};
1919
use str::StrSlice;
20-
use vec::ImmutableVector;
20+
use vec::{ImmutableVector, MutableTotalOrdVector};
2121
#[cfg(test)] use cast::transmute;
2222

2323
struct LogDirective {
@@ -141,7 +141,14 @@ fn update_log_settings(crate_map: &CrateMap, settings: ~str) {
141141
if settings.len() > 0 {
142142
if settings == ~"::help" || settings == ~"?" {
143143
rterrln!("\nCrate log map:\n");
144-
iter_crate_map(crate_map, |entry| rterrln!(" {}", entry.name));
144+
145+
let mut entries = ~[];
146+
iter_crate_map(crate_map, |entry| entries.push(entry.name.to_owned()));
147+
entries.sort();
148+
149+
for name in entries.iter() {
150+
rterrln!(" {}", *name);
151+
}
145152
unsafe { exit(1); }
146153
}
147154
dirs = parse_logging_spec(settings);

branches/try2/src/libstd/rt/unwind.rs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -180,29 +180,22 @@ impl Unwinder {
180180
self.unwinding = true;
181181
self.cause = Some(cause);
182182

183-
rust_fail();
183+
unsafe {
184+
let exception = ~uw::_Unwind_Exception {
185+
exception_class: rust_exception_class(),
186+
exception_cleanup: exception_cleanup,
187+
private_1: 0,
188+
private_2: 0
189+
};
190+
let error = uw::_Unwind_RaiseException(cast::transmute(exception));
191+
rtabort!("Could not unwind stack, error = {}", error as int)
192+
}
184193

185-
// An uninlined, unmangled function upon which to slap yer breakpoints
186-
#[inline(never)]
187-
#[no_mangle]
188-
fn rust_fail() -> ! {
194+
extern "C" fn exception_cleanup(_unwind_code: uw::_Unwind_Reason_Code,
195+
exception: *uw::_Unwind_Exception) {
196+
rtdebug!("exception_cleanup()");
189197
unsafe {
190-
let exception = ~uw::_Unwind_Exception {
191-
exception_class: rust_exception_class(),
192-
exception_cleanup: exception_cleanup,
193-
private_1: 0,
194-
private_2: 0
195-
};
196-
let error = uw::_Unwind_RaiseException(cast::transmute(exception));
197-
rtabort!("Could not unwind stack, error = {}", error as int)
198-
}
199-
200-
extern "C" fn exception_cleanup(_unwind_code: uw::_Unwind_Reason_Code,
201-
exception: *uw::_Unwind_Exception) {
202-
rtdebug!("exception_cleanup()");
203-
unsafe {
204-
let _: ~uw::_Unwind_Exception = cast::transmute(exception);
205-
}
198+
let _: ~uw::_Unwind_Exception = cast::transmute(exception);
206199
}
207200
}
208201
}

branches/try2/src/libstd/str.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,11 @@ there are three common kinds of strings in rust:
3838
As an example, here's a few different kinds of strings.
3939
4040
```rust
41-
#[feature(managed_boxes)];
42-
43-
fn main() {
44-
let owned_string = ~"I am an owned string";
45-
let managed_string = @"This string is garbage-collected";
46-
let borrowed_string1 = "This string is borrowed with the 'static lifetime";
47-
let borrowed_string2: &str = owned_string; // owned strings can be borrowed
48-
let borrowed_string3: &str = managed_string; // managed strings can also be borrowed
49-
}
41+
let owned_string = ~"I am an owned string";
42+
let managed_string = @"This string is garbage-collected";
43+
let borrowed_string1 = "This string is borrowed with the 'static lifetime";
44+
let borrowed_string2: &str = owned_string; // owned strings can be borrowed
45+
let borrowed_string3: &str = managed_string; // managed strings can also be borrowed
5046
```
5147
5248
From the example above, you can see that rust has 3 different kinds of string
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2013 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+
// On Windows this test checks that Rust binaries have an embedded
12+
// application manifest and don't trip UAC installer detection
13+
// heuristics ("setup" is one of the "installer" keywords).
14+
// For details, see issue #10512.
15+
16+
// On other platforms this is a no-op.
17+
18+
pub fn main() {
19+
}

0 commit comments

Comments
 (0)