ld discards -lrt despite clock_gettime being used, and wrongfully fails to link
Bug #995787 reported by
Mike Hommey
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
binutils (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
$ cat > test.c <<EOF
#include <time.h>
int main() {
struct timespec ts;
clock_gettime(
return 0;
}
EOF
$ gcc -o test -lrt test.c
test.c:
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...
Changed in binutils (Ubuntu): | |
status: | New → Invalid |
To post a comment you must log in.
Forget it, it's an ordering problem. (And I can't find how to close a bug)