From 0bf7f2f740e1ef9ae88d3a8e601a8eccb2d2adb8 Mon Sep 17 00:00:00 2001 From: klzgrad Date: Thu, 26 Aug 2021 01:23:53 +0800 Subject: [PATCH] Allow openwrt to build with static --- src/build/config/openwrt/BUILD.gn | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/build/config/openwrt/BUILD.gn b/src/build/config/openwrt/BUILD.gn index f8e4f91420..84e463307c 100644 --- a/src/build/config/openwrt/BUILD.gn +++ b/src/build/config/openwrt/BUILD.gn @@ -12,6 +12,10 @@ if (current_toolchain == default_toolchain) { assert(current_os == "openwrt") +declare_args() { + build_static = false +} + # This is included by reference in the //build/config/compiler config that # is applied to all targets. It is here to separate out the logic that is # Android-only. @@ -24,7 +28,10 @@ config("compiler") { "__UCLIBC__", ] - if (current_cpu == "x86") { + if (build_static) { + # Musl static objects are not built with -fPIC, cannot use -static-pie. + ldflags += [ "-static" ] + } else if (current_cpu == "x86") { ldflags += [ "-Wl,--dynamic-linker=/lib/ld-musl-i386.so.1" ] } else if (current_cpu == "mipsel") { ldflags += [ "-Wl,--dynamic-linker=/lib/ld-musl-mipsel-sf.so.1" ]