Skip to content
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

Rollup of 5 pull requests #40758

Merged
merged 15 commits into from
Mar 23, 2017
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
12 changes: 6 additions & 6 deletions src/ci/docker/dist-s390x-linux-netbsd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ COPY patches/ /tmp/patches/
COPY s390x-linux-gnu.config build-s390x-toolchain.sh /tmp/
RUN ./build-s390x-toolchain.sh

USER root

COPY build-netbsd-toolchain.sh /tmp/
RUN ./build-netbsd-toolchain.sh

ENV PATH=$PATH:/x-tools/s390x-ibm-linux-gnu/bin
USER root

ENV PATH=$PATH:/x-tools/s390x-ibm-linux-gnu/bin:/x-tools/x86_64-unknown-netbsd/bin

ENV \
AR_x86_64_unknown_netbsd=x86_64-unknown-netbsd-ar \
CC_x86_64_unknown_netbsd=x86_64-unknown-netbsd-gcc \
CXX_x86_64_unknown_netbsd=x86_64-unknown-netbsd-g++ \
AR_x86_64_unknown_netbsd=x86_64--netbsd-ar \
CC_x86_64_unknown_netbsd=x86_64--netbsd-gcc-sysroot \
CXX_x86_64_unknown_netbsd=x86_64--netbsd-g++-sysroot \
CC_s390x_unknown_linux_gnu=s390x-ibm-linux-gnu-gcc \
AR_s390x_unknown_linux_gnu=s390x-ibm-linux-gnu-ar \
CXX_s390x_unknown_linux_gnu=s390x-ibm-linux-gnu-g++
Expand Down
165 changes: 64 additions & 101 deletions src/ci/docker/dist-s390x-linux-netbsd/build-netbsd-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,108 +13,71 @@

set -ex

BINUTILS=2.25.1
GCC=5.3.0

# First up, build binutils
mkdir binutils
cd binutils
curl https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.bz2 | tar xjf -
mkdir binutils-build
cd binutils-build
../binutils-$BINUTILS/configure \
--target=x86_64-unknown-netbsd
make -j10
make install
cd ../..
rm -rf binutils
hide_output() {
set +x
on_err="
echo ERROR: An error was encountered with the build.
cat /tmp/build.log
exit 1
"
trap "$on_err" ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
$@ &> /tmp/build.log
rm /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
set -x
}

# Next, download the NetBSD libc and relevant header files
mkdir netbsd
# originally from:
# https://ftp.netbsd.org/pub/NetBSD/NetBSD-7.0/amd64/binary/sets/base.tgz
curl https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-01-16-netbsd-base.tgz | \
tar xzf - -C netbsd ./usr/include ./usr/lib ./lib
# originally from:
# https://ftp.netbsd.org/pub/NetBSD/NetBSD-7.0/amd64/binary/sets/comp.tgz
curl https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-01-16-netbsd-comp.tgz | \
tar xzf - -C netbsd ./usr/include ./usr/lib

dst=/usr/local/x86_64-unknown-netbsd
cp -r netbsd/usr/include $dst
cp netbsd/usr/lib/crt0.o $dst/lib
cp netbsd/usr/lib/crti.o $dst/lib
cp netbsd/usr/lib/crtn.o $dst/lib
cp netbsd/usr/lib/crtbeginS.o $dst/lib
cp netbsd/usr/lib/crtendS.o $dst/lib
cp netbsd/usr/lib/crtbegin.o $dst/lib
cp netbsd/usr/lib/crtend.o $dst/lib
cp netbsd/usr/lib/gcrt0.o $dst/lib
cp netbsd/usr/lib/libc.a $dst/lib
cp netbsd/usr/lib/libc_p.a $dst/lib
cp netbsd/usr/lib/libc_pic.a $dst/lib
cp netbsd/lib/libc.so.12.193.1 $dst/lib
cp netbsd/lib/libutil.so.7.21 $dst/lib
cp netbsd/usr/lib/libm.a $dst/lib
cp netbsd/usr/lib/libm_p.a $dst/lib
cp netbsd/usr/lib/libm_pic.a $dst/lib
cp netbsd/lib/libm.so.0.11 $dst/lib
cp netbsd/usr/lib/librt.so.1.1 $dst/lib
cp netbsd/usr/lib/libpthread.a $dst/lib
cp netbsd/usr/lib/libpthread_p.a $dst/lib
cp netbsd/usr/lib/libpthread_pic.a $dst/lib
cp netbsd/usr/lib/libpthread.so.1.2 $dst/lib

ln -s libc.so.12.193.1 $dst/lib/libc.so
ln -s libc.so.12.193.1 $dst/lib/libc.so.12
ln -s libm.so.0.11 $dst/lib/libm.so
ln -s libm.so.0.11 $dst/lib/libm.so.0
ln -s libutil.so.7.21 $dst/lib/libutil.so
ln -s libutil.so.7.21 $dst/lib/libutil.so.7
ln -s libpthread.so.1.2 $dst/lib/libpthread.so
ln -s libpthread.so.1.2 $dst/lib/libpthread.so.1
ln -s librt.so.1.1 $dst/lib/librt.so

rm -rf netbsd

# Finally, download and build gcc to target NetBSD
mkdir gcc
cd gcc
curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.bz2 | tar xjf -
cd gcc-$GCC
./contrib/download_prerequisites

# Originally from
# ftp://ftp.netbsd.org/pub/pkgsrc/pkgsrc-2016Q4/pkgsrc/lang/gcc5/patches/patch-libstdc%2B%2B-v3_config_os_bsd_netbsd_ctype__base.h
PATCHES="https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-01-13-netbsd-patch1.patch"

# Originally from
# ftp://ftp.netbsd.org/pub/pkgsrc/pkgsrc-2016Q4/pkgsrc/lang/gcc5/patches/patch-libstdc%2B%2B-v3_config_os_bsd_netbsd_ctype__configure__char.cc
PATCHES="$PATCHES https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-01-13-netbsd-patch2.patch"

for patch in $PATCHES; do
curl $patch | patch -Np0
done

mkdir ../gcc-build
cd ../gcc-build
../gcc-$GCC/configure \
--enable-languages=c,c++ \
--target=x86_64-unknown-netbsd \
--disable-libcilkrts \
--disable-multilib \
--disable-nls \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libcilkrt \
--disable-libada \
--disable-libsanitizer \
--disable-libquadmath-support \
--disable-lto
make -j10
make install
cd netbsd

mkdir -p /x-tools/x86_64-unknown-netbsd/sysroot

URL=https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror

# Originally from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-$BSD/source/sets/*.tgz
curl $URL/2017-03-17-netbsd-src.tgz | tar xzf -
curl $URL/2017-03-17-netbsd-gnusrc.tgz | tar xzf -
curl $URL/2017-03-17-netbsd-sharesrc.tgz | tar xzf -
curl $URL/2017-03-17-netbsd-syssrc.tgz | tar xzf -

# Originally from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-$BSD/amd64/binary/sets/*.tgz
curl $URL/2017-03-17-netbsd-base.tgz | \
tar xzf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib ./lib
curl $URL/2017-03-17-netbsd-comp.tgz | \
tar xzf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib

cd usr/src

# The options, in order, do the following
# * this is an unpriviledged build
# * output to a predictable location
# * disable various uneeded stuff
MKUNPRIVED=yes TOOLDIR=/x-tools/x86_64-unknown-netbsd \
MKSHARE=no MKDOC=no MKHTML=no MKINFO=no MKKMOD=no MKLINT=no MKMAN=no MKNLS=no MKPROFILE=no \
hide_output ./build.sh -j10 -m amd64 tools

cd ../..
rm -rf gcc

rm -rf usr

cat > /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-gcc-sysroot <<'EOF'
#!/bin/bash
exec /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-gcc --sysroot=/x-tools/x86_64-unknown-netbsd/sysroot "$@"
EOF

cat > /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-g++-sysroot <<'EOF'
#!/bin/bash
exec /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-g++ --sysroot=/x-tools/x86_64-unknown-netbsd/sysroot "$@"
EOF

GCC_SHA1=`sha1sum -b /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-gcc | cut -d' ' -f1`
GPP_SHA1=`sha1sum -b /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-g++ | cut -d' ' -f1`

echo "# $GCC_SHA1" >> /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-gcc-sysroot
echo "# $GPP_SHA1" >> /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-g++-sysroot

chmod +x /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-gcc-sysroot
chmod +x /x-tools/x86_64-unknown-netbsd/bin/x86_64--netbsd-g++-sysroot
6 changes: 3 additions & 3 deletions src/libcore/iter/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,17 +536,17 @@ impl<'a, I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for &'a mut I {
/// # }
/// # }
/// impl ExactSizeIterator for Counter {
/// // We already have the number of iterations, so we can use it directly.
/// // We can easily calculate the remaining number of iterations.
/// fn len(&self) -> usize {
/// self.count
/// 5 - self.count
/// }
/// }
///
/// // And now we can use it!
///
/// let counter = Counter::new();
///
/// assert_eq!(0, counter.len());
/// assert_eq!(5, counter.len());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub trait ExactSizeIterator: Iterator {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/object_safety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl ObjectSafetyViolation {
"the trait cannot require that `Self : Sized`".into(),
ObjectSafetyViolation::SupertraitSelf =>
"the trait cannot use `Self` as a type parameter \
in the supertrait listing".into(),
in the supertraits or where-clauses".into(),
ObjectSafetyViolation::Method(name, MethodViolationCode::StaticMethod) =>
format!("method `{}` has no receiver", name).into(),
ObjectSafetyViolation::Method(name, MethodViolationCode::ReferencesSelf) =>
Expand Down
92 changes: 43 additions & 49 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2059,55 +2059,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}

pub fn associated_item(self, def_id: DefId) -> AssociatedItem {
if !def_id.is_local() {
return queries::associated_item::get(self, DUMMY_SP, def_id);
}

self.maps.associated_item.memoize(def_id, || {
// When the user asks for a given associated item, we
// always go ahead and convert all the associated items in
// the container. Note that we are also careful only to
// ever register a read on the *container* of the assoc
// item, not the assoc item itself. This prevents changes
// in the details of an item (for example, the type to
// which an associated type is bound) from contaminating
// those tasks that just need to scan the names of items
// and so forth.

let id = self.hir.as_local_node_id(def_id).unwrap();
let parent_id = self.hir.get_parent(id);
let parent_def_id = self.hir.local_def_id(parent_id);
let parent_item = self.hir.expect_item(parent_id);
match parent_item.node {
hir::ItemImpl(.., ref impl_trait_ref, _, ref impl_item_refs) => {
for impl_item_ref in impl_item_refs {
let assoc_item =
self.associated_item_from_impl_item_ref(parent_def_id,
impl_trait_ref.is_some(),
impl_item_ref);
self.maps.associated_item.borrow_mut()
.insert(assoc_item.def_id, assoc_item);
}
}

hir::ItemTrait(.., ref trait_item_refs) => {
for trait_item_ref in trait_item_refs {
let assoc_item =
self.associated_item_from_trait_item_ref(parent_def_id, trait_item_ref);
self.maps.associated_item.borrow_mut()
.insert(assoc_item.def_id, assoc_item);
}
}

ref r => {
panic!("unexpected container of associated items: {:?}", r)
}
}

// memoize wants us to return something, so return
// the one we generated for this def-id
*self.maps.associated_item.borrow().get(&def_id).unwrap()
})
queries::associated_item::get(self, DUMMY_SP, def_id)
}

fn associated_item_from_trait_item_ref(self,
Expand Down Expand Up @@ -2643,3 +2595,45 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
}
}

fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
-> AssociatedItem
{
let id = tcx.hir.as_local_node_id(def_id).unwrap();
let parent_id = tcx.hir.get_parent(id);
let parent_def_id = tcx.hir.local_def_id(parent_id);
let parent_item = tcx.hir.expect_item(parent_id);
match parent_item.node {
hir::ItemImpl(.., ref impl_trait_ref, _, ref impl_item_refs) => {
if let Some(impl_item_ref) = impl_item_refs.iter().find(|i| i.id.node_id == id) {
let assoc_item =
tcx.associated_item_from_impl_item_ref(parent_def_id,
impl_trait_ref.is_some(),
impl_item_ref);
debug_assert_eq!(assoc_item.def_id, def_id);
return assoc_item;
}
}

hir::ItemTrait(.., ref trait_item_refs) => {
if let Some(trait_item_ref) = trait_item_refs.iter().find(|i| i.id.node_id == id) {
let assoc_item =
tcx.associated_item_from_trait_item_ref(parent_def_id, trait_item_ref);
debug_assert_eq!(assoc_item.def_id, def_id);
return assoc_item;
}
}

ref r => {
panic!("unexpected container of associated items: {:?}", r)
}
}
panic!("associated item not found for def_id: {:?}", def_id);
}

pub fn provide(providers: &mut ty::maps::Providers) {
*providers = ty::maps::Providers {
associated_item,
..*providers
};
}
1 change: 1 addition & 0 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
let mut local_providers = ty::maps::Providers::default();
mir::provide(&mut local_providers);
typeck::provide(&mut local_providers);
ty::provide(&mut local_providers);

let mut extern_providers = ty::maps::Providers::default();
cstore::provide(&mut extern_providers);
Expand Down
15 changes: 13 additions & 2 deletions src/librustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ fn main() {
if is_crossed && flag.starts_with("-m") {
continue;
}

// -Wdate-time is not supported by the netbsd cross compiler
if is_crossed && target.contains("netbsd") && flag.contains("date-time") {
continue;
}

cfg.flag(flag);
}

Expand Down Expand Up @@ -227,16 +233,21 @@ fn main() {
}
}

// OpenBSD has a particular C++ runtime library name
let llvm_static_stdcpp = env::var_os("LLVM_STATIC_STDCPP");

let stdcppname = if target.contains("openbsd") {
// OpenBSD has a particular C++ runtime library name
"estdc++"
} else if target.contains("netbsd") && llvm_static_stdcpp.is_some() {
// NetBSD uses a separate library when relocation is required
"stdc++_pic"
} else {
"stdc++"
};

// C++ runtime library
if !target.contains("msvc") {
if let Some(s) = env::var_os("LLVM_STATIC_STDCPP") {
if let Some(s) = llvm_static_stdcpp {
assert!(!cxxflags.contains("stdlib=libc++"));
let path = PathBuf::from(s);
println!("cargo:rustc-link-search=native={}",
Expand Down
Loading