Bug 1632343 - Fix artifact builds when --enable-openpgp is set. r=darktrojan DONTBUILD
authorRob Lemley <rob@thunderbird.net>
Thu, 23 Apr 2020 13:50:10 +0300
changeset 38028 d010d86cedeb754677886254f697dd775a0127ea
parent 38027 683a475237f6ce9524cf3bd1ddd4bcdbdf1ee4ad
child 38029 53c02cf46815108a2fdcb6e8872ff09c5a63054c
push id2595
push userclokep@gmail.com
push dateMon, 04 May 2020 19:02:04 +0000
treeherdercomm-beta@f53913797371 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdarktrojan
bugs1632343
Bug 1632343 - Fix artifact builds when --enable-openpgp is set. r=darktrojan DONTBUILD Compiler-based checks don't work when --enable-artifact-builds is set, so those checks need to have a when=compile_environment condition. Botan's configure script fails without a proper compiler and needs to be disabled.
third_party/botan/Makefile.in
third_party/botan/moz.build
third_party/openpgp.configure
third_party/rnpdefs.mozbuild
--- a/third_party/botan/Makefile.in
+++ b/third_party/botan/Makefile.in
@@ -1,8 +1,10 @@
 # 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/.
 
 include $(moztopsrcdir)/config/config.mk
 include $(topsrcdir)/config/rules.mk
 
+ifndef MOZ_ARTIFACT_BUILDS
 export:: build/build.h
+endif
--- a/third_party/botan/moz.build
+++ b/third_party/botan/moz.build
@@ -37,39 +37,41 @@ else:
 
 # Run Botan's configure.py to generate build.h. Use --with-cmake to avoid
 # writing a Makefile that would overwrite our own.
 botan_generated = [
     'build/build.h',
     'build/build_config.json',
     'CMakeLists.txt',
     ]
-GENERATED_FILES += botan_generated
-botan_build = GENERATED_FILES['build/build.h']
-botan_build.script = 'botan_configure.py'
-botan_build.flags = [
-    '--cc-bin={}'.format(CONFIG['MZLA_RNP_CXX']),
-    '--cpu={}'.format(CONFIG['target_cpu']),
-    '--os={}'.format(botan_os),
-    '--with-build-dir={}'.format(OBJDIR),
-    '--minimized-build',
-    '--disable-shared-library',
-    '--link-method=copy',
-    '--without-sphinx',
-    '--distribution-info={}'.format(rnp_dist_info),
-    '--without-rst2man',
-    '--with-cmake',
-]
 
-# Botan assumes this file exists on Linux, but it is not present on Taskcluster.
-if not CONFIG['HAVE_SYS_AUXV_H']:
-    botan_build.flags.append('--without-os-features=getauxval')
-# clock_gettime is not part of OSX until 10.12 sdk, Taskcluster builds with 10.11
-if CONFIG['OS_ARCH'] == 'Darwin':
-    botan_build.flags.append('--without-os-features=clock_gettime')
+if not CONFIG['MOZ_ARTIFACT_BUILDS']:
+    GENERATED_FILES += botan_generated
+    botan_build = GENERATED_FILES['build/build.h']
+    botan_build.script = 'botan_configure.py'
+    botan_build.flags = [
+        '--cc-bin={}'.format(CONFIG['MZLA_RNP_CXX']),
+        '--cpu={}'.format(CONFIG['target_cpu']),
+        '--os={}'.format(botan_os),
+        '--with-build-dir={}'.format(OBJDIR),
+        '--minimized-build',
+        '--disable-shared-library',
+        '--link-method=copy',
+        '--without-sphinx',
+        '--distribution-info={}'.format(rnp_dist_info),
+        '--without-rst2man',
+        '--with-cmake',
+    ]
+
+    # Botan assumes this file exists on Linux, but it is not present on Taskcluster.
+    if not CONFIG['HAVE_SYS_AUXV_H']:
+        botan_build.flags.append('--without-os-features=getauxval')
+    # clock_gettime is not part of OSX until 10.12 sdk, Taskcluster builds with 10.11
+    if CONFIG['OS_ARCH'] == 'Darwin':
+        botan_build.flags.append('--without-os-features=clock_gettime')
 
 LOCAL_INCLUDES = ['!build/include']
 
 # This list was obtained by running Botan's configure script in CMake mode
 # with the desired options and extracting the information from CMakeLists.txt.
 SOURCES += [
     'src/lib/asn1/alg_id.cpp',
     'src/lib/asn1/asn1_attribute.cpp',
--- a/third_party/openpgp.configure
+++ b/third_party/openpgp.configure
@@ -38,68 +38,69 @@ def check_symbol_exists(symbol, header, 
 (void) %s;
 #endif
 ''' % (symbol, symbol)
 
     return try_compile(includes, body, language=language, flags=flags,
                        check_msg='for %s' % symbol, when=when, onerror=onerror)
 
 
-have_fcntl_h = check_header('fcntl.h')
-have_stdlib_h = check_header('stdlib.h')
-have_locale_h = check_header('locale.h')
-have_string_h = check_header('string.h')
-have_strings_h = check_header('strings.h')
+with only_when('--enable-compile-environment'):
+    have_fcntl_h = check_header('fcntl.h')
+    have_stdlib_h = check_header('stdlib.h')
+    have_locale_h = check_header('locale.h')
+    have_string_h = check_header('string.h')
+    have_strings_h = check_header('strings.h')
 
-check_headers(
-    'stdarg.h',
-    'dlfcn.h',
-    'endian.h',
-    'limits.h',
-    'memory.h',
-    'sys/auxv.h',
-    'sys/cdefs.h',
-    'sys/resource.h',
-    'sys/param.h',
-    'sys/stat.h',
-    'sys/wait.h',
-    'xlocale.h'
-)
+    check_headers(
+        'stdarg.h',
+        'dlfcn.h',
+        'endian.h',
+        'limits.h',
+        'memory.h',
+        'sys/auxv.h',
+        'sys/cdefs.h',
+        'sys/resource.h',
+        'sys/param.h',
+        'sys/stat.h',
+        'sys/wait.h',
+        'xlocale.h'
+    )
 
-set_define('JSON_C_HAVE_INTTYPES_H', noset_check_header('inttypes.h'))
-
-set_define('HAVE_DECL__ISNAN', check_symbol_exists('_isnan', 'float.h'))
+    set_define('JSON_C_HAVE_INTTYPES_H', noset_check_header('inttypes.h'))
 
-set_define('HAVE_DECL__FINITE', check_symbol_exists('_finite', 'float.h'))
-set_define('HAVE_DECL_INFINITY', check_symbol_exists('INFINITY', 'math.h'))
-set_define('HAVE_DECL_ISINF', check_symbol_exists('isinf', 'math.h'))
-set_define('HAVE_DECL_ISNAN', check_symbol_exists('isnan', 'math.h'))
-set_define('HAVE_DECL_NAN', check_symbol_exists('nan', 'math.h'))
+    set_define('HAVE_DECL__ISNAN', check_symbol_exists('_isnan', 'float.h'))
 
-set_define('HAVE_DOPRNT', check_symbol_exists('_doprnt', 'stdio.h'))
-set_define('HAVE_SNPRINTF', check_symbol_exists('snprintf', 'stdio.h'))
-set_define('HAVE_VASPRINTF', check_symbol_exists('vasprintf', 'stdio.h', flags=['-D_GNU_SOURCE']))
-set_define('HAVE_VSNPRINTF', check_symbol_exists('vsnprintf', 'stdio.h'))
-set_define('HAVE_VPRINTF', check_symbol_exists('vprintf', 'stdio.h'))
+    set_define('HAVE_DECL__FINITE', check_symbol_exists('_finite', 'float.h'))
+    set_define('HAVE_DECL_INFINITY', check_symbol_exists('INFINITY', 'math.h'))
+    set_define('HAVE_DECL_ISINF', check_symbol_exists('isinf', 'math.h'))
+    set_define('HAVE_DECL_ISNAN', check_symbol_exists('isnan', 'math.h'))
+    set_define('HAVE_DECL_NAN', check_symbol_exists('nan', 'math.h'))
 
-set_define('HAVE_OPEN', check_symbol_exists('open', 'fcntl.h', when=have_fcntl_h))
-set_define('HAVE_REALLOC', check_symbol_exists('realloc', 'stdlib.h', when=have_stdlib_h))
-set_define('HAVE_SETLOCALE', check_symbol_exists('setlocale', 'locale.h', when=have_locale_h))
-set_define('HAVE_USELOCALE', check_symbol_exists('uselocale', 'locale.h', when=have_locale_h))
-set_define('HAVE_STRCASECMP', check_symbol_exists('strcasecmp', 'strings.h', when=have_strings_h))
-set_define('HAVE_STRNCASECMP', check_symbol_exists('strncasecmp', 'strings.h', when=have_strings_h))
-set_define('HAVE_STRDUP', check_symbol_exists('strdup', 'string.h', when=have_string_h))
+    set_define('HAVE_DOPRNT', check_symbol_exists('_doprnt', 'stdio.h'))
+    set_define('HAVE_SNPRINTF', check_symbol_exists('snprintf', 'stdio.h'))
+    set_define('HAVE_VASPRINTF', check_symbol_exists('vasprintf', 'stdio.h', flags=['-D_GNU_SOURCE']))
+    set_define('HAVE_VSNPRINTF', check_symbol_exists('vsnprintf', 'stdio.h'))
+    set_define('HAVE_VPRINTF', check_symbol_exists('vprintf', 'stdio.h'))
 
-set_define('HAVE_MKDTEMP', check_symbol_exists('mkdtemp', ['stdlib.h','unistd.h']))
-set_define('HAVE_REALPATH', check_symbol_exists('realpath', 'stdlib.h'))
-set_define('HAVE_O_BINARY', check_symbol_exists('O_BINARY', 'fcntl.h'))
-set_define('HAVE__O_BINARY', check_symbol_exists('_O_BINARY', 'fcntl.h'))
+    set_define('HAVE_OPEN', check_symbol_exists('open', 'fcntl.h', when=have_fcntl_h))
+    set_define('HAVE_REALLOC', check_symbol_exists('realloc', 'stdlib.h', when=have_stdlib_h))
+    set_define('HAVE_SETLOCALE', check_symbol_exists('setlocale', 'locale.h', when=have_locale_h))
+    set_define('HAVE_USELOCALE', check_symbol_exists('uselocale', 'locale.h', when=have_locale_h))
+    set_define('HAVE_STRCASECMP', check_symbol_exists('strcasecmp', 'strings.h', when=have_strings_h))
+    set_define('HAVE_STRNCASECMP', check_symbol_exists('strncasecmp', 'strings.h', when=have_strings_h))
+    set_define('HAVE_STRDUP', check_symbol_exists('strdup', 'string.h', when=have_string_h))
+
+    set_define('HAVE_MKDTEMP', check_symbol_exists('mkdtemp', ['stdlib.h','unistd.h']))
+    set_define('HAVE_REALPATH', check_symbol_exists('realpath', 'stdlib.h'))
+    set_define('HAVE_O_BINARY', check_symbol_exists('O_BINARY', 'fcntl.h'))
+    set_define('HAVE__O_BINARY', check_symbol_exists('_O_BINARY', 'fcntl.h'))
 
 
-@depends(c_compiler, target)
+@depends(c_compiler, target, when=compile_environment)
 @checking('for clang_rt.builtins path', lambda x: x if x is None else x.clang_rt_lib)
 @imports(_from='os', _import='pathsep')
 @imports(_from='os.path', _import='isdir')
 @imports(_from='os.path', _import='exists')
 @imports(_from='os.path', _import='join')
 def clang_rt_builtins(compiler_info, target):
     if compiler_info.type == 'clang-cl':
         if target.raw_cpu in ['i686']:
@@ -128,17 +129,17 @@ def clang_rt_builtins(compiler_info, tar
                                 )
         die('Cannot find clang_rt.builtins path.')
 
 
 set_config('COMPILER_RT_BUILTIN_PATH', clang_rt_builtins.clang_rt_path, when=is_windows)
 set_config('COMPILER_RT_BUILTIN_LIB', clang_rt_builtins.clang_rt_lib, when=is_windows)
 
 
-@depends(c_compiler, cxx_compiler)
+@depends(c_compiler, cxx_compiler, when=compile_environment)
 def rnp_compiler(c_compiler, cxx_compiler):
     _cflags = [f for f in c_compiler.flags if f not in ('-Xclang', '-std=gnu99')]
     _cxxflags = [f for f in cxx_compiler.flags if f not in ('-Xclang', '-std=c++17', '-std=gnu17')]
 
     rnp_cc = ' '.join(list(c_compiler.wrapper) + [c_compiler.compiler] + _cflags)
     rnp_cxx = ' '.join(list(cxx_compiler.wrapper) + [cxx_compiler.compiler] + _cxxflags)
 
     return namespace(rnp_cc=rnp_cc,
--- a/third_party/rnpdefs.mozbuild
+++ b/third_party/rnpdefs.mozbuild
@@ -14,17 +14,18 @@ rnp_dist_info = '{} {} rnp'.format(
     CONFIG['MOZ_APP_DISPLAYNAME'],
     CONFIG['MOZ_APP_VERSION_DISPLAY']
 )
 
 COMPILE_FLAGS['OS_CFLAGS'] = []
 COMPILE_FLAGS['OS_CXXFLAGS'] = []
 COMPILE_FLAGS['OS_INCLUDES'] = []
 COMPILE_FLAGS['CLANG_PLUGIN'] = []
-COMPILE_FLAGS['MOZ_HARDENING_CFLAGS'] = []
+if not CONFIG['MOZ_ARTIFACT_BUILDS']:
+    COMPILE_FLAGS['MOZ_HARDENING_CFLAGS'] = []
 
 if CONFIG['CC_TYPE'] == 'clang-cl':
     CFLAGS += [
         '-Wno-inconsistent-dllimport',
         '-Wno-macro-redefined', # 'WIN32_LEAN_AND_MEAN' macro redefined
     ]
     USE_STATIC_LIBS = True