Bug 1277338 - Part 7: Export mozglue when JS_STANDALONE && !jemalloc; r=glandium,sfink

This makes sure that:

* We don't define `MOZ_GLUE_IN_PROGRAM` so that everything in mozglue gets
  defined.

* `MFBT_API`'s symbol export rules match `JS_PUBLIC_API` and `EXPORT_JS_API`.

* We add mozglue to SpiderMonkey's `USE_LIBS` when jemalloc is disabled.
This commit is contained in:
Nick Fitzgerald 2017-08-31 15:59:13 -07:00
parent bbe9f20f84
commit 9da40f6365
6 changed files with 56 additions and 26 deletions

View file

@ -128,6 +128,12 @@ def main():
continue
filename = m.group(1)
# mozalloc contains calls to memalign. These are ok, so we whitelist
# them.
if "mozalloc" in filename:
continue
fn = m.group(2)
if filename == 'jsutil.o':
jsutil_cpp.add(fn)
@ -188,4 +194,3 @@ def main():
if __name__ == '__main__':
main()

View file

@ -22,12 +22,11 @@ option(env='JS_STANDALONE', default=building_js,
def js_standalone(value):
if value:
return True
set_config('JS_STANDALONE', js_standalone)
set_define('JS_STANDALONE', js_standalone)
add_old_configure_assignment('JS_STANDALONE', js_standalone)
js_option('--disable-js-shell', default=building_js,
help='Do not build the JS shell')
help='Do not build the JS shell')
@depends('--disable-js-shell')
def js_disable_shell(value):

View file

@ -25,7 +25,12 @@ fn main() {
let python = env::var("PYTHON").unwrap_or("python2.7".into());
let mut cmd = Command::new(&python);
cmd.args(&["./devtools/automation/autospider.py",
// Only build SpiderMonkey, don't run all the tests.
"--build-only",
// Disable Mozilla's jemalloc; Rust has its own jemalloc that we
// can swap in instead and everything using a single malloc is
// good.
"--no-jemalloc",
"--objdir", &out_dir,
variant])
.env("SOURCE", &js_src)

View file

@ -61,6 +61,14 @@ group.add_argument('--no-debug', action='store_false',
dest='debug',
help='generate a non-debug build. Overrides variant setting.')
group.set_defaults(debug=None)
group = parser.add_mutually_exclusive_group()
group.add_argument('--jemalloc', action='store_true',
dest='jemalloc',
help='use mozilla\'s jemalloc instead of the default allocator')
group.add_argument('--no-jemalloc', action='store_false',
dest='jemalloc',
help='use the default allocator instead of mozilla\'s jemalloc')
group.set_defaults(jemalloc=None)
parser.add_argument('--run-tests', '--tests', type=str, metavar='TESTSUITE',
default='',
help="comma-separated set of test suites to add to the variant's default set")
@ -176,6 +184,10 @@ if opt is None:
if opt is not None:
CONFIGURE_ARGS += (" --enable-debug" if opt else " --disable-debug")
opt = args.jemalloc
if opt is not None:
CONFIGURE_ARGS += (" --enable-jemalloc" if opt else " --disable-jemalloc")
# Any jobs that wish to produce additional output can save them into the upload
# directory if there is such a thing, falling back to OBJDIR.
env.setdefault('MOZ_UPLOAD_DIR', OBJDIR)

View file

@ -1495,16 +1495,20 @@ dnl ========================================================
dnl = Enable jemalloc
dnl ========================================================
case "${OS_TARGET}" in
Android|WINNT|Darwin)
if test "$JS_STANDALONE" -a -z "$MOZ_MEMORY"; then
MOZ_GLUE_IN_PROGRAM=
;;
*)
dnl On !Android !Windows !OSX, we only want to link executables against mozglue
MOZ_GLUE_IN_PROGRAM=1
AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
;;
esac
else
case "${OS_TARGET}" in
Android|WINNT|Darwin)
MOZ_GLUE_IN_PROGRAM=
;;
*)
dnl On !Android !Windows !OSX, we only want to link executables against mozglue
MOZ_GLUE_IN_PROGRAM=1
AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
;;
esac
fi
if test "$MOZ_MEMORY"; then
dnl The generic feature tests that determine how to compute ncpus are long and

View file

@ -78,23 +78,28 @@
* export mfbt declarations when building mfbt, and they expose import mfbt
* declarations when using mfbt.
*/
#if defined(IMPL_MFBT)
#if defined(IMPL_MFBT) || (defined(JS_STANDALONE) && !defined(MOZ_MEMORY) && (defined(EXPORT_JS_API) || defined(STATIC_EXPORTABLE_JS_API)))
# define MFBT_API MOZ_EXPORT
# define MFBT_DATA MOZ_EXPORT
#else
/*
* On linux mozglue is linked in the program and we link libxul.so with
* -z,defs. Normally that causes the linker to reject undefined references in
* libxul.so, but as a loophole it allows undefined references to weak
* symbols. We add the weak attribute to the import version of the MFBT API
* macros to exploit this.
*/
# if defined(MOZ_GLUE_IN_PROGRAM)
# define MFBT_API __attribute__((weak)) MOZ_IMPORT_API
# define MFBT_DATA __attribute__((weak)) MOZ_IMPORT_DATA
# if defined(JS_STANDALONE) && !defined(MOZ_MEMORY) && defined(STATIC_JS_API)
# define MFBT_API
# define MFBT_DATA
# else
# define MFBT_API MOZ_IMPORT_API
# define MFBT_DATA MOZ_IMPORT_DATA
/*
* On linux mozglue is linked in the program and we link libxul.so with
* -z,defs. Normally that causes the linker to reject undefined references in
* libxul.so, but as a loophole it allows undefined references to weak
* symbols. We add the weak attribute to the import version of the MFBT API
* macros to exploit this.
*/
# if defined(MOZ_GLUE_IN_PROGRAM)
# define MFBT_API __attribute__((weak)) MOZ_IMPORT_API
# define MFBT_DATA __attribute__((weak)) MOZ_IMPORT_DATA
# else
# define MFBT_API MOZ_IMPORT_API
# define MFBT_DATA MOZ_IMPORT_DATA
# endif
# endif
#endif