Étienne
Étienne

Reputation: 451

Link errors with -ffast-math (-ffinite-math-only) and glibc 2.31

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.

Upvotes: 2

Views: 1695

Answers (1)

Étienne
Étienne

Reputation: 451

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.

Upvotes: 4

Related Questions