#11 fix malloc tests in configure

Next_Release
open
None
Patch
2016-01-30
2014-05-30
No

Detection of malloc.h doesn't work properly, at least not on Mac.

With existing configulation it fails with:

checking malloc.h usability... no
checking malloc.h presence... no
checking for malloc.h... no
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for size_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking for working volatile... yes
checking whether closedir returns void... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... no
...
Undefined symbols for architecture x86_64:
"_rpl_malloc", referenced from:
_br_strcat in prefix.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [codeblocks] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1

The following workaround fixes the problem (but you probably need to modify it):

--- configure.ac.orig
+++ configure.ac
@@ -36,7 +36,7 @@ AC_PROG_LIBTOOL
 dnl Checks for header files.
 AC_HEADER_DIRENT
 AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h sys/param.h unistd.h malloc.h])
+AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h sys/param.h unistd.h sys/malloc.h])

 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_HEADER_STDBOOL

Discussion

  • Teodor Petrov

    Teodor Petrov - 2014-09-10

    The problem with this patch is that it will break the compilation for other OSes...

     
  • Mojca Miklavec

    Mojca Miklavec - 2014-09-10

    Sure, I didn't ask you to include that patch literally.

    (I'm just saying that the workaround worked for me. The final patch needs to be slightly different, but I don't know what would be the proper way.)

     
  • Morten MacFly

    Morten MacFly - 2015-02-07
    • Type: --> Undefined
     
  • Morten MacFly

    Morten MacFly - 2015-05-02

    GPERF tools do it like this:
    AC_CHECK_HEADERS(malloc.h) # some systems define stuff there, others not
    AC_CHECK_HEADERS(sys/malloc.h) # where some versions of OS X put malloc.h
    AC_CHECK_HEADERS(malloc/malloc.h) # another place OS X puts malloc.h (?)
    ...and it works.

    So what SHOULD work for us is:
    -AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h sys/param.h unistd.h malloc.h])
    +AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h sys/param.h unistd.h malloc.h sys/malloc.h malloc/malloc.h])

    Teodor/Mojca : If yo are on Linux, can you give it a try?

     
  • Morten MacFly

    Morten MacFly - 2015-05-02
    • assigned_to: Morten MacFly
    • Type: Undefined --> Patch
     
  • Mojca Miklavec

    Mojca Miklavec - 2015-05-02

    Just for the reference, here's what I get on a Mac after the proposed change:

    checking malloc.h usability... no
    checking malloc.h presence... no
    checking for malloc.h... no
    checking sys/malloc.h usability... yes
    checking sys/malloc.h presence... yes
    checking for sys/malloc.h... yes
    checking malloc/malloc.h usability... yes
    checking malloc/malloc.h presence... yes
    checking for malloc/malloc.h... yes
    ...
    checking for GNU libc compatible malloc... yes
    

    I assume that it will work (and will report back in case I'm wrong if it fails some time later during the build).

    I haven't tried building CB on linux yet, but I can report once I get access to a suitable setup.

     
  • Morten MacFly

    Morten MacFly - 2015-05-02

    OK, not too bad. I'll still wait to have that confirmed for Linux...

     
  • Jens Lody

    Jens Lody - 2015-05-03

    That's what I get on linux:
    checking malloc.h usability... yes
    checking malloc.h presence... yes
    checking for malloc.h... yes
    checking sys/malloc.h usability... no
    checking sys/malloc.h presence... no
    checking for sys/malloc.h... no
    checking malloc/malloc.h usability... no
    checking malloc/malloc.h presence... no
    checking for malloc/malloc.h... no
    and it compiles fine and seems to work.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks