diff --git a/rust/config/arm64_device.go b/rust/config/arm64_device.go index 180fd8ba0..a0c496d4a 100644 --- a/rust/config/arm64_device.go +++ b/rust/config/arm64_device.go @@ -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 { diff --git a/rust/config/arm_device.go b/rust/config/arm_device.go index ac2580b81..ac4f1c659 100644 --- a/rust/config/arm_device.go +++ b/rust/config/arm_device.go @@ -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 { diff --git a/rust/config/global.go b/rust/config/global.go index 2f4d930e7..6a5251bb5 100644 --- a/rust/config/global.go +++ b/rust/config/global.go @@ -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", } ) diff --git a/rust/config/x86_64_device.go b/rust/config/x86_64_device.go index 9a6c00b19..5f6e85a08 100644 --- a/rust/config/x86_64_device.go +++ b/rust/config/x86_64_device.go @@ -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 { diff --git a/rust/config/x86_darwin_host.go b/rust/config/x86_darwin_host.go index a13a9a6a4..ddd93e889 100644 --- a/rust/config/x86_darwin_host.go +++ b/rust/config/x86_darwin_host.go @@ -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 { diff --git a/rust/config/x86_device.go b/rust/config/x86_device.go index ec19b3c30..daeeb1476 100644 --- a/rust/config/x86_device.go +++ b/rust/config/x86_device.go @@ -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 { diff --git a/rust/config/x86_linux_host.go b/rust/config/x86_linux_host.go index b55b2f2a2..e7f26ce5c 100644 --- a/rust/config/x86_linux_host.go +++ b/rust/config/x86_linux_host.go @@ -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 {