diff --git a/gfx/graphite2/src/Code.cpp b/gfx/graphite2/src/Code.cpp
index 9428d76db..92ba92379 100644
--- a/gfx/graphite2/src/Code.cpp
+++ b/gfx/graphite2/src/Code.cpp
@@ -42,7 +42,7 @@ of the License or (at your option) any later version.
 #include "inc/Rule.h"
 #include "inc/Silf.h"
 
-#include <stdio.h>
+#include <cstdio>
 
 #ifdef NDEBUG
 #ifdef __GNUC__
diff --git a/gfx/graphite2/src/Collider.cpp b/gfx/graphite2/src/Collider.cpp
index a01135ac2..035bb9a31 100644
--- a/gfx/graphite2/src/Collider.cpp
+++ b/gfx/graphite2/src/Collider.cpp
@@ -26,11 +26,7 @@ of the License or (at your option) any later version.
 */
 #include <algorithm>
 #include <limits>
-#if defined(__GNUC__) && (__GNUC__ >= 6)
 #include <cmath>
-#else
-#include <math.h>
-#endif
 #include <string>
 #include <functional>
 #include "inc/Collider.h"
diff --git a/gfx/graphite2/src/MozGrMalloc.h b/gfx/graphite2/src/MozGrMalloc.h
index 73e5c674f..acaae1236 100644
--- a/gfx/graphite2/src/MozGrMalloc.h
+++ b/gfx/graphite2/src/MozGrMalloc.h
@@ -6,7 +6,7 @@
 #ifndef MOZ_GR_MALLOC_H
 #define MOZ_GR_MALLOC_H
 
-// Override malloc() and friends to call moz_malloc() etc, so that we get
+// Override malloc() and friends to call moz_xmalloc() etc, so that we get
 // predictable, safe OOM crashes rather than relying on the code to handle
 // allocation failures reliably.
 
@@ -15,6 +15,5 @@
 #define malloc moz_xmalloc
 #define calloc moz_xcalloc
 #define realloc moz_xrealloc
-#define free moz_free
 
 #endif // MOZ_GR_MALLOC_H
diff --git a/gfx/graphite2/src/gr_logging.cpp b/gfx/graphite2/src/gr_logging.cpp
index a4afcc2a5..3e453ba8e 100644
--- a/gfx/graphite2/src/gr_logging.cpp
+++ b/gfx/graphite2/src/gr_logging.cpp
@@ -24,7 +24,7 @@ Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public
 License, as published by the Free Software Foundation, either version 2
 of the License or (at your option) any later version.
 */
-#include <stdio.h>
+#include <cstdio>
 
 #include "graphite2/Log.h"
 #include "inc/debug.h"
diff --git a/gfx/graphite2/src/inc/Face.h b/gfx/graphite2/src/inc/Face.h
index 1ee39b0e3..43ea43196 100644
--- a/gfx/graphite2/src/inc/Face.h
+++ b/gfx/graphite2/src/inc/Face.h
@@ -26,7 +26,7 @@ of the License or (at your option) any later version.
 */
 #pragma once
 
-#include <stdio.h>
+#include <cstdio>
 
 #include "graphite2/Font.h"
 
diff --git a/gfx/graphite2/src/inc/FileFace.h b/gfx/graphite2/src/inc/FileFace.h
index dfcf3e8d3..81e501bab 100644
--- a/gfx/graphite2/src/inc/FileFace.h
+++ b/gfx/graphite2/src/inc/FileFace.h
@@ -32,7 +32,7 @@ of the License or (at your option) any later version.
 
 #ifndef GRAPHITE2_NFILEFACE
 
-#include <stdio.h>
+#include <cstdio>
 #include <cassert>
 
 #include "graphite2/Font.h"
diff --git a/gfx/graphite2/src/inc/json.h b/gfx/graphite2/src/inc/json.h
index e9826832e..90b8573d6 100644
--- a/gfx/graphite2/src/inc/json.h
+++ b/gfx/graphite2/src/inc/json.h
@@ -32,7 +32,7 @@ of the License or (at your option) any later version.
 
 #include "inc/Main.h"
 #include <cassert>
-#include <stdio.h>
+#include <cstdio>
 #include "inc/List.h"
 
 namespace graphite2 {
diff --git a/gfx/graphite2/src/json.cpp b/gfx/graphite2/src/json.cpp
index 48a563ce0..d6e5518a1 100644
--- a/gfx/graphite2/src/json.cpp
+++ b/gfx/graphite2/src/json.cpp
@@ -29,7 +29,7 @@ of the License or (at your option) any later version.
 
 #if !defined GRAPHITE2_NTRACING
 
-#include <stdio.h>
+#include <cstdio>
 #include <limits>
 #include "inc/json.h"
 
diff --git a/gfx/graphite2/src/moz.build b/gfx/graphite2/src/moz.build
index 5c00464db..4534872ed 100644
--- a/gfx/graphite2/src/moz.build
+++ b/gfx/graphite2/src/moz.build
@@ -1,4 +1,4 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# -*- 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
@@ -44,7 +44,6 @@ UNIFIED_SOURCES += [
     'Intervals.cpp',
     'json.cpp',
     'Justifier.cpp',
-    'NameTable.cpp',
     'Pass.cpp',
     'Position.cpp',
     'SegCache.cpp',
@@ -58,6 +57,12 @@ UNIFIED_SOURCES += [
     'UtfCodec.cpp',
 ]
 
+# Excluded from UNIFIED_SOURCES because <cmath> from other files breaks it,
+# see bug 1272647.
+SOURCES += [
+    'NameTable.cpp',
+]
+
 MSVC_ENABLE_PGO = True
 
 if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
