[Bug 995787] [NEW] ld discards -lrt despite clock_gettime being used, and wrongfully fails to link

2012-05-07 Thread Mike Hommey
Public bug reported:

$ cat  test.c EOF
#include time.h
int main() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, ts);
return 0;
}
EOF

$ gcc -o test -lrt test.c
test.c:(.text+0x15): undefined reference to `clock_gettime'

Adding -Wl,--no-as-needed before -lrt makes it link. Using gold instead
of BFD ld also makes it link. There is no reason why -Wl,--as-needed
-lrt (--as-needed being the ubuntu default) should drop -lrt when one of
its symbol is used, especially when dropping it makes the linkage
fail...

** Affects: binutils (Ubuntu)
 Importance: Undecided
 Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/995787

Title:
  ld discards -lrt despite clock_gettime being used, and wrongfully
  fails to link

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/binutils/+bug/995787/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 995787] Re: ld discards -lrt despite clock_gettime being used, and wrongfully fails to link

2012-05-07 Thread Mike Hommey
Forget it, it's an ordering problem. (And I can't find how to close a
bug)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/995787

Title:
  ld discards -lrt despite clock_gettime being used, and wrongfully
  fails to link

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/binutils/+bug/995787/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs