Skip to content

Commit b7ac84d

Browse files
committed
fix(native): pin clock_gettime to GLIBC_2.2.5 to keep glibc floor low
glibc 2.17 moved clock_gettime() into libc under a new GLIBC_2.17 version node. Building the release .so in a modern container (manylinux_2_28) binds clock_gettime@GLIBC_2.17, which raises the whole library's glibc floor to 2.17 and breaks loading on glibc 2.14-2.16 hosts. Add src/main/c/share/glibc_compat.h with a .symver directive forcing the reference back to clock_gettime@GLIBC_2.2.5 (x86-64 glibc only; no-op on aarch64/macOS/Windows), include it from net.c and os.c, list it in the CMake sources, and document the glibc floor in rebuild_native_libs.yml.
1 parent aee61cc commit b7ac84d

5 files changed

Lines changed: 63 additions & 0 deletions

File tree

.github/workflows/rebuild_native_libs.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ jobs:
7474
# inside the glibc-2.17 image (the old Node-20-glibc-217 override hack only
7575
# patched /__e/node20, not /__e/node24). 2.28 still runs stock Node 24 and
7676
# matches the linux-aarch64 job, which already ships glibc-2.28 binaries.
77+
#
78+
# NOTE: the build container's glibc (2.28) does NOT dictate the artifact's
79+
# runtime glibc floor. clock_gettime is pinned back to GLIBC_2.2.5 via
80+
# src/main/c/share/glibc_compat.h so the linux-x86-64 .so keeps loading on
81+
# glibc 2.14+ (its floor is memcpy@GLIBC_2.14), unchanged from before the
82+
# container move. If you add a symbol with a higher version node here, the
83+
# floor will rise -- check with: objdump -T libquestdb.so | grep GLIBC_.
7784
container:
7885
image: quay.io/pypa/manylinux_2_28_x86_64
7986
steps:

core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ set(
4848
src/main/c/share/files.h
4949
src/main/c/share/net.h
5050
src/main/c/share/os.h
51+
src/main/c/share/glibc_compat.h
5152
src/main/c/share/ooo.cpp
5253
src/main/c/share/cpprt_overrides.h
5354
src/main/c/share/cpprt_overrides.cpp
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*+*****************************************************************************
2+
* ___ _ ____ ____
3+
* / _ \ _ _ ___ ___| |_| _ \| __ )
4+
* | | | | | | |/ _ \/ __| __| | | | _ \
5+
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
6+
* \__\_\\__,_|\___||___/\__|____/|____/
7+
*
8+
* Copyright (c) 2014-2019 Appsicle
9+
* Copyright (c) 2019-2026 QuestDB
10+
*
11+
* Licensed under the Apache License, Version 2.0 (the "License");
12+
* you may not use this file except in compliance with the License.
13+
* You may obtain a copy of the License at
14+
*
15+
* http://www.apache.org/licenses/LICENSE-2.0
16+
*
17+
* Unless required by applicable law or agreed to in writing, software
18+
* distributed under the License is distributed on an "AS IS" BASIS,
19+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
* See the License for the specific language governing permissions and
21+
* limitations under the License.
22+
*
23+
******************************************************************************/
24+
25+
#ifndef QUESTDB_GLIBC_COMPAT_H
26+
#define QUESTDB_GLIBC_COMPAT_H
27+
28+
// Pin clock_gettime() to its original GLIBC_2.2.5 symbol version.
29+
//
30+
// glibc 2.17 moved clock_gettime() out of librt and into libc, exporting it
31+
// under a NEW version node: clock_gettime@GLIBC_2.17. The release binaries are
32+
// built in a modern toolchain container (CI uses manylinux_2_28 / glibc 2.28),
33+
// so without this pin the linker binds our calls to clock_gettime@GLIBC_2.17.
34+
// That single symbol raises the whole library's glibc floor to 2.17 and makes
35+
// it fail to LOAD on hosts running glibc 2.14-2.16 with:
36+
//
37+
// version `GLIBC_2.17' not found (required by libquestdb.so)
38+
//
39+
// The original clock_gettime@GLIBC_2.2.5 symbol is still exported as a compat
40+
// symbol by librt.so.1 on every glibc since (and by libc after the 2.34 librt
41+
// merge), so forcing the reference back to it keeps the library loadable down
42+
// to the previous floor (glibc 2.14, set by memcpy@GLIBC_2.14) with no change
43+
// in runtime behaviour. librt is already a NEEDED dependency (CMake links rt).
44+
//
45+
// Scope: x86-64 glibc only. aarch64 glibc started at 2.17 and has only ever
46+
// shipped clock_gettime in libc@GLIBC_2.17 -- there is no GLIBC_2.2.5 version
47+
// there, so emitting the pin on aarch64 would fail the link with an undefined
48+
// clock_gettime@GLIBC_2.2.5. The directive is a no-op on macOS/Windows.
49+
#if defined(__linux__) && defined(__GLIBC__) && defined(__x86_64__)
50+
__asm__(".symver clock_gettime,clock_gettime@GLIBC_2.2.5");
51+
#endif
52+
53+
#endif // QUESTDB_GLIBC_COMPAT_H

core/src/main/c/share/net.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <string.h>
3636
#include <poll.h>
3737
#include <time.h>
38+
#include "glibc_compat.h"
3839
#include "net.h"
3940
#include <netdb.h>
4041
#include "sysutil.h"

core/src/main/c/share/os.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <string.h>
3131
#include <sys/time.h>
3232
#include <time.h>
33+
#include "glibc_compat.h"
3334
#include "../share/os.h"
3435

3536
#ifdef __APPLE__

0 commit comments

Comments
 (0)