Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 370719 (PR49340) - sys-devel/gcc-4.5.2: gcda file not found for -fbranch-probabilities
Summary: sys-devel/gcc-4.5.2: gcda file not found for -fbranch-probabilities
Alias: PR49340
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
Depends on:
Reported: 2011-06-08 20:30 UTC by Martin von Gagern
Modified: 2014-11-01 06:53 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---

Call read_counts_file unconditionally (gentoo370719a.patch,457 bytes, patch)
2011-06-09 11:01 UTC, Martin von Gagern
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin von Gagern 2011-06-08 20:30:46 UTC
When using the -fbranch-probabilities switch to gcc, it reports a failure to find the required branch-probabilities file even if such a file exists all right.

$ cat test.c
#include <stdio.h>

int main(int argc, char** argv) {
  int i;
  for (i = 0; i < argc; ++i) {
    printf("argv[%d] = \"%s\"\n", i, argv[i]);
  return 0;

$ rm -f test.gcda
$ gcc -o prof -fprofile-arcs test.c
$ ./prof
argv[0] = "./prof"
$ test -f test.gcda && gcc -o final -fbranch-probabilities test.c
test.c: In function ‘main’:   test.c:9:1: note: file $PWD/test.gcda not found, execution counts assumed to be zero
$ strace -efile -f gcc -o final -fbranch-probabilities test.c \
  >/dev/null 2>&1 | grep gcda

No output from strace, so it appears that gcc doesn't even try to open that file.
Comment 1 Martin von Gagern 2011-06-09 09:55:25 UTC
Not a problem with gcc 3.3.6-r1, 3.4.6-r2, 4.1.2 or 4.2.4-r1. At least none of them prints an warning. So I guess this is a regression in recent gcc.

Identified the relevant command via strace and ran it through gdb:
$ gdb --args /usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.2/cc1 -quiet test.c \
  -D_FORTIFY_SOURCE=2 -quiet -dumpbase test.c -mtune=generic -march=x86-64 \
  -auxbase test -fbranch-probabilities -o test.s

It appears that coverage_init does not call read_counts_file because flag_profile_use is zero. So I assume that this problem was introduced by
Comment 2 Martin von Gagern 2011-06-09 11:01:05 UTC
Created attachment 276363 [details, diff]
Call read_counts_file unconditionally
Comment 3 Martin von Gagern 2011-06-09 11:49:26 UTC
Reproduced with USE=vanilla, filed report upstream:
Comment 4 SpanKY gentoo-dev 2014-11-01 06:52:43 UTC
appears to work w/gcc-4.9.1