Summary: | Static linking fails on Haswell and Sandy Bridge when certain math functions are used | ||
---|---|---|---|
Product: | glibc | Reporter: | rlcamp.pdx |
Component: | math | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | normal | Flags: | fweimer:
security-
|
Priority: | P2 | ||
Version: | 2.24 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: |
Description
rlcamp.pdx
2016-10-20 11:06:15 UTC
The following code example and compile line triggers the error. Code is taken verbatim from the glibc wiki: #include <math.h> int N = 3200; double b[3200]; double a[3200]; int main (void) { int i; for (i = 0; i < N; i += 1) { b[i] = sin (a[i]); } return (0); } cc -static -Ofast -march=haswell -o test test.c -lm /tmp/ccIWFVL3.o: In function `main': test.c:(.text.startup+0x14a): undefined reference to `_ZGVdN4v_sin' collect2: error: ld returned 1 exit status Explicitly adding -lmvec to the end of the compile line fixes the issue. However, the wiki page (https://sourceware.org/glibc/wiki/libmvec) indicates that this should not be required, and since no explicitly stated desire to use vectorized math functions is necessary to trigger this error, the user may not realize the nature of the problem, and will have a hard time determining the fix. That wiki page explicitly says "For static builds with gcc needed to add both options with the following order: -lmvec -lm.", but there's the question of whether we should make libm.a into a linker script like libm.so (we don't have any precedent for making .a files into linker scripts, however). *** This bug has been marked as a duplicate of bug 20539 *** |