berkeley-softfloat-3 icon indicating copy to clipboard operation
berkeley-softfloat-3 copied to clipboard

inline problems at -O0

Open programmerjake opened this issue 6 years ago • 3 comments

I wrote Rust bindings to softfloat (https://crates.io/crates/softfloat-sys), however I ran into linking problems since a lot of internal functions are declared inline but there is no out-of-line version of them. As a workaround, I had to make -O1 the minimum optimization level.

Note that I am not using softfloat's makefiles, I instead wrote the build.rs build script based on them.

programmerjake avatar Feb 04 '19 11:02 programmerjake

All of the inline-defined functions are believed to have out-of-line versions, assuming you make all the files correctly. If you can name a specific function for which this is not true, I will look into it.

Please note the difference between the FAST_INT64 and not-FAST_INT64 versions of the builds. It's possible you're not getting the out-of-line function versions because your build script is based on the wrong example Makefile.

jhauser-ucberkeley avatar Feb 08 '19 02:02 jhauser-ucberkeley

softfloat_countLeadingZeros32 is defined when build/Linux-x86_64-GCC/platform.h is included, so the out-of-line version in source/s_countLeadingZeros32.c is #ifdef-ed out.

programmerjake avatar Feb 08 '19 02:02 programmerjake

softfloat_countLeadingZeros32 is defined when build/Linux-x86_64-GCC/platform.h is included, so the out-of-line version in source/s_countLeadingZeros32.c is #ifdef-ed out.

Okay, I see the problem; it's the inline functions in opts-GCC.h, which were added in the last release. Those functions don't currently have non-inline equivalents.

For now, if you really want to compile with -O0, you can simply remove or comment out these lines from platform.h: #define SOFTFLOAT_BUILTIN_CLZ 1 #define SOFTFLOAT_INTRINSIC_INT128 1 #include "opts-GCC.h" As the source documentation explains, including opts-GCC.h is only an optimization improvement.

I imagine the reason this hasn't come up before is because the set of people who use SoftFloat and don't want their compiler to optimize the code is pretty small.

jhauser-ucberkeley avatar Feb 08 '19 03:02 jhauser-ucberkeley