| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 19824f8 commit 2179f21
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2310,17 +2310,20 @@ def without_sqlite_error(option): | |||
| 2310 | 2310 | configure_library('sqlite', o, pkgname='sqlite3') | |
| 2311 | 2311 | ||
| 2312 | 2312 | def bundled_ffi_supported(os_name, target_arch): | |
| 2313 | - supported = { | ||
| 2314 | - 'freebsd': {'arm', 'arm64', 'x64'}, | ||
| 2315 | - 'linux': {'arm', 'arm64', 'x64'}, | ||
| 2316 | - 'mac': {'arm64', 'x64'}, | ||
| 2317 | - 'win': {'arm64', 'x64'}, | ||
| 2318 | - } | ||
| 2319 | - | ||
| 2320 | 2313 | if target_arch == 'x86': | |
| 2321 | 2314 | target_arch = 'ia32' | |
| 2322 | 2315 | ||
| 2323 | - return target_arch in supported.get(os_name, set()) | ||
| 2316 | + if target_arch in {'arm', 'arm64', 'ia32', 'x64', 'x86_64', | ||
| 2317 | + 'riscv64', 'loong64'}: | ||
| 2318 | + return True | ||
| 2319 | + | ||
| 2320 | + if target_arch in {'mips', 'mipsel', 'mips64el'}: | ||
| 2321 | + return os_name in {'freebsd', 'linux', 'openbsd'} | ||
| 2322 | + | ||
| 2323 | + if target_arch == 'ppc64': | ||
| 2324 | + return os_name in {'aix', 'freebsd', 'linux', 'mac', 'openbsd'} | ||
| 2325 | + | ||
| 2326 | + return False | ||
| 2324 | 2327 | ||
| 2325 | 2328 | def configure_ffi(o): | |
| 2326 | 2329 | use_ffi = not options.without_ffi | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,33 +10,63 @@ | |||
| 10 | 10 | LIBFFI_VERSION = '3.5.2' | |
| 11 | 11 | LIBFFI_VERSION_NUMBER = '30502' | |
| 12 | 12 | ||
| 13 | - TARGETS = { | ||
| 14 | - ('freebsd', 'arm'): ('ARM', 'arm'), | ||
| 15 | - ('freebsd', 'arm64'): ('AARCH64', 'aarch64'), | ||
| 16 | - ('freebsd', 'x64'): ('X86_64', 'x86'), | ||
| 17 | - ('linux', 'arm'): ('ARM', 'arm'), | ||
| 18 | - ('linux', 'arm64'): ('AARCH64', 'aarch64'), | ||
| 19 | - ('linux', 'x64'): ('X86_64', 'x86'), | ||
| 20 | - ('mac', 'arm64'): ('AARCH64', 'aarch64'), | ||
| 21 | - ('mac', 'x64'): ('X86_64', 'x86'), | ||
| 22 | - ('win', 'arm'): ('ARM_WIN32', 'arm'), | ||
| 23 | - ('win', 'arm64'): ('ARM_WIN64', 'aarch64'), | ||
| 24 | - ('win', 'x64'): ('X86_WIN64', 'x86'), | ||
| 25 | - } | ||
| 13 | + def normalize_arch(target_arch): | ||
| 14 | + aliases = { | ||
| 15 | + 'x86': 'ia32', | ||
| 16 | + 'x86_64': 'x64', | ||
| 17 | + 'arm64': 'arm64', | ||
| 18 | + 'aarch64': 'arm64', | ||
| 19 | + } | ||
| 20 | + return aliases.get(target_arch, target_arch) | ||
| 26 | 21 | ||
| 27 | 22 | ||
| 28 | 23 | def get_target(os_name, target_arch): | |
| 29 | - try: | ||
| 30 | - return TARGETS[(os_name, target_arch)] | ||
| 31 | - except KeyError as exc: | ||
| 32 | - supported = ', '.join( | ||
| 33 | - f'{os_name}/{arch}' for os_name, arch in sorted(TARGETS)) | ||
| 34 | - raise ValueError( | ||
| 35 | - f'Unsupported libffi target {os_name}/{target_arch}. ' | ||
| 36 | - f'Supported targets: {supported}.') from exc | ||
| 24 | + target_arch = normalize_arch(target_arch) | ||
| 25 | + | ||
| 26 | + if target_arch == 'arm': | ||
| 27 | + return ('ARM_WIN32' if os_name == 'win' else 'ARM', 'arm') | ||
| 28 | + | ||
| 29 | + if target_arch == 'arm64': | ||
| 30 | + return ('ARM_WIN64' if os_name == 'win' else 'AARCH64', 'aarch64') | ||
| 31 | + | ||
| 32 | + if target_arch == 'ia32': | ||
| 33 | + if os_name in ('freebsd', 'openbsd'): | ||
| 34 | + return ('X86_FREEBSD', 'x86') | ||
| 35 | + if os_name in ('ios', 'mac'): | ||
| 36 | + return ('X86_DARWIN', 'x86') | ||
| 37 | + if os_name == 'win': | ||
| 38 | + return ('X86_WIN32', 'x86') | ||
| 39 | + return ('X86', 'x86') | ||
| 40 | + | ||
| 41 | + if target_arch == 'x64': | ||
| 42 | + return ('X86_WIN64' if os_name == 'win' else 'X86_64', 'x86') | ||
| 43 | + | ||
| 44 | + if target_arch == 'riscv64': | ||
| 45 | + return ('RISCV', 'riscv') | ||
| 46 | + | ||
| 47 | + if target_arch == 'loong64': | ||
| 48 | + return ('LOONGARCH64', 'loongarch64') | ||
| 49 | + | ||
| 50 | + if target_arch in ('mips', 'mipsel', 'mips64el'): | ||
| 51 | + if os_name in ('freebsd', 'linux', 'openbsd'): | ||
| 52 | + return ('MIPS', 'mips') | ||
| 53 | + | ||
| 54 | + if target_arch == 'ppc64': | ||
| 55 | + if os_name == 'aix': | ||
| 56 | + return ('POWERPC_AIX', 'powerpc') | ||
| 57 | + if os_name == 'mac': | ||
| 58 | + return ('POWERPC_DARWIN', 'powerpc') | ||
| 59 | + if os_name in ('freebsd', 'openbsd'): | ||
| 60 | + return ('POWERPC_FREEBSD', 'powerpc') | ||
| 61 | + if os_name == 'linux': | ||
| 62 | + return ('POWERPC', 'powerpc') | ||
| 63 | + | ||
| 64 | + raise ValueError(f'Unsupported libffi target {os_name}/{target_arch}.') | ||
| 37 | 65 | ||
| 38 | 66 | ||
| 39 | 67 | def has_long_double(os_name, target_arch): | |
| 68 | + target_arch = normalize_arch(target_arch) | ||
| 69 | + | ||
| 40 | 70 | if os_name == 'win': | |
| 41 | 71 | return '0' | |
| 42 | 72 | ||
@@ -50,6 +80,7 @@ def has_long_double(os_name, target_arch): | |||
| 50 | 80 | ||
| 51 | 81 | ||
| 52 | 82 | def uses_exec_trampoline_table(os_name, target_arch): | |
| 83 | + target_arch = normalize_arch(target_arch) | ||
| 53 | 84 | return os_name == 'mac' and target_arch in ('arm', 'arm64') | |
| 54 | 85 | ||
| 55 | 86 | ||
@@ -72,6 +103,7 @@ def render_ffi_header(base_dir, os_name, target_arch, target): | |||
| 72 | 103 | ||
| 73 | 104 | ||
| 74 | 105 | def render_fficonfig(os_name, target_arch): | |
| 106 | + target_arch = normalize_arch(target_arch) | ||
| 75 | 107 | lines = [ | |
| 76 | 108 | '/* Auto-generated by generate-headers.py. */', | |
| 77 | 109 | '#ifndef LIBFFI_FFICONFIG_H_', | |
@@ -94,15 +126,15 @@ def render_fficonfig(os_name, target_arch): | |||
| 94 | 126 | '#define EH_FRAME_FLAGS "a"', | |
| 95 | 127 | ]) | |
| 96 | 128 | ||
| 97 | - if target_arch in ('x64', 'x86') and os_name != 'win': | ||
| 129 | + if target_arch in ('ia32', 'x64') and os_name != 'win': | ||
| 98 | 130 | lines.append('#define HAVE_AS_X86_PCREL 1') | |
| 99 | 131 | ||
| 100 | 132 | if uses_exec_trampoline_table(os_name, target_arch): | |
| 101 | 133 | lines.append('#define FFI_EXEC_TRAMPOLINE_TABLE 1') | |
| 102 | - elif os_name in ('freebsd', 'mac'): | ||
| 134 | + elif os_name in ('freebsd', 'mac', 'openbsd'): | ||
| 103 | 135 | lines.append('#define FFI_MMAP_EXEC_WRIT 1') | |
| 104 | 136 | ||
| 105 | - if os_name == 'linux': | ||
| 137 | + if os_name != 'win': | ||
| 106 | 138 | lines.extend([ | |
| 107 | 139 | '#define HAVE_DLFCN_H 1', | |
| 108 | 140 | '#define HAVE_MMAP 1', | |
@@ -111,15 +143,10 @@ def render_fficonfig(os_name, target_arch): | |||
| 111 | 143 | '#define HAVE_SYS_MMAN_H 1', | |
| 112 | 144 | '#define HAVE_UNISTD_H 1', | |
| 113 | 145 | ]) | |
| 114 | - elif os_name in ('freebsd', 'mac'): | ||
| 146 | + | ||
| 147 | + if os_name in ('freebsd', 'ios', 'mac', 'openbsd'): | ||
| 115 | 148 | lines.extend([ | |
| 116 | - '#define HAVE_DLFCN_H 1', | ||
| 117 | - '#define HAVE_MMAP 1', | ||
| 118 | - '#define HAVE_MMAP_ANON 1', | ||
| 119 | 149 | '#define HAVE_MMAP_DEV_ZERO 1', | |
| 120 | - '#define HAVE_MMAP_FILE 1', | ||
| 121 | - '#define HAVE_SYS_MMAN_H 1', | ||
| 122 | - '#define HAVE_UNISTD_H 1', | ||
| 123 | 150 | ]) | |
| 124 | 151 | ||
| 125 | 152 | if os_name == 'mac' and target_arch == 'arm64': | |
@@ -204,12 +231,19 @@ def detect_target_arch(): | |||
| 204 | 231 | 'x86_64': 'x64', | |
| 205 | 232 | 'x64': 'x64', | |
| 206 | 233 | 'win32': 'x64', | |
| 207 | - 'i386': 'x86', | ||
| 208 | - 'i686': 'x86', | ||
| 209 | - 'x86': 'x86', | ||
| 234 | + 'i386': 'ia32', | ||
| 235 | + 'i686': 'ia32', | ||
| 236 | + 'ia32': 'ia32', | ||
| 237 | + 'x86': 'ia32', | ||
| 210 | 238 | 'arm64': 'arm64', | |
| 211 | 239 | 'aarch64': 'arm64', | |
| 212 | 240 | 'arm': 'arm', | |
| 241 | + 'riscv64': 'riscv64', | ||
| 242 | + 'loong64': 'loong64', | ||
| 243 | + 'ppc64': 'ppc64', | ||
| 244 | + 'mips': 'mips', | ||
| 245 | + 'mipsel': 'mipsel', | ||
| 246 | + 'mips64el': 'mips64el', | ||
| 213 | 247 | } | |
| 214 | 248 | ||
| 215 | 249 | for candidate in candidates: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments