|
| 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 |
0 commit comments