Skip to content

Commit ef02cf3

Browse files
committed
---
yaml --- r: 140275 b: refs/heads/try2 c: 229ebf0 h: refs/heads/master i: 140273: 8e9f5b3 140271: 2e225d0 v: v3
1 parent 7ac6924 commit ef02cf3

File tree

17 files changed

+282
-440
lines changed

17 files changed

+282
-440
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: c1ea72d88fb9739ae82a6e5a2f0bf9bbf9838558
8+
refs/heads/try2: 229ebf0bca23f5619940ecf2cf4541e0bb7416de
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2393,7 +2393,7 @@ variables in the arm's block, and control enters the block.
23932393
An example of an `match` expression:
23942394

23952395

2396-
~~~~
2396+
~~~~ {.xfail-test}
23972397
# fn process_pair(a: int, b: int) { }
23982398
# fn process_ten() { }
23992399

branches/try2/src/libcore/task/mod.rs

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use result;
4242
use task::rt::{task_id, sched_id, rust_task};
4343
use util;
4444
use util::replace;
45-
use unstable::finally::Finally;
4645

4746
#[cfg(test)] use comm::SharedChan;
4847

@@ -592,40 +591,76 @@ pub fn get_scheduler() -> Scheduler {
592591
* ~~~
593592
*/
594593
pub unsafe fn unkillable<U>(f: &fn() -> U) -> U {
595-
let t = rt::rust_get_task();
596-
do (|| {
597-
rt::rust_task_inhibit_kill(t);
598-
f()
599-
}).finally {
600-
rt::rust_task_allow_kill(t);
594+
struct AllowFailure {
595+
t: *rust_task,
596+
drop {
597+
unsafe {
598+
rt::rust_task_allow_kill(self.t);
599+
}
600+
}
601+
}
602+
603+
fn AllowFailure(t: *rust_task) -> AllowFailure{
604+
AllowFailure {
605+
t: t
606+
}
601607
}
608+
609+
let t = rt::rust_get_task();
610+
let _allow_failure = AllowFailure(t);
611+
rt::rust_task_inhibit_kill(t);
612+
f()
602613
}
603614
604615
/// The inverse of unkillable. Only ever to be used nested in unkillable().
605616
pub unsafe fn rekillable<U>(f: &fn() -> U) -> U {
606-
let t = rt::rust_get_task();
607-
do (|| {
608-
rt::rust_task_allow_kill(t);
609-
f()
610-
}).finally {
611-
rt::rust_task_inhibit_kill(t);
617+
struct DisallowFailure {
618+
t: *rust_task,
619+
drop {
620+
unsafe {
621+
rt::rust_task_inhibit_kill(self.t);
622+
}
623+
}
624+
}
625+
626+
fn DisallowFailure(t: *rust_task) -> DisallowFailure {
627+
DisallowFailure {
628+
t: t
629+
}
612630
}
631+
632+
let t = rt::rust_get_task();
633+
let _allow_failure = DisallowFailure(t);
634+
rt::rust_task_allow_kill(t);
635+
f()
613636
}
614637
615638
/**
616639
* A stronger version of unkillable that also inhibits scheduling operations.
617640
* For use with exclusive ARCs, which use pthread mutexes directly.
618641
*/
619642
pub unsafe fn atomically<U>(f: &fn() -> U) -> U {
620-
let t = rt::rust_get_task();
621-
do (|| {
622-
rt::rust_task_inhibit_kill(t);
623-
rt::rust_task_inhibit_yield(t);
624-
f()
625-
}).finally {
626-
rt::rust_task_allow_yield(t);
627-
rt::rust_task_allow_kill(t);
643+
struct DeferInterrupts {
644+
t: *rust_task,
645+
drop {
646+
unsafe {
647+
rt::rust_task_allow_yield(self.t);
648+
rt::rust_task_allow_kill(self.t);
649+
}
650+
}
651+
}
652+
653+
fn DeferInterrupts(t: *rust_task) -> DeferInterrupts {
654+
DeferInterrupts {
655+
t: t
656+
}
628657
}
658+
659+
let t = rt::rust_get_task();
660+
let _interrupts = DeferInterrupts(t);
661+
rt::rust_task_inhibit_kill(t);
662+
rt::rust_task_inhibit_yield(t);
663+
f()
629664
}
630665
631666
#[test] #[should_fail] #[ignore(cfg(windows))]

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

Lines changed: 77 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -747,71 +747,6 @@ pub fn link_binary(sess: Session,
747747
obj_filename: &Path,
748748
out_filename: &Path,
749749
lm: LinkMeta) {
750-
// In the future, FreeBSD will use clang as default compiler.
751-
// It would be flexible to use cc (system's default C compiler)
752-
// instead of hard-coded gcc.
753-
// For win32, there is no cc command,
754-
// so we add a condition to make it use gcc.
755-
let cc_prog: ~str = if sess.targ_cfg.os == session::os_android {
756-
match &sess.opts.android_cross_path {
757-
&Some(copy path) => {
758-
fmt!("%s/bin/arm-linux-androideabi-gcc", path)
759-
}
760-
&None => {
761-
sess.fatal(~"need Android NDK path for linking \
762-
(--android-cross-path)")
763-
}
764-
}
765-
} else if sess.targ_cfg.os == session::os_win32 { ~"gcc" }
766-
else { ~"cc" };
767-
// The invocations of cc share some flags across platforms
768-
769-
770-
let output = if *sess.building_library {
771-
let long_libname = output_dll_filename(sess.targ_cfg.os, lm);
772-
debug!("link_meta.name: %s", lm.name);
773-
debug!("long_libname: %s", long_libname);
774-
debug!("out_filename: %s", out_filename.to_str());
775-
debug!("dirname(out_filename): %s", out_filename.dir_path().to_str());
776-
777-
out_filename.dir_path().push(long_libname)
778-
} else {
779-
/*bad*/copy *out_filename
780-
};
781-
782-
debug!("output: %s", output.to_str());
783-
let mut cc_args = link_args(sess, obj_filename, out_filename, lm);
784-
debug!("%s link args: %s", cc_prog, str::connect(cc_args, ~" "));
785-
// We run 'cc' here
786-
let prog = run::program_output(cc_prog, cc_args);
787-
if 0 != prog.status {
788-
sess.err(fmt!("linking with `%s` failed with code %d",
789-
cc_prog, prog.status));
790-
sess.note(fmt!("%s arguments: %s",
791-
cc_prog, str::connect(cc_args, ~" ")));
792-
sess.note(prog.err + prog.out);
793-
sess.abort_if_errors();
794-
}
795-
796-
// Clean up on Darwin
797-
if sess.targ_cfg.os == session::os_macos {
798-
run::run_program(~"dsymutil", ~[output.to_str()]);
799-
}
800-
801-
// Remove the temporary object file if we aren't saving temps
802-
if !sess.opts.save_temps {
803-
if ! os::remove_file(obj_filename) {
804-
sess.warn(fmt!("failed to delete object file `%s`",
805-
obj_filename.to_str()));
806-
}
807-
}
808-
}
809-
810-
pub fn link_args(sess: Session,
811-
obj_filename: &Path,
812-
out_filename: &Path,
813-
lm:LinkMeta) -> ~[~str] {
814-
815750
// Converts a library file-stem into a cc -l argument
816751
fn unlib(config: @session::config, stem: ~str) -> ~str {
817752
if stem.starts_with("lib") &&
@@ -822,23 +757,48 @@ pub fn link_args(sess: Session,
822757
}
823758
}
824759
825-
826760
let output = if *sess.building_library {
827761
let long_libname = output_dll_filename(sess.targ_cfg.os, lm);
762+
debug!("link_meta.name: %s", lm.name);
763+
debug!("long_libname: %s", long_libname);
764+
debug!("out_filename: %s", out_filename.to_str());
765+
debug!("dirname(out_filename): %s", out_filename.dir_path().to_str());
766+
828767
out_filename.dir_path().push(long_libname)
829768
} else {
830769
/*bad*/copy *out_filename
831770
};
832771
772+
debug!("output: %s", output.to_str());
773+
833774
// The default library location, we need this to find the runtime.
834775
// The location of crates will be determined as needed.
835776
let stage: ~str = ~"-L" + sess.filesearch.get_target_lib_path().to_str();
836777
837-
let mut args = vec::append(~[stage], sess.targ_cfg.target_strs.cc_args);
778+
// In the future, FreeBSD will use clang as default compiler.
779+
// It would be flexible to use cc (system's default C compiler)
780+
// instead of hard-coded gcc.
781+
// For win32, there is no cc command,
782+
// so we add a condition to make it use gcc.
783+
let cc_prog: ~str = if sess.targ_cfg.os == session::os_android {
784+
match &sess.opts.android_cross_path {
785+
&Some(copy path) => {
786+
fmt!("%s/bin/arm-linux-androideabi-gcc", path)
787+
}
788+
&None => {
789+
sess.fatal(~"need Android NDK path for linking \
790+
(--android-cross-path)")
791+
}
792+
}
793+
} else if sess.targ_cfg.os == session::os_win32 { ~"gcc" }
794+
else { ~"cc" };
795+
// The invocations of cc share some flags across platforms
838796
839-
args.push(~"-o");
840-
args.push(output.to_str());
841-
args.push(obj_filename.to_str());
797+
let mut cc_args =
798+
vec::append(~[stage], sess.targ_cfg.target_strs.cc_args);
799+
cc_args.push(~"-o");
800+
cc_args.push(output.to_str());
801+
cc_args.push(obj_filename.to_str());
842802
843803
let lib_cmd;
844804
let os = sess.targ_cfg.os;
@@ -853,23 +813,23 @@ pub fn link_args(sess: Session,
853813
let cstore = sess.cstore;
854814
for cstore::get_used_crate_files(cstore).each |cratepath| {
855815
if cratepath.filetype() == Some(~".rlib") {
856-
args.push(cratepath.to_str());
816+
cc_args.push(cratepath.to_str());
857817
loop;
858818
}
859819
let dir = cratepath.dirname();
860-
if dir != ~"" { args.push(~"-L" + dir); }
820+
if dir != ~"" { cc_args.push(~"-L" + dir); }
861821
let libarg = unlib(sess.targ_cfg, cratepath.filestem().get());
862-
args.push(~"-l" + libarg);
822+
cc_args.push(~"-l" + libarg);
863823
}
864824
865825
let ula = cstore::get_used_link_args(cstore);
866-
for ula.each |arg| { args.push(/*bad*/copy *arg); }
826+
for ula.each |arg| { cc_args.push(/*bad*/copy *arg); }
867827
868828
// Add all the link args for external crates.
869829
do cstore::iter_crate_data(cstore) |crate_num, _| {
870830
let link_args = csearch::get_link_args_for_crate(cstore, crate_num);
871831
do vec::consume(link_args) |_, link_arg| {
872-
args.push(link_arg);
832+
cc_args.push(link_arg);
873833
}
874834
}
875835
@@ -882,74 +842,93 @@ pub fn link_args(sess: Session,
882842
// forces to make sure that library can be found at runtime.
883843
884844
for sess.opts.addl_lib_search_paths.each |path| {
885-
args.push(~"-L" + path.to_str());
845+
cc_args.push(~"-L" + path.to_str());
886846
}
887847
888848
// The names of the extern libraries
889849
let used_libs = cstore::get_used_libraries(cstore);
890-
for used_libs.each |l| { args.push(~"-l" + *l); }
850+
for used_libs.each |l| { cc_args.push(~"-l" + *l); }
891851
892852
if *sess.building_library {
893-
args.push(lib_cmd);
853+
cc_args.push(lib_cmd);
894854
895855
// On mac we need to tell the linker to let this library
896856
// be rpathed
897857
if sess.targ_cfg.os == session::os_macos {
898-
args.push(~"-Wl,-install_name,@rpath/"
858+
cc_args.push(~"-Wl,-install_name,@rpath/"
899859
+ output.filename().get());
900860
}
901861
}
902862
903863
// On linux librt and libdl are an indirect dependencies via rustrt,
904864
// and binutils 2.22+ won't add them automatically
905865
if sess.targ_cfg.os == session::os_linux {
906-
args.push_all(~[~"-lrt", ~"-ldl"]);
866+
cc_args.push_all(~[~"-lrt", ~"-ldl"]);
907867
908868
// LLVM implements the `frem` instruction as a call to `fmod`,
909869
// which lives in libm. Similar to above, on some linuxes we
910870
// have to be explicit about linking to it. See #2510
911-
args.push(~"-lm");
871+
cc_args.push(~"-lm");
912872
}
913873
else if sess.targ_cfg.os == session::os_android {
914-
args.push_all(~[~"-ldl", ~"-llog", ~"-lsupc++",
874+
cc_args.push_all(~[~"-ldl", ~"-llog", ~"-lsupc++",
915875
~"-lgnustl_shared"]);
916-
args.push(~"-lm");
876+
cc_args.push(~"-lm");
917877
}
918878
919879
if sess.targ_cfg.os == session::os_freebsd {
920-
args.push_all(~[~"-pthread", ~"-lrt",
921-
~"-L/usr/local/lib", ~"-lexecinfo",
922-
~"-L/usr/local/lib/gcc46",
923-
~"-L/usr/local/lib/gcc44", ~"-lstdc++",
924-
~"-Wl,-z,origin",
925-
~"-Wl,-rpath,/usr/local/lib/gcc46",
926-
~"-Wl,-rpath,/usr/local/lib/gcc44"]);
880+
cc_args.push_all(~[~"-pthread", ~"-lrt",
881+
~"-L/usr/local/lib", ~"-lexecinfo",
882+
~"-L/usr/local/lib/gcc46",
883+
~"-L/usr/local/lib/gcc44", ~"-lstdc++",
884+
~"-Wl,-z,origin",
885+
~"-Wl,-rpath,/usr/local/lib/gcc46",
886+
~"-Wl,-rpath,/usr/local/lib/gcc44"]);
927887
}
928888
929889
// OS X 10.6 introduced 'compact unwind info', which is produced by the
930890
// linker from the dwarf unwind info. Unfortunately, it does not seem to
931891
// understand how to unwind our __morestack frame, so we have to turn it
932892
// off. This has impacted some other projects like GHC.
933893
if sess.targ_cfg.os == session::os_macos {
934-
args.push(~"-Wl,-no_compact_unwind");
894+
cc_args.push(~"-Wl,-no_compact_unwind");
935895
}
936896
937897
// Stack growth requires statically linking a __morestack function
938-
args.push(~"-lmorestack");
898+
cc_args.push(~"-lmorestack");
939899
940900
// Always want the runtime linked in
941-
args.push(~"-lrustrt");
901+
cc_args.push(~"-lrustrt");
942902
943903
// FIXME (#2397): At some point we want to rpath our guesses as to where
944904
// extern libraries might live, based on the addl_lib_search_paths
945-
args.push_all(rpath::get_rpath_flags(sess, &output));
905+
cc_args.push_all(rpath::get_rpath_flags(sess, &output));
946906
947-
// Finally add all the linker arguments provided on the command line
948-
args.push_all(sess.opts.linker_args);
907+
debug!("%s link args: %s", cc_prog, str::connect(cc_args, ~" "));
908+
// We run 'cc' here
909+
let prog = run::program_output(cc_prog, cc_args);
910+
if 0 != prog.status {
911+
sess.err(fmt!("linking with `%s` failed with code %d",
912+
cc_prog, prog.status));
913+
sess.note(fmt!("%s arguments: %s",
914+
cc_prog, str::connect(cc_args, ~" ")));
915+
sess.note(prog.err + prog.out);
916+
sess.abort_if_errors();
917+
}
949918
950-
return args;
951-
}
919+
// Clean up on Darwin
920+
if sess.targ_cfg.os == session::os_macos {
921+
run::run_program(~"dsymutil", ~[output.to_str()]);
922+
}
952923
924+
// Remove the temporary object file if we aren't saving temps
925+
if !sess.opts.save_temps {
926+
if ! os::remove_file(obj_filename) {
927+
sess.warn(fmt!("failed to delete object file `%s`",
928+
obj_filename.to_str()));
929+
}
930+
}
931+
}
953932
//
954933
// Local Variables:
955934
// mode: rust

0 commit comments

Comments
 (0)