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

Open
#790 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
cmake, cpp

Research direction

Start with CMakeLists.txt and runtime/runtime.cmake, then review how the generated runtime-headers.h and dependency builds receive compiler flags. Clarify the target GLIBC version and the supported mechanism for custom headers, including the compiler-cache concern and rebuilt dependencies. Done means the versioning and header injection work consistently without relying on patchelf.

Written by the indexing model from the issue text.

Description

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.

Dominant language
C++
Stars
1.5k
Forks
116
Avg merge
5d 17h
Merged PRs (30d)
11

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from VKCOM/kphp

All issues in VKCOM/kphp

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.