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

*: make CI green again #146

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
31 changes: 9 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: rust
rust: nightly
services: docker

matrix:
jobs:
include:
# Linux
- name: "aarch64-unknown-linux-gnu"
Expand Down Expand Up @@ -72,7 +72,8 @@ matrix:
install: true
script:
- cargo test --bench roundtrip
- cargo test --features=alloc_trait --bench roundtrip
# FIXME: Re-enable this when allocator API is stable.
# - cargo test --features=alloc_trait --bench roundtrip
- name: "x86_64-unknown-linux-musl"
env: TARGET=x86_64-unknown-linux-musl NOBGT=1 NO_JEMALLOC_TESTS=1

Expand All @@ -86,24 +87,10 @@ matrix:
# FIXME: cannot jemalloc tests fail due to:
# /~https://github.com/jemalloc/jemalloc/issues/1320
# /~https://github.com/gnzlbg/jemallocator/issues/85
- name: "i686-apple-darwin (nightly)"
env: TARGET=i686-apple-darwin NO_JEMALLOC_TESTS=1
os: osx
osx_image: xcode10
- name: "i686-apple-darwin (beta)"
env: TARGET=i686-apple-darwin NO_JEMALLOC_TESTS=1
os: osx
osx_image: xcode10
rust: beta
- name: "i686-apple-darwin (stable)"
env: TARGET=i686-apple-darwin NO_JEMALLOC_TESTS=1
os: osx
osx_image: xcode10
rust: stable
# FIXME: valgrind fails on OSX
# /~https://github.com/gnzlbg/jemallocator/issues/86
- name: "x86_64-apple-darwin (nightly)"
env: TARGET=x86_64-apple-darwin NO_JEMALLOC_TESTS=1 JEMALLOC_SYS_VERIFY_CONFIGURE=1
env: TARGET=x86_64-apple-darwin NO_JEMALLOC_TESTS=1 # JEMALLOC_SYS_VERIFY_CONFIGURE=1
os: osx
osx_image: xcode10
install: rustup component add llvm-tools-preview
Expand Down Expand Up @@ -132,7 +119,7 @@ matrix:
deploy:
provider: script
script: curl -LsSf https://git.io/fhJ8n | rustc - && (cd target/doc && ../../rust_out)
skip_cleanup: true
cleanup: true
on:
branch: master
- name: "rustfmt"
Expand All @@ -148,10 +135,10 @@ matrix:
# allow(clippy::all) fails in the syscrate, so we can't use --all here:
script: |
if rustup component add clippy-preview ; then
cargo clippy -p jemalloc-sys -- -D clippy::pedantic
cargo clippy -p jemallocator -- -D clippy::pedantic
cargo clippy -p jemallocator-global -- -D clippy::pedantic
cargo clippy -p jemalloc-ctl -- -D clippy::pedantic
cargo clippy -p jemalloc-sys -- -D clippy::all
cargo clippy -p jemallocator -- -D clippy::all
cargo clippy -p jemallocator-global -- -D clippy::all
cargo clippy -p jemalloc-ctl -- -D clippy::all
fi
- name: "Shellcheck"
install: true
Expand Down
1 change: 0 additions & 1 deletion benches/roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ mod pow2 {
1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072,
4194304
]);

}

mod even {
Expand Down
51 changes: 28 additions & 23 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ fi

if [ "${TARGET}" = "x86_64-unknown-linux-gnu" ] || [ "${TARGET}" = "x86_64-apple-darwin" ]
then
${CARGO_CMD} build -vv --target "${TARGET}" 2>&1 | tee build_no_std.txt
# Not using tee to avoid too much logs that exceeds travis' limit.
if ! ${CARGO_CMD} build -vv --target "${TARGET}" > build_no_std.txt 2>&1; then
tail -n 1024 build_no_std.txt
exit 1
fi

# Check that the no-std builds are not linked against a libc with default
# features or the `use_std` feature enabled:
Expand All @@ -71,42 +75,42 @@ then
done
fi

${CARGO_CMD} test -vv --target "${TARGET}"
${CARGO_CMD} test --target "${TARGET}"

if [ "${JEMALLOC_SYS_GIT_DEV_BRANCH}" = "1" ]; then
# FIXME: profiling tests broken on dev-branch
# /~https://github.com/jemalloc/jemalloc/issues/1477
:
else
${CARGO_CMD} test -vv --target "${TARGET}" --features profiling
${CARGO_CMD} test --target "${TARGET}" --features profiling
fi

${CARGO_CMD} test -vv --target "${TARGET}" --features debug
${CARGO_CMD} test -vv --target "${TARGET}" --features stats
${CARGO_CMD} test --target "${TARGET}" --features debug
${CARGO_CMD} test --target "${TARGET}" --features stats
if [ "${JEMALLOC_SYS_GIT_DEV_BRANCH}" = "1" ]; then
# FIXME: profiling tests broken on dev-branch
# /~https://github.com/jemalloc/jemalloc/issues/1477
:
else
${CARGO_CMD} test -vv --target "${TARGET}" --features 'debug profiling'
${CARGO_CMD} test --target "${TARGET}" --features 'debug profiling'
fi

${CARGO_CMD} test -vv --target "${TARGET}" \
${CARGO_CMD} test --target "${TARGET}" \
--features unprefixed_malloc_on_supported_platforms
${CARGO_CMD} test -vv --target "${TARGET}" --no-default-features
${CARGO_CMD} test -vv --target "${TARGET}" --no-default-features \
${CARGO_CMD} test --target "${TARGET}" --no-default-features
${CARGO_CMD} test --target "${TARGET}" --no-default-features \
--features background_threads_runtime_support

if [ "${NOBGT}" = "1" ]
then
echo "enabling background threads by default at run-time is not tested"
else
${CARGO_CMD} test -vv --target "${TARGET}" --features background_threads
${CARGO_CMD} test --target "${TARGET}" --features background_threads
fi

${CARGO_CMD} test -vv --target "${TARGET}" --release
${CARGO_CMD} test -vv --target "${TARGET}" --manifest-path jemalloc-sys/Cargo.toml
${CARGO_CMD} test -vv --target "${TARGET}" \
${CARGO_CMD} test --target "${TARGET}" --release
${CARGO_CMD} test --target "${TARGET}" --manifest-path jemalloc-sys/Cargo.toml
${CARGO_CMD} test --target "${TARGET}" \
--manifest-path jemalloc-sys/Cargo.toml \
--features unprefixed_malloc_on_supported_platforms

Expand All @@ -116,25 +120,26 @@ case "${TARGET}" in
"x86_64-unknown-linux-musl") ;;
*)

${CARGO_CMD} test -vv --target "${TARGET}" \
${CARGO_CMD} test --target "${TARGET}" \
--manifest-path jemalloc-ctl/Cargo.toml \
--no-default-features
# FIXME: cross fails to pass features to jemalloc-ctl
# ${CARGO_CMD} test -vv --target "${TARGET}" \
# ${CARGO_CMD} test --target "${TARGET}" \
# --manifest-path jemalloc-ctl \
# --no-default-features --features use_std
;;
esac

${CARGO_CMD} test -vv --target "${TARGET}" -p systest
${CARGO_CMD} test -vv --target "${TARGET}" \
${CARGO_CMD} test --target "${TARGET}" -p systest
${CARGO_CMD} test --target "${TARGET}" \
--manifest-path jemallocator-global/Cargo.toml
${CARGO_CMD} test -vv --target "${TARGET}" \
${CARGO_CMD} test --target "${TARGET}" \
--manifest-path jemallocator-global/Cargo.toml \
--features force_global_jemalloc

if [ "${TRAVIS_RUST_VERSION}" = "nightly" ]
then
# The Alloc trait is unstable:
${CARGO_CMD} test -vv --target "${TARGET}" --features alloc_trait
fi
# FIXME: Re-enable following test when allocator API is stable again.
# if [ "${TRAVIS_RUST_VERSION}" = "nightly" ]
# then
# # The Alloc trait is unstable:
# ${CARGO_CMD} test --target "${TARGET}" --features alloc_trait
# fi
3 changes: 0 additions & 3 deletions jemalloc-ctl/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ pub trait AsName {

impl AsName for [u8] {
fn name(&self) -> &Name {
use str;
assert!(
!self.is_empty(),
"cannot create Name from empty byte-string"
Expand Down Expand Up @@ -125,14 +124,12 @@ impl Name {

impl fmt::Debug for Name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use str;
write!(f, "{}", str::from_utf8(&self.0).unwrap())
}
}

impl fmt::Display for Name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use str;
write!(f, "{}", str::from_utf8(&self.0).unwrap())
}
}
Expand Down
38 changes: 11 additions & 27 deletions jemalloc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ extern crate fs_extra;

use std::env;
use std::fs;
use std::fs::File;
use std::path::{Path, PathBuf};
use std::process::Command;

Expand Down Expand Up @@ -54,16 +53,18 @@ macro_rules! warning {
}
}

// TODO: split main functions and remove following allow.
#[allow(clippy::cognitive_complexity)]
fn main() {
let target = env::var("TARGET").expect("TARGET was not set");
let host = env::var("HOST").expect("HOST was not set");
let num_jobs = env::var("NUM_JOBS").expect("NUM_JOBS was not set");
let out_dir = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR was not set"));
let src_dir = env::current_dir().expect("failed to get current directory");

info!("TARGET={}", target.clone());
info!("HOST={}", host.clone());
info!("NUM_JOBS={}", num_jobs.clone());
info!("TARGET={}", target);
info!("HOST={}", host);
info!("NUM_JOBS={}", num_jobs);
info!("OUT_DIR={:?}", out_dir);
let build_dir = out_dir.join("build");
info!("BUILD_DIR={:?}", build_dir);
Expand Down Expand Up @@ -185,28 +186,11 @@ fn main() {
run(&mut cmd);

for f in &config_files {
use std::io::Read;
fn read_content(file_path: &Path) -> String {
assert!(
file_path.exists(),
"config file path `{}` does not exist",
file_path.display()
);
let mut file = File::open(file_path).expect("file not found");
let mut content = String::new();
file.read_to_string(&mut content)
.expect("failed to read file");
content
}

if verify_configure {
let current = read_content(&jemalloc_src_dir.join(f));
let reference = read_content(&Path::new("configure").join(f));
assert_eq!(
current, reference,
"the current and reference configuration files \"{}\" differ",
f
);
let mut cmd = Command::new("diff");
run(cmd
.arg(&jemalloc_src_dir.join(f))
.arg(&Path::new("configure").join(f)));
}
}
} else {
Expand All @@ -231,7 +215,7 @@ fn main() {
.env("CC", compiler.path())
.env("CFLAGS", cflags.clone())
.env("LDFLAGS", cflags.clone())
.env("CPPFLAGS", cflags.clone())
.env("CPPFLAGS", cflags)
.arg("--disable-cxx");

if target.contains("ios") {
Expand Down Expand Up @@ -361,7 +345,7 @@ fn main() {
.arg("install_lib_static")
.arg("install_include")
.arg("-j")
.arg(num_jobs.clone()));
.arg(num_jobs));

println!("cargo:root={}", out_dir.display());

Expand Down
14 changes: 13 additions & 1 deletion jemalloc-sys/configure/configure
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
Expand Down Expand Up @@ -849,6 +850,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE}'
Expand Down Expand Up @@ -1101,6 +1103,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;

-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;

-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
Expand Down Expand Up @@ -1238,7 +1249,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir
libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
Expand Down Expand Up @@ -1391,6 +1402,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use libc::{c_int, c_void};
target_arch = "mipsel",
target_arch = "powerpc"
)))]
const alignof_max_align_t: usize = 8;
const ALIGNOF_MAX_ALIGN_T: usize = 8;
#[cfg(all(any(
target_arch = "x86",
target_arch = "x86_64",
Expand All @@ -60,7 +60,7 @@ const alignof_max_align_t: usize = 8;
target_arch = "s390x",
target_arch = "sparc64"
)))]
const alignof_max_align_t: usize = 16;
const ALIGNOF_MAX_ALIGN_T: usize = 16;

/// If `align` is less than `_Alignof(max_align_t)`, and if the requested
/// allocation `size` is larger than the alignment, we are guaranteed to get a
Expand All @@ -69,7 +69,7 @@ const alignof_max_align_t: usize = 16;
///
/// Otherwise, it returns the alignment flag to pass to the jemalloc APIs.
fn layout_to_flags(align: usize, size: usize) -> c_int {
if align <= alignof_max_align_t && align <= size {
if align <= ALIGNOF_MAX_ALIGN_T && align <= size {
0
} else {
ffi::MALLOCX_ALIGN(align)
Expand All @@ -83,7 +83,7 @@ macro_rules! assume {
if !($e) {
core::hint::unreachable_unchecked();
}
}
};
}

/// Handle to the jemalloc allocator
Expand Down Expand Up @@ -122,7 +122,7 @@ unsafe impl GlobalAlloc for Jemalloc {

#[inline]
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
assume!(!ptr.is_null())
assume!(!ptr.is_null());
assume!(layout.size() != 0);
let flags = layout_to_flags(layout.align(), layout.size());
ffi::sdallocx(ptr as *mut c_void, layout.size(), flags)
Expand Down
2 changes: 1 addition & 1 deletion systest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ jemalloc-sys = { path = "../jemalloc-sys" }
libc = "0.2"

[build-dependencies]
ctest = "^0.2.6"
ctest = "0.2.22"
Loading