Closed Bug 681588 Opened 13 years ago Closed 13 years ago

Cleanup wrap malloc and its use on Android

Categories

(Firefox Build System :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla9

People

(Reporter: glandium, Assigned: glandium)

References

Details

(Whiteboard: fixed-in-bs)

Attachments

(2 files, 3 obsolete files)

There are various issues with how wrap malloc is being used, from the nonsense of the variable names to the lack of flags when building C programs. It also happens that android builds without jemalloc fail (and even if they wouldn't fail at build time, they'd fail at run time on devices without enough free space on the internal flash).
Depends on: 680373
This makes things clearer (IMHO), and fixes Android build without jemalloc.
Attachment #555354 - Flags: review?(ted.mielczarek)
Without the nspr part, and with a temporary workaround until the nspr part lands
Attachment #555368 - Flags: review?(ted.mielczarek)
Attachment #555354 - Attachment is obsolete: true
Attachment #555354 - Flags: review?(ted.mielczarek)
Assignee: nobody → mh+mozilla
Comment on attachment 555371 [details] [diff] [review]
Cleanup wrap malloc and its use on Android. NSPR part
[Checked in: Comment 8]

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

::: nsprpub/configure.in
@@ +3180,5 @@
> +        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
> +        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
> +        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=PR_Free,--wrap=PR_Malloc,--wrap=PR_Calloc,--wrap=PR_Realloc"
> +        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
> +        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"

Can you maybe do these as a heredoc or something?
WRAP_LDFLAGS=`cat<<EOF
${WRAP_LDFLAGS} ...
...
...
EOF`
?
Attachment #555371 - Flags: review?(ted.mielczarek) → review+
Comment on attachment 555368 [details] [diff] [review]
Cleanup wrap malloc and its use on Android

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

::: build/unix/elfhack/Makefile.in
@@ +74,5 @@
>    $(NULL)
>  
>  libs:: $(CSRCS:.c=.$(OBJ_SUFFIX))
>  
> +WRAP_FLAGS=

You probably meant WRAP_LDFLAGS= here, right?

::: configure.in
@@ +7473,5 @@
> +        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
> +        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
> +        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=PR_Free,--wrap=PR_Malloc,--wrap=PR_Calloc,--wrap=PR_Realloc"
> +        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
> +        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"

Same comment here as in the NSPR patch.

::: security/coreconf/OS2.mk
@@ +70,5 @@
>  HIGHMEM_LDFLAG          = -Zhigh-mem
>  endif
>  
>  ifndef NO_SHARED_LIB
> +WRAP_LDFLAGS            = 

This is an NSS file...
Attachment #555368 - Flags: review?(ted.mielczarek) → review+
(In reply to Ted Mielczarek [:ted, :luser] from comment #5)
> > +WRAP_FLAGS=
> 
> You probably meant WRAP_LDFLAGS= here, right?

Yes
 
> ::: security/coreconf/OS2.mk
> > +WRAP_LDFLAGS            = 
> 
> This is an NSS file...

Oops

(In reply to Ted Mielczarek [:ted, :luser] from comment #4)
> Comment on attachment 555371 [details] [diff] [review]
> Cleanup wrap malloc and its use on Android. NSPR part
> 
> Review of attachment 555371 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: nsprpub/configure.in
> @@ +3180,5 @@
> > +        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
> > +        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
> > +        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=PR_Free,--wrap=PR_Malloc,--wrap=PR_Calloc,--wrap=PR_Realloc"
> > +        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
> > +        WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
> 
> Can you maybe do these as a heredoc or something?
> WRAP_LDFLAGS=`cat<<EOF
> ${WRAP_LDFLAGS} ...
> ...
> ...
> EOF`
> ?

Putting it on several lines doesn't work because the variable then contains newlines, and that messes up the sed used to generate autoconf.mk.
  WRAP_LDFLAGS=`cat <<EOF | xargs echo
  ${WRAP_LDFLAGS}
  ...
  ...
EOF`

would work, but it's somehow ugly, isn't it? Plus the EOF needs not to be indented. Except if we do
    WRAP_LDFLAGS=`cat <<"    EOF" | xargs echo
    ...
    EOF
Without the typo and the nss file.
Attachment #555368 - Attachment is obsolete: true
Checking in configure;
/cvsroot/mozilla/nsprpub/configure,v  <--  configure
new revision: 1.313; previous revision: 1.312
done
Checking in configure.in;
/cvsroot/mozilla/nsprpub/configure.in,v  <--  configure.in
new revision: 1.315; previous revision: 1.314
done
Checking in config/autoconf.mk.in;
/cvsroot/mozilla/nsprpub/config/autoconf.mk.in,v  <--  autoconf.mk.in
new revision: 1.45; previous revision: 1.44
done
Checking in config/rules.mk;
/cvsroot/mozilla/nsprpub/config/rules.mk,v  <--  rules.mk
new revision: 3.84; previous revision: 3.83
done
Checking in lib/tests/Makefile.in;
/cvsroot/mozilla/nsprpub/lib/tests/Makefile.in,v  <--  Makefile.in
new revision: 1.25; previous revision: 1.24
done
Checking in pr/tests/Makefile.in;
/cvsroot/mozilla/nsprpub/pr/tests/Makefile.in,v  <--  Makefile.in
new revision: 1.68; previous revision: 1.67
done
And without the nspr workaround
Attachment #556589 - Attachment is obsolete: true
http://hg.mozilla.org/mozilla-central/rev/cf4d258fd0f6
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla9
Attachment #555371 - Attachment description: Cleanup wrap malloc and its use on Android. NSPR part → Cleanup wrap malloc and its use on Android. NSPR part [Checked in: Comment 8]
Attachment #556595 - Attachment description: Cleanup wrap malloc and its use on Android. → Cleanup wrap malloc and its use on Android [Checked in: Comment 11]
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: