From 2a33d26d2110a9332e343a1deb32c9eee486c0db Mon Sep 17 00:00:00 2001
From: Anari Jalakas <anari.jalakas@gmail.com>
Date: Sat, 7 Oct 2023 16:43:09 +0300
Subject: [PATCH] libselinux: opt-out of lto usage

This fixes building with USE_LTO enabled:

<artificial>:(.text.exit+0x6e): relocation R_MIPS16_26 against `pthread_key_delete' cannot be used when making a shared object; recompile with -fPIC
./openwrt/staging_dir/toolchain-mips_24kc_gcc-12.3.0_musl/lib/gcc/mips-openwrt-linux-musl/12.3.0/../../../../mips-openwrt-linux-musl/bin/ld.bfd: non-dynamic relocations refer to dynamic symbol stpcpy
./openwrt/staging_dir/toolchain-mips_24kc_gcc-12.3.0_musl/lib/gcc/mips-openwrt-linux-musl/12.3.0/../../../../mips-openwrt-linux-musl/bin/ld.bfd: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status

Signed-off-by: Anari Jalakas <anari.jalakas@gmail.com>
---
 package/libs/libselinux/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/package/libs/libselinux/Makefile b/package/libs/libselinux/Makefile
index 816e09f30c..f90d4993c8 100644
--- a/package/libs/libselinux/Makefile
+++ b/package/libs/libselinux/Makefile
@@ -18,6 +18,8 @@ PKG_LICENSE_FILES:=LICENSE
 PKG_MAINTAINER:=Thomas Petazzoni <thomas.petazzoni@bootlin.com>
 PKG_CPE_ID:=cpe:/a:selinuxproject:libselinux
 
+PKG_BUILD_FLAGS:=no-lto
+
 HOST_BUILD_DEPENDS:=libsepol/host musl-fts/host pcre2/host
 
 include $(INCLUDE_DIR)/package.mk
-- 
2.30.2