Skip to content

Rolling up PRs in the queue #14867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 19 additions & 54 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ opt mingw-cross 0 "cross-compile for win32 using mingw"
opt clang 0 "prefer clang to gcc for building the runtime"
opt ccache 0 "invoke gcc/clang via ccache to reuse object files between builds"
opt local-rust 0 "use an installed rustc rather than downloading a snapshot"
opt pax-flags 0 "apply PaX flags to rustc binaries (required for GRSecurity/PaX-patched kernels)"
opt inject-std-version 1 "inject the current compiler version of libstd into programs"
opt llvm-static-stdcpp 0 "statically link to libstdc++ for LLVM"
opt rpath 1 "build rpaths into rustc itself"
Expand Down Expand Up @@ -518,12 +517,6 @@ then
fi
fi

if [ "$CFG_OSTYPE" = "unknown-linux-gnu" ]
then
probe CFG_PAXCTL paxctl /sbin/paxctl
probe CFG_ZCAT zcat
fi

step_msg "looking for target specific programs"

probe CFG_ADB adb
Expand All @@ -546,51 +539,6 @@ then
fi
fi

if [ "$CFG_OSTYPE" = "unknown-linux-gnu" ]
then
if [ ! -z "$CFG_ENABLE_PAX_FLAGS" -a -z "$CFG_PAXCTL" ]
then
err "enabled PaX markings but no paxctl binary found"
fi

if [ -z "$CFG_DISABLE_PAX_FLAGS" ]
then
# GRSecurity/PaX detection. This can be very flaky.
GRSEC_DETECTED=

# /dev/grsec only exists if CONFIG_GRKERNSEC_NO_RBAC is not set.
# /proc/sys/kernel/grsecurity is not available if ÇONFIG_GRKERNSEC_SYSCTL is not set.
if [ -e /dev/grsec -o -d /proc/sys/kernel/grsecurity ]
then
GRSEC_DETECTED=1
# /proc/config.gz is normally only available to root, and only if CONFIG_IKCONFIG_PROC has been set.
elif [ -r /proc/config.gz -a ! -z "$CFG_ZCAT" ]
then
if "$CFG_ZCAT" /proc/config.gz | grep --quiet "CONFIG_GRKERNSEC=y"
then
GRSEC_DETECTED=1
fi
# Flaky.
elif grep --quiet grsec /proc/version
then
GRSEC_DETECTED=1
fi

if [ ! -z "$GRSEC_DETECTED" ]
then
step_msg "GRSecurity: yes"
if [ ! -z "$CFG_PAXCTL" ]
then
CFG_ENABLE_PAX_FLAGS=1
else
warn "GRSecurity kernel detected but no paxctl binary found: not setting CFG_ENABLE_PAX_FLAGS"
fi
else
step_msg "GRSecurity: no"
fi
fi
fi

BIN_SUF=
if [ "$CFG_OSTYPE" = "pc-mingw32" ] || [ "$CFG_OSTYPE" = "w64-mingw32" ]
then
Expand Down Expand Up @@ -942,16 +890,33 @@ then
msg "git: submodule sync"
"${CFG_GIT}" submodule sync

msg "git: submodule init"
"${CFG_GIT}" submodule init

# Disable submodules that we're not using
if [ ! -z "${CFG_LLVM_ROOT}" ]; then
msg "git: submodule deinit src/llvm"
"${CFG_GIT}" submodule deinit src/llvm
fi
if [ ! -z "${CFG_JEMALLOC_ROOT}" ]; then
msg "git: submodule deinit src/jemalloc"
"${CFG_GIT}" submodule deinit src/jemalloc
fi
if [ ! -z "${CFG_LIBUV_ROOT}" ]; then
msg "git: submodule deinit src/libuv"
"${CFG_GIT}" submodule deinit src/libuv
fi

msg "git: submodule update"
"${CFG_GIT}" submodule update --init
"${CFG_GIT}" submodule update
need_ok "git failed"

msg "git: submodule foreach sync"
"${CFG_GIT}" submodule foreach --recursive 'if test -e .gitmodules; then git submodule sync; fi'
need_ok "git failed"

msg "git: submodule foreach update"
"${CFG_GIT}" submodule update --init --recursive
"${CFG_GIT}" submodule update --recursive
need_ok "git failed"

# NB: this is just for the sake of getting the submodule SHA1 values
Expand Down
4 changes: 0 additions & 4 deletions mk/stage0.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ ifdef CFG_ENABLE_LOCAL_RUST
$(Q)$(S)src/etc/local_stage0.sh $(CFG_BUILD) $(CFG_LOCAL_RUST_ROOT) rustlib
else
$(Q)$(CFG_PYTHON) $(S)src/etc/get-snapshot.py $(CFG_BUILD) $(SNAPSHOT_FILE)
ifdef CFG_ENABLE_PAX_FLAGS
@$(call E, apply PaX flags: $@)
@"$(CFG_PAXCTL)" -cm "$@"
endif
endif
$(Q)touch $@

Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ pub struct IntersectionItems<'a, T> {
b: Peekable<&'a T, SetItems<'a, T>>,
}

/// Lazy iterator producing elements in the set intersection (in-order)
/// Lazy iterator producing elements in the set union (in-order)
pub struct UnionItems<'a, T> {
a: Peekable<&'a T, SetItems<'a, T>>,
b: Peekable<&'a T, SetItems<'a, T>>,
Expand Down
18 changes: 14 additions & 4 deletions src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Traits for dynamic typing of any type (through runtime reflection)
//! Traits for dynamic typing of any `'static` type (through runtime reflection)
//!
//! This module implements the `Any` trait, which enables dynamic typing
//! of any type, through runtime reflection.
//! of any `'static` type through runtime reflection.
//!
//! `Any` itself can be used to get a `TypeId`, and has more features when used as a trait object.
//! As `&Any` (a borrowed trait object), it has the `is` and `as_ref` methods, to test if the
Expand All @@ -32,8 +32,10 @@ pub enum Void { }
// Any trait
///////////////////////////////////////////////////////////////////////////////

/// The `Any` trait is implemented by all types, and can be used as a trait object
/// for dynamic typing
/// The `Any` trait is implemented by all `'static` types, and can be used for dynamic typing
///
/// Every type with no non-`'static` references implements `Any`, so `Any` can be used as a trait
/// object to emulate the effects dynamic typing.
pub trait Any {
/// Get the `TypeId` of `self`
fn get_type_id(&self) -> TypeId;
Expand Down Expand Up @@ -261,6 +263,14 @@ mod tests {
let s = format!("{}", b);
assert_eq!(s.as_slice(), "&Any");
}

#[test]
fn any_fixed_vec() {
let test = [0u, ..8];
let test = &test as &Any;
assert!(test.is::<[uint, ..8]>());
assert!(!test.is::<[uint, ..10]>());
}
}

#[cfg(test)]
Expand Down
14 changes: 14 additions & 0 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,20 @@ extern "rust-intrinsic" {
/// `forget` is unsafe because the caller is responsible for
/// ensuring the argument is deallocated already.
pub fn forget<T>(_: T) -> ();

/// Unsafely transforms a value of one type into a value of another type.
///
/// Both types must have the same size and alignment, and this guarantee
/// is enforced at compile-time.
///
/// # Example
///
/// ```rust
/// use std::mem;
///
/// let v: &[u8] = unsafe { mem::transmute("L") };
/// assert!(v == [76u8]);
/// ```
pub fn transmute<T,U>(e: T) -> U;

/// Returns `true` if a type requires drop glue.
Expand Down
25 changes: 2 additions & 23 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use ptr;
use intrinsics;
use intrinsics::{bswap16, bswap32, bswap64};

pub use intrinsics::transmute;

/// Returns the size of a type in bytes.
#[inline]
#[stable]
Expand Down Expand Up @@ -412,29 +414,6 @@ pub fn drop<T>(_x: T) { }
#[stable]
pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing) }

/// Unsafely transforms a value of one type into a value of another type.
///
/// Both types must have the same size and alignment, and this guarantee is
/// enforced at compile-time.
///
/// # Example
///
/// ```rust
/// use std::mem;
///
/// let v: &[u8] = unsafe { mem::transmute("L") };
/// assert!(v == [76u8]);
/// ```
#[inline]
#[unstable = "this function will be modified to reject invocations of it which \
cannot statically prove that T and U are the same size. For \
example, this function, as written today, will be rejected in \
the future because the size of T and U cannot be statically \
known to be the same"]
pub unsafe fn transmute<T, U>(thing: T) -> U {
intrinsics::transmute(thing)
}

/// Interprets `src` as `&U`, and then reads `src` without moving the contained
/// value.
///
Expand Down
25 changes: 15 additions & 10 deletions src/libnative/io/c_win32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,20 @@ pub mod compat {
fn GetProcAddress(hModule: HMODULE, lpProcName: LPCSTR) -> LPVOID;
}

// store_func() is idempotent, so using relaxed ordering for the atomics should be enough.
// This way, calling a function in this compatibility layer (after it's loaded) shouldn't
// be any slower than a regular DLL call.
unsafe fn store_func<T: Copy>(ptr: *mut T, module: &str, symbol: &str, fallback: T) {
// store_func() is idempotent, so using relaxed ordering for the atomics
// should be enough. This way, calling a function in this compatibility
// layer (after it's loaded) shouldn't be any slower than a regular DLL
// call.
unsafe fn store_func(ptr: *mut uint, module: &str, symbol: &str, fallback: uint) {
let module = module.to_utf16().append_one(0);
symbol.with_c_str(|symbol| {
let handle = GetModuleHandleW(module.as_ptr());
let func: Option<T> = transmute(GetProcAddress(handle, symbol));
atomic_store_relaxed(ptr, func.unwrap_or(fallback))
let func: uint = transmute(GetProcAddress(handle, symbol));
atomic_store_relaxed(ptr, if func == 0 {
fallback
} else {
func
})
})
}

Expand All @@ -109,10 +114,10 @@ pub mod compat {

extern "system" fn thunk($($argname: $argtype),*) -> $rettype {
unsafe {
::io::c::compat::store_func(&mut ptr,
stringify!($module),
stringify!($symbol),
fallback);
::io::c::compat::store_func(&mut ptr as *mut _ as *mut uint,
stringify!($module),
stringify!($symbol),
fallback as uint);
::std::intrinsics::atomic_load_relaxed(&ptr)($($argname),*)
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ pub fn phase_3_run_analysis_passes(sess: Session,
time(time_passes, "privacy checking", maps, |(a, b)|
middle::privacy::check_crate(&ty_cx, &exp_map2, a, b, krate));

time(time_passes, "intrinsic checking", (), |_|
middle::intrinsicck::check_crate(&ty_cx, krate));

time(time_passes, "effect checking", (), |_|
middle::effect::check_crate(&ty_cx, krate));

Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub mod middle {
pub mod dependency_format;
pub mod weak_lang_items;
pub mod save;
pub mod intrinsicck;
}

pub mod front {
Expand Down
Loading