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/.
9 if CONFIG["MOZ_SYSTEM_FFI"]:
10 OS_LIBS += CONFIG["MOZ_FFI_LIBS"]
12 AllowCompilerWarnings()
15 CONFIGURE_DEFINE_FILES += [
16 "/js/src/ctypes/libffi/fficonfig.h",
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"],
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
37 "/js/src/ctypes/libffi/src/debug.c",
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"'
52 DEFINES["EH_FRAME_FLAGS"] = '"a"'
54 # Common source files.
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",
63 # Per-platform sources and flags.
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
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",
77 script="preprocess_libffi_asm.py",
78 flags=["$(DEFINES)", "$(LOCAL_INCLUDES)"],
80 SOURCES += ["!win64_intel.asm"]
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":
90 # libffi asm needs to be preprocessed for MSVC's assembler
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",
98 script="preprocess_libffi_asm.py",
99 flags=["$(DEFINES)", "$(LOCAL_INCLUDES)"],
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
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",
115 script="preprocess_libffi_asm.py",
116 flags=["$(DEFINES)", "$(LOCAL_INCLUDES)"],
118 SOURCES += ["!win64_armasm.asm"]
121 ffi_srcs = ("ffi.c", "sysv.S")
123 if CONFIG["FFI_TARGET"] in ("X86_WIN32", "X86_DARWIN") and CONFIG["CC_TYPE"] in (
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")
134 CONFIG["OS_ARCH"] in ("Darwin", "FreeBSD", "GNU_kFreeBSD", "OpenBSD", "SunOS")
135 or CONFIG["OS_TARGET"] == "Android"
137 DEFINES["FFI_MMAP_EXEC_WRIT"] = True
140 "/js/src/ctypes/libffi/src/%s/%s" % (CONFIG["FFI_TARGET_DIR"], s)
141 for s in sorted(ffi_srcs)
145 "/js/src/ctypes/libffi/include/ffi.h",
146 script="subst_header.py",
147 inputs=["/js/src/ctypes/libffi/include/ffi.h.in"],