rizsotto / Bear

Bear is a tool that generates a compilation database for clang tooling.
GNU General Public License v3.0
4.64k stars 306 forks source link

bear::func_test failed 7 tests (3.1.4) #575

Open DarthGandalf opened 1 month ago

DarthGandalf commented 1 month ago

Describe the bug Tests fail

To Reproduce

ctest --verbose in subprojects/Build/BearTest

Expected behavior Tests should pass

Environment:

Additional context I haven't checked whether 3.1.3 also fails.

build.log LastTest.log

Before you send...

rizsotto commented 1 month ago

Hey @DarthGandalf ,

thanks for the report. What I have noticed from the logs, all the failed tests are involving to compile and link a program. (Other tests are usually stops at compiling, but these are involving linking too.) And that is failing with the message:

collect2: fatal error: cannot find 'ld'

So, I am wondering if the ld is not available in the environment where the test are running? Or anything special happens with the environment variables that make the compiler fail to execute the linker? (My experience that gcc is sensitive about the environment variables to find other tools it executes.)

DarthGandalf commented 1 month ago

yeah, /usr/bin/ld exists

rizsotto commented 1 month ago

Can you show me what the gcc -print-prog-name=ld prints? Or what the gcc -v prints out?

DarthGandalf commented 1 month ago

/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld

Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/13/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /mnt/portagetmp/portage/sys-devel/gcc-13.2.1_p20240210/work/gcc-13-20240210/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/13 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/13/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/13 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/13/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/13/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13 --disable-silent-rules --disable-dependency-tracking --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/13/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 13.2.1_p20240210 p14' --with-gcc-major-version-only --enable-libstdcxx-time --enable-lto --disable-libstdcxx-pch --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libssp --disable-libada --enable-cet --disable-systemtap --disable-valgrind-annotations --disable-vtable-verify --disable-libvtv --with-zstd --without-isl --enable-default-pie --enable-default-ssp --disable-fixincludes --with-build-config=bootstrap-cet Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.2.1 20240210 (Gentoo 13.2.1_p20240210 p14)

rizsotto commented 1 month ago

thanks!

Correct me if I am wrong, but is the path /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld resolves to /usr/x86_64-pc-linux-gnu/bin/ld? So, it looks like gcc is looking for the linker in /usr/x86_64-pc-linux-gnu/bin and not in /usr/bin. Is that correct reading of that?

DarthGandalf commented 1 month ago

I guess... And it has ld there.

$ ls -l /usr/x86_64-pc-linux-gnu/bin/ld lrwxrwxrwx - root 23 мая 23:08 /usr/x86_64-pc-linux-gnu/bin/ld -> /usr/x86_64-pc-linux-gnu/binutils-bin/2.42/ld

$ ls -l /usr/x86_64-pc-linux-gnu/binutils-bin/2.42/ld .rwxr-xr-x 979k root 21 мая 01:44 /usr/x86_64-pc-linux-gnu/binutils-bin/2.42/ld

$ /usr/x86_64-pc-linux-gnu/binutils-bin/2.42/ld --version GNU ld (Gentoo 2.42 p3) 2.42.0 Copyright (C) 2024 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version. This program has absolutely no warranty.

That is the same ld which /usr/bin/ld symlinks to, through several steps

lrwxrwxrwx - root 23 мая 23:08 /usr/bin/ld -> x86_64-pc-linux-gnu-ld lrwxrwxrwx - root 23 мая 23:08 /usr/bin/x86_64-pc-linux-gnu-ld -> /usr/x86_64-pc-linux-gnu/bin/ld

rizsotto commented 1 month ago

https://gcc.gnu.org/onlinedocs/gccint/Collect2.html

The GCC documentation about collect2 behavior to resolve the ld. I don't truly understand why it does not find the /usr/bin/ld one.

rizsotto commented 1 month ago

To note here...

$ cat /tmp/main.c 
#include <stdio.h>

int main() {
    return 0;
}
$ /usr/bin/gcc /tmp/main.c
$ env - /usr/bin/gcc /tmp/main.c
collect2: fatal error: cannot find 'ld'
compilation terminated.
$