Bug 1262241 - Move the definition of the js library to a subdirectory. r=mshal
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 04 Apr 2017 11:43:14 +0900
changeset 390179 2159959522f4180bdca483162c9134beb108575a
parent 390178 a0201cb01a56a5a42b73dc8fcc38fc7dc6fe38e5
child 390180 28f8a3519d733370c1f6a848a243f05ade19663d
push id4
push userbugmail@asutherland.org
push dateMon, 26 Jun 2017 06:55:04 +0000
reviewersmshal
bugs1262241
milestone55.0a1
Bug 1262241 - Move the definition of the js library to a subdirectory. r=mshal Also move some related files and rules used for `make install`. Also move the js directory up in the top-level directory, so that the linking order for the js library stays the same (fdlibm and ffi going after the js engine objects) This has the side effect of moving js/src/target very early in the compilation tier.
js/src/Makefile.in
js/src/build.rs
js/src/build/Makefile.in
js/src/build/js-config.in
js/src/build/js.pc.in
js/src/build/moz.build
js/src/build/symverscript.in
js/src/js-config.in
js/src/js.pc.in
js/src/moz.build
js/src/symverscript.in
moz.build
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -13,46 +13,18 @@ ifneq ($(make_min_ver),$(firstword $(sor
 endif
 
 DASH_R		= -r
 
 # Define keyword generator before rules.mk, see bug 323979 comment 50
 
 USE_HOST_CXX = 1
 
-# Ensure symbol versions of shared library on Linux do not conflict
-# with those in libxul.
-ifeq (Linux,$(OS_TARGET))
-OS_LDFLAGS += -Wl,-version-script,symverscript
-
-symverscript: symverscript.in
-	$(call py_action,preprocessor, \
-		-DVERSION='$(subst -,_,$(LIBRARY_NAME))' $< -o $@)
-
-EXTRA_DEPS += symverscript
-endif
-
 include $(topsrcdir)/config/rules.mk
 
-# check_vanilla_allocations.py is tailored to Linux, so only run it there.
-# That should be enough to catch any problems.
-check-vanilla-allocations:
-	$(PYTHON) $(topsrcdir)/config/check_vanilla_allocations.py $(REAL_LIBRARY)
-
-# The "aggressive" variant will likely fail on some compiler/platform
-# combinations, but is worth running by hand every once in a while.
-check-vanilla-allocations-aggressive:
-	$(PYTHON) $(topsrcdir)/config/check_vanilla_allocations.py --aggressive $(REAL_LIBRARY)
-
-ifeq ($(OS_ARCH),Linux)
-ifeq (,$(filter -flto,$(CFLAGS) $(CXXFLAGS) $(LDFLAGS)))
-check:: check-vanilla-allocations
-endif
-endif
-
 # Help ensure that the number of OOM errors in SpiderMonkey doesn't increase.
 # If the number of OOM errors changes, update the number below. We intend this
 # number to go down over time, by fixing OOMs.
 check-ooms:
 	$(wildcard $(RUN_TEST_PROGRAM)) $(PYTHON) -u $(topsrcdir)/config/find_OOM_errors.py --regression 125
 
 ifeq ($(MOZ_DEBUG),1)
 #check:: check-ooms
@@ -157,72 +129,18 @@ ifeq ($(TARGET_CPU),sparc)
 ifdef GNU_CC
 CFLAGS   += -mcpu=v9
 CXXFLAGS += -mcpu=v9
 endif # GNU_CC
 
 endif
 endif
 
-SCRIPTS = $(JS_CONFIG_NAME)
-
-$(LIBRARY_NAME).pc: js.pc
-	cp $^ $@
-
-install:: $(LIBRARY_NAME).pc
-	$(SYSINSTALL) $^ $(DESTDIR)$(libdir)/pkgconfig
-
-install:: js-config.h
-	$(SYSINSTALL) $^ $(DESTDIR)$(includedir)
-
-######################################################
-# BEGIN SpiderMonkey header installation
-#
-# Mozilla/Gecko/Firefox mostly doesn't concern itself with defining a sensible
-# install target, because it's shipping primarily packaged builds.  And even if
-# it did, those builds wouldn't really have reason to include header files.  So
-# we have to install public headers ourselves, rather than using something from
-# config/rules.mk or similar.
-#
-# The overall directory structure of the installed headers looks like so:
-#
-#   $(includedir)/
-#      $(LIBRARY_NAME)/
-#        jsapi.h, jspubtd.h, etc. (all of EXPORTS)
-#        js/
-#          js/public/* headers (all are public)
-#        ds/
-#          js/src/ds/* public headers
-#        gc/
-#          js/src/gc/* public headers
-#        mozilla/
-#          mfbt headers
-#
-
 install::
-	$(call py_action,process_install_manifest,--no-remove --no-symlinks $(DESTDIR)$(includedir) $(DEPTH)/_build_manifests/install/dist_include)
-
-#
-# END SpiderMonkey header installation
-#############################################
-
-install:: $(SCRIPTS)
-	$(SYSINSTALL) $^ $(DESTDIR)$(bindir)
-
-install:: $(REAL_LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY)
-ifneq (,$(REAL_LIBRARY))
-	$(SYSINSTALL) $(REAL_LIBRARY) $(DESTDIR)$(libdir)
-	mv -f $(DESTDIR)$(libdir)/$(REAL_LIBRARY) $(subst $(STATIC_LIBRARY_NAME),$(LIBRARY_NAME),$(DESTDIR)$(libdir)/$(REAL_LIBRARY))
-endif
-ifneq (,$(SHARED_LIBRARY))
-	$(SYSINSTALL) $(SHARED_LIBRARY) $(DESTDIR)$(libdir)
-endif
-ifneq (,$(IMPORT_LIBRARY))
-	$(SYSINSTALL) $(IMPORT_LIBRARY) $(DESTDIR)$(libdir)
-endif
+	$(MAKE) -C build install
 	$(MAKE) -C shell install
 
 ifdef HAVE_DTRACE
 javascript-trace.h: $(srcdir)/devtools/javascript-trace.d
 	dtrace -x nolibs -h -s $(srcdir)/devtools/javascript-trace.d -o javascript-trace.h.in
 	sed -e 's/if _DTRACE_VERSION/ifdef INCLUDE_MOZILLA_DTRACE/' \
 	    -e '/const/!s/char \*/const char */g' \
 	    javascript-trace.h.in > javascript-trace.h
--- a/js/src/build.rs
+++ b/js/src/build.rs
@@ -31,17 +31,17 @@ fn main() {
         .stdout(Stdio::inherit())
         .stderr(Stdio::inherit());
     println!("Running command: {:?}", cmd);
     let result = cmd
         .status()
         .expect("Should spawn autospider OK");
     assert!(result.success(), "autospider should exit OK");
 
-    println!("cargo:rustc-link-search=native={}/js/src", out_dir);
+    println!("cargo:rustc-link-search=native={}/js/src/build", out_dir);
 
     if target.contains("windows") {
         println!("cargo:rustc-link-lib=winmm");
         if target.contains("gnu") {
             println!("cargo:rustc-link-lib=stdc++");
         }
     } else {
         println!("cargo:rustc-link-lib=stdc++");
new file mode 100644
--- /dev/null
+++ b/js/src/build/Makefile.in
@@ -0,0 +1,92 @@
+# -*- Mode: makefile -*-
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# Ensure symbol versions of shared library on Linux do not conflict
+# with those in libxul.
+ifeq (Linux,$(OS_TARGET))
+OS_LDFLAGS += -Wl,-version-script,symverscript
+
+symverscript: symverscript.in
+	$(call py_action,preprocessor, \
+		-DVERSION='$(subst -,_,$(LIBRARY_NAME))' $< -o $@)
+
+EXTRA_DEPS += symverscript
+endif
+
+include $(topsrcdir)/config/rules.mk
+
+# check_vanilla_allocations.py is tailored to Linux, so only run it there.
+# That should be enough to catch any problems.
+check-vanilla-allocations:
+	$(PYTHON) $(topsrcdir)/config/check_vanilla_allocations.py $(REAL_LIBRARY)
+
+# The "aggressive" variant will likely fail on some compiler/platform
+# combinations, but is worth running by hand every once in a while.
+check-vanilla-allocations-aggressive:
+	$(PYTHON) $(topsrcdir)/config/check_vanilla_allocations.py --aggressive $(REAL_LIBRARY)
+
+ifeq ($(OS_ARCH),Linux)
+ifeq (,$(filter -flto,$(CFLAGS) $(CXXFLAGS) $(LDFLAGS)))
+check:: check-vanilla-allocations
+endif
+endif
+
+SCRIPTS = $(JS_CONFIG_NAME)
+
+$(LIBRARY_NAME).pc: js.pc
+	cp $^ $@
+
+install:: $(LIBRARY_NAME).pc
+	$(SYSINSTALL) $^ $(DESTDIR)$(libdir)/pkgconfig
+
+install:: ../js-config.h
+	$(SYSINSTALL) $^ $(DESTDIR)$(includedir)
+
+######################################################
+# BEGIN SpiderMonkey header installation
+#
+# Mozilla/Gecko/Firefox mostly doesn't concern itself with defining a sensible
+# install target, because it's shipping primarily packaged builds.  And even if
+# it did, those builds wouldn't really have reason to include header files.  So
+# we have to install public headers ourselves, rather than using something from
+# config/rules.mk or similar.
+#
+# The overall directory structure of the installed headers looks like so:
+#
+#   $(includedir)/
+#      $(LIBRARY_NAME)/
+#        jsapi.h, jspubtd.h, etc. (all of EXPORTS)
+#        js/
+#          js/public/* headers (all are public)
+#        ds/
+#          js/src/ds/* public headers
+#        gc/
+#          js/src/gc/* public headers
+#        mozilla/
+#          mfbt headers
+#
+
+install::
+	$(call py_action,process_install_manifest,--no-remove --no-symlinks $(DESTDIR)$(includedir) $(DEPTH)/_build_manifests/install/dist_include)
+
+#
+# END SpiderMonkey header installation
+#############################################
+
+install:: $(SCRIPTS)
+	$(SYSINSTALL) $^ $(DESTDIR)$(bindir)
+
+install:: $(REAL_LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY)
+ifneq (,$(REAL_LIBRARY))
+	$(SYSINSTALL) $(REAL_LIBRARY) $(DESTDIR)$(libdir)
+	mv -f $(DESTDIR)$(libdir)/$(REAL_LIBRARY) $(subst $(STATIC_LIBRARY_NAME),$(LIBRARY_NAME),$(DESTDIR)$(libdir)/$(REAL_LIBRARY))
+endif
+ifneq (,$(SHARED_LIBRARY))
+	$(SYSINSTALL) $(SHARED_LIBRARY) $(DESTDIR)$(libdir)
+endif
+ifneq (,$(IMPORT_LIBRARY))
+	$(SYSINSTALL) $(IMPORT_LIBRARY) $(DESTDIR)$(libdir)
+endif
rename from js/src/js-config.in
rename to js/src/build/js-config.in
rename from js/src/js.pc.in
rename to js/src/build/js.pc.in
new file mode 100644
--- /dev/null
+++ b/js/src/build/moz.build
@@ -0,0 +1,77 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+CONFIGURE_SUBST_FILES += [
+    'js-config',
+    'js.pc',
+]
+
+if not CONFIG['JS_STANDALONE']:
+    LIBRARY_DEFINES['MOZ_HAS_MOZGLUE'] = True
+
+# JavaScript must be built shared, even for static builds, as it is used by
+# other modules which are always built shared. Failure to do so results in
+# the js code getting copied into xpinstall and jsd as well as mozilla-bin,
+# and then the static data cells used for locking no longer work.
+#
+# In fact, we now build both a static and a shared library, as the
+# JS shell would like to link to the static library.
+
+if CONFIG['JS_SHARED_LIBRARY']:
+    GeckoSharedLibrary('js', linkage=None)
+    SHARED_LIBRARY_NAME = CONFIG['JS_LIBRARY_NAME']
+else:
+    Library('js')
+
+FORCE_STATIC_LIB = True
+STATIC_LIBRARY_NAME = 'js_static'
+
+if CONFIG['ENABLE_INTL_API']:
+    if not CONFIG['MOZ_ICU_DATA_ARCHIVE']:
+        USE_LIBS += [
+            'icu',
+        ]
+    else:
+        # Linking 'icu' will pull in the stubdata library,
+        # which the shell doesn't want, so link the other bits.
+        USE_LIBS += [
+            'icui18n',
+            'icuuc',
+        ]
+
+USE_LIBS += [
+    'nspr',
+    'zlib',
+]
+
+if CONFIG['OS_ARCH'] not in ('WINNT', 'HP-UX'):
+    OS_LIBS += [
+        'm',
+    ]
+
+if CONFIG['OS_ARCH'] == 'FreeBSD':
+    OS_LIBS += [
+        '-pthread',
+    ]
+
+if CONFIG['OS_ARCH'] == 'Linux':
+    OS_LIBS += [
+        'dl',
+    ]
+
+if CONFIG['OS_ARCH'] == 'SunOS':
+    OS_LIBS += [
+        'posix4',
+        'dl',
+        'nsl',
+        'socket',
+    ]
+
+OS_LIBS += CONFIG['REALTIME_LIBS']
+
+NO_EXPAND_LIBS = True
+
+DIST_INSTALL = True
rename from js/src/symverscript.in
rename to js/src/build/symverscript.in
--- a/js/src/moz.build
+++ b/js/src/moz.build
@@ -47,26 +47,22 @@ if CONFIG['JS_BUNDLED_EDITLINE']:
 
 if not CONFIG['JS_DISABLE_SHELL']:
     DIRS += ['shell']
 
 TEST_DIRS += ['jsapi-tests', 'tests', 'gdb']
 
 CONFIGURE_SUBST_FILES += [
     'devtools/rootAnalysis/Makefile',
-    'js-config',
-    'js.pc',
 ]
 CONFIGURE_DEFINE_FILES += [
     'js-confdefs.h',
 ]
 
 if not CONFIG['JS_STANDALONE']:
-    LIBRARY_DEFINES['MOZ_HAS_MOZGLUE'] = True
-
     CONFIGURE_SUBST_FILES += [
         '../../config/autoconf-js.mk',
         '../../config/emptyvars-js.mk',
     ]
 
 CONFIGURE_DEFINE_FILES += [
     'js-config.h',
 ]
@@ -627,50 +623,21 @@ else:
 
 GENERATED_FILES += ['frontend/ReservedWordsGenerated.h']
 ReservedWordsGenerated = GENERATED_FILES['frontend/ReservedWordsGenerated.h']
 ReservedWordsGenerated.script = 'frontend/GenerateReservedWords.py'
 ReservedWordsGenerated.inputs += [
     'frontend/ReservedWords.h'
 ]
 
-# JavaScript must be built shared, even for static builds, as it is used by
-# other modules which are always built shared. Failure to do so results in
-# the js code getting copied into xpinstall and jsd as well as mozilla-bin,
-# and then the static data cells used for locking no longer work.
-#
-# In fact, we now build both a static and a shared library, as the
-# JS shell would like to link to the static library.
-
-if CONFIG['JS_SHARED_LIBRARY']:
-    GeckoSharedLibrary('js', linkage=None)
-    SHARED_LIBRARY_NAME = CONFIG['JS_LIBRARY_NAME']
-else:
-    Library('js')
-
-FORCE_STATIC_LIB = True
-STATIC_LIBRARY_NAME = 'js_static'
+DIRS += [
+    'build',
+]
 
-if CONFIG['ENABLE_INTL_API']:
-    if not CONFIG['MOZ_ICU_DATA_ARCHIVE']:
-        USE_LIBS += [
-            'icu',
-        ]
-    else:
-        # Linking 'icu' will pull in the stubdata library,
-        # which the shell doesn't want, so link the other bits.
-        USE_LIBS += [
-            'icui18n',
-            'icuuc',
-        ]
-
-USE_LIBS += [
-    'nspr',
-    'zlib',
-]
+FINAL_LIBRARY = 'js'
 
 if CONFIG['NIGHTLY_BUILD']:
     DEFINES['ENABLE_BINARYDATA'] = True
 
 if CONFIG['NIGHTLY_BUILD']:
     DEFINES['ENABLE_SIMD'] = True
 
 # Also set in shell/moz.build
@@ -707,48 +674,19 @@ if CONFIG['_MSC_VER']:
     CXXFLAGS += ['-wd4146'] # FIXME: unary minus operator applied to unsigned type (bug 1229189)
 
     # This is intended as a temporary hack to support building with VS2015.
     # 'noexcept' used with no exception handling mode specified;
     # termination on exception is not guaranteed. Specify /EHsc
     CXXFLAGS += ['-wd4577']
     CXXFLAGS += ['-wd4312']
 
-if CONFIG['OS_ARCH'] not in ('WINNT', 'HP-UX'):
-    OS_LIBS += [
-        'm',
-    ]
-
-if CONFIG['OS_ARCH'] == 'FreeBSD':
-    OS_LIBS += [
-        '-pthread',
-    ]
-
-if CONFIG['OS_ARCH'] == 'Linux':
-    OS_LIBS += [
-        'dl',
-    ]
-
-if CONFIG['OS_ARCH'] == 'SunOS':
-    OS_LIBS += [
-        'posix4',
-        'dl',
-        'nsl',
-        'socket',
-    ]
-
-OS_LIBS += CONFIG['REALTIME_LIBS']
-
 CFLAGS += CONFIG['MOZ_ICU_CFLAGS']
 CXXFLAGS += CONFIG['MOZ_ICU_CFLAGS']
 
-NO_EXPAND_LIBS = True
-
-DIST_INSTALL = True
-
 # Prepare self-hosted JS code for embedding
 GENERATED_FILES += [('selfhosted.out.h', 'selfhosted.js')]
 selfhosted = GENERATED_FILES[('selfhosted.out.h', 'selfhosted.js')]
 selfhosted.script = 'builtin/embedjs.py:generate_selfhosted'
 selfhosted.inputs = [
     'js.msg',
     'builtin/TypedObjectConstants.h',
     'builtin/SelfHostingDefines.h',
--- a/moz.build
+++ b/moz.build
@@ -90,43 +90,44 @@ if not CONFIG['JS_STANDALONE']:
     GENERATED_FILES['buildid.h'].script = 'build/variables.py:buildid_header'
     GENERATED_FILES['source-repo.h'].script = 'build/variables.py:source_repo_header'
 
     DIRS += [
         'build',
         'probes',
     ]
 
+if CONFIG['COMPILE_ENVIRONMENT']:
+    DIRS += ['js/src']
+
 DIRS += [
     'config/external/fdlibm',
     'config/external/nspr',
     'config/external/zlib',
     'memory',
     'mfbt',
     'mozglue',
 ]
 
 if not CONFIG['JS_STANDALONE']:
     DIRS += ['xpcom/xpidl']
 
 if CONFIG['USE_ICU']:
     DIRS += ['config/external/icu']
 
 if CONFIG['COMPILE_ENVIRONMENT']:
-
     if not CONFIG['JS_STANDALONE']:
         DIRS += [
             'config/external',
             'security',
         ]
 
     if CONFIG['BUILD_CTYPES']:
         DIRS += ['config/external/ffi']
 
-    DIRS += ['js/src']
 else:
     TEST_DIRS += ['js/src/tests']
 
 if not CONFIG['JS_STANDALONE'] and CONFIG['MOZ_BUILD_APP']:
     # Bring in the configuration for the configured application.
     include('/' + CONFIG['MOZ_BUILD_APP'] + '/app.mozbuild')
 
 CONFIGURE_SUBST_FILES += ['.cargo/config']