From 7188b90e699a76f1737c6480920f82f1c8794946 Mon Sep 17 00:00:00 2001 From: "A. Cody Schuffelen" Date: Tue, 27 Jun 2023 19:10:27 -0700 Subject: [PATCH] Disable "-Wl,-plugin-opt,-import-instr-limit=5" on MacOS This option is unsupported on the MacOS ld used in Android, leading to compilation errors when LTO is enabled for binaries. In particular the error includes: ``` ld64.lld: error: unknown argument '-plugin-opt' ld64.lld: error: unknown argument '-import-instr-limit=5' ``` Test: m libc++ on a Mac OS machine Bug: 288983988 Change-Id: I1873e0a77777832f833f211beb42633d462f04d5 --- cc/lto.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cc/lto.go b/cc/lto.go index 878c21fdf..547ebff4e 100644 --- a/cc/lto.go +++ b/cc/lto.go @@ -109,7 +109,7 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags { // If the module does not have a profile, be conservative and limit cross TU inline // limit to 5 LLVM IR instructions, to balance binary size increase and performance. - if !ctx.isPgoCompile() && !ctx.isAfdoCompile() { + if !ctx.Darwin() && !ctx.isPgoCompile() && !ctx.isAfdoCompile() { flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-plugin-opt,-import-instr-limit=5") }