[Bug lto/89930] New: - -Wl,--wrap= incompatible with -flto

dilyan.palauzov at aegee dot org gcc-bugzilla@gcc.gnu.org
Tue Apr 2 17:04:00 GMT 2019


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

            Bug ID: 89930
           Summary: - -Wl,--wrap= incompatible with -flto
           Product: gcc
           Version: 8.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dilyan.palauzov at aegee dot org
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

This is t.c:
------------
#include <stdio.h>
#include <unistd.h>

ssize_t __wrap_read(int fd, void *buffer, size_t count) {
  printf("%s\n", (char*)buffer);
  return fd + count; 
}


int main() {
  int i = read(1, "abc", 5);
  printf("%i\n", i);
}

------------
I have gcc 8.3.1 20190311, ld.bfd 2.32.51.20190319, ld.gold 1.16
2.32.51.20190319 and clang 8.0.0.

This works
clang -flto -fuse-ld=gold -Wl,--wrap=read t.c
gcc         -fuse-ld=bfd  -Wl,--wrap=read t.c
gcc         -fuse-ld=gold -Wl,--wrap=read t.c
clang       -fuse-ld=bfd  -Wl,--wrap=read t.c
clang       -fuse-ld=gold -Wl,--wrap=read t.c

This fails
clang -flto -fuse-ld=bfd  -Wl,--wrap=read t.c
gcc   -flto -fuse-ld=gold -Wl,--wrap=read t.c
gcc   -flto -fuse-ld=bfd  -Wl,--wrap=read t.c

Since clang+gold works, gcc+gold should also work.

See also https://sourceware.org/bugzilla/show_bug.cgi?id=24406.


More information about the Gcc-bugs mailing list