summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@gmail.com>2018-05-27 17:54:50 +0200
committerGitHub <noreply@github.com>2018-05-27 17:54:50 +0200
commit7840c750dbfd3f1b2ab3b4f0db561cafdc7dcfe2 (patch)
tree3c40aedae6cb2551066b406cec3559dc1a488baf
parenta65c26ccf590103a07174d9722ef86bcaac877a6 (diff)
parent3c3c85983f96ed48fb6a2c16df712dd229c1f358 (diff)
downloadUXP-7840c750dbfd3f1b2ab3b4f0db561cafdc7dcfe2.tar
UXP-7840c750dbfd3f1b2ab3b4f0db561cafdc7dcfe2.tar.gz
UXP-7840c750dbfd3f1b2ab3b4f0db561cafdc7dcfe2.tar.lz
UXP-7840c750dbfd3f1b2ab3b4f0db561cafdc7dcfe2.tar.xz
UXP-7840c750dbfd3f1b2ab3b4f0db561cafdc7dcfe2.zip
Merge pull request #395 from trav90/buildsystem-work
Always build with SSE2 support & display an error if not available
-rw-r--r--application/palemoon/app/Makefile.in8
-rw-r--r--application/palemoon/app/moz.build3
-rw-r--r--application/palemoon/app/nsBrowserApp.cpp45
-rw-r--r--application/palemoon/confvars.sh5
-rw-r--r--browser/app/Makefile.in8
-rw-r--r--browser/app/moz.build4
-rw-r--r--browser/app/nsBrowserApp.cpp45
-rwxr-xr-xbrowser/confvars.sh5
-rw-r--r--build/autoconf/compiler-opts.m44
-rw-r--r--old-configure.in6
10 files changed, 131 insertions, 2 deletions
diff --git a/application/palemoon/app/Makefile.in b/application/palemoon/app/Makefile.in
index c0f01212c..94f4dc1f3 100644
--- a/application/palemoon/app/Makefile.in
+++ b/application/palemoon/app/Makefile.in
@@ -33,6 +33,14 @@ NSDISTMODE = copy
include $(topsrcdir)/config/config.mk
+# If we are trying to show an error dialog about the lack of SSE2 support,
+# make sure that code itself doesn't use SSE2.
+ifdef MOZ_LINUX_SSE2_STARTUP_ERROR
+CXXFLAGS := $(filter-out -march=% -msse2 -mfpmath=sse,$(CXXFLAGS))
+CXX := $(filter-out -march=% -msse2 -mfpmath=sse,$(CXX))
+CXXFLAGS += -msse -mno-sse2 -mfpmath=387
+endif
+
ifeq ($(OS_ARCH),WINNT)
# Rebuild firefox.exe if the manifest changes - it's included by splash.rc.
# (this dependency should really be just for firefox.exe, not other targets)
diff --git a/application/palemoon/app/moz.build b/application/palemoon/app/moz.build
index 8b358b622..044c3e2d1 100644
--- a/application/palemoon/app/moz.build
+++ b/application/palemoon/app/moz.build
@@ -68,3 +68,6 @@ if CONFIG['MOZ_LINKER']:
if CONFIG['HAVE_CLOCK_MONOTONIC']:
OS_LIBS += CONFIG['REALTIME_LIBS']
+
+if CONFIG['MOZ_LINUX_SSE2_STARTUP_ERROR']:
+ DEFINES['MOZ_LINUX_SSE2_STARTUP_ERROR'] = True
diff --git a/application/palemoon/app/nsBrowserApp.cpp b/application/palemoon/app/nsBrowserApp.cpp
index 8b0613528..c73b05d23 100644
--- a/application/palemoon/app/nsBrowserApp.cpp
+++ b/application/palemoon/app/nsBrowserApp.cpp
@@ -35,6 +35,51 @@
#include "mozilla/Telemetry.h"
#include "mozilla/WindowsDllBlocklist.h"
+#ifdef MOZ_LINUX_SSE2_STARTUP_ERROR
+#include <cpuid.h>
+#include "mozilla/Unused.h"
+
+static bool
+IsSSE2Available()
+{
+ // The rest of the app has been compiled to assume that SSE2 is present
+ // unconditionally, so we can't use the normal copy of SSE.cpp here.
+ // Since SSE.cpp caches the results and we need them only transiently,
+ // instead of #including SSE.cpp here, let's just inline the specific check
+ // that's needed.
+ unsigned int level = 1u;
+ unsigned int eax, ebx, ecx, edx;
+ unsigned int bits = (1u<<26);
+ unsigned int max = __get_cpuid_max(0, nullptr);
+ if (level > max) {
+ return false;
+ }
+ __cpuid_count(level, 0, eax, ebx, ecx, edx);
+ return (edx & bits) == bits;
+}
+
+static const char sSSE2Message[] =
+ "This browser version requires a processor with the SSE2 instruction "
+ "set extension.\n";
+
+__attribute__((constructor))
+static void
+SSE2Check()
+{
+ if (IsSSE2Available()) {
+ return;
+ }
+ // Using write() in order to avoid jemalloc-based buffering. Ignoring return
+ // values, since there isn't much we could do on failure and there is no
+ // point in trying to recover from errors.
+ MOZ_UNUSED(write(STDERR_FILENO,
+ sSSE2Message,
+ MOZ_ARRAY_LENGTH(sSSE2Message) - 1));
+ // _exit() instead of exit() to avoid running the usual "at exit" code.
+ _exit(255);
+}
+#endif
+
#if !defined(MOZ_WIDGET_COCOA) && !defined(MOZ_WIDGET_ANDROID)
#define MOZ_BROWSER_CAN_BE_CONTENTPROC
#include "../../ipc/contentproc/plugin-container.cpp"
diff --git a/application/palemoon/confvars.sh b/application/palemoon/confvars.sh
index 5109c0829..d1d2ce065 100644
--- a/application/palemoon/confvars.sh
+++ b/application/palemoon/confvars.sh
@@ -98,6 +98,11 @@ if test "$OS_ARCH" = "WINNT" -o \
MOZ_BUNDLED_FONTS=1
fi
+# Display an error on non-SSE2 Linux systems
+if test "$OS_ARCH" = "Linux"; then
+ MOZ_LINUX_SSE2_STARTUP_ERROR=1
+fi
+
# Short-circuit a few services to be removed
MOZ_MAINTENANCE_SERVICE=
MOZ_SERVICES_HEALTHREPORT=
diff --git a/browser/app/Makefile.in b/browser/app/Makefile.in
index d807b4337..ca87f0995 100644
--- a/browser/app/Makefile.in
+++ b/browser/app/Makefile.in
@@ -23,6 +23,14 @@ NSDISTMODE = copy
include $(topsrcdir)/config/config.mk
+# If we are trying to show an error dialog about the lack of SSE2 support,
+# make sure that code itself doesn't use SSE2.
+ifdef MOZ_LINUX_SSE2_STARTUP_ERROR
+CXXFLAGS := $(filter-out -march=% -msse2 -mfpmath=sse,$(CXXFLAGS))
+CXX := $(filter-out -march=% -msse2 -mfpmath=sse,$(CXX))
+CXXFLAGS += -msse -mno-sse2 -mfpmath=387
+endif
+
ifeq ($(OS_ARCH),WINNT)
# Rebuild firefox.exe if the manifest changes - it's included by splash.rc.
# (this dependency should really be just for firefox.exe, not other targets)
diff --git a/browser/app/moz.build b/browser/app/moz.build
index 1004e280c..9650761ee 100644
--- a/browser/app/moz.build
+++ b/browser/app/moz.build
@@ -70,6 +70,10 @@ if CONFIG['HAVE_CLOCK_MONOTONIC']:
if CONFIG['MOZ_GPSD']:
DEFINES['MOZ_GPSD'] = True
+
+if CONFIG['MOZ_LINUX_SSE2_STARTUP_ERROR']:
+ DEFINES['MOZ_LINUX_SSE2_STARTUP_ERROR'] = True
+
for icon in ('firefox', 'document', 'newwindow', 'newtab', 'pbmode'):
DEFINES[icon.upper() + '_ICO'] = '"%s/dist/branding/%s.ico"' % (
TOPOBJDIR, icon)
diff --git a/browser/app/nsBrowserApp.cpp b/browser/app/nsBrowserApp.cpp
index 66ea8aed5..fc5ea8785 100644
--- a/browser/app/nsBrowserApp.cpp
+++ b/browser/app/nsBrowserApp.cpp
@@ -35,6 +35,51 @@
#include "mozilla/Telemetry.h"
#include "mozilla/WindowsDllBlocklist.h"
+#ifdef MOZ_LINUX_SSE2_STARTUP_ERROR
+#include <cpuid.h>
+#include "mozilla/Unused.h"
+
+static bool
+IsSSE2Available()
+{
+ // The rest of the app has been compiled to assume that SSE2 is present
+ // unconditionally, so we can't use the normal copy of SSE.cpp here.
+ // Since SSE.cpp caches the results and we need them only transiently,
+ // instead of #including SSE.cpp here, let's just inline the specific check
+ // that's needed.
+ unsigned int level = 1u;
+ unsigned int eax, ebx, ecx, edx;
+ unsigned int bits = (1u<<26);
+ unsigned int max = __get_cpuid_max(0, nullptr);
+ if (level > max) {
+ return false;
+ }
+ __cpuid_count(level, 0, eax, ebx, ecx, edx);
+ return (edx & bits) == bits;
+}
+
+static const char sSSE2Message[] =
+ "This browser version requires a processor with the SSE2 instruction "
+ "set extension.\n";
+
+__attribute__((constructor))
+static void
+SSE2Check()
+{
+ if (IsSSE2Available()) {
+ return;
+ }
+ // Using write() in order to avoid jemalloc-based buffering. Ignoring return
+ // values, since there isn't much we could do on failure and there is no
+ // point in trying to recover from errors.
+ MOZ_UNUSED(write(STDERR_FILENO,
+ sSSE2Message,
+ MOZ_ARRAY_LENGTH(sSSE2Message) - 1));
+ // _exit() instead of exit() to avoid running the usual "at exit" code.
+ _exit(255);
+}
+#endif
+
#if !defined(MOZ_WIDGET_COCOA) && !defined(MOZ_WIDGET_ANDROID)
#define MOZ_BROWSER_CAN_BE_CONTENTPROC
#include "../../ipc/contentproc/plugin-container.cpp"
diff --git a/browser/confvars.sh b/browser/confvars.sh
index 0343034a4..e8b911da3 100755
--- a/browser/confvars.sh
+++ b/browser/confvars.sh
@@ -18,6 +18,11 @@ if test "$OS_ARCH" = "WINNT"; then
MOZ_MAINTENANCE_SERVICE=
fi
+# Display an error on non-SSE2 Linux systems
+if test "$OS_ARCH" = "Linux"; then
+ MOZ_LINUX_SSE2_STARTUP_ERROR=1
+fi
+
# For Basilisk we want to use 52.9.YYYY.MM.DD as MOZ_APP_VERSION in release
# builds so add-on developers have something to target while maintaining
# Firefox compatiblity.
diff --git a/build/autoconf/compiler-opts.m4 b/build/autoconf/compiler-opts.m4
index c47d792f4..82d0b43fc 100644
--- a/build/autoconf/compiler-opts.m4
+++ b/build/autoconf/compiler-opts.m4
@@ -176,8 +176,8 @@ if test "$GNU_CC"; then
CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections"
fi
- CFLAGS="$CFLAGS -fno-math-errno"
- CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-math-errno"
+ CFLAGS="$CFLAGS -fno-math-errno -msse2 -mfpmath=sse"
+ CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-math-errno -msse2 -mfpmath=sse"
if test -z "$CLANG_CC"; then
case "$CC_VERSION" in
diff --git a/old-configure.in b/old-configure.in
index 0d169d55f..4d4d66f88 100644
--- a/old-configure.in
+++ b/old-configure.in
@@ -4802,6 +4802,12 @@ if test "$USE_FC_FREETYPE"; then
fi
dnl ========================================================
+dnl Check if we need the Linux SSE2 error dialog
+dnl ========================================================
+
+AC_SUBST(MOZ_LINUX_SSE2_STARTUP_ERROR)
+
+dnl ========================================================
dnl Check for pixman and cairo
dnl ========================================================