2

Recently, glibc (namely with glibc 2.31, included in Ubuntu 20.04) seems to have removed families of functions like __exp_finite().

These functions were used when compiling with gcc's option -ffinite-math-only (or -ffast-math, which enables the said option).

My problem is that I have compiled closed sources static libraries provided by third parties which have been presumably compiled with this flag and those libraries generate linking errors to missing math functions like __exp_finite().

My question is what is my better solution?

  1. Submit the issue to the third parties, ask them to remove the offending flag from their command line and wait (months...) ?
  2. Submit the issue to the glibc developpers, explaining that they broke compatibility with this build option ?
  3. Define myself the missing functions ?
  4. ?

I would prefer to omit solutions which involes compiling in a different environment than the native one provided by Ubuntu (and later probably other distribution as they upgrade glibc).

Hopefully I have understood the problem correctly and any help is appreciated.

Étienne
  • 407
  • 4
  • 15
  • You could try to write some short wrapper-functions, that delegate to `exp` and so on. Then you would have to inject it at runtime. Or you could take the source code from glibc, add the functions and load it first, if you use this library – JCWasmx86 Aug 05 '20 at 08:42

1 Answers1

3

I added the following c++ file to our main project, defining the missing functions:

#include <math.h>

extern "C" {
    double __exp_finite(double x) { return exp(x); }
    double __log_finite(double x) { return log(x); }
    double __pow_finite(double x, double y) { return pow(x, y); }

    float __expf_finite(float x) { return expf(x); }
    float __logf_finite(float x) { return logf(x); }
    float __powf_finite(float x, float y) { return powf(x, y); }
}

It's by far the quickest solution.

Étienne
  • 407
  • 4
  • 15
  • I have libs built in GCC 4.8.5 and new sourcode code built in GCC 9.x which leads to the same problem. This clever solution saves my day. – Lan Do Jul 02 '21 at 05:25
  • I seem to have run into the same problem. What do I need to do so as to have the linker use my definitions? – Frank Weslien Oct 19 '21 at 11:53
  • 1
    It was easy, just had to wrap a couple more functions and stick everything in a .hpp file – Frank Weslien Oct 19 '21 at 13:59