Bug 115628 - undefined reference to `__gcov_merge
Summary: undefined reference to `__gcov_merge
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: gcov-profile (show other bugs)
Version: 13.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-25 05:19 UTC by sadineniharish8446
Modified: 2024-06-25 22:24 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-06-25 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sadineniharish8446 2024-06-25 05:19:47 UTC

    
Comment 1 Andrew Pinski 2024-06-25 05:23:39 UTC
Did you accidently submit the bug report without any message?
Comment 2 sadineniharish8446 2024-06-25 05:34:52 UTC
I was trying build source code coverage for gcc but while running the tests we are getting the following errors:
crtstuff.c:(.text.exit+0x5): undefined reference to `__gcov_exit'^M
collect2: error: ld returned 1 exit status^M
compiler exited with status 1
FAIL: g++.old-deja/g++.other/static13.C  -std=c++98 (test for excess errors)
Excess errors:
/usr/bin/ld: /home/hsadineni/newgcc/gcc/build/gcc/testsuite/g++/../../crtbegin.o:(.data+0x80): undefined reference to `__gcov_merge_add'
crtstuff.c:(.text.startup+0xa): undefined reference to `__gcov_init'
crtstuff.c:(.text.exit+0x5): undefined reference to `__gcov_exit'

Reproducible steps:

../configure --enable-languages=c++ --enable-coverage --disable-bootstrap --disable-multilib  CFLAGS="-ftest-coverage -fprofile-arcs" CXXFLAGS="-ftest-coverage -fprofile-arcs " LDFLAGS="--coverage"

make -j $(nproc)

make check-gcc RUNTESTFLAGS="old-deja.exp=g++.other/rtti4.C"

can you please let me know, whether its potential bug or any  flags(or) configuration need to be added.

even, i have by tried passing -lgcov flag in LDFLAGS but still getting the same error.

thanks,
Harish
Comment 3 Andrew Pinski 2024-06-25 05:39:19 UTC
(In reply to sadineniharish8446 from comment #2)
> I was trying build source code coverage for gcc but while running the tests
> we are getting the following errors:
> crtstuff.c:(.text.exit+0x5): undefined reference to `__gcov_exit'^M
> collect2: error: ld returned 1 exit status^M
> compiler exited with status 1
> FAIL: g++.old-deja/g++.other/static13.C  -std=c++98 (test for excess errors)
> Excess errors:
> /usr/bin/ld:
> /home/hsadineni/newgcc/gcc/build/gcc/testsuite/g++/../../crtbegin.o:(.
> data+0x80): undefined reference to `__gcov_merge_add'
> crtstuff.c:(.text.startup+0xa): undefined reference to `__gcov_init'
> crtstuff.c:(.text.exit+0x5): undefined reference to `__gcov_exit'
> 
> Reproducible steps:
> 
> ../configure --enable-languages=c++ --enable-coverage --disable-bootstrap
> --disable-multilib  CFLAGS="-ftest-coverage -fprofile-arcs"
> CXXFLAGS="-ftest-coverage -fprofile-arcs " LDFLAGS="--coverage"

Yes this is not going to work as you are compiling libgcc with -ftest-coverage which will almost never work.

you just need either --enable-coverage or --enable-coverage=opt .
Comment 4 sadineniharish8446 2024-06-25 08:43:28 UTC
we ate trying to take coverage for libstdc++, I have tried following configuration options but getting same error.

../configure --enable-languages=c,c++ - --disable-bootstrap --disable-multilib  CFLAGS="-ftest-coverage -fprofile-arcs" CXXFLAGS="-ftest-coverage -fprofile-arcs " LDFLAGS="--coverage"


can you please let me know which configuration will work. 

thanks,
Harish
Comment 5 Andrew Pinski 2024-06-25 22:24:51 UTC
(In reply to sadineniharish8446 from comment #4)
> we ate trying to take coverage for libstdc++, I have tried following
> configuration options but getting same error.
> 
> ../configure --enable-languages=c,c++ - --disable-bootstrap
> --disable-multilib  CFLAGS="-ftest-coverage -fprofile-arcs"
> CXXFLAGS="-ftest-coverage -fprofile-arcs " LDFLAGS="--coverage"
> 
> 
> can you please let me know which configuration will work. 

Try setting CXXFLAGS_FOR_TARGET only. Note this is not the right place to get help like this. gcc@ (and libstdc++@) mailing list are better places to ask for help on getting this working and only filing a bug if there is no way in the end.