volk icon indicating copy to clipboard operation
volk copied to clipboard

gnuradio/volk/#430 move log2f_non_ieee back to kernel header

Open jbruno opened this issue 4 years ago • 7 comments

This minor change allows VOLK to build with older versions of GCC. Currently GCC6 is the minimum, and some developers are stuck using older tools.

Project fully builds for x86-64 as well as armv7. Tested by running volk_profile on both targets.

jbruno avatar Mar 08 '21 20:03 jbruno

Older versions of G++ (pre v6) don't automatically sub in "std::" when building C code. A user in #430 linked this:

https://developers.redhat.com/blog/2016/02/29/why-cstdlib-is-more-complicated-than-you-might-think/

which describes it well.

The fix comes about because the kernels are all C code, and like the syntax. The C++ code which includes volk_common.h does not like the syntax, however. The C++ function would require "std::isinf".

I got away with moving it to the kernel header, because none of the C++ application code actually uses that function. Only a couple of the kernels do.

jbruno avatar Mar 08 '21 21:03 jbruno

make_master_ububtu1604.log cmake_master_ububtu1604.log

Build logs attached. This is on Ubuntu 16.04 with GCC 5.4.0

jbruno avatar Mar 08 '21 21:03 jbruno

I got away with moving it to the kernel header, because none of the C++ application code actually uses that function. Only a couple of the kernels do.

Gotcha! Thank you for the detailed explanation. What you bring up is indeed a critical oversight in mixing C & C++ code. Can you test wrapping the original function with extern "C" {}? That might do the trick, and if so then it's a better and safer solution. I will boot up an older computer of mine that uses GCC5 optionally to see if I can replicate the issue & verify the fix independently.

michaelld avatar Mar 08 '21 21:03 michaelld

It does not build, with the same errors.

However, wrapping the entire function with a #ifndef __cplusplus macro does the trick.

Clearly, this disables the function for C++ code, but it does have the added safety of not relying on the kernel headers being included in the right order.

jbruno avatar Mar 09 '21 01:03 jbruno

hmm ... interesting. Thanks for testing! I think a point in having that code where it is is to make it available outside the kernel. Which means it needs to be usable in C or C++. Hence my hoping that extern would do the trick. I need to look at the code more to decide if I'm OK with just moving that function into the kernel.

michaelld avatar Mar 09 '21 01:03 michaelld

Understood. It's a simple enough function that I can likely macro wrap 2 versions. Let me give that a shot and update the branch.

jbruno avatar Mar 09 '21 01:03 jbruno

Now that Ubuntu 16.04 is EOL, I'd say we can avoid this work around (and thus added complexity).

Still, I'd be happy to merge your README updates. Would you mind to reduce your PR to these commits?

jdemel avatar Jul 02 '21 10:07 jdemel

Closing this PR now. There's reason to hope that this issue doesn't get raised again on later distros.

jdemel avatar Jan 14 '23 14:01 jdemel