From 90cdbfa41ddd48bff32d8e460fb34ac42d4e290c Mon Sep 17 00:00:00 2001 From: Jan Horak Date: Thu, 1 Jun 2017 15:20:24 +0200 Subject: [PATCH] Fixed xulrunner build problems with stl headers --- build-stl-headers-fix-mbz1269171.patch | 169 +++++++++++++++++++++++++ xulrunner.spec | 2 + 2 files changed, 171 insertions(+) create mode 100644 build-stl-headers-fix-mbz1269171.patch diff --git a/build-stl-headers-fix-mbz1269171.patch b/build-stl-headers-fix-mbz1269171.patch new file mode 100644 index 0000000..7f9db14 --- /dev/null +++ b/build-stl-headers-fix-mbz1269171.patch @@ -0,0 +1,169 @@ +diff -up firefox-44.0/config/gcc-stl-wrapper.template.h.1269171 firefox-44.0/config/gcc-stl-wrapper.template.h +--- firefox-44.0/config/gcc-stl-wrapper.template.h.1269171 2017-06-01 12:06:24.481286748 +0200 ++++ firefox-44.0/config/gcc-stl-wrapper.template.h 2017-06-01 12:09:28.883022995 +0200 +@@ -17,24 +17,6 @@ + // Silence "warning: #include_next is a GCC extension" + #pragma GCC system_header + +-// mozalloc.h wants ; break the cycle by always explicitly +-// including here. NB: this is a tad sneaky. Sez the gcc docs: +-// +-// `#include_next' does not distinguish between and "file" +-// inclusion, nor does it check that the file you specify has the +-// same name as the current file. It simply looks for the file +-// named, starting with the directory in the search path after the +-// one where the current file was found. +-#include_next +- +-// See if we're in code that can use mozalloc. NB: this duplicates +-// code in nscore.h because nscore.h pulls in prtypes.h, and chromium +-// can't build with that being included before base/basictypes.h. +-#if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC) +-# include "mozilla/mozalloc.h" +-#else +-# error "STL code can only be used with infallible ::operator new()" +-#endif + + #if defined(DEBUG) && !defined(_GLIBCXX_DEBUG) + // Enable checked iterators and other goodies +@@ -46,10 +28,34 @@ + // # define _GLIBCXX_DEBUG 1 + #endif + ++// Don't include mozalloc for cstdlib. See bug 1245076. ++#ifndef moz_dont_include_mozalloc_for_cstdlib ++# define moz_dont_include_mozalloc_for_cstdlib ++#endif ++ ++// Include mozalloc after the STL header and all other headers it includes ++// have been preprocessed. ++#if !defined(MOZ_INCLUDE_MOZALLOC_H) && \ ++ !defined(moz_dont_include_mozalloc_for_${HEADER}) ++# define MOZ_INCLUDE_MOZALLOC_H ++# define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER} ++#endif ++ + #pragma GCC visibility push(default) + #include_next <${HEADER}> + #pragma GCC visibility pop + ++#ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER} ++// See if we're in code that can use mozalloc. NB: this duplicates ++// code in nscore.h because nscore.h pulls in prtypes.h, and chromium ++// can't build with that being included before base/basictypes.h. ++# if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC) ++# include "mozilla/mozalloc.h" ++# else ++# error "STL code can only be used with infallible ::operator new()" ++# endif ++#endif ++ + // gcc calls a __throw_*() function from bits/functexcept.h when it + // wants to "throw an exception". functexcept exists nominally to + // support -fno-exceptions, but since we'll always use the system +diff -up firefox-44.0/config/make-stl-wrappers.py.1269171 firefox-44.0/config/make-stl-wrappers.py +--- firefox-44.0/config/make-stl-wrappers.py.1269171 2016-01-24 00:23:37.000000000 +0100 ++++ firefox-44.0/config/make-stl-wrappers.py 2017-06-01 12:06:24.482286747 +0200 +@@ -30,7 +30,6 @@ def main(outdir, compiler, template_file + os.mkdir(outdir) + + template = open(template_file, 'r').read() +- path_to_new = header_path('new', compiler) + + for header in open(header_list_file, 'r'): + header = header.rstrip() +@@ -40,8 +39,7 @@ def main(outdir, compiler, template_file + path = header_path(header, compiler) + with FileAvoidWrite(os.path.join(outdir, header)) as f: + f.write(string.Template(template).substitute(HEADER=header, +- HEADER_PATH=path, +- NEW_HEADER_PATH=path_to_new)) ++ HEADER_PATH=path)) + + + if __name__ == '__main__': +diff -up firefox-44.0/config/msvc-stl-wrapper.template.h.1269171 firefox-44.0/config/msvc-stl-wrapper.template.h +--- firefox-44.0/config/msvc-stl-wrapper.template.h.1269171 2016-01-24 00:23:37.000000000 +0100 ++++ firefox-44.0/config/msvc-stl-wrapper.template.h 2017-06-01 12:06:24.482286747 +0200 +@@ -8,35 +8,23 @@ + #ifndef mozilla_${HEADER}_h + #define mozilla_${HEADER}_h + +-#ifndef MOZ_HAVE_INCLUDED_ALLOC +-#define MOZ_HAVE_INCLUDED_ALLOC +- + #if _HAS_EXCEPTIONS + # error "STL code can only be used with -fno-exceptions" + #endif + ++// Include mozalloc after the STL header and all other headers it includes ++// have been preprocessed. ++#if !defined(MOZ_INCLUDE_MOZALLOC_H) ++# define MOZ_INCLUDE_MOZALLOC_H ++# define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER} ++#endif ++ + // Code built with !_HAS_EXCEPTIONS calls std::_Throw(), but the win2k + // CRT doesn't export std::_Throw(). So we define it. + #ifndef mozilla_Throw_h + # include "mozilla/throw_msvc.h" + #endif + +-// Code might include before other wrapped headers, but +-// includes and so we want to wrap it. But mozalloc.h +-// wants also, so we break the cycle by always explicitly +-// including here. +-#include <${NEW_HEADER_PATH}> +- +-// See if we're in code that can use mozalloc. NB: this duplicates +-// code in nscore.h because nscore.h pulls in prtypes.h, and chromium +-// can't build with that being included before base/basictypes.h. +-#if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC) +-# include "mozilla/mozalloc.h" +-#else +-# error "STL code can only be used with infallible ::operator new()" +-#endif +-#endif /* MOZ_HAVE_INCLUDED_ALLOC */ +- + #ifdef _DEBUG + // From + // http://msdn.microsoft.com/en-us/library/aa985982%28VS.80%29.aspx +@@ -75,4 +63,15 @@ + + #pragma warning( pop ) + ++#ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER} ++// See if we're in code that can use mozalloc. NB: this duplicates ++// code in nscore.h because nscore.h pulls in prtypes.h, and chromium ++// can't build with that being included before base/basictypes.h. ++# if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC) ++# include "mozilla/mozalloc.h" ++# else ++# error "STL code can only be used with infallible ::operator new()" ++# endif ++#endif ++ + #endif // if mozilla_${HEADER}_h +diff -up firefox-44.0/memory/mozalloc/mozalloc.h.1269171 firefox-44.0/memory/mozalloc/mozalloc.h +--- firefox-44.0/memory/mozalloc/mozalloc.h.1269171 2016-01-24 00:23:44.000000000 +0100 ++++ firefox-44.0/memory/mozalloc/mozalloc.h 2017-06-01 12:06:24.482286747 +0200 +@@ -12,10 +12,17 @@ + * https://bugzilla.mozilla.org/show_bug.cgi?id=427099 + */ + +-#include +-#include + #if defined(__cplusplus) + # include ++// Since libstdc++ 6, including the C headers (e.g. stdlib.h) instead of the ++// corresponding C++ header (e.g. cstdlib) can cause confusion in C++ code ++// using things defined there. Specifically, with stdlib.h, the use of abs() ++// in gfx/graphite2/src/inc/UtfCodec.h somehow ends up picking the wrong abs() ++# include ++# include ++#else ++# include ++# include + #endif + + #if defined(__cplusplus) diff --git a/xulrunner.spec b/xulrunner.spec index e0720a4..d477a8a 100644 --- a/xulrunner.spec +++ b/xulrunner.spec @@ -98,6 +98,7 @@ Patch20: firefox-build-prbool.patch Patch21: aarch64-fix-skia.patch Patch24: rhbz-1219542-s390-build.patch Patch25: firefox-gcc-6.0.patch +Patch26: build-stl-headers-fix-mbz1269171.patch # Fedora specific patches Patch200: mozilla-193-pkgconfig.patch @@ -252,6 +253,7 @@ cd %{tarballdir} %patch24 -p1 -b .rhbz-1219542-s390 %endif %patch25 -p1 -b .gcc6 +%patch26 -p1 -b .1269171 %patch200 -p2 -b .pk %patch204 -p2 -b .966424