Backed out changeset 496886cb30a5 (bug 1867152) for bc failures on browser_user_input...
[gecko.git] / config / external / ffi / moz.build
blobee0dc884e0115c55ef8152fbd5988b1c18f00f9b
1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2 # vim: set filetype=python:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 FINAL_LIBRARY = "js"
9 if CONFIG["MOZ_SYSTEM_FFI"]:
10     OS_LIBS += CONFIG["MOZ_FFI_LIBS"]
11 else:
12     AllowCompilerWarnings()
13     NoVisibilityFlags()
15     CONFIGURE_DEFINE_FILES += [
16         "/js/src/ctypes/libffi/fficonfig.h",
17     ]
18     LOCAL_INCLUDES += [
19         "!/js/src/ctypes/libffi",
20         "!/js/src/ctypes/libffi/include",
21         "/js/src/ctypes/libffi/include",
22         "/js/src/ctypes/libffi/src/%s" % CONFIG["FFI_TARGET_DIR"],
23     ]
25     DEFINES["TARGET"] = CONFIG["FFI_TARGET"]
26     DEFINES[CONFIG["FFI_TARGET"]] = True
27     DEFINES["FFI_NO_RAW_API"] = True
28     DEFINES["FFI_BUILDING"] = True
29     DEFINES["HAVE_AS_ASCII_PSEUDO_OP"] = True
30     DEFINES["HAVE_AS_STRING_PSEUDO_OP"] = True
32     if CONFIG["MOZ_DEBUG"]:
33         DEFINES["FFI_DEBUG"] = True
34         if not CONFIG["MOZ_NO_DEBUG_RTL"]:
35             DEFINES["USE_DEBUG_RTL"] = True
36         SOURCES += [
37             "/js/src/ctypes/libffi/src/debug.c",
38         ]
40     if CONFIG["OS_TARGET"] != "WINNT":
41         DEFINES["HAVE_HIDDEN_VISIBILITY_ATTRIBUTE"] = True
43     if CONFIG["INTEL_ARCHITECTURE"]:
44         DEFINES["HAVE_AS_X86_PCREL"] = True
46     # Don't bother setting EH_FRAME_FLAGS on Windows.
47     # Quoted defines confuse msvcc.sh, and the value isn't used there.
48     if CONFIG["OS_TARGET"] != "WINNT":
49         if CONFIG["FFI_TARGET"] == "ARM":
50             DEFINES["EH_FRAME_FLAGS"] = '"aw"'
51         else:
52             DEFINES["EH_FRAME_FLAGS"] = '"a"'
54     # Common source files.
55     SOURCES += [
56         "/js/src/ctypes/libffi/src/closures.c",
57         "/js/src/ctypes/libffi/src/java_raw_api.c",
58         "/js/src/ctypes/libffi/src/prep_cif.c",
59         "/js/src/ctypes/libffi/src/raw_api.c",
60         "/js/src/ctypes/libffi/src/types.c",
61     ]
63     # Per-platform sources and flags.
64     ffi_srcs = ()
65     ffi_h_defines = []
66     if CONFIG["FFI_TARGET"] == "X86_WIN64":
67         if CONFIG["CC_TYPE"] == "clang-cl":
68             ffi_srcs = ("ffiw64.c",)
69             # libffi asm needs to be preprocessed for MSVC's assembler
70             GeneratedFile(
71                 "win64_intel.asm",
72                 inputs=[
73                     "/js/src/ctypes/libffi/src/x86/win64_intel.S",
74                     "!/js/src/ctypes/libffi/fficonfig.h",
75                     "!/js/src/ctypes/libffi/include/ffi.h",
76                 ],
77                 script="preprocess_libffi_asm.py",
78                 flags=["$(DEFINES)", "$(LOCAL_INCLUDES)"],
79             )
80             SOURCES += ["!win64_intel.asm"]
81         else:
82             ffi_srcs = ("ffiw64.c", "win64.S")
84     elif CONFIG["FFI_TARGET"] == "X86_64":
85         DEFINES["HAVE_AS_X86_64_UNWIND_SECTION_TYPE"] = True
86         ffi_srcs = ("ffi64.c", "unix64.S", "ffiw64.c", "win64.S")
88     elif CONFIG["FFI_TARGET"] == "X86_WIN32" and CONFIG["CC_TYPE"] == "clang-cl":
89         ffi_srcs = ("ffi.c",)
90         # libffi asm needs to be preprocessed for MSVC's assembler
91         GeneratedFile(
92             "sysv_intel.asm",
93             inputs=[
94                 "/js/src/ctypes/libffi/src/x86/sysv_intel.S",
95                 "!/js/src/ctypes/libffi/fficonfig.h",
96                 "!/js/src/ctypes/libffi/include/ffi.h",
97             ],
98             script="preprocess_libffi_asm.py",
99             flags=["$(DEFINES)", "$(LOCAL_INCLUDES)"],
100         )
101         SOURCES += ["!sysv_intel.asm"]
102         ASFLAGS += ["-safeseh"]
104     elif CONFIG["FFI_TARGET"] == "ARM_WIN64":
105         ffi_srcs = ("ffi.c",)
107         # libffi asm needs to be preprocessed for MSVC's assembler
108         GeneratedFile(
109             "win64_armasm.asm",
110             inputs=[
111                 "/js/src/ctypes/libffi/src/aarch64/win64_armasm.S",
112                 "!/js/src/ctypes/libffi/fficonfig.h",
113                 "!/js/src/ctypes/libffi/include/ffi.h",
114             ],
115             script="preprocess_libffi_asm.py",
116             flags=["$(DEFINES)", "$(LOCAL_INCLUDES)"],
117         )
118         SOURCES += ["!win64_armasm.asm"]
120     else:
121         ffi_srcs = ("ffi.c", "sysv.S")
123     if CONFIG["FFI_TARGET"] in ("X86_WIN32", "X86_DARWIN") and CONFIG["CC_TYPE"] in (
124         "gcc",
125         "clang",
126     ):
127         DEFINES["SYMBOL_UNDERSCORE"] = True
129     if CONFIG["OS_ARCH"] == "Darwin" and CONFIG["TARGET_CPU"] in ("arm", "aarch64"):
130         DEFINES["FFI_EXEC_TRAMPOLINE_TABLE"] = True
131         ffi_h_defines.append("FFI_EXEC_TRAMPOLINE_TABLE")
133     elif (
134         CONFIG["OS_ARCH"] in ("Darwin", "FreeBSD", "GNU_kFreeBSD", "OpenBSD", "SunOS")
135         or CONFIG["OS_TARGET"] == "Android"
136     ):
137         DEFINES["FFI_MMAP_EXEC_WRIT"] = True
139     SOURCES += [
140         "/js/src/ctypes/libffi/src/%s/%s" % (CONFIG["FFI_TARGET_DIR"], s)
141         for s in sorted(ffi_srcs)
142     ]
144     GeneratedFile(
145         "/js/src/ctypes/libffi/include/ffi.h",
146         script="subst_header.py",
147         inputs=["/js/src/ctypes/libffi/include/ffi.h.in"],
148         flags=ffi_h_defines,
149     )