]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/allocator-dylib-is-system.rs
Auto merge of #42976 - ids1024:redoxfix, r=sfackler
[rust.git] / src / test / compile-fail / allocator-dylib-is-system.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-dylib.rs
13 // aux-build:allocator1.rs
14 // no-prefer-dynamic
15 // error-pattern: cannot link together two allocators
16
17 // Verify that the allocator for statically linked dynamic libraries is the
18 // system allocator. Do this by linking in jemalloc and making sure that we get
19 // an error.
20
21 // ignore-emscripten FIXME: What "other allocator" should we use for emcc?
22
23 #![feature(alloc_jemalloc)]
24
25 extern crate allocator_dylib;
26
27 // The main purpose of this test is to ensure that `alloc_jemalloc` **fails**
28 // here (specifically the jemalloc allocator), but currently jemalloc is
29 // disabled on quite a few platforms (bsds, emscripten, msvc, etc). To ensure
30 // that this just passes on those platforms we link in some other allocator to
31 // ensure we get the same error.
32 //
33 // So long as we CI linux/macOS we should be good.
34 #[cfg(any(target_os = "linux", target_os = "macos"))]
35 extern crate alloc_jemalloc;
36 #[cfg(not(any(target_os = "linux", target_os = "macos")))]
37 extern crate allocator1;
38
39 fn main() {
40     allocator_dylib::foo();
41 }