Backed out changeset e7acb4e12051 (bug 1893666) for causing xpcshell failures on...
[gecko.git] / security / nss / coreconf / config.gypi
blobbaf4256a8781da3eeadd7e0afa6755d6a26bd0f6
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5   'variables': {
6     'module%': '',
7     'variables': {
8       'variables': {
9         'variables': {
10           'python%': 'python',
11         },
12         # chromium uses pymod_do_main, but gyp doesn't set a sensible
13         # Python sys.path (gyp_chromium does).
14         'python%': '<(python)',
15         'host_arch%': '<!("<(python)" <(DEPTH)/coreconf/detect_host_arch.py)',
16       },
17       'python%': '<(python)',
18       'host_arch%': '<(host_arch)',
19       'conditions': [
20         ['OS=="android"', {
21           'target_arch%': 'arm',
22         }, 'OS=="ios"', {
23           'target_arch%': 'arm64',
24         }, {
25           # Default architecture we're building for is the architecture we're
26           # building on.
27           'target_arch%': '<(host_arch)',
28         }],
29         ['OS=="linux"', {
30           # FIPS-140 LOWHASH
31           'freebl_name': 'freeblpriv3',
32         }, {
33           'freebl_name': 'freebl3',
34         }],
35         ['OS=="mac"', {
36           'use_system_sqlite%': 1,
37         },{
38           'use_system_sqlite%': 0,
39         }],
40         ['OS=="mac" or OS=="ios" or OS=="solaris" or OS=="win"', {
41           'cc_use_gnu_ld%': 0,
42         }, {
43           'cc_use_gnu_ld%': 1,
44         }],
45         ['OS=="win"', {
46           'use_system_zlib%': 0,
47           'nspr_libs%': ['libnspr4.lib', 'libplc4.lib', 'libplds4.lib'],
48           'zlib_libs%': [],
49           #TODO
50           'moz_debug_flags%': '',
51           'dll_prefix': '',
52           'dll_suffix': 'dll',
53         }, {
54           'use_system_zlib%': 1,
55           'nspr_libs%': ['-lplds4', '-lplc4', '-lnspr4'],
56           'zlib_libs%': ['-lz'],
57           'dll_prefix': 'lib',
58           'conditions': [
59             ['OS=="mac" or OS=="ios"', {
60               'moz_debug_flags%': '-gdwarf-2 -gfull',
61               'dll_suffix': 'dylib',
62             }, {
63               'moz_debug_flags%': '-gdwarf-2',
64               'dll_suffix': 'so',
65             }],
66           ],
67         }],
68         ['"<(GENERATOR)"=="ninja"', {
69           'cc_is_clang%': '<!("<(python)" <(DEPTH)/coreconf/check_cc.py clang)',
70         }, {
71           'cc_is_clang%': '0',
72         }],
73         ['"<(GENERATOR)"=="ninja"', {
74           'cc_is_gcc%': '<!("<(python)" <(DEPTH)/coreconf/check_cc.py gcc)',
75         }, {
76           'cc_is_gcc%': '0',
77         }],
78         ['"<(GENERATOR)"=="ninja"', {
79           'cc_is_cc%': '<!("<(python)" <(DEPTH)/coreconf/check_cc.py cc)',
80         }, {
81           'cc_is_cc%': '0',
82         }],
83       ],
84     },
85     # Copy conditionally-set variables out one scope.
86     'python%': '<(python)',
87     'host_arch%': '<(host_arch)',
88     'target_arch%': '<(target_arch)',
89     'use_system_zlib%': '<(use_system_zlib)',
90     'zlib_libs%': ['<@(zlib_libs)'],
91     'moz_debug_flags%': '<(moz_debug_flags)',
92     'nspr_libs%': ['<@(nspr_libs)'],
93     'nspr_lib_dir%': '<(nspr_lib_dir)',
94     'nspr_include_dir%': '<(nspr_include_dir)',
95     'use_system_sqlite%': '<(use_system_sqlite)',
96     'sqlite_libs%': ['-lsqlite3'],
97     'dll_prefix': '<(dll_prefix)',
98     'dll_suffix': '<(dll_suffix)',
99     'freebl_name': '<(freebl_name)',
100     'cc_is_clang%': '<(cc_is_clang)',
101     'cc_is_gcc%': '<(cc_is_gcc)',
102     'cc_use_gnu_ld%': '<(cc_use_gnu_ld)',
103     # Some defaults
104     'disable_arm_hw_aes%': 0,
105     'disable_arm_hw_sha1%': 0,
106     'disable_arm_hw_sha2%': 0,
107     'disable_intel_hw_sha%': 0,
108     'disable_tests%': 0,
109     'disable_chachapoly%': 0,
110     'disable_deprecated_seed%': 0,
111     'disable_deprecated_rc2%': 0,
112     'disable_dbm%': 1,
113     'disable_libpkix%': 1,
114     'disable_werror%': 0,
115     'disable_altivec%': 0,
116     'disable_crypto_vsx%': 0,
117     'disable_arm32_neon%': 0,
118     'mozilla_client%': 0,
119     'comm_client%': 0,
120     'moz_fold_libs%': 0,
121     'moz_folded_library_name%': '',
122     'sanitizer_flags%': 0,
123     'static_libs%': 0,
124     'no_zdefs%': 0,
125     'fuzz%': 0,
126     'fuzz_tls%': 0,
127     'fuzz_oss%': 0,
128     'sign_libs%': 1,
129     'use_pprof%': 0,
130     'ct_verif%': 0,
131     'emit_llvm%': 0,
132     'nss_public_dist_dir%': '<(nss_dist_dir)/public',
133     'nss_private_dist_dir%': '<(nss_dist_dir)/private',
134     # This is only needed when building with --mozpkix-only and might not work
135     # on all machines.
136     'nss_include_dir%': '/usr/include/nss',
137     'only_dev_random%': 1,
138     'disable_fips%': 1,
139     'fips_module_id%': '',
140     'mozpkix_only%': 0,
141     'mozilla_central%': 0,
142     'coverage%': 0,
143     'softfp_cflags%': '',
144     'enable_draft_hpke%': 0,
145     'force_integrated_as%': 0,
146     'disable_ckbi%': 0,
147     'ppc_abi%': 0,
148   },
149   'target_defaults': {
150     # Settings specific to targets should go here.
151     # This is mostly for linking to libraries.
152     'variables': {
153       'mapfile%': '',
154       'static_libs%': 0,
155       'debug_optimization_level%': '0',
156       'release_optimization_level%': '2',
157     },
158     'standalone_static_library': 0,
159     'include_dirs': [
160       '<(nspr_include_dir)',
161       '<(nss_dist_dir)/private/<(module)',
162     ],
163     'conditions': [
164       [ 'mozpkix_only==1 and OS=="linux"', {
165         'include_dirs': [
166           '<(nss_include_dir)',
167         ],
168       }],
169       [ 'disable_fips==0', {
170         'defines': [
171           'NSS_ENABLE_FIPS_INDICATORS',
172         ],
173       }],
174       [ 'disable_fips==1', {
175         'defines': [
176           'NSS_FIPS_DISABLED',
177           'NSS_NO_INIT_SUPPORT',
178         ],
179       }],
180       [ 'fips_module_id!=""', {
181         'defines': [
182           'NSS_FIPS_MODULE_ID="<(fips_module_id)"'
183         ],
184       }],
185       [ 'OS!="android" and OS!="mac" and OS!="ios" and OS!="win"', {
186         'libraries': [
187           '-lpthread',
188         ],
189       }],
190       [ 'OS=="linux"', {
191         'libraries': [
192           '-ldl',
193           '-lc',
194         ],
195       }],
196       [ 'OS=="android"', {
197         'libraries': [
198           '-llog',
199         ],
200       }],
201       [ 'fuzz==1', {
202         'variables': {
203           'debug_optimization_level%': '1',
204         },
205       }],
206       [ 'target_arch=="ia32" or target_arch=="x64"', {
207         'defines': [
208           'NSS_X86_OR_X64',
209         ],
210         # For Windows.
211         'msvs_settings': {
212           'VCCLCompilerTool': {
213             'PreprocessorDefinitions': [
214               'NSS_X86_OR_X64',
215             ],
216           },
217         },
218       }],
219       [ 'target_arch=="ia32"', {
220         'defines': [
221           'NSS_X86',
222         ],
223         # For Windows.
224         'msvs_settings': {
225           'VCCLCompilerTool': {
226             'PreprocessorDefinitions': [
227               'NSS_X86',
228             ],
229           },
230         },
231       }],
232       [ 'target_arch=="arm64" or target_arch=="aarch64" or target_arch=="sparc64" or target_arch=="ppc64" or target_arch=="ppc64le" or target_arch=="s390x" or target_arch=="mips64" or target_arch=="e2k" or target_arch=="riscv64" or target_arch=="loongarch64"', {
233         'defines': [
234           'NSS_USE_64',
235         ],
236       }],
237       [ 'target_arch=="x64"', {
238         'defines': [
239           'NSS_X64',
240           'NSS_USE_64',
241         ],
242         # For Windows.
243         'msvs_settings': {
244           'VCCLCompilerTool': {
245             'PreprocessorDefinitions': [
246               'NSS_X64',
247               'NSS_USE_64',
248             ],
249           },
250         },
251       }],
252     ],
253     'target_conditions': [
254       # If we want to properly export a static library, and copy it to lib,
255       # we need to mark it as a 'standalone_static_library'. Otherwise,
256       # the relative paths in the thin archive will break linking.
257       [ '_type=="shared_library"', {
258         'product_dir': '<(nss_dist_obj_dir)/lib'
259       }, '_type=="executable"', {
260         'product_dir': '<(nss_dist_obj_dir)/bin'
261       }, 'static_libs==1 or _standalone_static_library==1', {
262         'product_dir': '<(nss_dist_obj_dir)/lib'
263       }],
264       # mapfile handling
265       [ 'mapfile!=""', {
266         # Work around a gyp bug. Fixed upstream but not in Ubuntu packages:
267         # https://chromium.googlesource.com/external/gyp/+/b85ad3e578da830377dbc1843aa4fbc5af17a192%5E%21/
268         'sources': [
269           '<(DEPTH)/coreconf/empty.c',
270         ],
271         'xcode_settings': {
272           'OTHER_LDFLAGS': [
273             '-exported_symbols_list',
274             '<(INTERMEDIATE_DIR)/out.>(mapfile)',
275           ],
276         },
277         'conditions': [
278           [ 'cc_use_gnu_ld==1', {
279             'ldflags': [
280               '-Wl,--version-script,<(INTERMEDIATE_DIR)/out.>(mapfile)',
281             ],
282           }],
283           [ 'cc_use_gnu_ld!=1 and OS=="win"', {
284             # On Windows, .def files are used directly as sources.
285             'sources': [
286               '>(mapfile)',
287             ],
288           }, {
289             # On other platforms, .def files need processing.
290             'sources': [
291               '<(INTERMEDIATE_DIR)/out.>(mapfile)',
292             ],
293             'actions': [{
294               'action_name': 'generate_mapfile',
295               'inputs': [
296                 '>(mapfile)',
297               ],
298               'outputs': [
299                 '<(INTERMEDIATE_DIR)/out.>(mapfile)',
300               ],
301               'action': ['<@(process_map_file)'],
302             }],
303           }]
304         ],
305       }, 'static_libs==1 and _type=="shared_library"', {
306         # When linking a shared lib against a static one, XCode doesn't
307         # export the latter's symbols by default. -all_load fixes that.
308         'xcode_settings': {
309           'OTHER_LDFLAGS': [
310             '-all_load',
311           ],
312         },
313       }],
314       [ '_type=="shared_library" or _type=="executable"', {
315         'libraries': [
316           '<@(nspr_libs)',
317         ],
318         'library_dirs': [
319           '<(nspr_lib_dir)',
320         ],
321       }],
322       # Shared library specific settings.
323       [ '_type=="shared_library"', {
324         'conditions': [
325           [ 'cc_use_gnu_ld==1', {
326             'ldflags': [
327               '-Wl,--gc-sections',
328             ],
329             'conditions': [
330               ['no_zdefs==0', {
331                 'ldflags': [
332                   '-Wl,-z,defs',
333                 ],
334               }],
335             ],
336           }],
337         ],
338         'xcode_settings': {
339           'DYLIB_INSTALL_NAME_BASE': '@executable_path',
340           'DYLIB_COMPATIBILITY_VERSION': '1',
341           'DYLIB_CURRENT_VERSION': '1',
342           'OTHER_LDFLAGS': [
343             '-headerpad_max_install_names',
344           ],
345         },
346         'msvs_settings': {
347           'VCLinkerTool': {
348             'SubSystem': '2',
349           },
350         },
351       }],
352       [ '_type=="static_library" and static_libs==1', {
353         'standalone_static_library': 1,
354       }],
355     ],
356     'default_configuration': 'Debug',
357     'configurations': {
358       # Common settings for Debug+Release should go here.
359       'Common': {
360         'abstract': 1,
361         'defines': [
362           'USE_UTIL_DIRECTLY',
363           'NO_NSPR_10_SUPPORT',
364           'SSL_DISABLE_DEPRECATED_CIPHER_SUITE_NAMES',
365         ],
366         'msvs_configuration_attributes': {
367           'OutputDirectory': '$(SolutionDir)$(ConfigurationName)',
368           'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)',
369         },
370         'msvs_settings': {
371           'VCCLCompilerTool': {
372             'AdditionalIncludeDirectories': ['<(nspr_include_dir)'],
373           },
374         },
375         'xcode_settings': {
376           'CLANG_CXX_LANGUAGE_STANDARD': 'c++0x',
377           'OTHER_CFLAGS': [
378             '-fPIC',
379             '-fno-common',
380             '-pipe',
381           ],
382         },
383         'conditions': [
384           [ 'OS=="linux" or OS=="android"', {
385             'defines': [
386               'LINUX2_1',
387               'LINUX',
388               'linux',
389               '_DEFAULT_SOURCE', # for <endian.h> functions, strdup, realpath, and getentropy
390               '_BSD_SOURCE', # for the above in glibc <= 2.19
391               '_POSIX_SOURCE', # for <signal.h>
392               'SDB_MEASURE_USE_TEMP_DIR', # use tmpdir for the access calls
393             ],
394           }],
395           [ 'OS=="dragonfly" or OS=="freebsd"', {
396             'defines': [
397               'FREEBSD',
398             ],
399           }],
400           [ 'OS=="netbsd"', {
401             'defines': [
402               'NETBSD',
403             ],
404           }],
405           [ 'OS=="openbsd"', {
406             'defines': [
407               'OPENBSD',
408             ],
409           }],
410           ['OS=="mac" or OS=="ios" or OS=="dragonfly" or OS=="freebsd" or OS=="netbsd" or OS=="openbsd"', {
411             'defines': [
412               'HAVE_BSD_FLOCK',
413             ],
414           }],
415           [ 'OS!="win"', {
416             'defines': [
417               'HAVE_STRERROR',
418               'XP_UNIX',
419               '_REENTRANT',
420             ],
421           }],
422           [ 'OS!="mac" and OS!="ios" and OS!="solaris" and OS!="win"', {
423             'ldflags': [
424               '-z', 'noexecstack',
425             ],
426           }],
427           [ 'OS!="mac" and OS!="ios" and OS!="win"', {
428             'cflags': [
429               '-fPIC',
430               '-pipe',
431               '-ffunction-sections',
432               '-fdata-sections',
433             ],
434             'cflags_c': [
435               '-std=c99',
436             ],
437             'cflags_cc': [
438               '-std=c++11',
439             ],
440             'conditions': [
441               [ 'target_arch=="ia32"', {
442                 'cflags': ['-m32'],
443                 'ldflags': ['-m32'],
444               }],
445               [ 'target_arch=="x64"', {
446                 'cflags': ['-m64'],
447                 'ldflags': ['-m64'],
448               }],
449             ],
450           }],
451           [ 'use_pprof==1 and OS!="android" and OS!="win"', {
452             'conditions': [
453               [ 'OS=="mac" or OS=="ios"', {
454                 'xcode_settings': {
455                   'OTHER_LDFLAGS': [ '-lprofiler' ],
456                 },
457               }, {
458                 'ldflags': [ '-lprofiler' ],
459               }],
460               [ 'OS!="linux"', {
461                 'library_dirs': [
462                   '/usr/local/lib/',
463                 ],
464               }],
465             ],
466           }],
467           [ 'disable_werror==0 and OS!="android" and OS!="win"', {
468             'cflags': [
469               '<!@("<(python)" <(DEPTH)/coreconf/werror.py)',
470             ],
471             'xcode_settings': {
472               'OTHER_CFLAGS': [
473                 '<!@("<(python)" <(DEPTH)/coreconf/werror.py)',
474               ],
475             },
476           }],
477           [ 'fuzz_tls==1', {
478             'cflags': [
479               '-Wno-unused-function',
480               '-Wno-unused-variable',
481             ],
482             'xcode_settings': {
483               'OTHER_CFLAGS': [
484                 '-Wno-unused-function',
485                 '-Wno-unused-variable',
486               ],
487             },
488           }],
489           [ 'sanitizer_flags!=0', {
490             'cflags': ['<@(sanitizer_flags)'],
491             'ldflags': ['<@(sanitizer_flags)'],
492             'xcode_settings': {
493               'OTHER_CFLAGS': ['<@(sanitizer_flags)'],
494               # We want to pass -fsanitize=... to our final link call,
495               # but not to libtool. OTHER_LDFLAGS is passed to both.
496               # To trick GYP into doing what we want, we'll piggyback on
497               # LIBRARY_SEARCH_PATHS, producing "-L/usr/lib -fsanitize=...".
498               # The -L/usr/lib is redundant but innocuous: it's a default path.
499               'LIBRARY_SEARCH_PATHS': ['/usr/lib <(sanitizer_flags)'],
500             },
501           }],
502           [ 'emit_llvm==1', {
503             'cflags': ['-flto'],
504             'ldflags': ['-flto', '-fuse-ld=gold', '-Wl,-plugin-opt=save-temps'],
505           }],
506           [ 'OS=="android" and mozilla_client==0', {
507             'defines': [
508               'NO_SYSINFO',
509               'NO_FORK_CHECK',
510               'ANDROID',
511             ],
512           }],
513           [ 'OS=="mac" or OS=="ios"', {
514             'defines': [
515               'DARWIN',
516             ],
517             'conditions': [
518               [ 'target_arch=="ia32"', {
519                 'xcode_settings': {
520                   'ARCHS': ['i386'],
521                 },
522               }],
523               [ 'target_arch=="x64"', {
524                 'xcode_settings': {
525                   'ARCHS': ['x86_64'],
526                 },
527               }],
528               [ 'target_arch=="arm64"', {
529                 'xcode_settings': {
530                   'ARCHS': ['arm64'],
531                 },
532               }],
533             ],
534           }],
535           [ 'OS=="ios"', {
536             'xcode_settings': {
537               'IPHONEOS_DEPLOYMENT_TARGET': '<(iphone_deployment_target)',
538             },
539           }],
540           [ 'OS=="win"', {
541             'defines': [
542               '_WINDOWS',
543               'WIN95',
544               '_CRT_SECURE_NO_WARNINGS',
545               '_CRT_NONSTDC_NO_WARNINGS',
546             ],
547             'cflags': [
548               '-W3',
549               '-w44267', # Disable C4267: conversion from 'size_t' to 'type', possible loss of data
550               '-w44244', # Disable C4244: conversion from 'type1' to 'type2', possible loss of data
551               '-w44018', # Disable C4018: 'expression' : signed/unsigned mismatch
552               '-w44312', # Disable C4312: 'type cast': conversion from 'type1' to 'type2' of greater size
553             ],
554             'conditions': [
555               [ 'disable_werror==0', {
556                 'cflags': ['-WX']
557               }],
558               [ 'target_arch=="ia32"', {
559                 'msvs_configuration_platform': 'Win32',
560                 'msvs_settings': {
561                   'VCLinkerTool': {
562                     'MinimumRequiredVersion': '5.01',  # XP.
563                     'TargetMachine': '1',
564                     'ImageHasSafeExceptionHandlers': 'false',
565                   },
566                   'VCCLCompilerTool': {
567                     'PreprocessorDefinitions': [
568                       'WIN32',
569                     ],
570                     'AdditionalOptions': [ '/EHsc' ],
571                   },
572                 },
573               }],
574               [ 'target_arch=="x64"', {
575                 'msvs_configuration_platform': 'x64',
576                 'msvs_settings': {
577                   'VCLinkerTool': {
578                     'TargetMachine': '17', # x86-64
579                   },
580                   'VCCLCompilerTool': {
581                     'PreprocessorDefinitions': [
582                       'WIN64',
583                       '_AMD64_',
584                     ],
585                     'AdditionalOptions': [ '/EHsc' ],
586                   },
587                 },
588               }],
589             ],
590           }],
591           [ 'disable_dbm==1', {
592             'defines': [
593               'NSS_DISABLE_DBM',
594             ],
595           }],
596           [ 'disable_libpkix==1', {
597             'defines': [
598               'NSS_DISABLE_LIBPKIX',
599             ],
600           }],
601           [ 'disable_deprecated_seed==1', {
602             'defines': [
603               'NSS_DISABLE_DEPRECATED_SEED',
604             ],
605           }],
606           [ 'disable_deprecated_rc2==1', {
607             'defines': [
608               'NSS_DISABLE_DEPRECATED_RC2',
609             ],
610           }],
611         ],
612       },
613       # Common settings for debug should go here.
614       'Debug': {
615         'inherit_from': ['Common'],
616         'conditions': [
617           [ 'OS!="mac" and OS!="ios" and OS!="win"', {
618             'cflags': [
619               '-g',
620               '<(moz_debug_flags)',
621             ],
622           }]
623         ],
624         #TODO: DEBUG_$USER
625         'defines': ['DEBUG'],
626         'cflags': [ '-O<(debug_optimization_level)' ],
627         'xcode_settings': {
628           'COPY_PHASE_STRIP': 'NO',
629           'GCC_OPTIMIZATION_LEVEL': '<(debug_optimization_level)',
630           'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES',
631         },
632         'msvs_settings': {
633           'VCCLCompilerTool': {
634             'Optimization': '<(debug_optimization_level)',
635             'BasicRuntimeChecks': '3',
636             'RuntimeLibrary': '2', # /MD
637             'DebugInformationFormat': '3',
638           },
639           'VCLinkerTool': {
640             'LinkIncremental': '1',
641             'GenerateDebugInformation' : 'true',
642           },
643           'VCResourceCompilerTool': {
644             'PreprocessorDefinitions': ['DEBUG'],
645           },
646         },
647       },
648       # Common settings for release should go here.
649       'Release': {
650         'inherit_from': ['Common'],
651         'defines': ['NDEBUG'],
652         'cflags': [ '-O<(release_optimization_level)' ],
653         'xcode_settings': {
654           'DEAD_CODE_STRIPPING': 'YES',  # -Wl,-dead_strip
655           'GCC_OPTIMIZATION_LEVEL': '<(release_optimization_level)',
656         },
657         'msvs_settings': {
658           'VCCLCompilerTool': {
659             'Optimization': '<(release_optimization_level)',
660             'RuntimeLibrary': '2', # /MD
661           },
662           'VCLinkerTool': {
663             'LinkIncremental': '1',
664           },
665         },
666       },
667       'conditions': [
668         [ 'OS=="win"', {
669           # The gyp ninja backend requires these.
670           # TODO: either we should support building both 32/64-bit as
671           # configurations from the same gyp build, or we should fix
672           # upstream gyp to not require these.
673           'Debug_x64': {
674             'inherit_from': ['Debug'],
675           },
676           'Release_x64': {
677             'inherit_from': ['Release'],
678           },
679         }],
680       ],
681     },
682   },
683   'conditions': [
684     [ 'cc_use_gnu_ld==1 or OS=="solaris"', {
685       'variables': {
686         'process_map_file': ['/bin/sh', '-c', '/usr/bin/env grep -v ";-" >(mapfile) | sed -e "s,;+,," -e "s; DATA ;;" -e "s,;;,," -e "s,;.*,;," > >@(_outputs)'],
687       },
688     }],
689     [ 'OS=="mac" or OS=="ios"', {
690       'variables': {
691         'process_map_file': ['/bin/sh', '-c', '/usr/bin/grep -v ";+" >(mapfile) | grep -v ";-" | sed -e "s; DATA ;;" -e "s,;;,," -e "s,;.*,," -e "s,^,_," > >@(_outputs)'],
692       },
693     }],
694   ],