kphp icon indicating copy to clipboard operation
kphp copied to clipboard

Set libc versioning to GLIBC 2.2.5 ot add support to inject custom headers to generated runtime-headers.h

Open comm644 opened this issue 1 year ago • 0 comments

Problem:

  1. When we create commercial software we need build application for all Linux-based distros.
  2. We can't build static binary because because some GLIBC features does not support it. (related to authorization, change permissions)

Solution.

  1. Build KPHP runtime with using version headers https://github.com/wheybags/glibc_version_header
  2. 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.

comm644 avatar Mar 19 '23 11:03 comm644