Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-91812

Fix gcc v8.5 pre-processing failure on derickr/timelib

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • Fully Compatible
    • ALL
    • QE 2024-07-08, QE 2024-07-22

      The following issue appeared when trying to port SERVER-90147 to mongodb v6.0 and v5.0:

      [2024/06/21 11:31:06.445] /opt/mongodbtoolchain/v3/bin/gcc -o build/cached/third_party/timelib/dist/parse_date.dyn.o -c -std=c11 -Werror -ffp-contract=off -fasynchronous-unwind-tables -ggdb -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -fno-omit-frame-pointer -fno-strict-aliasing -O2 -march=sandybridge -mtune=generic -mprefer-vector-width=128 -Wno-unused-local-typedefs -Wno-unused-function -Wno-deprecated-declarations -Wno-unused-const-variable -Wno-unused-but-set-variable -Wno-missing-braces -fstack-protector-strong -Wa,--nocompress-debug-sections -fno-builtin-memcmp -DHAVE_GETTIMEOFDAY -DHAVE_STRING_H -DHAVE_DIRENT_H -DHAVE_SYS_TIME_H -DHAVE_UNISTD_H -D_GNU_SOURCE -fPIC -DPCRE_STATIC -DNDEBUG -D_XOPEN_SOURCE=700 -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 -DBOOST_THREAD_VERSION=5 -DBOOST_THREAD_USES_DATETIME -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS -DBOOST_ENABLE_ASSERT_DEBUG_HANDLER -DBOOST_LOG_NO_SHORTHAND_NAMES -DBOOST_LOG_USE_NATIVE_SYSLOG -DBOOST_LOG_WITHOUT_THREAD_ATTR -DABSL_FORCE_ALIGNED_ACCESS -DBOOST_LOG_DYN_LINK -Isrc/third_party/timelib/dist src/third_party/timelib/dist/parse_date.c
      ...
      [2024/06/21 11:31:06.681] parse_date.re: In function 'add_with_overflow':
      [2024/06/21 11:31:06.681] parse_date.re:716:44: error: missing binary operator before token "(" 

      The failure stems the following __has_builtin check for __builtin_saddll_overflow:

      static void add_with_overflow(Scanner *s, timelib_sll *e, timelib_sll amount, int multiplier)
      {
      #if defined(__has_builtin) && __has_builtin(__builtin_saddll_overflow) // <-- fails here
          if (__builtin_saddll_overflow(*e, amount * multiplier, e)) {
              add_error(s, TIMELIB_ERR_NUMBER_OUT_OF_RANGE, "Number out of range");
          }
      #else
          *e += (amount * multiplier);
      #endif
      } 

      source: [parse_date.re

      These mongodb versions still use the v3 version of the toolchain (gcc/g++ version v8.5), which do not seem to support the {}has_builtin {}utility. This would intuitively lead to the defined(_has_builtin) conditional to evaluate the false, but in reality it would error out due to *has_builtin(_builtin_saddll_overflow)* being invalid syntax.

       

            Assignee:
            catalin.sumanaru@mongodb.com Catalin Sumanaru
            Reporter:
            catalin.sumanaru@mongodb.com Catalin Sumanaru
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: