Bug 991 - Build fails with call to mallopt()
Summary: Build fails with call to mallopt()
Status: RESOLVED WORKSFORME
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.16.x
Hardware: All Linux
: P1 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-27 14:23 UTC by African Chief
Modified: 2010-01-27 23:53 UTC (History)
1 user (show)

See Also:
Host: mipsel-linux-gnu
Target: mipsel-linux-uclibc
Build: mipsel-linux-gnu


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description African Chief 2010-01-27 14:23:48 UTC
The build fails due to two calls to mallopt() in appletlib.c.

"libbb/lib.a(appletlib.o): In function `main':
appletlib.c:(.text.main+0x20): undefined reference to `mallopt'
appletlib.c:(.text.main+0x3c): undefined reference to `mallopt'
collect2: ld returned 1 exit status"
Comment 1 Bernhard Reutner-Fischer 2010-01-27 19:36:11 UTC
$ grep MALLOC uClibc/.config
Comment 2 Bernhard Reutner-Fischer 2010-01-27 19:40:40 UTC
Note that mallopt is only implemented for MALLOC_STANDARD and i guess you're trying to use MALLOC_SIMPLE.

If this is correct, then either wrap the calls to mallopt with #if (defined __UCLIBC__ && defined __MALLOC_STANDARD__) || !defined __UCLIBC__
or switch to MALLOC_STANDARD.
Comment 3 African Chief 2010-01-27 21:35:43 UTC
(In reply to comment #1)
> $ grep MALLOC uClibc/.config
> 

$ grep MALLOC uClibc/.config
# CONFIG_FEATURE_BUFFERS_USE_MALLOC is not set
CONFIG_MIPS_CPMAC_INIT_BUF_MALLOC=y
# MALLOC_930716 is not set
MALLOC=y
# UCLIBC_MALLOC_DEBUGGING is not set
Comment 4 Denys Vlasenko 2010-01-27 22:43:53 UTC
Well, the code is:

#ifdef M_TRIM_THRESHOLD
        /* M_TRIM_THRESHOLD is the maximum amount of freed top-most memory
         * to keep before releasing to the OS
         * Default is way too big: 256k
         */
        mallopt(M_TRIM_THRESHOLD, 2 * PAGE_SIZE);
#endif

does uclibc really defines M_TRIM_THRESHOLD if it does not support it? Which version of uclibc does that?
Comment 5 African Chief 2010-01-27 22:57:35 UTC
(In reply to comment #4)
[...]
> does uclibc really defines M_TRIM_THRESHOLD if it does not support it? 

Yes, it is defined in a header:

$ grep -r M_TRIM_THRESHOLD uClibc/*
uClibc/include/malloc.h:#define M_TRIM_THRESHOLD    -1

> Which version of uclibc does that?

uClibc 0.9.19, for an embedded platform (mipsel).

It seems to be a uClibc problem:

# define __MALLOC_P(args)	args __THROW
...
extern int mallopt __MALLOC_P ((int __param, int __val));
...
Comment 6 Denys Vlasenko 2010-01-27 23:14:25 UTC
Nope, it's inside #ifdef:

#ifdef __MALLOC_STANDARD__
...
/* mallopt options that actually do something */
#define M_TRIM_THRESHOLD    -1
#define M_TOP_PAD           -2
#define M_MMAP_THRESHOLD    -3
#define M_MMAP_MAX          -4
#define M_CHECK_ACTION      -5
#define M_PERTURB           -6

/* General SVID/XPG interface to tunable parameters. */
extern int mallopt __MALLOC_P ((int __param, int __val));

#endif /* __MALLOC_STANDARD__ */


uclibc 0.9.19?? That's ten versions older than most recent uclibc release, it's seven years old.
Comment 7 African Chief 2010-01-27 23:32:56 UTC
(In reply to comment #6)
> Nope, it's inside #ifdef:
> 
> #ifdef __MALLOC_STANDARD__

Unfortunately, not in our version (TI AR7 + MontaVista Linux 2.4.17).

[...]
> uclibc 0.9.19?? That's ten versions older than most recent uclibc release, it's
> seven years old.

Sadly so. This is code for firmwares for ADSL modem/routers, and it is not easily upgraded.

I'll just add the #ifdef myself.

Thanks.
Comment 8 Mike Frysinger 2010-01-27 23:53:18 UTC
i think the answer is fix your uClibc