This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Difference between gcc and g++ drivers


Glibc 2.22 will have implemented as linker script helping to
link as needed against vector math library without addition
of -lmvec (for not static builds). Another words -lm is enough to link

But g++ driver inserts -lm for linker command, gcc griver not.

It gives different behavior of g++ and gcc (I mean Glibc 2.22
installed system-wide):
g++ -fopenmp -ffast-math -O1 cos.c (compiled, -lm passed to linker by driver)
gcc -fopenmp -ffast-math -O1 cos.c (linker error because of no -lm passed)
/tmp/cclVmUxv.o: In function `main':
cos.c:(.text+0x3a): undefined reference to `_ZGVbN2v_cos'
cos.c:(.text+0x6b): undefined reference to `cos'
collect2: error: ld returned 1 exit status

#include <math.h>

int N = 3200;
double b[3200];
double a[3200];

int main (void)
  int i;

  #pragma omp simd
  for (i = 0; i < N; i += 1)
    b[i] = cos (a[i]);

  return (0);

For static builds with gcc needed to add both options with the
following order: -lmvec -lm.
For static builds with g++ needed to add only -lmvec.

Can anybody tell something about this difference in drivers?

May be needed fix for g++ driver to add also -lmvec if GLIBC version
>= 2.22 found on configure?

May be some other way needed to achieve similar drivers behavior?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]