The file gcc/config/m68k/math-68881.h is distributed with GCC, however it does not support C99. When this file is included in multiple files, then compiled with --std=c99 or --std=gnu99 this leads to duplicate definitions.
This is because it uses "extern inline" unconditionally.
Created attachment 23291 [details]
Fix for math-68881.h and C99
This patch fixes the problem.
I'd rather remove that file.
Should math-68881.h be part of a OS's libc/libm then ?
Normal math implementation should always reside inside libm, to fully support exceptions, error handling, etc.
When better speed is required, and strict standard compliance is not required, a user can compile his program with -ffast-math. As a result, any call to sin() will be implemented by a single fsin instruction rather than a call to libm. The purpose is the same as math-68881.h. But the implementation is different: math-68881.h relies on the preprocessor, while -ffast-math is directly handled by GCC at low level for better register usage, etc. This is why ideally math-68881.h should be removed from GCC and -ffast-math always used by the users, when needed. However, someone reported that all the functionnality of math-68881.h was not reported to -ffast-math: some instructions are missing.
So I propose the following roadmap:
1) Commit my proposed patch, then close this bug. This will fix the current math-68881.h for C99. I hit that problem when compiling libtiff.
2) Move the missing functionnality from math-68881.h to -ffast-math, then remove math-68881.h from GCC.
(In reply to comment #4)
> However, someone reported that all the functionnality of
> math-68881.h was not reported to -ffast-math: some instructions are missing.
> 2) Move the missing functionnality from math-68881.h to -ffast-math, then
> remove math-68881.h from GCC.
I only see this PR and PR49295 mention math-68881.h, and neither PR lists any missing instructions.
What specific instructions are missing from -ffast-math?
> What specific instructions are missing from -ffast-math?
I don't know myself, but I have been told it was the case.
math-m68881.h is obsolete and should not be used. There are no plans to fix/upgrade the contents of that file.