ncbi/ncbi-vdb

build issues with gcc 10.3.0 on Linux/x86-64

drhpc opened this issue · 3 comments

drhpc commented

Hi, I'm trying to build ncbi-vcb 2.11.2 on a CentOS 7 box with pkgsrc-2021Q2 for various updated dependencies. I was able to build 2.10.8 in the same environment, but the current release/tag just doesn't want to play because of various issues.

  1. Using std::malloc and friends without cstdlib header: I need to add `include ' to vdb3/platform/memory/PrimordialMemoryMgr.cpp (and added std:: prefixes, of which I am not sure if you need them there).
  2. Unpleasant warnings … even if the build succeeded, I would be worried about them (more below)
  3. Undefined references at the end of the build:
[ 98%] Linking CXX executable /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/.build/ncbi-vdb/linux/gcc/x86_64/rel/test-bin/test-cmn-log
/sw/compiler/gcc-10.3.0/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/test-cmn-nconv.dir/nconv-tst.cpp.o: in function `vdb3::NumberConversionTest_DecFltPoint64_from_int_to_Text_Test::TestBody()':
nconv-tst.cpp:(.text+0x123ed): undefined reference to `testing::internal::CmpHelperEQ(char const*, char const*, long long, long long)'
/sw/compiler/gcc-10.3.0/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: nconv-tst.cpp:(.text+0x12446): undefined reference to `testing::internal::CmpHelperEQ(char const*, char const*, long long, long long)'
/sw/compiler/gcc-10.3.0/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/test-cmn-nconv.dir/nconv-tst.cpp.o: in function `vdb3::NumberConversionTest_DecFltPoint64_from_int_to_String_Test::TestBody()':
nconv-tst.cpp:(.text+0x12acd): undefined reference to `testing::internal::CmpHelperEQ(char const*, char const*, long long, long long)'
/sw/compiler/gcc-10.3.0/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: nconv-tst.cpp:(.text+0x12b25): undefined reference to `testing::internal::CmpHelperEQ(char const*, char const*, long long, long long)'
/sw/compiler/gcc-10.3.0/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: nconv-tst.cpp:(.text+0x12bf9): undefined reference to `testing::internal::CmpHelperEQ(char const*, char const*, long long, long long)'
/sw/compiler/gcc-10.3.0/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/test-cmn-nconv.dir/nconv-tst.cpp.o:nconv-tst.cpp:(.text+0x12c51): more undefined references to `testing::internal::CmpHelperEQ(char const*, char const*, long long, long long)' follow
/sw/compiler/gcc-10.3.0/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: CMakeFiles/test-cmn-nconv.dir/nconv-tst.cpp.o: in function `testing::AssertionResult testing::internal::CmpHelperEQFailure<vdb3::CTextLiteral, vdb3::CText>(char const*, char const*, vdb3::CTextLiteral const&, vdb3::CText const&)':
nconv-tst.cpp:(.text._ZN7testing8internal18CmpHelperEQFailureIN4vdb312CTextLiteralENS2_5CTextEEENS_15AssertionResultEPKcS7_RKT_RKT0_[_ZN7testing8internal18CmpHelperEQFailureIN4vdb312CTextLiteralENS2_5CTextEEENS_15AssertionResultEPKcS7_RKT_RKT0_]+0x1bc): undefined reference to `testing::internal2::PrintBytesInObjectTo(unsigned char const*, unsigned long, std::ostream*)'
/sw/compiler/gcc-10.3.0/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: nconv-tst.cpp:(.text._ZN7testing8internal18CmpHelperEQFailureIN4vdb312CTextLiteralENS2_5CTextEEENS_15AssertionResultEPKcS7_RKT_RKT0_[_ZN7testing8internal18CmpHelperEQFailureIN4vdb312CTextLiteralENS2_5CTextEEENS_15AssertionResultEPKcS7_RKT_RKT0_]+0x446): undefined reference to `testing::internal2::PrintBytesInObjectTo(unsigned char const*, unsigned long, std::ostream*)'
collect2: error: ld returned 1 exit status
make[4]: *** [platform/cmn/test/CMakeFiles/test-cmn-nconv.dir/build.make:100: /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/.build/ncbi-vdb/linux/gcc/x86_64/rel/test-bin/test-cmn-nconv] Error 1
make[4]: Leaving directory '/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/.build/ncbi-vdb/linux/gcc/x86_64/rel/vdb3'
make[3]: *** [CMakeFiles/Makefile2:1325: platform/cmn/test/CMakeFiles/test-cmn-nconv.dir/all] Error 2
make[4]: Leaving directory '/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/.build/ncbi-vdb/linux/gcc/x86_64/rel/vdb3'
[ 98%] Built target test-cmn-log
make[3]: Leaving directory '/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/.build/ncbi-vdb/linux/gcc/x86_64/rel/vdb3'
make[2]: *** [Makefile:146: all] Error 2
make[2]: Leaving directory '/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/.build/ncbi-vdb/linux/gcc/x86_64/rel/vdb3'
make[1]: *** [Makefile:33: cmake] Error 2
make[1]: Leaving directory '/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/vdb3'
make: *** [Makefile:51: vdb3] Error 2

Does that ring a bell? Testing::internal not being in the mix? I'm pausing right now, but maybe there is an easy fix awaiting me when I come back …

The warnings:

/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/ext/magic/apprentice.c:2276:3: warning: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 2276 |   asprintf(&buf, "%.*s.mime%s", (int)(q - fn), fn, ext);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/ext/magic/apprentice.c:2283:2: warning: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 2283 |  asprintf(&buf, "%.*s%s", (int)(q - fn), fn, ext);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/ext/magic/compress.c: In function ‘uncompressbuf’:
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/ext/magic/compress.c:394:14: warning: ignoring return value of ‘dup’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  394 |       (void) dup(fd);
      |              ^~~~~~~
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/ext/magic/compress.c:397:14: warning: ignoring return value of ‘dup’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  397 |       (void) dup(fdin[0]);
      |              ^~~~~~~~~~~~
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/ext/magic/compress.c:403:10: warning: ignoring return value of ‘dup’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  403 |   (void) dup(fdout[1]);
      |          ^~~~~~~~~~~~~
In function ‘close_and_restore’,
    inlined from ‘file_or_fd’ at /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/ext/magic/magic.c:370:2,
    inlined from ‘magic_descriptor’ at /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/ext/magic/magic.c:269:9:
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/ext/magic/magic.c:249:10: warning: argument 1 null where non-null expected [-Wnonnull]
  249 |   (void) utimes(name, utsbuf); /* don't care if loses */
      |          ^~~~~~~~~~~~~~~~~~~~
In file included from /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/ext/magic/magic.c:47:
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/ext/magic/magic.c: In function ‘magic_descriptor’:
/usr/include/sys/time.h:139:12: note: in a call to function ‘utimes’ declared here
  139 | extern int utimes (const char *__file, const struct timeval __tvp[2])
      |            ^~~~~~
In function ‘file_or_fd’,
    inlined from ‘magic_descriptor’ at /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/ext/magic/magic.c:269:9:
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/ext/magic/magic.c:359:4: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  359 |    file_error(ms, errno, "cannot read `%s'", inname);
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Well, that's not your code, but when you vendor it, it becomes your problem … Then, we got:

/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyIns.c: In function ‘j__udyInsWalk’:
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyIns.c:1504:51: warning: iteration 8 invokes undefined behavior [-Waggressive-loop-optimizations]
 1504 |                 JU_BITMAPSETL(Pjlb, Pjp->jp_1Index[offset]);
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/Judy1.h:400:58: note: in definition of macro ‘J1_JLB_BITMAP’
  400 | #define J1_JLB_BITMAP(Pjlb,Subexp)  ((Pjlb)->j1lb_Bitmap[Subexp])
      |                                                          ^~~~~~
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyPrivate.h:822:26: note: in expansion of macro ‘JU_SUBEXPL’
  822 |     (JU_JLB_BITMAP(PJLB, JU_SUBEXPL(INDEX)) |= JU_BITPOSMASKL(INDEX))
      |                          ^~~~~~~~~~
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyIns.c:1504:17: note: in expansion of macro ‘JU_BITMAPSETL’
 1504 |                 JU_BITMAPSETL(Pjlb, Pjp->jp_1Index[offset]);
      |                 ^~~~~~~~~~~~~
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyIns.c:1503:13: note: within this loop
 1503 |             for (offset = 0; offset < 15; ++offset)
      |             ^~~
In file included from /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/Judy1.h:70,
                 from /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyIns.c:29:
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyPrivate.h:1096:31: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 1096 |         (PBYTE)[i_dx + 0 + 5] = (PBYTE)[i_dx + 0];              \
      |         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyIns.c:1235:13: note: in expansion of macro ‘JU_INSERTINPLACE5’
 1235 |             InsertInPlace(Pjll, exppop1, offset, Index);                \
      |             ^~~~~~~~~~~~~
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyIns.c:1592:13: note: in expansion of macro ‘JU_IMMSETINPLACE’
 1592 |             JU_IMMSETINPLACE(5, uint8_t *, cJ1_JPIMMED_5_02, j__udySearchLeaf5,
      |             ^~~~~~~~~~~~~~~~
In file included from /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/Judy1.h:71,
                 from /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyIns.c:29:
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyPrivateBranch.h:81:21: note: at offset 0 to object ‘j_pi_1Index’ with size 8 declared here
   81 |             uint8_t j_pi_1Index[sizeof(Word_t)];        // see above.
      |                     ^~~~~~~~~~~
In file included from /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/Judy1.h:70,
                 from /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyIns.c:29:
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyPrivate.h:1097:31: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 1097 |         (PBYTE)[i_dx + 1 + 5] = (PBYTE)[i_dx + 1];              \
      |         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyIns.c:1235:13: note: in expansion of macro ‘JU_INSERTINPLACE5’
 1235 |             InsertInPlace(Pjll, exppop1, offset, Index);                \
      |             ^~~~~~~~~~~~~
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyIns.c:1592:13: note: in expansion of macro ‘JU_IMMSETINPLACE’
 1592 |             JU_IMMSETINPLACE(5, uint8_t *, cJ1_JPIMMED_5_02, j__udySearchLeaf5,
      |             ^~~~~~~~~~~~~~~~
In file included from /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/Judy1.h:71,
                 from /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyIns.c:29:
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyPrivateBranch.h:81:21: note: at offset 0 to object ‘j_pi_1Index’ with size 8 declared here
   81 |             uint8_t j_pi_1Index[sizeof(Word_t)];        // see above.
      |                     ^~~~~~~~~~~
In file included from /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/Judy1.h:70,
                 from /scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyIns.c:29:
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyPrivate.h:1098:31: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 1098 |         (PBYTE)[i_dx + 2 + 5] = (PBYTE)[i_dx + 2];              \
      |         ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyIns.c:1235:13: note: in expansion of macro ‘JU_INSERTINPLACE5’
 1235 |             InsertInPlace(Pjll, exppop1, offset, Index);                \
      |             ^~~~~~~~~~~~~
/scratch/sw/wdb2dc2/ncbi-vdb/2.11.2/ncbi-vdb-2.11.2/libs/klib/judy/JudyIns.c:1592:13: note: in expansion of macro ‘JU_IMMSETINPLACE’
 1592 |             JU_IMMSETINPLACE(5, uint8_t *, cJ1_JPIMMED_5_02, j__udySearchLeaf5,
      |             ^~~~~~~~~~~~~~~~

There are more similar lines on this. This one looks pretty ugly. Is it a false positive on buffer overflow?

drhpc commented

[Edit: Sorry, wrong project and issue. There's too much build issues in the stack.]

Build with 'make NO_VDB3=1', this should remove the compilation errors. They come from a technology preview sub-project (vdb3) which was not tested with newer compilers and inadvertently became a part of this release. It is not included in any production libraries, so skipping it is safe.
The many ugly warnings from libs/klib/judy come from some ancient and very heavily macro-ed 3d party code. So far we have not seen any of these warnings manifest as problems in either testing or production, so we treat them as false positives. Naturally, the library is a prime candidate for replacement, but for now please ignore the warnings.

drhpc commented

Thanks, NO_VDB3=1 does the trick.