Merge "rust: Pass lld flags from cc to rust linker args."

This commit is contained in:
Ivan Lozano 2020-09-09 22:03:23 +00:00 committed by Gerrit Code Review
commit 0eef27a556
7 changed files with 25 additions and 27 deletions

View file

@ -23,12 +23,7 @@ import (
var (
Arm64RustFlags = []string{}
Arm64ArchFeatureRustFlags = map[string][]string{}
Arm64LinkFlags = []string{
"-Wl,--icf=safe",
"-Wl,-z,max-page-size=4096",
"-Wl,-z,separate-code",
}
Arm64LinkFlags = []string{}
Arm64ArchVariantRustFlags = map[string][]string{
"armv8-a": []string{},
@ -59,7 +54,8 @@ func (t *toolchainArm64) RustTriple() string {
}
func (t *toolchainArm64) ToolchainLinkFlags() string {
return "${config.DeviceGlobalLinkFlags} ${config.Arm64ToolchainLinkFlags}"
// Prepend the lld flags from cc_config so we stay in sync with cc
return "${config.DeviceGlobalLinkFlags} ${cc_config.Arm64Lldflags} ${config.Arm64ToolchainLinkFlags}"
}
func (t *toolchainArm64) ToolchainRustFlags() string {

View file

@ -23,10 +23,7 @@ import (
var (
ArmRustFlags = []string{}
ArmArchFeatureRustFlags = map[string][]string{}
ArmLinkFlags = []string{
"-Wl,--icf=safe",
"-Wl,-m,armelf",
}
ArmLinkFlags = []string{}
ArmArchVariantRustFlags = map[string][]string{
"armv7-a": []string{},
@ -59,7 +56,8 @@ func (t *toolchainArm) RustTriple() string {
}
func (t *toolchainArm) ToolchainLinkFlags() string {
return "${config.DeviceGlobalLinkFlags} ${config.ArmToolchainLinkFlags}"
// Prepend the lld flags from cc_config so we stay in sync with cc
return "${config.DeviceGlobalLinkFlags} ${cc_config.ArmLldflags} ${config.ArmToolchainLinkFlags}"
}
func (t *toolchainArm) ToolchainRustFlags() string {

View file

@ -42,22 +42,18 @@ var (
deviceGlobalRustFlags = []string{}
deviceGlobalLinkFlags = []string{
// Prepend the lld flags from cc_config so we stay in sync with cc
"${cc_config.DeviceGlobalLldflags}",
// Override cc's --no-undefined-version to allow rustc's generated alloc functions
"-Wl,--undefined-version",
"-Bdynamic",
"-nostdlib",
"-Wl,-z,noexecstack",
"-Wl,-z,relro",
"-Wl,-z,now",
"-Wl,--build-id=md5",
"-Wl,--warn-shared-textrel",
"-Wl,--fatal-warnings",
"-Wl,--pack-dyn-relocs=android+relr",
"-Wl,--use-android-relr-tags",
"-Wl,--no-undefined",
"-Wl,--hash-style=gnu",
"-B${cc_config.ClangBin}",
"-fuse-ld=lld",
}
)

View file

@ -61,7 +61,8 @@ func (t *toolchainX86_64) RustTriple() string {
}
func (t *toolchainX86_64) ToolchainLinkFlags() string {
return "${config.DeviceGlobalLinkFlags} ${config.X86_64ToolchainLinkFlags}"
// Prepend the lld flags from cc_config so we stay in sync with cc
return "${config.DeviceGlobalLinkFlags} ${cc_config.X86_64Lldflags} ${config.X86_64ToolchainLinkFlags}"
}
func (t *toolchainX86_64) ToolchainRustFlags() string {

View file

@ -77,7 +77,8 @@ func (t *toolchainDarwin) ProcMacroSuffix() string {
}
func (t *toolchainDarwinX8664) ToolchainLinkFlags() string {
return "${config.DarwinToolchainLinkFlags} ${config.DarwinToolchainX8664LinkFlags}"
// Prepend the lld flags from cc_config so we stay in sync with cc
return "${cc_config.DarwinClangLldflags} ${config.DarwinToolchainLinkFlags} ${config.DarwinToolchainX8664LinkFlags}"
}
func (t *toolchainDarwinX8664) ToolchainRustFlags() string {

View file

@ -64,7 +64,8 @@ func (t *toolchainX86) RustTriple() string {
}
func (t *toolchainX86) ToolchainLinkFlags() string {
return "${config.DeviceGlobalLinkFlags} ${config.X86ToolchainLinkFlags}"
// Prepend the lld flags from cc_config so we stay in sync with cc
return "${config.DeviceGlobalLinkFlags} ${cc_config.X86ClangLldflags} ${config.X86ToolchainLinkFlags}"
}
func (t *toolchainX86) ToolchainRustFlags() string {

View file

@ -25,6 +25,7 @@ var (
LinuxRustLinkFlags = []string{
"-B${cc_config.ClangBin}",
"-fuse-ld=lld",
"-Wl,--undefined-version",
}
linuxX86Rustflags = []string{}
linuxX86Linkflags = []string{}
@ -77,7 +78,9 @@ func (t *toolchainLinuxX8664) RustTriple() string {
}
func (t *toolchainLinuxX8664) ToolchainLinkFlags() string {
return "${config.LinuxToolchainLinkFlags} ${config.LinuxToolchainX8664LinkFlags}"
// Prepend the lld flags from cc_config so we stay in sync with cc
return "${cc_config.LinuxClangLldflags} ${cc_config.LinuxX8664ClangLldflags} " +
"${config.LinuxToolchainLinkFlags} ${config.LinuxToolchainX8664LinkFlags}"
}
func (t *toolchainLinuxX8664) ToolchainRustFlags() string {
@ -105,7 +108,9 @@ func (t *toolchainLinuxX86) RustTriple() string {
}
func (t *toolchainLinuxX86) ToolchainLinkFlags() string {
return "${config.LinuxToolchainLinkFlags} ${config.LinuxToolchainX86LinkFlags}"
// Prepend the lld flags from cc_config so we stay in sync with cc
return "${cc_config.LinuxClangLldflags} ${cc_config.LinuxX86ClangLldflags} " +
"${config.LinuxToolchainLinkFlags} ${config.LinuxToolchainX86LinkFlags}"
}
func (t *toolchainLinuxX86) ToolchainRustFlags() string {