| Ivan Lozano | bf3b6e9 | 2020-12-07 16:16:55 -0500 | [diff] [blame] | 1 | // 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 |  | 
|  | 15 | package config | 
|  | 16 |  | 
|  | 17 | import ( | 
|  | 18 | "strings" | 
|  | 19 |  | 
|  | 20 | "android/soong/android" | 
|  | 21 | ) | 
|  | 22 |  | 
|  | 23 | var ( | 
| Colin Cross | 91c8f25 | 2023-02-07 09:51:45 -0800 | [diff] [blame] | 24 | LinuxBionicRustFlags = []string{ | 
|  | 25 | "-C panic=abort", | 
|  | 26 | } | 
| Ivan Lozano | bf3b6e9 | 2020-12-07 16:16:55 -0500 | [diff] [blame] | 27 | LinuxBionicRustLinkFlags = []string{ | 
|  | 28 | "-B${cc_config.ClangBin}", | 
|  | 29 | "-fuse-ld=lld", | 
|  | 30 | "-Wl,--undefined-version", | 
|  | 31 | "-nostdlib", | 
|  | 32 | } | 
|  | 33 | ) | 
|  | 34 |  | 
|  | 35 | func init() { | 
|  | 36 | registerToolchainFactory(android.LinuxBionic, android.X86_64, linuxBionicX8664ToolchainFactory) | 
|  | 37 |  | 
|  | 38 | pctx.StaticVariable("LinuxBionicToolchainRustFlags", strings.Join(LinuxBionicRustFlags, " ")) | 
|  | 39 | pctx.StaticVariable("LinuxBionicToolchainLinkFlags", strings.Join(LinuxBionicRustLinkFlags, " ")) | 
|  | 40 | } | 
|  | 41 |  | 
|  | 42 | type toolchainLinuxBionicX8664 struct { | 
|  | 43 | toolchain64Bit | 
|  | 44 | } | 
|  | 45 |  | 
|  | 46 | func (toolchainLinuxBionicX8664) Supported() bool { | 
|  | 47 | return true | 
|  | 48 | } | 
|  | 49 |  | 
|  | 50 | func (toolchainLinuxBionicX8664) Bionic() bool { | 
|  | 51 | return true | 
|  | 52 | } | 
|  | 53 |  | 
|  | 54 | func (t *toolchainLinuxBionicX8664) Name() string { | 
|  | 55 | return "x86_64" | 
|  | 56 | } | 
|  | 57 |  | 
|  | 58 | func (t *toolchainLinuxBionicX8664) RustTriple() string { | 
|  | 59 | return "x86_64-linux-android" | 
|  | 60 | } | 
|  | 61 |  | 
|  | 62 | func (t *toolchainLinuxBionicX8664) ToolchainLinkFlags() string { | 
|  | 63 | // Prepend the lld flags from cc_config so we stay in sync with cc | 
|  | 64 | return "${cc_config.LinuxBionicLldflags} ${config.LinuxBionicToolchainLinkFlags}" | 
|  | 65 | } | 
|  | 66 |  | 
|  | 67 | func (t *toolchainLinuxBionicX8664) ToolchainRustFlags() string { | 
|  | 68 | return "${config.LinuxBionicToolchainRustFlags}" | 
|  | 69 | } | 
|  | 70 |  | 
|  | 71 | func linuxBionicX8664ToolchainFactory(arch android.Arch) Toolchain { | 
|  | 72 | return toolchainLinuxBionicX8664Singleton | 
|  | 73 | } | 
|  | 74 |  | 
|  | 75 | var toolchainLinuxBionicX8664Singleton Toolchain = &toolchainLinuxBionicX8664{} |