blob: b1a2c178e84a599a37459d4c8a244b5c3dace028 [file] [log] [blame]
Ivan Lozanobf3b6e92020-12-07 16:16:55 -05001// Copyright 2020 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package config
16
17import (
18 "strings"
19
20 "android/soong/android"
21)
22
23var (
24 LinuxBionicRustFlags = []string{}
25 LinuxBionicRustLinkFlags = []string{
26 "-B${cc_config.ClangBin}",
27 "-fuse-ld=lld",
28 "-Wl,--undefined-version",
29 "-nostdlib",
30 }
31)
32
33func init() {
34 registerToolchainFactory(android.LinuxBionic, android.X86_64, linuxBionicX8664ToolchainFactory)
35
36 pctx.StaticVariable("LinuxBionicToolchainRustFlags", strings.Join(LinuxBionicRustFlags, " "))
37 pctx.StaticVariable("LinuxBionicToolchainLinkFlags", strings.Join(LinuxBionicRustLinkFlags, " "))
38}
39
40type toolchainLinuxBionicX8664 struct {
41 toolchain64Bit
42}
43
44func (toolchainLinuxBionicX8664) Supported() bool {
45 return true
46}
47
48func (toolchainLinuxBionicX8664) Bionic() bool {
49 return true
50}
51
52func (t *toolchainLinuxBionicX8664) Name() string {
53 return "x86_64"
54}
55
56func (t *toolchainLinuxBionicX8664) RustTriple() string {
57 return "x86_64-linux-android"
58}
59
60func (t *toolchainLinuxBionicX8664) ToolchainLinkFlags() string {
61 // Prepend the lld flags from cc_config so we stay in sync with cc
62 return "${cc_config.LinuxBionicLldflags} ${config.LinuxBionicToolchainLinkFlags}"
63}
64
65func (t *toolchainLinuxBionicX8664) ToolchainRustFlags() string {
66 return "${config.LinuxBionicToolchainRustFlags}"
67}
68
69func linuxBionicX8664ToolchainFactory(arch android.Arch) Toolchain {
70 return toolchainLinuxBionicX8664Singleton
71}
72
73var toolchainLinuxBionicX8664Singleton Toolchain = &toolchainLinuxBionicX8664{}