From 1eafd0a4d59ade35e9c1c79f4c27078f616ecb9c Mon Sep 17 00:00:00 2001 From: klzgrad Date: Sun, 4 Jun 2023 09:15:13 +0800 Subject: [PATCH] Fix broken overloading of libc close in static OpenWrt build --- src/base/files/scoped_file_linux.cc | 4 ++++ src/build/config/openwrt/BUILD.gn | 1 + 2 files changed, 5 insertions(+) diff --git a/src/base/files/scoped_file_linux.cc b/src/base/files/scoped_file_linux.cc index 61ee19f9c8..338550107f 100644 --- a/src/base/files/scoped_file_linux.cc +++ b/src/base/files/scoped_file_linux.cc @@ -81,6 +81,8 @@ bool IsFDOwned(int fd) { } // namespace base +#ifndef OPENWRT_BUILD_STATIC + using LibcCloseFuncPtr = int (*)(int); // Load the libc close symbol to forward to from the close wrapper. @@ -110,3 +112,5 @@ __attribute__((visibility("default"), noinline)) int close(int fd) { } } // extern "C" + +#endif // OPENWRT_BUILD_STATIC diff --git a/src/build/config/openwrt/BUILD.gn b/src/build/config/openwrt/BUILD.gn index 9e437641bc..0ffb6a0d36 100644 --- a/src/build/config/openwrt/BUILD.gn +++ b/src/build/config/openwrt/BUILD.gn @@ -34,6 +34,7 @@ config("compiler") { if (build_static) { # Musl static objects are not built with -fPIC, cannot use -static-pie. ldflags += [ "-static" ] + defines += [ "OPENWRT_BUILD_STATIC" ] } else if (current_cpu == "x86") { ldflags += [ "-Wl,--dynamic-linker=/lib/ld-musl-i386.so.1" ] } else if (current_cpu == "mipsel") {