添加_FILE_OFFSET_BITS=64与_TIME_BITS=64编译glibc失败,寻求Y2038问题解决方案
Hey Catalin, let's tackle your Y2038 and glibc compilation issues head-on:
First off, yes, glibc 2.34 fully supports Y2038 fixes for 32-bit ARM architectures. The Y2038 mitigation work for most 32-bit platforms (including ARM) was completed in glibc 2.32, and 2.34 builds on that to refine the implementation. Your approach of using the _FILE_OFFSET_BITS=64 and _TIME_BITS=64 compile flags is exactly the right way to enable the 64-bit time interfaces that resolve the Y2038 problem.
__sigtimedwait64 Duplicate Definition Error That assembler error you're seeing is a sign of conflicting symbol definitions during compilation, not an issue with glibc's Y2038 support itself. Here are the most likely fixes:
- Check Buildroot configuration conflicts: Open
make menuconfigand navigate toToolchain→C library→glibcoptions. Ensure you haven't enabled any legacy 32-bit time compatibility flags alongside_TIME_BITS=64and_FILE_OFFSET_BITS=64. Some Buildroot options might force fallback to old time APIs, causing duplicate symbols like__sigtimedwait64. - Avoid duplicate macro definitions: Make sure you're not setting
_TIME_BITS=64and_FILE_OFFSET_BITS=64in multiple places (e.g., both in Buildroot's globalCFLAGSand in glibc's local build flags). Redundant definitions can trigger the compiler to generate duplicate symbol entries. - Clean and rebuild from scratch: Buildroot's cached build files in
output/build/glibc-*might contain leftover objects from previous builds that conflict with the new 64-bit time flags. Runmake cleanor delete the specific glibc build directory, then restart the compilation process. - Inspect custom patches: If you've applied any custom patches to glibc in your Buildroot setup, double-check that they aren't accidentally redefining
__sigtimedwait64or interfering with the 64-bit time interface implementation.
- Verify your ARM CPU architecture: glibc's Y2038 support works best on ARMv5 and newer. If you're targeting an older ARMv4 device, you might need to check for additional compatibility patches, though this is rare with glibc 2.34.
- Validate compile flags in logs: Look into
output/build/glibc-*/config.logto confirm that_TIME_BITS=64and_FILE_OFFSET_BITS=64are actually being applied during the build—sometimes other configuration options can override these macros.
内容的提问来源于stack exchange,提问作者Catalin Demergian

