From ef79168f9368c36344cad5505fad09dba2c61122 Mon Sep 17 00:00:00 2001 From: klzgrad Date: Sun, 21 Jan 2024 01:22:38 +0800 Subject: [PATCH] build: Work around MPIS floating point ABI passing in LTO --- src/build/config/compiler/BUILD.gn | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/build/config/compiler/BUILD.gn b/src/build/config/compiler/BUILD.gn index 1fdd8d1585..c3e7295152 100644 --- a/src/build/config/compiler/BUILD.gn +++ b/src/build/config/compiler/BUILD.gn @@ -1297,6 +1297,14 @@ config("compiler_cpu_abi") { } cflags += [ "-m${mips_float_abi}-float" ] + + # Fix float ABI information not being passed in LLVM bitcode for LTO + # and link failure with -mdouble-float being incorrectly used by default + # while the bitcode was compiled with -msoft-float. + # See https://discourse.llvm.org/t/myterious-soft-float-output-in-lto-cache/70753 + if (!is_debug && use_thin_lto && is_a_target_toolchain && mips_float_abi == "soft") { + ldflags += [ "-Wl,-mllvm,-mattr=+soft-float" ] + } } else if (current_cpu == "mips" && !is_nacl) { ldflags += [ "-Wl,--hash-style=sysv" ] if (custom_toolchain == "") { @@ -1342,6 +1350,14 @@ config("compiler_cpu_abi") { } cflags += [ "-m${mips_float_abi}-float" ] + + # Fix float ABI information not being passed in LLVM bitcode for LTO + # and link failure with -mdouble-float being incorrectly used by default + # while the bitcode was compiled with -msoft-float. + # See https://discourse.llvm.org/t/myterious-soft-float-output-in-lto-cache/70753 + if (!is_debug && use_thin_lto && is_a_target_toolchain && mips_float_abi == "soft") { + ldflags += [ "-Wl,-mllvm,-mattr=+soft-float" ] + } } else if (current_cpu == "mips64el") { cflags += [ "-D__SANE_USERSPACE_TYPES__" ] ldflags += [ "-Wl,--hash-style=sysv" ]