From 9abb5fb00fad4595d109bb88503acf72606cf5a8 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 28 Nov 2019 13:17:06 +0100 Subject: [PATCH 01/12] Remove badges --- Cargo.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6fc95a2c06..59888f1b90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,9 +21,6 @@ A Rust allocator backed by jemalloc edition = "2015" [badges] -appveyor = { repository = "gnzlbg/jemallocator" } -travis-ci = { repository = "gnzlbg/jemallocator" } -codecov = { repository = "gnzlbg/jemallocator" } is-it-maintained-issue-resolution = { repository = "gnzlbg/jemallocator" } is-it-maintained-open-issues = { repository = "gnzlbg/jemallocator" } maintenance = { status = "actively-developed" } From 181c3ad2427426a8db81fd61d49cf27675af9cec Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 28 Nov 2019 14:29:23 +0100 Subject: [PATCH 02/12] Reformat --- benches/roundtrip.rs | 1 - src/lib.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/benches/roundtrip.rs b/benches/roundtrip.rs index eddbb6bb68..ecdd6cfe65 100644 --- a/benches/roundtrip.rs +++ b/benches/roundtrip.rs @@ -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 { diff --git a/src/lib.rs b/src/lib.rs index 7aa9f9b9b3..3d3f167abd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,7 +83,7 @@ macro_rules! assume { if !($e) { core::hint::unreachable_unchecked(); } - } + }; } /// Handle to the jemalloc allocator From 5dd07174bcb90cc52b4e1c1b3ae2bb89f59c09d8 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 28 Nov 2019 15:58:59 +0100 Subject: [PATCH 03/12] Add must_use and const to jemalloc-sys APIs --- jemalloc-sys/src/lib.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/jemalloc-sys/src/lib.rs b/jemalloc-sys/src/lib.rs index ca0d303bb7..019a161b7b 100644 --- a/jemalloc-sys/src/lib.rs +++ b/jemalloc-sys/src/lib.rs @@ -59,7 +59,8 @@ type c_bool = c_int; /// /// It does not validate that `la` is within the valid range. #[inline] -pub fn MALLOCX_LG_ALIGN(la: usize) -> c_int { +#[must_use] +pub const fn MALLOCX_LG_ALIGN(la: usize) -> c_int { la as c_int } @@ -70,7 +71,8 @@ pub fn MALLOCX_LG_ALIGN(la: usize) -> c_int { /// /// This macro does not validate that a is a power of 2. #[inline] -pub fn MALLOCX_ALIGN(aling: usize) -> c_int { +#[must_use] +pub const fn MALLOCX_ALIGN(aling: usize) -> c_int { aling.trailing_zeros() as c_int } @@ -90,7 +92,8 @@ pub const MALLOCX_ZERO: c_int = 0x40; /// `tc` must have been acquired via the `tcache.create mallctl`. This function /// does not validate that `tc` specifies a valid identifier. #[inline] -pub fn MALLOCX_TCACHE(tc: usize) -> c_int { +#[must_use] +pub const fn MALLOCX_TCACHE(tc: usize) -> c_int { tc.wrapping_add(2).wrapping_shl(8) as c_int } @@ -103,9 +106,9 @@ pub fn MALLOCX_TCACHE(tc: usize) -> c_int { /// /// This option cannot be used in the same `flags` argument as /// `MALLOCX_TCACHE(tc)`. -// FIXME: This should just be a const. #[inline] -pub fn MALLOCX_TCACHE_NONE() -> c_int { +#[must_use] +pub const fn MALLOCX_TCACHE_NONE() -> c_int { MALLOCX_TCACHE(!0) } @@ -119,7 +122,8 @@ pub fn MALLOCX_TCACHE_NONE() -> c_int { /// This function does not validate that `a` specifies an arena index in the /// valid range. #[inline] -pub fn MALLOCX_ARENA(a: usize) -> c_int { +#[must_use] +pub const fn MALLOCX_ARENA(a: usize) -> c_int { (a as c_int).wrapping_add(1).wrapping_shl(20) } From 07387638a0c1d30168022184173b6260f1b20af9 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 28 Nov 2019 16:09:18 +0100 Subject: [PATCH 04/12] Fix typo in jemallocator docs --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 3d3f167abd..5513267e26 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -277,7 +277,7 @@ unsafe impl Alloc for Jemalloc { /// and the size reported by this function should not be depended on, /// since such behavior is entirely implementation-dependent. /// -/// # Unsafety +/// # Safety /// /// `ptr` must have been allocated by `Jemalloc` and must not have been freed yet. pub unsafe fn usable_size(ptr: *const T) -> usize { From 2ab3c2d3099b4488a2ed59c4837a59f41e101840 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 28 Nov 2019 16:15:01 +0100 Subject: [PATCH 05/12] Allow non-upper-case globals --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 5513267e26..e8855b8ac5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,6 +17,7 @@ #![cfg_attr(feature = "alloc_trait", feature(allocator_api))] #![deny(missing_docs, intra_doc_link_resolution_failure)] +#![allow(non_upper_case_globals)] #![no_std] extern crate jemalloc_sys; From b21631ac67b09f1deace679692b6611dfb8f7290 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 28 Nov 2019 16:40:11 +0100 Subject: [PATCH 06/12] Bump minimum required libc version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 59888f1b90..a02229dd24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ members = ["systest", "jemallocator-global", "jemalloc-ctl", "jemalloc-sys" ] [dependencies] jemalloc-sys = { path = "jemalloc-sys", version = "0.3.2", default-features = false } -libc = { version = "^0.2.8", default-features = false } +libc = { version = "^0.2.65", default-features = false } [dev-dependencies] paste = "0.1" From 770694df8986838c8ab572544b07d07e3c567194 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 28 Nov 2019 16:40:29 +0100 Subject: [PATCH 07/12] Clean-up max_align_t logic --- src/lib.rs | 49 +++++++++---------------------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e8855b8ac5..ee03c2d775 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,54 +23,23 @@ extern crate jemalloc_sys; extern crate libc; -#[cfg(feature = "alloc_trait")] -use core::alloc::{Alloc, AllocErr, CannotReallocInPlace, Excess}; use core::alloc::{GlobalAlloc, Layout}; #[cfg(feature = "alloc_trait")] -use core::ptr::NonNull; - +use core::{ + alloc::{Alloc, AllocErr, CannotReallocInPlace, Excess}, + ptr::NonNull, +}; use libc::{c_int, c_void}; -// This constant equals _Alignof(max_align_t) and is platform-specific. It -// contains the _maximum_ alignment that the memory allocations returned by the -// C standard library memory allocation APIs (e.g. `malloc`) are guaranteed to -// have. -// -// The memory allocation APIs are required to return memory that can fit any -// object whose fundamental aligment is <= _Alignof(max_align_t). -// -// In C, there are no ZSTs, and the size of all types is a multiple of their -// alignment (size >= align). So for allocations with size <= -// _Alignof(max_align_t), the malloc-APIs return memory whose alignment is -// either the requested size if its a power-of-two, or the next smaller -// power-of-two. -#[cfg(all(any( - target_arch = "arm", - target_arch = "mips", - target_arch = "mipsel", - target_arch = "powerpc" -)))] -const alignof_max_align_t: usize = 8; -#[cfg(all(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "aarch64", - target_arch = "powerpc64", - target_arch = "powerpc64le", - target_arch = "mips64", - target_arch = "s390x", - target_arch = "sparc64" -)))] -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 -/// suitably aligned allocation by default, without passing extra flags, and -/// this function returns `0`. +/// allocation `size` is larger than the alignment, and if jemalloc was +/// configured with a C standard compatible `--with-lg-quantum` value, we are +/// guaranteed to get a suitably aligned allocation with jemallocs default +/// options, without passing extra flags, and this function returns `0`. /// /// 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 <= core::mem::align_of::() && align <= size { 0 } else { ffi::MALLOCX_ALIGN(align) From a47c50a2ac3dc0b234e7cdeba6a01a7cb6b07e73 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 28 Nov 2019 17:16:17 +0100 Subject: [PATCH 08/12] Remove duplicated imports --- jemalloc-ctl/src/keys.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/jemalloc-ctl/src/keys.rs b/jemalloc-ctl/src/keys.rs index 12ca6f6392..fe2fdbdcaa 100644 --- a/jemalloc-ctl/src/keys.rs +++ b/jemalloc-ctl/src/keys.rs @@ -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" @@ -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()) } } From 562a530b83ba882292bda31ca24f663b8c5740a9 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 28 Nov 2019 17:20:35 +0100 Subject: [PATCH 09/12] Silence buggy clippy lint --- jemalloc-ctl/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jemalloc-ctl/src/lib.rs b/jemalloc-ctl/src/lib.rs index 63c2ad80ac..986c027704 100644 --- a/jemalloc-ctl/src/lib.rs +++ b/jemalloc-ctl/src/lib.rs @@ -72,7 +72,10 @@ //! ``` #![deny(missing_docs, intra_doc_link_resolution_failure)] #![cfg_attr(not(feature = "use_std"), no_std)] -#![cfg_attr(feature = "cargo-clippy", allow(clippy::module_name_repetitions))] +#![allow( + clippy::module_name_repetitions, + clippy::needless_doctest_main // bug: https://github.com/rust-lang/rust-clippy/issues/4858 +)] extern crate jemalloc_sys; extern crate libc; From 61f653fe6c2ff33a90b8c7b4812a50e9534ef0c8 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 28 Nov 2019 17:26:45 +0100 Subject: [PATCH 10/12] Add some must_use to jemalloc-ctl key APIs --- jemalloc-ctl/src/keys.rs | 2 ++ jemalloc-ctl/src/macros.rs | 1 + jemalloc-ctl/src/thread.rs | 1 + 3 files changed, 4 insertions(+) diff --git a/jemalloc-ctl/src/keys.rs b/jemalloc-ctl/src/keys.rs index fe2fdbdcaa..ac32048b87 100644 --- a/jemalloc-ctl/src/keys.rs +++ b/jemalloc-ctl/src/keys.rs @@ -88,6 +88,7 @@ impl Name { /// Returns `true` if `self` is a key in the _MALLCTL NAMESPCE_ referring to /// a null-terminated string. + #[must_use] pub fn value_type_str(&self) -> bool { // remove the null-terminator: let name = self.0.split_at(self.0.len() - 1).0; @@ -117,6 +118,7 @@ impl Name { } /// Returns the name as null-terminated byte-string. + #[must_use] pub fn as_bytes(&self) -> &'static [u8] { unsafe { &*(self as *const Self as *const [u8]) } } diff --git a/jemalloc-ctl/src/macros.rs b/jemalloc-ctl/src/macros.rs index 1e54e3491a..ff6bc09ace 100644 --- a/jemalloc-ctl/src/macros.rs +++ b/jemalloc-ctl/src/macros.rs @@ -27,6 +27,7 @@ macro_rules! types { } /// Key [`::keys::Name`]. + #[must_use] pub fn name() -> &'static ::keys::Name { Self::NAME } diff --git a/jemalloc-ctl/src/thread.rs b/jemalloc-ctl/src/thread.rs index cfa21fa1e7..c8fcbc877d 100644 --- a/jemalloc-ctl/src/thread.rs +++ b/jemalloc-ctl/src/thread.rs @@ -127,6 +127,7 @@ where { /// Returns the current value at the pointer. #[inline] + #[must_use] pub fn get(self) -> T { unsafe { *self.0 } } From bce67f3d2dbea665abe08bffe070bf242b6fa2e7 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 28 Nov 2019 17:51:40 +0100 Subject: [PATCH 11/12] Disable use_self lint for jemalloc-ctl error mod --- jemalloc-ctl/src/error.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jemalloc-ctl/src/error.rs b/jemalloc-ctl/src/error.rs index 4e4f3c8e79..dd720a475d 100644 --- a/jemalloc-ctl/src/error.rs +++ b/jemalloc-ctl/src/error.rs @@ -1,7 +1,8 @@ //! Error type -#![cfg_attr( - feature = "cargo-clippy", - allow(clippy::cast_sign_loss, clippy::cast_possible_wrap) +#![allow( + clippy::cast_sign_loss, + clippy::cast_possible_wrap, +clippy::use_self // https://github.com/rust-lang/rust-clippy/issues/2843 )] use libc::c_int; From c69975db99e788e847d82e11b4b5f003e3d4bc14 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 28 Nov 2019 14:11:43 +0100 Subject: [PATCH 12/12] Migrate CI to Github Actions --- .github/workflows/main.yml | 189 +++++++++++++++++- .travis.yml | 164 --------------- .../aarch64-unknown-linux-gnu/Dockerfile | 7 + ci/docker/x86_64-unknown-linux-gnu/Dockerfile | 6 + ci/dox.sh | 1 + ci/run-docker.sh | 46 +++++ ci/style.sh | 24 +++ 7 files changed, 264 insertions(+), 173 deletions(-) delete mode 100644 .travis.yml create mode 100644 ci/docker/aarch64-unknown-linux-gnu/Dockerfile create mode 100644 ci/docker/x86_64-unknown-linux-gnu/Dockerfile create mode 100755 ci/run-docker.sh create mode 100755 ci/style.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b2340b2446..34c816573f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,17 +1,188 @@ name: CI - -on: [push] +on: + push: + branches: + - master + pull_request: + branches: + - master jobs: - build: + style: + name: Check Style + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + with: + submodules: true + - name: Install Rust + run: rustup update nightly && rustup default nightly + - run: ci/style.sh + + docs: + name: Build Documentation + needs: [style] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + with: + submodules: true + - name: Install Rust + run: rustup update nightly && rustup default nightly + - run: ci/dox.sh + env: + CI: 1 + - name: Publish documentation + run: | + cd target/doc + git init + git add . + git -c user.name='ci' -c user.email='ci' commit -m init + git push -f -q https://git:${{ secrets.github_token }}@github.com/${{ github.repository }} HEAD:gh-pages + if: github.event_name == 'push' && github.event.ref == 'refs/heads/master' + benches: + name: Build benchmarks + needs: [style] runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + with: + submodules: true + - name: Install Rust + run: rustup update nightly && rustup default nightly + - name: Benchmarks + run: | + cargo test --bench roundtrip + cargo test --features=alloc_trait --bench roundtrip + test: + needs: [style] + name: Test + runs-on: ${{ matrix.os }} + strategy: + matrix: + target: + - aarch64-unknown-linux-gnu + - x86_64-apple-darwin + - x86_64-unknown-linux-gnu + include: + # - target: aarch64-linux-android + # os: ubuntu-latest + # rust: nightly + # no_jemalloc_tests: 1 + - target: aarch64-unknown-linux-gnu + os: ubuntu-latest + rust: nightly + no_jemalloc_tests: 1 + # - target: arm-linux-androideabi + # os: ubuntu-latest + # rust: nightly + # no_jemalloc_tests: 1 + # - target: arm-unknown-linux-gnueabi + # os: ubuntu-latest + # rust: nightly + # no_jemalloc_tests: 1 + # - target: armv7-unknown-linux-gnueabihf + # os: ubuntu-latest + # rust: nightly + # no_jemalloc_tests: 1 + # - target: i586-unknown-linux-gnu + # os: ubuntu-latest + # rust: nightly + # - target: i686-pc-windows-gnu + # os: windows-latest + # rust: nightly + # - target: i686-pc-windows-msvc + # os: windows-latest + # rust: nightly + # - target: i686-unknown-linux-gnu + # os: ubuntu-latest + # rust: nightly + # - target: mips-unknown-linux-gnu + # os: ubuntu-latest + # rust: nightly + # no_jemalloc_tests: 1 + # - target: mips64-unknown-linux-gnuabi64 + # os: ubuntu-latest + # rust: nightly + # no_jemalloc_tests: 1 + # - target: mips64el-unknown-linux-gnuabi64 + # os: ubuntu-latest + # rust: nightly + # no_jemalloc_tests: 1 + # - target: mipsel-unknown-linux-gnu + # os: ubuntu-latest + # rust: nightly + # no_jemalloc_tests: 1 + # - target: s390x-unknown-linux-gnu + # os: ubuntu-latest + # rust: nightly + # no_jemalloc_tests: 1 + - target: x86_64-apple-darwin + os: macos-latest + rust: nightly + # - target: x86_64-apple-darwin + # os: macos-latest + # rust: beta + # - target: x86_64-apple-darwin + # os: macos-latest + # rust: stable + # - target: x86_64-linux-android + # os: ubuntu-latest + # rust: nightly + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + rust: nightly + # - target: x86_64-unknown-linux-gnu + # os: ubuntu-latest + # rust: nightly + # valgrind: 1 + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + rust: nightly + jemalloc-dev: 1 + valgrind: 1 + # - target: x86_64-unknown-linux-gnu + # os: ubuntu-latest + # rust: beta + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + rust: stable + steps: - - uses: actions/checkout@v1 - - name: Run a one-line script - run: echo Hello, world! - - name: Run a multi-line script + - uses: actions/checkout@master + with: + submodules: true + - name: Install Rust (rustup) + run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} + if: matrix.os != 'macos-latest' + - name: Install Rust (macos) run: | - echo Add other actions to build, - echo test, and deploy your project. + curl https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly + echo "##[add-path]$HOME/.cargo/bin" + if: matrix.os == 'macos-latest' + - run: rustup target add ${{ matrix.target }} + - run: cargo generate-lockfile + + # Configure some env vars based on matrix configuration + - run: echo "##[set-env name=NO_JEMALLOC_TESTS]1" + if: matrix.no_jemalloc_tests != '' + - run: echo "##[set-env name=JEMALLOC_SYS_GIT_DEV_BRANCH]1" + if: matrix.jemalloc-dev != '' + - run: echo "##[set-env name=VALGRIND]1" + if: matrix.valgrind != '' + + # Windows & OSX go straight to `run.sh` ... + - run: ./ci/run.sh + shell: bash + if: matrix.os != 'ubuntu-latest' + env: + TARGET: ${{ matrix.target }} + + # ... while Linux goes to `run-docker.sh` + - run: ./ci/run-docker.sh ${{ matrix.target }} + shell: bash + if: "matrix.os == 'ubuntu-latest'" + env: + TARGET: ${{ matrix.target }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1e2542e38e..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,164 +0,0 @@ -language: rust -rust: nightly -services: docker - -matrix: - include: - # Linux - - name: "aarch64-unknown-linux-gnu" - env: TARGET=aarch64-unknown-linux-gnu NO_JEMALLOC_TESTS=1 - - name: "arm-unknown-linux-gnueabi" - env: TARGET=arm-unknown-linux-gnueabi NO_JEMALLOC_TESTS=1 - - name: "armv7-unknown-linux-gnueabihf" - env: TARGET=armv7-unknown-linux-gnueabihf NO_JEMALLOC_TESTS=1 - - name: "i586-unknown-linux-gnu" - env: TARGET=i586-unknown-linux-gnu - addons: &gcc_multilib - apt: - packages: - - gcc-multilib - - name: "i686-unknown-linux-gnu (nightly)" - env: TARGET=i686-unknown-linux-gnu - addons: *gcc_multilib - - name: "i686-unknown-linux-gnu (beta)" - env: TARGET=i686-unknown-linux-gnu - addons: *gcc_multilib - rust: beta - - name: "i686-unknown-linux-gnu (stable)" - env: TARGET=i686-unknown-linux-gnu - addons: *gcc_multilib - rust: stable - # FIXME: blocked onhttps://github.com/jemalloc/jemalloc/issues/1464 - # - name: "i686-unknown-linux-musl" - # env: TARGET=i686-unknown-linux-musl NOBGT=1 NO_JEMALLOC_TESTS=1 - - name: "mips-unknown-linux-gnu" - env: TARGET=mips-unknown-linux-gnu NO_JEMALLOC_TESTS=1 - - name: "mips64-unknown-linux-gnuabi64" - env: TARGET=mips64-unknown-linux-gnuabi64 NO_JEMALLOC_TESTS=1 - - name: "mips64el-unknown-linux-gnuabi64" - env: TARGET=mips64el-unknown-linux-gnuabi64 NO_JEMALLOC_TESTS=1 - - name: "mipsel-unknown-linux-gnu" - env: TARGET=mipsel-unknown-linux-gnu NO_JEMALLOC_TESTS=1 - - name: "powerpc-unknown-linux-gnu" - env: TARGET=powerpc-unknown-linux-gnu NO_JEMALLOC_TESTS=1 - - name: "powerpc64-unknown-linux-gnu" - env: TARGET=powerpc64-unknown-linux-gnu NO_JEMALLOC_TESTS=1 - - name: "powerpc64le-unknown-linux-gnu" - env: TARGET=powerpc64le-unknown-linux-gnu NO_JEMALLOC_TESTS=1 - - name: "x86_64-unknown-linux-gnu (nightly)" - env: TARGET=x86_64-unknown-linux-gnu VALGRIND=1 JEMALLOC_SYS_VERIFY_CONFIGURE=1 - install: rustup component add llvm-tools-preview - addons: &valgrind - apt: - packages: - - valgrind - - autoconf - - name: "x86_64-unknown-linux-gnu (nightly - jemalloc's dev branch)" - env: TARGET=x86_64-unknown-linux-gnu VALGRIND=1 JEMALLOC_SYS_GIT_DEV_BRANCH=1 - install: rustup component add llvm-tools-preview - addons: *valgrind - - name: "x86_64-unknown-linux-gnu (beta)" - env: TARGET=x86_64-unknown-linux-gnu VALGRIND=1 - rust: beta - install: rustup component add llvm-tools-preview - addons: *valgrind - - name: "x86_64-unknown-linux-gnu (stable)" - env: TARGET=x86_64-unknown-linux-gnu VALGRIND=1 - rust: stable - install: rustup component add llvm-tools-preview - addons: *valgrind - - name: "Benchmarks using x86_64-unknown-linux-gnu (nightly)" - env: TARGET=x86_64-unknown-linux-gnu - install: true - script: - - cargo test --bench roundtrip - - 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 - - # Android - - name: "aarch64-linux-android" - env: TARGET=aarch64-linux-android NO_JEMALLOC_TESTS=1 - - name: "x86_64-linux-android" - env: TARGET=x86_64-linux-android - - # OSX - # 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 - os: osx - osx_image: xcode10 - install: rustup component add llvm-tools-preview - - name: "x86_64-apple-darwin (nightly - jemalloc's dev branch)" - env: TARGET=x86_64-apple-darwin NO_JEMALLOC_TESTS=1 JEMALLOC_SYS_GIT_DEV_BRANCH=1 - os: osx - osx_image: xcode10 - install: rustup component add llvm-tools-preview - - name: "x86_64-apple-darwin (beta)" - env: TARGET=x86_64-apple-darwin NO_JEMALLOC_TESTS=1 - os: osx - osx_image: xcode10 - rust: beta - install: rustup component add llvm-tools-preview - - name: "x86_64-apple-darwin (stable)" - env: TARGET=x86_64-apple-darwin NO_JEMALLOC_TESTS=1 - os: osx - osx_image: xcode10 - rust: stable - install: rustup component add llvm-tools-preview - - # TOOLING - - name: "Documentation" - install: true - script: RUSTDOCFLAGS="--cfg jemallocator_docs" cargo doc - deploy: - provider: script - script: curl -LsSf https://git.io/fhJ8n | rustc - && (cd target/doc && ../../rust_out) - skip_cleanup: true - on: - branch: master - - name: "rustfmt" - install: true - rust: nightly - script: | - if rustup component add rustfmt-preview ; then - cargo fmt --all -- --check - fi - - name: "clippy" - install: true - rust: nightly - # 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 - fi - - name: "Shellcheck" - install: true - script: shellcheck ci/*.sh - -install: rustup target add ${TARGET} -script: sh ci/run.sh -notifications: - email: - on_success: never diff --git a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile new file mode 100644 index 0000000000..716a445d34 --- /dev/null +++ b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile @@ -0,0 +1,7 @@ +FROM ubuntu:19.04 +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc libc6-dev ca-certificates \ + gcc-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user +ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu" \ + PATH=$PATH:/rust/bin diff --git a/ci/docker/x86_64-unknown-linux-gnu/Dockerfile b/ci/docker/x86_64-unknown-linux-gnu/Dockerfile new file mode 100644 index 0000000000..0262cef108 --- /dev/null +++ b/ci/docker/x86_64-unknown-linux-gnu/Dockerfile @@ -0,0 +1,6 @@ +FROM ubuntu:19.04 +RUN apt-get update +RUN apt-get install -y --no-install-recommends \ + gcc libc6-dev ca-certificates valgrind + +ENV PATH=$PATH:/rust/bin diff --git a/ci/dox.sh b/ci/dox.sh index 88fbd692ec..8fb985eded 100755 --- a/ci/dox.sh +++ b/ci/dox.sh @@ -6,3 +6,4 @@ export RUSTDOCFLAGS="--cfg jemallocator_docs" cargo doc --features alloc_trait cargo doc -p jemalloc-sys cargo doc -p jemalloc-ctl +cargo doc -p jemallocator-global diff --git a/ci/run-docker.sh b/ci/run-docker.sh new file mode 100755 index 0000000000..3c0736a265 --- /dev/null +++ b/ci/run-docker.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env sh + +# Small script to run tests for a target (or all targets) inside all the +# respective docker images. + +set -ex + +echo "${HOME}" +pwd + +run() { + echo "Building docker container for target ${1}" + + # use -f so we can use ci/ as build context + docker build -t libc -f "ci/docker/${1}/Dockerfile" ci/ + mkdir -p target + if [ -w /dev/kvm ]; then + kvm="--volume /dev/kvm:/dev/kvm" + else + kvm="" + fi + + docker run \ + --rm \ + --user "$(id -u)":"$(id -g)" \ + --env LIBC_CI \ + --env CARGO_HOME=/cargo \ + --env CARGO_TARGET_DIR=/checkout/target \ + --volume "$(dirname "$(dirname "$(command -v cargo)")")":/cargo \ + --volume "$(rustc --print sysroot)":/rust:ro \ + --volume "$(pwd)":/checkout:ro \ + --volume "$(pwd)"/target:/checkout/target \ + $kvm \ + --init \ + --workdir /checkout \ + libc \ + sh -c "HOME=/tmp PATH=\$PATH:/rust/bin exec ci/run.sh ${1}" +} + +if [ -z "${1}" ]; then + for d in ci/docker/*; do + run "${d}" + done +else + run "${1}" +fi diff --git a/ci/style.sh b/ci/style.sh new file mode 100755 index 0000000000..41e34e7307 --- /dev/null +++ b/ci/style.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env sh + +set -ex + +if rustup component add rustfmt-preview ; then + command -v rustfmt + rustfmt -V + cargo fmt --all -- --check +fi + +if rustup component add clippy-preview ; then + cargo clippy -V + 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 +fi + +if shellcheck --version ; then + shellcheck ci/*.sh +else + echo "shellcheck not found" + exit 1 +fi