kphp
kphp copied to clipboard
Set libc versioning to GLIBC 2.2.5 ot add support to inject custom headers to generated runtime-headers.h
Problem:
- When we create commercial software we need build application for all Linux-based distros.
- We can't build static binary because because some GLIBC features does not support it. (related to authorization, change permissions)
Solution.
- Build KPHP runtime with using version headers https://github.com/wheybags/glibc_version_header
- Provide CMake flags for including custom headers to build sequence and runtime-header.h
Current my way:
Fix functions version for runtime library:
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,6 +30,10 @@ include(cmake/external-libraries.cmake)
# TODO: use FetchContent_Declare instead of include_directories
include_directories(.)
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include ${BASE_DIR}/../glibc_version_header/version_headers/x64/force_link_glibc_2.25.h")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ${BASE_DIR}/../glibc_version_header/version_headers/x64/force_link_glibc_2.25.h")
+
Fix functions version for application:
--- a/runtime/runtime.cmake
+++ b/runtime/runtime.cmake
@@ -167,6 +167,9 @@ file(WRITE ${AUTO_DIR}/runtime/runtime-headers.h "\
#ifndef MERGED_RUNTIME_HEADERS_H
#define MERGED_RUNTIME_HEADERS_H
+#include \"${BASE_DIR}/../glibc_version_header/version_headers/x64/force_link_glibc_2.5.h\"
${MERGED_RUNTIME_HEADERS}
#endif
Note: Option -include breaks compiler caching when KPHP build it.
Also: I rebuilt all dependencies with this headers: libh3, libsqlite, libcurl, libkphp-timelib
Note: patchelf utility does not work very good for fixing symbols version.