]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs
Rollup merge of #40521 - TimNN:panic-free-shift, r=alexcrichton
[rust.git] / src / test / compile-fail / allocator-rust-dylib-is-jemalloc.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-musl no dylibs
12 // aux-build:allocator-dylib2.rs
13 // aux-build:allocator1.rs
14 // error-pattern: cannot link together two allocators
15
16 // Ensure that rust dynamic libraries use jemalloc as their allocator, verifying
17 // by linking in the system allocator here and ensuring that we get a complaint.
18
19 // ignore-emscripten FIXME: What "other allocator" is correct for emscripten?
20
21 #![feature(alloc_system)]
22
23 extern crate allocator_dylib2;
24
25 // The main purpose of this test is to ensure that `alloc_system` **fails**
26 // here (specifically the system allocator), but currently system is
27 // disabled on quite a few platforms (bsds, emscripten, msvc, etc). To ensure
28 // that this just passes on those platforms we link in some other allocator to
29 // ensure we get the same error.
30 //
31 // So long as we CI linux/macOS we should be good.
32 #[cfg(any(all(target_os = "linux", any(target_arch = "x86", target_arch = "x86_64")),
33           target_os = "macos"))]
34 extern crate alloc_system;
35 #[cfg(not(any(all(target_os = "linux", any(target_arch = "x86", target_arch = "x86_64")),
36               target_os = "macos")))]
37 extern crate allocator1;
38
39 fn main() {
40     allocator_dylib2::foo();
41 }