build fails: malloc_decls.h conflicting types for 'malloc_usable_size'

RESOLVED FIXED in Firefox 37

Status

()

Firefox for Android
Build Config & IDE Support
RESOLVED FIXED
3 years ago
11 months ago

People

(Reporter: Axel Nennker, Assigned: blassey)

Tracking

Trunk
Firefox 37
ARM
Android
Points:
---

Firefox Tracking Flags

(fennec+)

Details

(Whiteboard: [ndk-r10c])

Attachments

(1 attachment, 3 obsolete attachments)

(Reporter)

Description

3 years ago
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0
Build ID: 20140924083558

Steps to reproduce:

hg pull -u
MOZCONFIG=fennec_mozconfig ./mach build


Actual results:

4:10.36 replace_malloc.o
 4:10.39 In file included from /home/ignisvulpis/mozilla-central/memory/build/mozmemory_wrap.c:13:0:
 4:10.39 /home/ignisvulpis/mozilla-central/memory/build/malloc_decls.h:48:47: error: conflicting types for 'malloc_usable_size'
 4:10.39  MALLOC_DECL(malloc_usable_size, size_t, usable_ptr_t)
 4:10.39                                                ^
 4:10.39 In file included from ../../dist/system_wrappers/malloc.h:3:0,
 4:10.39                  from /usr/local/android-ndk-r10b/platforms/android-9/arch-arm/usr/include/string.h:33,
 4:10.39                  from ../../dist/system_wrappers/string.h:3,
 4:10.39                  from /home/ignisvulpis/mozilla-central/memory/build/mozmemory_wrap.c:5:
 4:10.39 /usr/local/android-ndk-r10b/platforms/android-9/arch-arm/usr/include/malloc.h:36:15: note: previous declaration of 'malloc_usable_size' was here
 4:10.39  extern size_t malloc_usable_size(const void*);
 4:10.39                ^
 4:10.39 
 4:10.39 In the directory  /home/ignisvulpis/mozilla-central/obj-arm-linux-androideabi/memory/build
 4:10.39 The following command failed to execute properly:
 4:10.39 /usr/bin/ccache /usr/local/android-ndk-r10b//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -o mozmemory_wrap.o -c -I../../dist/system_wrappers -include /home/ignisvulpis/mozilla-central/config/gcc_hidden.h -DMOZ_MEMORY_IMPL -DMOZ_REPLACE_MALLOC -DAB_CD=en-US -DNO_NSPR_10_SUPPORT -I/home/ignisvulpis/mozilla-central/memory/build -I. -I../../dist/include -I/home/ignisvulpis/mozilla-central/obj-arm-linux-androideabi/dist/include/nspr -I/home/ignisvulpis/mozilla-central/obj-arm-linux-androideabi/dist/include/nss -fPIC -idirafter /usr/local/android-ndk-r10b//platforms/android-9/arch-arm/usr/include -include ../../mozilla-config.h -DMOZILLA_CLIENT -MD -MP -MF .deps/mozmemory_wrap.o.pp -idirafter /usr/local/android-ndk-r10b//platforms/android-9/arch-arm/usr/include -Wall -Wdeclaration-after-statement -Wempty-body -Wpointer-to-int-cast -Wsign-compare -Wtype-limits -Werror=char-subscripts -Werror=comment -Werror=endif-labels -Werror=enum-compare -Werror=ignored-qualifiers -Werror=int-to-pointer-cast -Werror=multichar -Werror=nonnull -Werror=pointer-arith -Werror=pointer-sign -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=unknown-pragmas -Wno-unused -mandroid -fno-short-enums -fno-exceptions -march=armv7-a -mthumb -mfpu=vfp -mfloat-abi=softfp -mno-unaligned-access -std=gnu99 -fgnu89-inline -fno-strict-aliasing -fno-math-errno -pipe -DNDEBUG -DTRIMMED -g -freorder-blocks -Os -fno-reorder-functions -fomit-frame-pointer /home/ignisvulpis/mozilla-central/memory/build/mozmemory_wrap.c
 4:10.39 make[5]: *** [mozmemory_wrap.o] Error 1



Expected results:

build fennec
(Reporter)

Comment 1

3 years ago
Maybe this is interesting to know too:
ignisvulpis@namenlos:~/mozilla-central$ cat fennec_mozconfig 
# Add the correct paths here:
ac_add_options --with-android-ndk="/usr/local/android-ndk-r10b/"
ac_add_options --with-android-sdk="/usr/local/adt-bundle-linux-x86_64-20140702/sdk/platforms/android-20/"

# android options
ac_add_options --enable-application=mobile/android
ac_add_options --target=arm-linux-androideabi

ac_add_options --with-ccache
ac_add_options --disable-gstreamer


I am on Ubuntu 14.04 LTS.

Updated

3 years ago
Component: General → Build Config & IDE Support
OS: Linux → Android
Hardware: x86_64 → ARM
At first blush, I'm pretty sure we do not use NDK 10b on the buildbots.  That doesn't mean it won't work, but it's essentially unsupported.  Redirecting to glandium to see if he's seen this or knows what would be relevant.
Flags: needinfo?(mh+mozilla)
(Reporter)

Comment 3

3 years ago
My guess is that this line is borked:
http://dxr.mozilla.org/mozilla-central/source/memory/build/malloc_decls.h#18

Maybe an AC_TRY_COMPILE/AC_TRY_LINK with and without const to define usable_ptr_t right would be best.
(Reporter)

Comment 4

3 years ago
I downloaded and installed android-ndk-r9 and get the same error.

Axel

MOZCONFIG=fennec_mozconfig ./mach build -j1
...
...
 0:10.50 mozmemory_wrap.o
 0:10.55 In file included from /home/ignisvulpis/mozilla-central/memory/build/mozmemory_wrap.c:13:0:
 0:10.56 /home/ignisvulpis/mozilla-central/memory/build/malloc_decls.h:48:47: error: conflicting types for 'malloc_usable_size'
 0:10.56  MALLOC_DECL(malloc_usable_size, size_t, usable_ptr_t)
 0:10.56                                                ^
 0:10.56 In file included from ../../dist/system_wrappers/malloc.h:3:0,
 0:10.56                  from /usr/local/android-ndk-r9/platforms/android-9/arch-arm/usr/include/string.h:33,
 0:10.56                  from ../../dist/system_wrappers/string.h:3,
 0:10.56                  from /home/ignisvulpis/mozilla-central/memory/build/mozmemory_wrap.c:5:
 0:10.56 /usr/local/android-ndk-r9/platforms/android-9/arch-arm/usr/include/malloc.h:36:15: note: previous declaration of 'malloc_usable_size' was here
 0:10.56  extern size_t malloc_usable_size(const void*);
 0:10.56                ^
 0:10.56 
 0:10.56 In the directory  /home/ignisvulpis/mozilla-central/obj-arm-linux-androideabi/memory/build
 0:10.56 The following command failed to execute properly:
 0:10.56 /usr/bin/ccache /usr/local/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc -o mozmemory_wrap.o -c -I../../dist/system_wrappers -include /home/ignisvulpis/mozilla-central/config/gcc_hidden.h -DMOZ_MEMORY_IMPL -DMOZ_REPLACE_MALLOC -DAB_CD=en-US -DNO_NSPR_10_SUPPORT -I/home/ignisvulpis/mozilla-central/memory/build -I. -I../../dist/include -I/home/ignisvulpis/mozilla-central/obj-arm-linux-androideabi/dist/include/nspr -I/home/ignisvulpis/mozilla-central/obj-arm-linux-androideabi/dist/include/nss -fPIC -idirafter /usr/local/android-ndk-r9//platforms/android-9/arch-arm/usr/include -include ../../mozilla-config.h -DMOZILLA_CLIENT -MD -MP -MF .deps/mozmemory_wrap.o.pp -idirafter /usr/local/android-ndk-r9//platforms/android-9/arch-arm/usr/include -Wall -Wdeclaration-after-statement -Wempty-body -Wpointer-to-int-cast -Wsign-compare -Wtype-limits -Werror=char-subscripts -Werror=comment -Werror=endif-labels -Werror=enum-compare -Werror=ignored-qualifiers -Werror=int-to-pointer-cast -Werror=multichar -Werror=nonnull -Werror=pointer-arith -Werror=pointer-sign -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=unknown-pragmas -Wno-unused -mandroid -fno-short-enums -fno-exceptions -march=armv7-a -mthumb -mfpu=vfp -mfloat-abi=softfp -mno-unaligned-access -std=gnu99 -fgnu89-inline -fno-strict-aliasing -fno-math-errno -pipe -DNDEBUG -DTRIMMED -g -freorder-blocks -Os -fno-reorder-functions -fomit-frame-pointer /home/ignisvulpis/mozilla-central/memory/build/mozmemory_wrap.c
 0:10.56 make[5]: *** [mozmemory_wrap.o] Error 1
 0:10.56 make[4]: *** [memory/build/target] Error 2
 0:10.56 make[3]: *** [compile] Error 2
 0:10.56 make[2]: *** [default] Error 2
 0:10.56 make[1]: *** [realbuild] Error 2
 0:10.56 make: *** [build] Error 2
 0:10.60 374 compiler warnings present.
 0:11.66 ccache (direct) hit rate: 0.0%; (preprocessed) hit rate: 0.0%; miss rate: 100.0%
ignisvulpis@namenlos:~/mozilla-central$ cat fennec_mozconfig 
# Add the correct paths here:
ac_add_options --with-android-ndk="/usr/local/android-ndk-r9/"
ac_add_options --with-android-sdk="/usr/local/adt-bundle-linux-x86_64-20140702/sdk/platforms/android-20/"

# android options
ac_add_options --enable-application=mobile/android
ac_add_options --target=arm-linux-androideabi

ac_add_options --with-ccache
ac_add_options --disable-gstreamer
ignisvulpis@namenlos:~/mozilla-central$
(Reporter)

Comment 5

3 years ago
What I don't understand is that there is already a test for this here:
http://mxr.mozilla.org/mozilla-central/source/memory/jemalloc/src/configure.ac#359

I think the test should be moved (or copied) into mozilla-central/configure.in
and this line and following
http://dxr.mozilla.org/mozilla-central/source/memory/build/malloc_decls.h#18
should be rewritten as somethink like:

typedef JEMALLOC_USABLE_SIZE_CONST void * usable_ptr_t;
That ANDROID_VERSION test added in bug 957450 is just probably wrong.
Blocks: 957450
Flags: needinfo?(mh+mozilla)
(Reporter)

Comment 7

3 years ago
Created attachment 8507166 [details] [diff] [review]
hg diff > malloc_usable_size_const_ptr.patch

This works for me.
host: ubuntu target: android

Created a test in configure.in and removed the bogus ifdef
Comment on attachment 8507166 [details] [diff] [review]
hg diff > malloc_usable_size_const_ptr.patch

glandium: does this look reasonable?
Attachment #8507166 - Flags: review?(mh+mozilla)
Comment on attachment 8507166 [details] [diff] [review]
hg diff > malloc_usable_size_const_ptr.patch

Review of attachment 8507166 [details] [diff] [review]:
-----------------------------------------------------------------

::: memory/build/malloc_decls.h
@@ +15,4 @@
>  
>  #  include "jemalloc_types.h"
>  
> +typedef MALLOC_USABLE_SIZE_CONST_PTR void * usable_ptr_t;

I'd rather avoid a configure test for that unless it's _really_ necessary, and I don't think it should be necessary.
Attachment #8507166 - Flags: review?(mh+mozilla) → feedback-
Comment on attachment 8507166 [details] [diff] [review]
hg diff > malloc_usable_size_const_ptr.patch

Review of attachment 8507166 [details] [diff] [review]:
-----------------------------------------------------------------

::: configure.in
@@ +3405,5 @@
> +if test "$ac_cv_malloc_usable_size_const_ptr" = yes ; then
> +  AC_DEFINE(MALLOC_USABLE_SIZE_CONST_PTR, [const])
> +else
> +  AC_DEFINE(MALLOC_USABLE_SIZE_CONST_PTR,)
> +fi

IIRC from when I added the test to upstream jemalloc, you do need to test malloc.h exists first, and default to const, not an empty value

::: memory/build/malloc_decls.h
@@ +15,4 @@
>  
>  #  include "jemalloc_types.h"
>  
> +typedef MALLOC_USABLE_SIZE_CONST_PTR void * usable_ptr_t;

Forget my previous comment, I can see what the problem is: they actually changed the old platform headers in the new NDKs... sigh.
(Slightly inaccurate whiteboard tag, but it'll do for now.)
Whiteboard: [ndk-r10c]
(Reporter)

Comment 12

3 years ago
Regarding Comment 9 : I am a big fan of configure tests. Predecessor directives can become wrong like this one which causing the trouble:
#  if defined(__linux__) && (!defined(MOZ_MEMORY_ANDROID) || ANDROID_VERSION < 19)

configure tests are kind of more authoritative than preprocessor #if's and even with a big number of configure tests the developement setup time is IMO short.

Q: shouldn't the status be "NEW" instead of "UNCONFIRMED"?
(In reply to Nick Alexander :nalexander from comment #8)
> Comment on attachment 8507166 [details] [diff] [review]
> hg diff > malloc_usable_size_const_ptr.patch

fwiw this patch helped for Fennec builds, but fails on a Flame b2g build.
(Reporter)

Comment 14

3 years ago
(In reply to Douglas Crosher [:dougc] from comment #13)
> (In reply to Nick Alexander :nalexander from comment #8)
> > Comment on attachment 8507166 [details] [diff] [review]
> > hg diff > malloc_usable_size_const_ptr.patch
> 
> fwiw this patch helped for Fennec builds, but fails on a Flame b2g build.

Hm, I just build b2g for the nexus-5 with this patch and it built.
I added the new test to B2G/gecko/configure.in and changed B2G/gecko/memory/build/malloc_decls.h 
Why does it fail for you?

I would like to add a B2G patch but I do not know how to create one.
ignisvulpis@namenlos:~/development/B2G$ git diff -U8 --patience -M -C
returns nothing... Strange.
(Reporter)

Comment 15

3 years ago
(In reply to Axel Nennker from comment #14)
> (In reply to Douglas Crosher [:dougc] from comment #13)
> > (In reply to Nick Alexander :nalexander from comment #8)
> > > Comment on attachment 8507166 [details] [diff] [review]
> > > hg diff > malloc_usable_size_const_ptr.patch
> > 
> > fwiw this patch helped for Fennec builds, but fails on a Flame b2g build.
> 
> Hm, I just build b2g for the nexus-5 with this patch and it built.
> I added the new test to B2G/gecko/configure.in and changed
> B2G/gecko/memory/build/malloc_decls.h 
> Why does it fail for you?
> 
> I would like to add a B2G patch but I do not know how to create one.
> ignisvulpis@namenlos:~/development/B2G$ git diff -U8 --patience -M -C
> returns nothing... Strange.

Regarding b2g: I guessed how the diff works here
ignisvulpis@namenlos:~/development/B2G$ git diff
ignisvulpis@namenlos:~/development/B2G$ hg diff
abort: no repository found in '/home/ignisvulpis/development/B2G' (.hg not found)!
ignisvulpis@namenlos:~/development/B2G$ ./repo diff

project gecko/
diff --git a/configure.in b/configure.in
index bc4d9e2..2ffde4e 100644
--- a/configure.in
+++ b/configure.in
@@ -3420,6 +3420,20 @@ done
 
 AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
 
+AC_CACHE_CHECK(for malloc_usable_size_const_ptr,
+               ac_cv_malloc_usable_size_const_ptr,
+               [AC_TRY_COMPILE([#include <malloc.h>
+                                #include <stddef.h>
+                                size_t malloc_usable_size(const void *ptr);],
+                               [],
+                               ac_cv_malloc_usable_size_const_ptr=yes,
+                               ac_cv_malloc_usable_size_const_ptr=no)])
+if test "$ac_cv_malloc_usable_size_const_ptr" = yes ; then
+  AC_DEFINE(MALLOC_USABLE_SIZE_CONST_PTR, [const])
+else
+  AC_DEFINE(MALLOC_USABLE_SIZE_CONST_PTR,)
+fi
+
 AC_CHECK_FUNCS(malloc_usable_size)
 
 dnl See if compiler supports some gcc-style attributes
diff --git a/memory/build/malloc_decls.h b/memory/build/malloc_decls.h
index e46cf59..ff33ec0 100644
--- a/memory/build/malloc_decls.h
+++ b/memory/build/malloc_decls.h
@@ -15,11 +15,7 @@
 
 #  include "jemalloc_types.h"
 
-#  if defined(__linux__) && (!defined(MOZ_MEMORY_ANDROID) || ANDROID_VERSION < 19)
-typedef void * usable_ptr_t;
-#  else
-typedef const void * usable_ptr_t;
-#  endif
+typedef MALLOC_USABLE_SIZE_CONST_PTR void * usable_ptr_t;
 
 #  define MALLOC_FUNCS_MALLOC 1
 #  define MALLOC_FUNCS_JEMALLOC 2
ignisvulpis@namenlos:~/development/B2G$ 

I think that the patch works with b2g too.
Duplicate of this bug: 1095091
(Reporter)

Comment 17

3 years ago
Silence on this bug for a week...

Could someone please set the status from unconfirmed to new? 

What about the claim that the patch (configure.in) is responsible for B2G bot build failures? 
I can build B2G on Ubuntu64 with the patch in place.

Is there a plan to update B2G/ndk to the latest ndk?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Created attachment 8544911 [details] [diff] [review]
malloc_usable_size.patch
Assignee: nobody → blassey.bugs
Attachment #8507166 - Attachment is obsolete: true
Attachment #8544911 - Flags: review?(mh+mozilla)
(Assignee)

Updated

3 years ago
tracking-fennec: --- → ?
Comment on attachment 8544911 [details] [diff] [review]
malloc_usable_size.patch

Review of attachment 8544911 [details] [diff] [review]:
-----------------------------------------------------------------

::: configure.in
@@ +3405,5 @@
>  AC_CHECK_FUNCS(strndup posix_memalign memalign)
>  
>  AC_CHECK_FUNCS(malloc_usable_size)
> +MALLOC_USABLE_SIZE_CONST_PTR=const
> +AC_CHECK_HEADERS([malloc.h], [

MOZ_CHECK_HEADERS

@@ +3411,5 @@
> +  AC_TRY_COMPILE([#include <malloc.h>
> +                  #include <stddef.h>
> +                  size_t malloc_usable_size(const void *ptr);],
> +                  [return malloc_usable_size(0);],
> +                  ,

AC_MSG_RESULT([yes]),

@@ +3412,5 @@
> +                  #include <stddef.h>
> +                  size_t malloc_usable_size(const void *ptr);],
> +                  [return malloc_usable_size(0);],
> +                  ,
> +                  MALLOC_USABLE_SIZE_CONST_PTR=)

AC_MSG_RESULT([no])

@@ +3414,5 @@
> +                  [return malloc_usable_size(0);],
> +                  ,
> +                  MALLOC_USABLE_SIZE_CONST_PTR=)
> +])
> +AC_DEFINE_UNQUOTED(MALLOC_USABLE_SIZE_CONST_PTR, $MALLOC_USABLE_SIZE_CONST_PTR)

AC_DEFINE_UNQUOTED([MALLOC_USABLE_SIZE_CONST_PTR], [$MALLOC_USABLE_SIZE_CONST_PTR])
Attachment #8544911 - Flags: review?(mh+mozilla) → review+
sorry had to back this out for bustage like https://treeherder.mozilla.org/logviewer.html#?job_id=5157727&repo=mozilla-inbound
Created attachment 8545635 [details] [diff] [review]
malloc_usable-win.patch
Attachment #8544911 - Attachment is obsolete: true
Attachment #8545635 - Flags: review?(mh+mozilla)
tracking-fennec: ? → +
https://hg.mozilla.org/projects/cypress/rev/3d587e85f2a2
https://hg.mozilla.org/projects/cypress/rev/127c5aadbddd
Comment on attachment 8545635 [details] [diff] [review]
malloc_usable-win.patch

Review of attachment 8545635 [details] [diff] [review]:
-----------------------------------------------------------------

::: memory/build/malloc_decls.h
@@ +15,4 @@
>  
>  #  include "jemalloc_types.h"
>  
> +#ifdef MALLOC_USABLE_SIZE_CONST_PTR

I'd rather go with
#ifndef MALLOC_USABLE_SIZE_CONST_PTR
#define MALLOC_USABLE_SIZE_CONST_PTR const
#endif

or move the configure test in a zone where windows builds run it (at least the AC_DEFINE_UNQUOTED and the default value, but it's better if the block stays together)
Attachment #8545635 - Flags: review?(mh+mozilla) → feedback+
Created attachment 8546628 [details] [diff] [review]
usable_malloc.patch
Attachment #8545635 - Attachment is obsolete: true
Attachment #8546628 - Flags: review?(mh+mozilla)
Attachment #8546628 - Flags: review?(mh+mozilla) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/bceadf54fee8
https://hg.mozilla.org/mozilla-central/rev/bceadf54fee8
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 37
You need to log in before you can comment on or make changes to this bug.