]> git.proxmox.com Git - rustc.git/blame - src/libprofiler_builtins/build.rs
New upstream version 1.32.0+dfsg1
[rustc.git] / src / libprofiler_builtins / build.rs
CommitLineData
041b39d2
XL
1// Copyright 2017 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//! Compiles the profiler part of the `compiler-rt` library.
12//!
13//! See the build.rs for libcompiler_builtins crate for details.
14
ea8adc8c 15extern crate cc;
041b39d2
XL
16
17use std::env;
18use std::path::Path;
19
20fn main() {
21 let target = env::var("TARGET").expect("TARGET was not set");
ea8adc8c 22 let cfg = &mut cc::Build::new();
041b39d2
XL
23
24 let mut profile_sources = vec!["GCDAProfiling.c",
25 "InstrProfiling.c",
26 "InstrProfilingBuffer.c",
27 "InstrProfilingFile.c",
28 "InstrProfilingMerge.c",
29 "InstrProfilingMergeFile.c",
0531ce1d 30 "InstrProfilingNameVar.c",
041b39d2
XL
31 "InstrProfilingPlatformDarwin.c",
32 "InstrProfilingPlatformLinux.c",
33 "InstrProfilingPlatformOther.c",
34 "InstrProfilingRuntime.cc",
35 "InstrProfilingUtil.c",
36 "InstrProfilingValue.c",
37 "InstrProfilingWriter.c"];
38
39 if target.contains("msvc") {
40 // Don't pull in extra libraries on MSVC
41 cfg.flag("/Zl");
42 profile_sources.push("WindowsMMap.c");
43 cfg.define("strdup", Some("_strdup"));
44 cfg.define("open", Some("_open"));
45 cfg.define("fdopen", Some("_fdopen"));
0531ce1d
XL
46 cfg.define("getpid", Some("_getpid"));
47 cfg.define("fileno", Some("_fileno"));
041b39d2
XL
48 } else {
49 // Turn off various features of gcc and such, mostly copying
50 // compiler-rt's build system already
51 cfg.flag("-fno-builtin");
52 cfg.flag("-fvisibility=hidden");
53 cfg.flag("-fomit-frame-pointer");
54 cfg.flag("-ffreestanding");
55 cfg.define("VISIBILITY_HIDDEN", None);
0531ce1d 56 cfg.define("COMPILER_RT_HAS_UNAME", Some("1"));
041b39d2
XL
57 }
58
59 for src in profile_sources {
60 cfg.file(Path::new("../libcompiler_builtins/compiler-rt/lib/profile").join(src));
61 }
62
ff7c6d11 63 cfg.compile("profiler-rt");
041b39d2 64}