GitLab will be upgraded on June 2nd 2020 at 2.00 pm (AEDT) to 3.00 pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to local Gitlab admin team.

build.rs 2.42 KB
Newer Older
1
// Copyright 2017 The Australian National University
2
//
3 4 5
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9 10 11 12 13 14
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

15
extern crate cc;
16

Kunshan Wang's avatar
Kunshan Wang committed
17
#[cfg(any(target_os = "macos", target_os = "linux"))]
18
#[cfg(target_arch = "x86_64")]
19
fn build_libgc() {
20
    cc::Build::new()
21 22
        .flag("-O3")
        .flag("-c")
23 24
        .file("src/heap/gc/clib_x64.c")
        .compile("libgc_clib_x64.a");
Kunshan Wang's avatar
Kunshan Wang committed
25
}
26 27 28

#[cfg(target_os = "linux")]
#[cfg(target_arch = "aarch64")]
29
fn build_libgc() {
30
    cc::Build::new()
31 32
        .flag("-O3")
        .flag("-c")
33 34
        .file("src/heap/gc/clib_aarch64.S")
        .compile("libgc_clib_aarch64.a");
35 36 37 38 39
}

// This is here to enable cross compiling from windows/x86_64 to linux/aarch64
#[cfg(target_os = "windows")]
#[cfg(target_arch = "x86_64")]
40
fn build_libgc() {
41
    cc::Build::new()
42 43
        .flag("-O3")
        .flag("-c")
44 45
        .file("src/heap/gc/clib_aarch64.S")
        .compile("libgc_clib_aarch64.a");
46
}
47

48 49
// Due to bugs, it is currently not possible to use conditional compilation \
// using features or target_..., so instead we use env variables
50
fn main() {
51
    use std::env;
52 53
    // For this variable: 1 means rumprun-sel4 and 0 means others
    let mut gc_target = 0;
54 55 56 57 58
    for (key, value) in env::vars() {
        if key == "ZEBU_TARGET" {
            if value == "x86_64-rumprun-netbsd" {
                gc_target = 1;
                break;
59
            } else {
60 61 62 63 64 65 66 67 68 69 70
                gc_target = 0;
                break;
            }
        }
    }
    // for sel4-rumprun, do (if)
    // otherwise, call the related target function
    if gc_target == 1 {
        use std::path::Path;
        let mut compiler_name = String::new();
        compiler_name.push_str("x86_64-rumprun-netbsd-gcc");
71
        cc::Build::new()
72 73
            .flag("-O3")
            .flag("-c")
74 75 76
            .compiler(Path::new(compiler_name.as_str()))
            .file("src/heap/gc/clib_x64_sel4_rumprun.c")
            .compile("libgc_clib_x64.a");
77 78 79
    } else {
        build_libgc();
    }
80
}