diff mbox series

[libgpiod] AC_FUNC_MALLOC cross-compile failure

Message ID X/RzBqyV4hCdmrBy@kelvin.aketzu.net
State New
Headers show
Series [libgpiod] AC_FUNC_MALLOC cross-compile failure | expand

Commit Message

Anssi Kolehmainen Jan. 5, 2021, 2:09 p.m. UTC
When libgpiod is cross-compiled it will use rpl_malloc instead malloc which then 
causes linking failure at later stage.

This happens because AC_FUNC_MALLOC wants to execute malloc() in a live system 
and thus cannot be run at cross-compilation time. libgpiod should just do 
AC_CHECK_FUNC instead.

Comments

Andy Shevchenko Jan. 5, 2021, 5:24 p.m. UTC | #1
On Tue, Jan 5, 2021 at 4:17 PM Anssi Kolehmainen <anssi@aketzu.net> wrote:
>
> When libgpiod is cross-compiled it will use rpl_malloc instead malloc which then
> causes linking failure at later stage.
>
> This happens because AC_FUNC_MALLOC wants to execute malloc() in a live system
> and thus cannot be run at cross-compilation time. libgpiod should just do
> AC_CHECK_FUNC instead.

Which version of aufotools you tried? (2.69?)
Btw, have you tried autotools-2.70?
Anssi Kolehmainen Jan. 5, 2021, 7:52 p.m. UTC | #2
On Tue, Jan 05, 2021 at 07:24:46PM +0200, Andy Shevchenko wrote:
>On Tue, Jan 5, 2021 at 4:17 PM Anssi Kolehmainen <anssi@aketzu.net> wrote:
>>
>> When libgpiod is cross-compiled it will use rpl_malloc instead malloc which then
>> causes linking failure at later stage.
>>
>> This happens because AC_FUNC_MALLOC wants to execute malloc() in a live system
>> and thus cannot be run at cross-compilation time. libgpiod should just do
>> AC_CHECK_FUNC instead.
>
>Which version of aufotools you tried? (2.69?)
>Btw, have you tried autotools-2.70?

I have autoconf 2.69 from Debian testing.

Quick testing with 2.70 looks good.
Apparently fixed in 7fbb55372 in May 2012... And 2.69 is from April 2012.

I don't know which kind of facepalm would be suitable for this.
Bartosz Golaszewski Jan. 6, 2021, 7:19 a.m. UTC | #3
On Tue, Jan 5, 2021 at 8:54 PM Anssi Kolehmainen <anssi@aketzu.net> wrote:
>
> On Tue, Jan 05, 2021 at 07:24:46PM +0200, Andy Shevchenko wrote:
> >On Tue, Jan 5, 2021 at 4:17 PM Anssi Kolehmainen <anssi@aketzu.net> wrote:
> >>
> >> When libgpiod is cross-compiled it will use rpl_malloc instead malloc which then
> >> causes linking failure at later stage.
> >>
> >> This happens because AC_FUNC_MALLOC wants to execute malloc() in a live system
> >> and thus cannot be run at cross-compilation time. libgpiod should just do
> >> AC_CHECK_FUNC instead.
> >
> >Which version of aufotools you tried? (2.69?)
> >Btw, have you tried autotools-2.70?
>
> I have autoconf 2.69 from Debian testing.
>
> Quick testing with 2.70 looks good.
> Apparently fixed in 7fbb55372 in May 2012... And 2.69 is from April 2012.
>
> I don't know which kind of facepalm would be suitable for this.
>
> --
> Anssi Kolehmainen

IIRC someone suggested this to me a long time ago but since there were
no other reports and I mostly just use an SDK generated by yocto which
has some workaround for it, I never saw the need for it. I'll apply
the patch even if it was fixed in v2.70 because it looks like a valid
concern.

Bartosz
Bartosz Golaszewski Jan. 6, 2021, 7:21 a.m. UTC | #4
On Tue, Jan 5, 2021 at 3:16 PM Anssi Kolehmainen <anssi@aketzu.net> wrote:
>
> When libgpiod is cross-compiled it will use rpl_malloc instead malloc which then
> causes linking failure at later stage.
>
> This happens because AC_FUNC_MALLOC wants to execute malloc() in a live system
> and thus cannot be run at cross-compilation time. libgpiod should just do
> AC_CHECK_FUNC instead.
>
> diff --git a/configure.ac b/configure.ac
> index ddb9dc2..5f41c4a 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -82,7 +82,7 @@ AC_DEFUN([HEADER_NOT_FOUND_CXX],
>
>   # This is always checked (library needs this)
>   AC_HEADER_STDC
> -AC_FUNC_MALLOC
> +AC_CHECK_FUNC([malloc], [], [FUNC_NOT_FOUND_LIB([malloc])])
>   AC_CHECK_FUNC([ioctl], [], [FUNC_NOT_FOUND_LIB([ioctl])])
>   AC_CHECK_FUNC([asprintf], [], [FUNC_NOT_FOUND_LIB([asprintf])])
>   AC_CHECK_FUNC([scandir], [], [FUNC_NOT_FOUND_LIB([scandir])])

What is the target branch here? It doesn't apply neither to master nor
to v1.6.x. Can you also add the Signed-off-by tag please?

Bartosz
diff mbox series

Patch

diff --git a/configure.ac b/configure.ac
index ddb9dc2..5f41c4a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,7 +82,7 @@  AC_DEFUN([HEADER_NOT_FOUND_CXX],
  
  # This is always checked (library needs this)
  AC_HEADER_STDC
-AC_FUNC_MALLOC
+AC_CHECK_FUNC([malloc], [], [FUNC_NOT_FOUND_LIB([malloc])])
  AC_CHECK_FUNC([ioctl], [], [FUNC_NOT_FOUND_LIB([ioctl])])
  AC_CHECK_FUNC([asprintf], [], [FUNC_NOT_FOUND_LIB([asprintf])])
  AC_CHECK_FUNC([scandir], [], [FUNC_NOT_FOUND_LIB([scandir])])