libgpiod icon indicating copy to clipboard operation
libgpiod copied to clipboard

Drop AC_FUNC_MALLOC and _REALLOC and check for them as regular functions.

Open joluxer opened this issue 5 years ago • 6 comments

While cross-compiling there occurred "undefined reference to `rpl_malloc'", the suggested change fixes the problem.

Tested for native X86_64 and armv7a-unknown-linux-gnueabihf.

joluxer avatar Nov 14 '19 09:11 joluxer

This is strange - I've been cross-compiling this a lot for different platforms and it's also deployed in yocto and buildroot - I have never seen any such problem. Could you give some more details?

brgl avatar Nov 14 '19 10:11 brgl

I'm cross-compiling on Gentoo, the cross-build environment is created by Gentoo's crossdev system, which produced up to now an very high quality cross-build enviroment. The cross-target is armv7a-unknown-linux-gnueabihf.

 

The build run is controlled by a larger CMake project, which calls autogen.sh and thus configure automatically as an ExternalProject with out-of-source-build. I can provide You with the detailed artifacts of this project part, if you need it. Sharing the whole project is'nt possible. The build enviroment is available publicly as a docker image: joluxer/dyna-linux-imx6ull-colibri.

 

In a few days I can do a minimal example for reproducing the problem.

 

More details to come on request.

 

Gesendet: Donnerstag, 14. November 2019 um 11:31 Uhr Von: "Bartosz Gołaszewski" [email protected] An: brgl/libgpiod [email protected] Cc: joluxer [email protected], Author [email protected] Betreff: Re: [brgl/libgpiod] Drop AC_FUNC_MALLOC and _REALLOC and check for them as regular functions. (#45)

This is strange - I've been cross-compiling this a lot for different platforms and it's also deployed in yocto and buildroot - I have never seen any such problem. Could you give some more details?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

joluxer avatar Nov 14 '19 14:11 joluxer

The thing is: AC_FUNC_MALLOC is a very standard macro. It not only checks the existence of malloc() but also verifies that it's compatible with GNUC malloc(). The comment you're adding about it not working when cross-compiling is untrue in 99% cases. I'll even risk saying that if it doesn't work in your environment, it's a problem with the environment and not the project.

brgl avatar Nov 20 '19 15:11 brgl

I found that cross-building with Gentoos cross-emerge works flawless, but compiling by hand does not. So the AC_FUNC_MALLOC macro seems to do special things, which are not compatible with my manual tests. To see other build systems which compile this thing without problems makes me believe, that this is a problem of my manual tests. I'll keep an eye on this in my test environment.

joluxer avatar Nov 20 '19 18:11 joluxer

The autoconf AC_FUNC_MALLOC macro does not only check for the presence of malloc, but it also verifies its behaviour when allocating 0 bytes. Since autoconf is not able to check with cross-compilers, malloc is always marked as missing when cross-building.

When using Yocto or Buildroot to build the package, the build system adds a set of autoconf variables to work around this issue, and specify that this detection should be successfull.

romain-izard-pro avatar Feb 26 '20 15:02 romain-izard-pro

Thanks for bringing this to my attention. I'll take another look at this and potentially apply this patch.

brgl avatar Feb 26 '20 18:02 brgl