Bug 89930 - - -Wl,--wrap= incompatible with -flto
Summary: - -Wl,--wrap= incompatible with -flto
Status: RESOLVED DUPLICATE of bug 88643
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 8.3.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-02 17:04 UTC by Дилян Палаузов
Modified: 2019-04-02 17:13 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Дилян Палаузов 2019-04-02 17:04:23 UTC
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.
Comment 1 Andrew Pinski 2019-04-02 17:13:14 UTC
Dup.

*** This bug has been marked as a duplicate of bug 88643 ***