Bug 1368260 - Enable warnings-as-errors for embedjs.py. r=glandium
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Sat, 27 May 2017 22:38:43 +0900
changeset 410174 17c0e9c9698b4e79bb674bbf2aa2a7c9f83507d2
parent 410173 6fc608d6f3fdf0c8e8fa8301f01846a07b39d2c9
child 410175 1c58753cc0fa45dae47832c9f78f49f5efb72315
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1368260
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1368260 - Enable warnings-as-errors for embedjs.py. r=glandium js/src/builtin/Intl.js will spew three C4819 warnings every time non-Western developers build the tree locally on Windows because of non-ASCII characters in the file. Usually we have compilers use UTF-8 to prevent this, but it did not work for Intl.js because embedjs.py did not pass around $CPPFLAGS. --enable-warnings-as-errors did not catch this because embedjs.py did not pass around warnings-as-errors flags either. This patch will fix both issues. MozReview-Commit-ID: 5D1TCGnIX1T
js/src/builtin/embedjs.py
js/src/old-configure.in
old-configure.in
--- a/js/src/builtin/embedjs.py
+++ b/js/src/builtin/embedjs.py
@@ -73,19 +73,19 @@ namespace %(namespace)s {
 
     uint32_t GetRawScriptsSize() {
         return %(raw_total_length)i;
     }
 } // selfhosted
 } // js
 """
 
-def embed(cxx, preprocessorOption, msgs, sources, c_out, js_out, namespace, env):
+def embed(cxx, preprocessorOption, cppflags, msgs, sources, c_out, js_out, namespace, env):
   combinedSources = '\n'.join([msgs] + ['#include "%(s)s"' % { 's': source } for source in sources])
-  args = ['-D%(k)s=%(v)s' % { 'k': k, 'v': env[k] } for k in env]
+  args = cppflags + ['-D%(k)s=%(v)s' % { 'k': k, 'v': env[k] } for k in env]
   preprocessed = preprocess(cxx, preprocessorOption, combinedSources, args)
   processed = '\n'.join([line for line in preprocessed.splitlines() if \
                          (line.strip() and not line.startswith('#'))])
 
   js_out.write(processed)
   import zlib
   compressed = zlib.compress(processed)
   data = ToCArray(compressed)
@@ -138,22 +138,24 @@ def get_config_defines(buildconfig):
     env[define] = 1
   return env
 
 def process_inputs(namespace, c_out, msg_file, inputs):
   deps = [path for path in inputs if path.endswith(".h") or path.endswith(".h.js")]
   sources = [path for path in inputs if path.endswith(".js") and not path.endswith(".h.js")]
   assert len(deps) + len(sources) == len(inputs)
   cxx = shlex.split(buildconfig.substs['CXX'])
-  cxx_option = buildconfig.substs['PREPROCESS_OPTION']
+  pp_option = buildconfig.substs['PREPROCESS_OPTION']
+  cppflags = shlex.split(buildconfig.substs['OS_CPPFLAGS'])
+  cppflags += shlex.split(buildconfig.substs['WARNINGS_AS_ERRORS'])
   env = get_config_defines(buildconfig)
   js_path = re.sub(r"\.out\.h$", "", c_out.name) + ".js"
   msgs = messages(msg_file)
   with open(js_path, 'w') as js_out:
-    embed(cxx, cxx_option, msgs, sources, c_out, js_out, namespace, env)
+    embed(cxx, pp_option, cppflags, msgs, sources, c_out, js_out, namespace, env)
 
 def generate_selfhosted(c_out, msg_file, *inputs):
   # Called from moz.build to embed selfhosted JS.
   process_inputs('selfhosted', c_out, msg_file, inputs)
 
 def generate_shellmoduleloader(c_out, msg_file, *inputs):
   # Called from moz.build to embed shell module loader JS.
   process_inputs('moduleloader', c_out, msg_file, inputs)
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -140,18 +140,17 @@ case "$target" in
     if test "$GCC" != "yes"; then
         # Check to see if we are really running in a msvc environemnt
         _WIN32_MSVC=1
 
         # Make sure compilers are valid
         CFLAGS="$CFLAGS -TC -nologo"
         CXXFLAGS="$CXXFLAGS -TP -nologo"
         if test -z "$CLANG_CL"; then
-            CFLAGS="$CFLAGS -utf-8"
-            CXXFLAGS="$CXXFLAGS -utf-8"
+            CPPFLAGS="$CPPFLAGS -utf-8"
         fi
         # MSVC warning C4800 warns when a value is implicitly cast to bool,
         # because this also forces narrowing to a single byte, which can be a
         # perf hit.  But this matters so little in practice (and often we want
         # that behavior) that it's better to turn it off.
         # _CRT_SECURE_NO_WARNINGS disables warnings about using MSVC-specific
         # secure CRT functions.
         # MSVC warning C4595 warns non-member operator new or delete functions
--- a/old-configure.in
+++ b/old-configure.in
@@ -968,18 +968,17 @@ case "$target" in
         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
         _USE_CPP_INCLUDE_FLAG=1
         _DEFINES_CFLAGS='-FI $(topobjdir)/mozilla-config.h -DMOZILLA_CLIENT'
         _DEFINES_CXXFLAGS='-FI $(topobjdir)/mozilla-config.h -DMOZILLA_CLIENT'
         CFLAGS="$CFLAGS -W3 -Gy -Zc:inline"
         CXXFLAGS="$CXXFLAGS -W3 -Gy -Zc:inline"
         if test -z "$CLANG_CL"; then
-            CFLAGS="$CFLAGS -utf-8"
-            CXXFLAGS="$CXXFLAGS -utf-8"
+            CPPFLAGS="$CPPFLAGS -utf-8"
         fi
         if test "$CPU_ARCH" = "x86"; then
             dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
             dnl more recent, so set that explicitly here unless another
             dnl target arch has already been set.
             changequote(,)
             if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
               CFLAGS="$CFLAGS -arch:SSE2"