1 From: Jens Lody <fedora@jenslody.de>
2 Date: Thu, 16 Feb 2017 09:31:56 +0100
3 Subject: Backport of fix for mozilla-bug 1269171, needed for gcc7.
5 diff --git a/mozilla/config/gcc-stl-wrapper.template.h b/mozilla/config/gcc-stl-wrapper.template.h
6 --- a/mozilla/config/gcc-stl-wrapper.template.h
7 +++ b/mozilla/config/gcc-stl-wrapper.template.h
9 // Silence "warning: #include_next is a GCC extension"
10 #pragma GCC system_header
12 -// mozalloc.h wants <new>; break the cycle by always explicitly
13 -// including <new> here. NB: this is a tad sneaky. Sez the gcc docs:
15 -// `#include_next' does not distinguish between <file> and "file"
16 -// inclusion, nor does it check that the file you specify has the
17 -// same name as the current file. It simply looks for the file
18 -// named, starting with the directory in the search path after the
19 -// one where the current file was found.
22 -// See if we're in code that can use mozalloc. NB: this duplicates
23 -// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
24 -// can't build with that being included before base/basictypes.h.
25 -#if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
26 -# include "mozilla/mozalloc.h"
28 -# error "STL code can only be used with infallible ::operator new()"
31 #if defined(DEBUG) && !defined(_GLIBCXX_DEBUG)
32 // Enable checked iterators and other goodies
35 // # define _GLIBCXX_DEBUG 1
38 +// Don't include mozalloc for cstdlib. See bug 1245076.
39 +#ifndef moz_dont_include_mozalloc_for_cstdlib
40 +# define moz_dont_include_mozalloc_for_cstdlib
43 +// Include mozalloc after the STL header and all other headers it includes
44 +// have been preprocessed.
45 +#if !defined(MOZ_INCLUDE_MOZALLOC_H) && \
46 + !defined(moz_dont_include_mozalloc_for_${HEADER})
47 +# define MOZ_INCLUDE_MOZALLOC_H
48 +# define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
51 #pragma GCC visibility push(default)
52 #include_next <${HEADER}>
53 #pragma GCC visibility pop
55 +#ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
56 +// See if we're in code that can use mozalloc. NB: this duplicates
57 +// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
58 +// can't build with that being included before base/basictypes.h.
59 +# if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
60 +# include "mozilla/mozalloc.h"
62 +# error "STL code can only be used with infallible ::operator new()"
66 // gcc calls a __throw_*() function from bits/functexcept.h when it
67 // wants to "throw an exception". functexcept exists nominally to
68 // support -fno-exceptions, but since we'll always use the system
69 --- a/mozilla/config/make-stl-wrappers.py
70 +++ b/mozilla/config/make-stl-wrappers.py
71 @@ -25,28 +25,26 @@ def header_path(header, compiler):
73 return re.match(r'\s*#.*', line)
75 def main(outdir, compiler, template_file, header_list_file):
76 if not os.path.isdir(outdir):
79 template = open(template_file, 'r').read()
80 - path_to_new = header_path('new', compiler)
82 for header in open(header_list_file, 'r'):
83 header = header.rstrip()
84 if 0 == len(header) or is_comment(header):
87 path = header_path(header, compiler)
88 with FileAvoidWrite(os.path.join(outdir, header)) as f:
89 f.write(string.Template(template).substitute(HEADER=header,
91 - NEW_HEADER_PATH=path_to_new))
95 if __name__ == '__main__':
96 if 5 != len(sys.argv):
98 python {0} OUT_DIR ('msvc'|'gcc') TEMPLATE_FILE HEADER_LIST_FILE
99 """.format(sys.argv[0]), file=sys.stderr)
101 diff --git a/mozilla/config/msvc-stl-wrapper.template.h b/mozilla/config/msvc-stl-wrapper.template.h
102 --- a/mozilla/config/msvc-stl-wrapper.template.h
103 +++ b/mozilla/config/msvc-stl-wrapper.template.h
106 /* This Source Code Form is subject to the terms of the Mozilla Public
107 * License, v. 2.0. If a copy of the MPL was not distributed with this
108 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
110 #ifndef mozilla_${HEADER}_h
111 #define mozilla_${HEADER}_h
113 -#ifndef MOZ_HAVE_INCLUDED_ALLOC
114 -#define MOZ_HAVE_INCLUDED_ALLOC
117 # error "STL code can only be used with -fno-exceptions"
120 +// Include mozalloc after the STL header and all other headers it includes
121 +// have been preprocessed.
122 +#if !defined(MOZ_INCLUDE_MOZALLOC_H)
123 +# define MOZ_INCLUDE_MOZALLOC_H
124 +# define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
127 // Code built with !_HAS_EXCEPTIONS calls std::_Throw(), but the win2k
128 // CRT doesn't export std::_Throw(). So we define it.
129 #ifndef mozilla_Throw_h
130 # include "mozilla/throw_msvc.h"
133 -// Code might include <new> before other wrapped headers, but <new>
134 -// includes <exception> and so we want to wrap it. But mozalloc.h
135 -// wants <new> also, so we break the cycle by always explicitly
136 -// including <new> here.
137 -#include <${NEW_HEADER_PATH}>
139 -// See if we're in code that can use mozalloc. NB: this duplicates
140 -// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
141 -// can't build with that being included before base/basictypes.h.
142 -#if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
143 -# include "mozilla/mozalloc.h"
145 -# error "STL code can only be used with infallible ::operator new()"
147 -#endif /* MOZ_HAVE_INCLUDED_ALLOC */
151 // http://msdn.microsoft.com/en-us/library/aa985982%28VS.80%29.aspx
153 // http://msdn.microsoft.com/en-us/library/aa985965%28VS.80%29.aspx
154 // there appear to be two types of STL container checking. The
155 // former is enabled by -D_DEBUG (which is implied by -MDd or -MTd), and
156 // looks to be full generation/mutation checked iterators as done by
158 // but that's OK because we're not throwing them.
159 #pragma warning( push )
160 #pragma warning( disable : 4275 4530 )
162 #include <${HEADER_PATH}>
164 #pragma warning( pop )
166 +#ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
167 +// See if we're in code that can use mozalloc. NB: this duplicates
168 +// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
169 +// can't build with that being included before base/basictypes.h.
170 +# if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
171 +# include "mozilla/mozalloc.h"
173 +# error "STL code can only be used with infallible ::operator new()"
177 #endif // if mozilla_${HEADER}_h
178 diff --git a/mozilla/memory/mozalloc/mozalloc.h b/mozilla/memory/mozalloc/mozalloc.h
179 --- a/mozilla/memory/mozalloc/mozalloc.h
180 +++ b/mozilla/memory/mozalloc/mozalloc.h
183 #ifndef mozilla_mozalloc_h
184 #define mozilla_mozalloc_h
187 * https://bugzilla.mozilla.org/show_bug.cgi?id=427099
192 #if defined(__cplusplus)
194 +// Since libstdc++ 6, including the C headers (e.g. stdlib.h) instead of the
195 +// corresponding C++ header (e.g. cstdlib) can cause confusion in C++ code
196 +// using things defined there. Specifically, with stdlib.h, the use of abs()
197 +// in gfx/graphite2/src/inc/UtfCodec.h somehow ends up picking the wrong abs()
201 +# include <stdlib.h>
202 +# include <string.h>
205 #if defined(__cplusplus)
206 #include "mozilla/fallible.h"
207 #include "mozilla/TemplateLib.h"
209 #include "mozilla/Attributes.h"
210 #include "mozilla/Types.h"