https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123068

            Bug ID: 123068
           Summary: [14 Regression] link failure at -O2 or above with
                    -fprofile-generate
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xintong.zhou1 at uwaterloo dot ca
  Target Milestone: ---

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/home/x27zhou/compilers/gcc-trunk-install/libexec/gcc/x86_64-pc-linux-gnu/16.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --enable-checking=yes --disable-bootstrap
--disable-multilib --disable-shared --enable-languages=c,c++
--prefix=/home/x27zhou/compilers/gcc-trunk-install
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.0.0 20251202 (experimental) (GCC)
$
$
$ gcc-trunk -O0 -fprofile-generate small.c
$ gcc-trunk -O2 -fprofile-generate small.c 
/usr/bin/ld: /tmp/ccfxZw7l.o:(.data+0x50): undefined reference to `__gcov3.e'
collect2: error: ld returned 1 exit status
$
$ cat small.c
int a, b, c;
char d;
void e() {
  for (; d;) {
    for (int f = 0; f <= 1; f++)
      for (int g = 0; g <= 1; g++)
        for (int h = 0; h <= 1; h++)
          if (h)
            return;
    a = c / b;
  }
}
int main() {}


Compiler Explorer: https://godbolt.org/z/hKT7bG6se

Reply via email to