Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inline problems at -O0 #11

Open
programmerjake opened this issue Feb 4, 2019 · 3 comments
Open

inline problems at -O0 #11

programmerjake opened this issue Feb 4, 2019 · 3 comments

Comments

@programmerjake
Copy link

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.

@jhauser-ucberkeley
Copy link
Contributor

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.

@programmerjake
Copy link
Author

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.

@jhauser-ucberkeley
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants