Bug 1132771 - moz.build fixups to enable execution in no config mode draft
authorGregory Szorc <gps@mozilla.com>
Wed, 18 Feb 2015 22:02:23 -0800
changeset 243488 705063cffc01a69750d8ecb4cfcd24853be2ffd2
parent 243487 852dc34f8bec226a0fc492298acacf66bff3233e
child 505375 9cde26cad35aee9386e1341d8da00f916af59359
push id727
push usergszorc@mozilla.com
push dateThu, 19 Feb 2015 06:04:18 +0000
bugs1132771
milestone38.0a1
Bug 1132771 - moz.build fixups to enable execution in no config mode Various moz.build files fail to execute when a build config is not present. Many of these are due to assuming certain CONFIG entries are present. This patch attempts to fix them all.
build/gyp.mozbuild
build/unix/elfhack/inject/moz.build
config/external/icu/moz.build
extensions/moz.build
gfx/cairo/libpixman/src/moz.build
gfx/qcms/moz.build
ipc/chromium/moz.build
ipc/glue/moz.build
media/libtheora/moz.build
mobile/android/base/moz.build
moz.build
mozglue/build/moz.build
netwerk/build/moz.build
security/sandbox/linux/moz.build
toolkit/content/moz.build
toolkit/library/StaticXULComponentsEnd/moz.build
toolkit/library/moz.build
widget/gtk/mozgtk/gtk2/moz.build
widget/gtk/mozgtk/gtk3/moz.build
xpcom/reflect/xptcall/md/unix/moz.build
xulrunner/stub/moz.build
--- a/build/gyp.mozbuild
+++ b/build/gyp.mozbuild
@@ -90,17 +90,18 @@ flavors = {
     'Darwin': 'mac' if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa' else 'ios',
     'SunOS': 'solaris',
     'GNU/kFreeBSD': 'freebsd',
     'DragonFly': 'dragonfly',
     'FreeBSD': 'freebsd',
     'NetBSD': 'netbsd',
     'OpenBSD': 'openbsd',
 }
-gyp_vars['OS'] = flavors[os]
+
+gyp_vars['OS'] = flavors.get(os)
 
 arches = {
     'x86_64': 'x64',
     'x86': 'ia32',
 }
 
 gyp_vars['target_arch'] = arches.get(CONFIG['CPU_ARCH'], CONFIG['CPU_ARCH'])
 
--- a/build/unix/elfhack/inject/moz.build
+++ b/build/unix/elfhack/inject/moz.build
@@ -1,19 +1,19 @@
 # -*- Mode: python; c-basic-offset: 4; 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
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 NO_DIST_INSTALL = True
 
-if CONFIG['TARGET_CPU'].endswith('86'):
+if CONFIG.get('TARGET_CPU', '').endswith('86'):
     cpu = 'x86'
-elif CONFIG['TARGET_CPU'].startswith('arm'):
+elif CONFIG.get('TARGET_CPU', '').startswith('arm'):
     cpu = 'arm'
 else:
     cpu = CONFIG['TARGET_CPU']
 
 GENERATED_SOURCES += [
     "%s.c" % cpu,
 ]
 
--- a/config/external/icu/moz.build
+++ b/config/external/icu/moz.build
@@ -5,14 +5,14 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 Library('icu')
 
 if CONFIG['MOZ_NATIVE_ICU']:
     OS_LIBS += CONFIG['MOZ_ICU_LIBS']
 else:
     # Order needs to be preserved
-    for l in CONFIG['ICU_LIB_NAMES']:
+    for l in CONFIG.get('ICU_LIB_NAMES', []):
         USE_LIBS += ['%s/intl/icu/target/lib/%s%s' % (
             'static:' if not CONFIG['MOZ_SHARED_ICU'] else '',
             l,
             CONFIG['MOZ_ICU_DBG_SUFFIX']
         )]
--- a/extensions/moz.build
+++ b/extensions/moz.build
@@ -1,7 +1,8 @@
 # -*- Mode: python; c-basic-offset: 4; 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
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-DIRS += CONFIG['MOZ_EXTENSIONS'].split()
+if CONFIG['MOZ_EXTENSIONS']:
+    DIRS += CONFIG['MOZ_EXTENSIONS'].split()
--- a/gfx/cairo/libpixman/src/moz.build
+++ b/gfx/cairo/libpixman/src/moz.build
@@ -75,37 +75,37 @@ DEFINES['PACKAGE'] = 'mozpixman'
 
 DEFINES['_USE_MATH_DEFINES'] = True
 
 use_mmx = False
 use_sse2 = False
 use_vmx = False
 use_arm_simd_gcc = False
 use_arm_neon_gcc = False
-if '86' in CONFIG['OS_TEST']:
-    if '64' in CONFIG['OS_TEST']:
+if '86' in CONFIG.get('OS_TEST', ''):
+    if '64' in CONFIG.get('OS_TEST', ''):
         if CONFIG['GNU_CC']:
             use_sse2 = True
     else:
         if CONFIG['_MSC_VER']:
             use_mmx = True
         if CONFIG['HAVE_GCC_ALIGN_ARG_POINTER']:
             use_sse2 = True
     if CONFIG['GNU_CC']:
         use_mmx = True
     if CONFIG['_MSC_VER']:
         use_sse2 = True
-elif 'ppc' in CONFIG['OS_TEST']:
+elif 'ppc' in CONFIG.get('OS_TEST', ''):
     if CONFIG['GNU_CC']:
         use_vmx = True
 # Apple's arm assembler doesn't support the same syntax as
 # the standard GNU assembler, so use the C fallback paths for now.
 # This may be fixable if clang's ARM/iOS assembler improves into a
 # viable solution in the future.
-elif 'arm' in CONFIG['OS_TEST']:
+elif 'arm' in CONFIG.get('OS_TEST', ''):
     if CONFIG['OS_ARCH'] != 'Darwin':
         if CONFIG['HAVE_ARM_SIMD']:
             use_arm_simd_gcc = True
         if CONFIG['HAVE_ARM_NEON']:
             use_arm_neon_gcc = True
 
 if use_mmx:
     DEFINES['USE_MMX'] = True
--- a/gfx/qcms/moz.build
+++ b/gfx/qcms/moz.build
@@ -22,24 +22,24 @@ MSVC_ENABLE_PGO = True
 FINAL_LIBRARY = 'gkmedias'
 
 if CONFIG['GNU_CC']:
     CFLAGS += ['-Wno-missing-field-initializers']
 
 use_sse1 = False
 use_sse2 = False
 use_altivec = False
-if '86' in CONFIG['OS_TEST']:
+if '86' in CONFIG.get('OS_TEST', ''):
     use_sse2 = True
     if CONFIG['_MSC_VER']:
         if CONFIG['OS_ARCH'] != 'WINNT' or CONFIG['OS_TEST'] != 'x86_64':
             use_sse1 = True
     else:
         use_sse1 = True
-elif 'ppc' in CONFIG['CPU_ARCH']:
+elif 'ppc' in CONFIG.get('CPU_ARCH', ''):
     if CONFIG['GNU_CC']:
         use_altivec = True
 
 if use_sse1:
     SOURCES += ['transform-sse1.c']
     SOURCES['transform-sse1.c'].flags += CONFIG['SSE_FLAGS']
     if CONFIG['SOLARIS_SUNPRO_CC']:
         if '64' in CONFIG['OS_TEST']:
--- a/ipc/chromium/moz.build
+++ b/ipc/chromium/moz.build
@@ -241,17 +241,17 @@ if os_bsd:
             'moc_message_pump_qt.cc',
         ]
     if not CONFIG['MOZ_NATIVE_LIBEVENT']:
         SOURCES += [
             'src/third_party/libevent/kqueue.c',
         ]
         LOCAL_INCLUDES += ['src/third_party/libevent/bsd']
 
-ost = CONFIG['OS_TEST']
+ost = CONFIG.get('OS_TEST', '')
 if ost.find('86') == -1 and ost.find('arm') == -1 and ost.find('mips') == -1:
     SOURCES += [
         'src/base/atomicops_internals_mutex.cc',
     ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
--- a/ipc/glue/moz.build
+++ b/ipc/glue/moz.build
@@ -82,17 +82,17 @@ else:
 if CONFIG['OS_ARCH'] == 'Linux':
     UNIFIED_SOURCES += [
         'ProcessUtils_linux.cpp',
     ]
 elif CONFIG['OS_ARCH'] in ('DragonFly', 'FreeBSD', 'NetBSD', 'OpenBSD'):
     UNIFIED_SOURCES += [
         'ProcessUtils_bsd.cpp'
     ]
-elif CONFIG['OS_ARCH'] in ('Darwin'):
+elif CONFIG['OS_ARCH'] == 'Darwin':
     UNIFIED_SOURCES += [
         'ProcessUtils_mac.mm'
     ]
 else:
     UNIFIED_SOURCES += [
         'ProcessUtils_none.cpp',
     ]
 
--- a/media/libtheora/moz.build
+++ b/media/libtheora/moz.build
@@ -47,17 +47,17 @@ LOCAL_INCLUDES += ['include']
 if CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_AS']:
     GENERATED_SOURCES += [ '%s.%s' % (f, CONFIG['ASM_SUFFIX']) for f in [
         'armbits-gnu',
         'armfrag-gnu',
         'armidct-gnu',
         'armloop-gnu',
     ]]
 
-if '86' in CONFIG['OS_TEST']:
+if '86' in CONFIG.get('OS_TEST', ''):
     if CONFIG['OS_ARCH'] != 'SunOS':
         if CONFIG['OS_ARCH'] != 'WINNT' or CONFIG['OS_TEST'] != 'x86_64':
             DEFINES['OC_X86_ASM'] = True
             if '64' in CONFIG['OS_TEST']:
                 DEFINES['OC_X86_64_ASM'] = True
     if CONFIG['_MSC_VER']:
         if '64' not in CONFIG['OS_TEST']:
             SOURCES += [
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -521,17 +521,17 @@ gbjar.sources += [
     'widget/ThemedTextView.java',
     'widget/ThemedView.java',
 ]
 gbjar.sources += [ thirdparty_source_dir + f for f in [
     'com/googlecode/eyesfree/braille/selfbraille/ISelfBrailleService.java',
     'com/googlecode/eyesfree/braille/selfbraille/SelfBrailleClient.java',
     'com/googlecode/eyesfree/braille/selfbraille/WriteData.java',
 ] ]
-android_package_dir = CONFIG['ANDROID_PACKAGE_NAME'].replace('.', '/')
+android_package_dir = CONFIG.get('ANDROID_PACKAGE_NAME', '').replace('.', '/')
 gbjar.generated_sources = [] # Keep it this way.
 gbjar.extra_jars += [
     'constants.jar'
 ]
 if CONFIG['MOZ_CRASHREPORTER']:
     gbjar.sources += [ 'CrashReporter.java' ]
     ANDROID_RES_DIRS += [ SRCDIR + '/crashreporter/res' ]
 
@@ -666,17 +666,17 @@ gtjar.sources += [ thirdparty_source_dir
 if not CONFIG['MOZILLA_OFFICIAL']:
     gtjar.sources += [ thirdparty_source_dir + f for f in [
         'org/lucasr/dspec/DesignSpec.java',
         'org/lucasr/dspec/RawResource.java'
     ] ]
 
 ANDROID_RES_DIRS += [
     SRCDIR + '/resources',
-    TOPSRCDIR + '/' + CONFIG['MOZ_BRANDING_DIRECTORY'] + '/res',
+    TOPSRCDIR + '/' + CONFIG.get('MOZ_BRANDING_DIRECTORY', '') + '/res',
     OBJDIR + '/res',
 ]
 
 ANDROID_GENERATED_RESFILES += [
     'res/raw/suggestedsites.json',
     'res/values/strings.xml',
 ]
 
@@ -695,20 +695,20 @@ for var in ('ANDROID_PACKAGE_NAME', 'AND
             'GRE_MILESTONE', 'MOZ_APP_BASENAME', 'MOZ_MOZILLA_API_KEY',
             'MOZ_APP_DISPLAYNAME', 'MOZ_APP_ID', 'MOZ_APP_NAME',
             'MOZ_APP_VENDOR', 'MOZ_APP_VERSION', 'MOZ_CHILD_PROCESS_NAME',
             'MOZ_CRASHREPORTER', 'MOZ_UPDATE_CHANNEL', 'OMNIJAR_NAME',
             'OS_TARGET', 'TARGET_XPCOM_ABI'):
     DEFINES[var] = CONFIG[var]
 
 # Mangle our package name to avoid Bug 750548.
-DEFINES['MANGLED_ANDROID_PACKAGE_NAME'] = CONFIG['ANDROID_PACKAGE_NAME'].replace('fennec', 'f3nn3c')
+DEFINES['MANGLED_ANDROID_PACKAGE_NAME'] = CONFIG.get('ANDROID_PACKAGE_NAME', '').replace('fennec', 'f3nn3c')
 DEFINES['MOZ_APP_ABI'] = CONFIG['TARGET_XPCOM_ABI']
 
-if '-march=armv7' in CONFIG['OS_CFLAGS']:
+if '-march=armv7' in CONFIG.get('OS_CFLAGS', ''):
     DEFINES['MOZ_MIN_CPU_VERSION'] = 7
 else:
     DEFINES['MOZ_MIN_CPU_VERSION'] = 5
 
 if CONFIG['MOZ_ANDROID_SEARCH_ACTIVITY']:
     # The Search Activity is mostly independent of Fennec proper, but
     # it does depend on Geckoview.  Therefore, we build it as a jar
     # that depends on the Geckoview jars.
@@ -731,17 +731,17 @@ generated_recursive_make_targets = ['.aa
 
 generated = add_android_eclipse_library_project('FennecResourcesGenerated')
 generated.package_name = 'org.mozilla.gecko.generated'
 generated.res = OBJDIR + '/res'
 generated.recursive_make_targets += generated_recursive_make_targets
 
 branding = add_android_eclipse_library_project('FennecResourcesBranding')
 branding.package_name = 'org.mozilla.gecko.branding'
-branding.res = TOPSRCDIR + '/' + CONFIG['MOZ_BRANDING_DIRECTORY'] + '/res'
+branding.res = TOPSRCDIR + '/' + CONFIG.get('MOZ_BRANDING_DIRECTORY', '') + '/res'
 branding.recursive_make_targets += generated_recursive_make_targets
 
 static = add_android_eclipse_library_project('FennecResourcesStatic')
 # 'org.mozilla.gecko.static' is not a valid Java package name, so we use a different one.
 static.package_name = 'org.mozilla.gecko.resources'
 static.res = SRCDIR + '/resources'
 static.recursive_make_targets += generated_recursive_make_targets
 static.included_projects += ['../' + generated.name, '../' + branding.name]
@@ -760,20 +760,20 @@ main.filtered_resources += [
 
 main.recursive_make_targets += generated_recursive_make_targets
 main.recursive_make_targets += ['generated/' + f for f in mgjar.generated_sources]
 main.recursive_make_targets += ['generated/' + f for f in gbjar.generated_sources]
 
 main.extra_jars += [CONFIG['ANDROID_COMPAT_LIB']]
 main.assets = TOPOBJDIR + '/dist/' + CONFIG['MOZ_APP_NAME'] + '/assets'
 main.libs = [
-    (TOPOBJDIR + '/dist/' + CONFIG['MOZ_APP_NAME'] + '/lib/' + CONFIG['ANDROID_CPU_ARCH'] + '/libmozglue.so',
-     'libs/' + CONFIG['ANDROID_CPU_ARCH'] + '/libmozglue.so'),
-    (TOPOBJDIR + '/dist/' + CONFIG['MOZ_APP_NAME'] + '/lib/' + CONFIG['ANDROID_CPU_ARCH'] + '/libplugin-container.so',
-     'libs/' + CONFIG['ANDROID_CPU_ARCH'] + '/libplugin-container.so'),
+    (TOPOBJDIR + '/dist/' + CONFIG['MOZ_APP_NAME'] + '/lib/' + CONFIG.get('ANDROID_CPU_ARCH', '') + '/libmozglue.so',
+     'libs/' + CONFIG.get('ANDROID_CPU_ARCH', '') + '/libmozglue.so'),
+    (TOPOBJDIR + '/dist/' + CONFIG['MOZ_APP_NAME'] + '/lib/' + CONFIG.get('ANDROID_CPU_ARCH', '') + '/libplugin-container.so',
+     'libs/' + CONFIG.get('ANDROID_CPU_ARCH', '') + '/libplugin-container.so'),
 ]
 main.res = None
 
 cpe = main.add_classpathentry('src', SRCDIR,
     dstdir='src/org/mozilla/gecko',
     exclude_patterns=[
         'org/mozilla/gecko/tests/**',
         'org/mozilla/gecko/resources/**'])
--- a/moz.build
+++ b/moz.build
@@ -61,13 +61,13 @@ if CONFIG['COMPILE_ENVIRONMENT'] and not
         ]
 
     if CONFIG['BUILD_CTYPES']:
         DIRS += ['config/external/ffi']
     if CONFIG['USE_ICU']:
         DIRS += ['config/external/icu']
     DIRS += ['js/src']
 
-if not CONFIG['JS_STANDALONE']:
+if not CONFIG['JS_STANDALONE'] and CONFIG['MOZ_BUILD_APP']:
     # Bring in the configuration for the configured application.
     include('/' + CONFIG['MOZ_BUILD_APP'] + '/app.mozbuild')
 
 include('build/templates.mozbuild')
--- a/mozglue/build/moz.build
+++ b/mozglue/build/moz.build
@@ -47,17 +47,17 @@ if CONFIG['MOZ_NUWA_PROCESS']:
     ]
 
 EXPORTS.mozilla += [
     'arm.h',
     'SSE.h',
     'WindowsDllBlocklist.h',
 ]
 
-if CONFIG['CPU_ARCH'].startswith('x86'):
+if CONFIG.get('CPU_ARCH', '').startswith('x86'):
     SOURCES += [
         'SSE.cpp',
     ]
 
 if CONFIG['CPU_ARCH'] == 'arm':
     SOURCES += [
         'arm.cpp',
     ]
--- a/netwerk/build/moz.build
+++ b/netwerk/build/moz.build
@@ -28,17 +28,18 @@ LOCAL_INCLUDES += [
     '/netwerk/protocol/about',
     '/netwerk/protocol/app',
     '/netwerk/socket',
     '/netwerk/streamconv',
     '/netwerk/streamconv/converters',
 ]
 
 protocols = CONFIG['NECKO_PROTOCOLS'].copy()
-protocols.remove("about")
+if 'about' in protocols:
+    protocols.remove('about')
 LOCAL_INCLUDES += sorted([
     '/netwerk/protocol/%s' % d for d in protocols
 ])
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     LOCAL_INCLUDES += [
         '/netwerk/system/win32',
     ]
--- a/security/sandbox/linux/moz.build
+++ b/security/sandbox/linux/moz.build
@@ -57,17 +57,17 @@ SOURCES += [
     'Sandbox.cpp',
     'SandboxAssembler.cpp',
     'SandboxFilter.cpp',
 ]
 
 # gcc lto likes to put the top level asm in syscall.cc in a different partition
 # from the function using it which breaks the build.  Work around that by
 # forcing there to be only one partition.
-if '-flto' in CONFIG['OS_CXXFLAGS'] and not CONFIG['CLANG_CXX']:
+if '-flto' in CONFIG.get('OS_CXXFLAGS', '') and not CONFIG['CLANG_CXX']:
     LDFLAGS += ['--param lto-partitions=1']
 
 DEFINES['NS_NO_XPCOM'] = True
 DISABLE_STL_WRAPPING = True
 
 LOCAL_INCLUDES += ['/security/sandbox/chromium-shim']
 LOCAL_INCLUDES += ['/security/sandbox/chromium']
 LOCAL_INCLUDES += ['/nsprpub']
--- a/toolkit/content/moz.build
+++ b/toolkit/content/moz.build
@@ -10,12 +10,12 @@ for var in ('target', 'ac_configure_args
             'CXX', 'CXX_VERSION'):
     DEFINES[var] = CONFIG[var]
 
 DEFINES['CFLAGS'] = CONFIG['OS_CFLAGS']
 
 if CONFIG['OS_TARGET'] == 'Android':
     DEFINES['ANDROID_PACKAGE_NAME'] = CONFIG['ANDROID_PACKAGE_NAME']
 
-if 'stlport' in CONFIG['STLPORT_LIBS']:
+if 'stlport' in CONFIG.get('STLPORT_LIBS', ''):
     DEFINES['USE_STLPORT'] = True
 
 JAR_MANIFESTS += ['jar.mn']
--- a/toolkit/library/StaticXULComponentsEnd/moz.build
+++ b/toolkit/library/StaticXULComponentsEnd/moz.build
@@ -2,16 +2,16 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 SOURCES += [
     'StaticXULComponentsEnd.cpp',
 ]
 
 # Don't let LTO reorder StaticXULComponentsStart.o.
-if '-flto' in CONFIG['OS_CXXFLAGS']:
+if '-flto' in CONFIG.get('OS_CXXFLAGS', ''):
     SOURCES['StaticXULComponentsEnd.cpp'].flags += ['-fno-lto']
 
 Library('StaticXULComponentsEnd')
 
 DEFINES['MOZILLA_INTERNAL_API'] = True
 
 FAIL_ON_WARNINGS = True
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -72,17 +72,17 @@ SOURCES += [
 
 MSVC_ENABLE_PGO = True
 
 # This, combined with the fact the file is first, makes the start pointer
 # it contains first in Windows PGO builds.
 SOURCES['StaticXULComponentsStart.cpp'].no_pgo = True
 
 # Don't let LTO reorder StaticXULComponentsStart.o.
-if '-flto' in CONFIG['OS_CXXFLAGS']:
+if '-flto' in CONFIG.get('OS_CXXFLAGS', ''):
     SOURCES['StaticXULComponentsStart.cpp'].flags += ['-fno-lto']
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     SOURCES += [
         'nsDllMain.cpp',
     ]
 
 LOCAL_INCLUDES += [
--- a/widget/gtk/mozgtk/gtk2/moz.build
+++ b/widget/gtk/mozgtk/gtk2/moz.build
@@ -13,22 +13,22 @@ DEFINES['GTK3_SYMBOLS'] = True
 SharedLibrary('mozgtk2')
 
 SONAME = 'mozgtk'
 
 # If LDFLAGS contains -Wl,--as-needed, we need to add -Wl,--no-as-needed
 # before the gtk libraries, otherwise the linker will drop those dependencies
 # because no symbols are used from them. But those dependencies need to be
 # kept for things to work properly.
-if '-Wl,--as-needed' in CONFIG['OS_LDFLAGS']:
+if '-Wl,--as-needed' in CONFIG.get('OS_LDFLAGS', ''):
     no_as_needed = ['-Wl,--no-as-needed']
     as_needed = ['-Wl,--as-needed']
 else:
     no_as_needed = []
     as_needed = []
 
-OS_LIBS += [f for f in CONFIG['MOZ_GTK2_LIBS'] if f.startswith('-L')]
+OS_LIBS += [f for f in CONFIG.get('MOZ_GTK2_LIBS', '') if f.startswith('-L')]
 OS_LIBS += no_as_needed
 OS_LIBS += [
     'gtk-x11-2.0',
     'gdk-x11-2.0',
 ]
 OS_LIBS += as_needed
--- a/widget/gtk/mozgtk/gtk3/moz.build
+++ b/widget/gtk/mozgtk/gtk3/moz.build
@@ -13,22 +13,22 @@ DEFINES['GTK2_SYMBOLS'] = True
 SharedLibrary('mozgtk')
 
 SONAME = 'mozgtk'
 
 # If LDFLAGS contains -Wl,--as-needed, we need to add -Wl,--no-as-needed
 # before the gtk libraries, otherwise the linker will drop those dependencies
 # because no symbols are used from them. But those dependencies need to be
 # kept for things to work properly.
-if '-Wl,--as-needed' in CONFIG['OS_LDFLAGS']:
+if '-Wl,--as-needed' in CONFIG.get('OS_LDFLAGS', ''):
     no_as_needed = ['-Wl,--no-as-needed']
     as_needed = ['-Wl,--as-needed']
 else:
     no_as_needed = []
     as_needed = []
 
-OS_LIBS += [f for f in CONFIG['MOZ_GTK3_LIBS'] if f.startswith('-L')]
+OS_LIBS += [f for f in CONFIG.get('MOZ_GTK3_LIBS', '') if f.startswith('-L')]
 OS_LIBS += no_as_needed
 OS_LIBS += [
     'gtk-3',
     'gdk-3',
 ]
 OS_LIBS += as_needed
--- a/xpcom/reflect/xptcall/md/unix/moz.build
+++ b/xpcom/reflect/xptcall/md/unix/moz.build
@@ -22,17 +22,17 @@ if CONFIG['OS_ARCH'] == 'Darwin':
 if CONFIG['OS_ARCH'] == 'GNU':
     if CONFIG['CPU_ARCH'] == 'x86':
         SOURCES += [
             'xptcinvoke_gcc_x86_unix.cpp',
             'xptcstubs_gcc_x86_unix.cpp'
         ]
 
 if CONFIG['OS_ARCH'] in ('Linux', 'FreeBSD', 'NetBSD', 'OpenBSD') or \
-   CONFIG['OS_ARCH'].startswith('GNU_'):
+   CONFIG.get('OS_ARCH', '').startswith('GNU_'):
     if CONFIG['OS_TEST'] == 'x86_64':
         SOURCES += [
             'xptcinvoke_x86_64_unix.cpp',
             'xptcstubs_x86_64_linux.cpp',
         ]
     elif CONFIG['OS_TEST'].find('86') != -1:
         SOURCES += [
             'xptcinvoke_gcc_x86_unix.cpp',
--- a/xulrunner/stub/moz.build
+++ b/xulrunner/stub/moz.build
@@ -6,17 +6,17 @@
 
 # The value of XULRUNNER_STUB_NAME is generated by configure to allow XULRunner
 # apps to override it using the --with-xulrunner-stub-name=<appname> argument.
 # If this configure argument is not present then the default name is
 # 'xulrunner-stub'.
 
 # We don't want to create a dependency on mozglue.
 # Statically link against the RTL on windows
-GeckoProgram(CONFIG['XULRUNNER_STUB_NAME'], mozglue=None, msvcrt='static')
+GeckoProgram(CONFIG.get('XULRUNNER_STUB_NAME', ''), mozglue=None, msvcrt='static')
 
 SOURCES += [
     'nsXULStub.cpp',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     FINAL_TARGET = 'dist/XUL.framework/Versions/%(MOZILLA_VERSION)s' % CONFIG