Skip to content

Commit 945c412

Browse files
committed
sys: refactor jit config
1 parent 2f87eb9 commit 945c412

File tree

1 file changed

+39
-27
lines changed

1 file changed

+39
-27
lines changed

pcre2-sys/build.rs

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const FILES: &'static [&'static str] = &[
4545
"pcre2_newline.c",
4646
"pcre2_ord2utf.c",
4747
"pcre2_pattern_info.c",
48+
"pcre2_script_run.c",
4849
"pcre2_serialize.c",
4950
"pcre2_string_utils.c",
5051
"pcre2_study.c",
@@ -99,7 +100,44 @@ fn main() {
99100
builder.define("HAVE_WINDOWS_H", "1");
100101
}
101102

102-
enable_jit(&target, &mut builder);
103+
// Configure JIT according to https://www.pcre.org/current/doc/html/pcre2jit.html#SEC2.
104+
// We disable unsupported targets despite `is_jit_available` because “if --enable-jit
105+
// is set on an unsupported platform, compilation fails.”
106+
match target.as_str() {
107+
"aarch64-apple-ios" // does not support executable pages due to vendor‘s terms
108+
| "aarch64-apple-tvos" // =
109+
| "aarch64-apple-ios-sim" // disabled for device–simulator consistency
110+
| "x86_64-apple-ios" // =
111+
| "x86_64-apple-tvos" // =
112+
| "armv7-apple-ios" // assumed equivalent to aarch64-apple-ios
113+
| "armv7s-apple-ios" // =
114+
| "i386-apple-ios" // =
115+
| "msp430-none-elf"
116+
| "armv4t-unknown-linux-gnueabi"
117+
| "thumbv4t-none-eabi"
118+
| "wasm64-unknown-unknown"
119+
| "asmjs-unknown-emscripten"
120+
| "bpfel-unknown-none"
121+
| "bpfeb-unknown-none"
122+
| "hexagon-unknown-linux-musl"
123+
| "sparc64-unknown-netbsd"
124+
| "sparc64-unknown-openbsd"
125+
| "sparc64-unknown-linux-gnu"
126+
| "riscv64imac-unknown-none-elf"
127+
| "riscv64gc-unknown-none-elf"
128+
| "riscv32imc-unknown-none-elf"
129+
| "riscv32imac-unknown-none-elf"
130+
| "riscv32i-unknown-none-elf"
131+
| "riscv32gc-unknown-linux-gnu"
132+
| "riscv32gc-unknown-linux-musl"
133+
| "riscv64gc-unknown-linux-musl"
134+
| "riscv64gc-unknown-linux-gnu"
135+
| "nvptx64-nvidia-cuda"
136+
| "s390x-unknown-linux-gnu"
137+
| "s390x-unknown-linux-musl"
138+
=> (),
139+
_ => { builder.define("SUPPORT_JIT", "1"); },
140+
}
103141

104142
// Copy PCRE2 headers. Typically, `./configure` would do this for us
105143
// automatically, but since we're compiling by hand, we do it ourselves.
@@ -152,29 +190,3 @@ fn pcre2_sys_static() -> Option<bool> {
152190
}
153191
}
154192
}
155-
156-
// On `aarch64-apple-ios` clang fails with the following error.
157-
//
158-
// Undefined symbols for architecture arm64:
159-
// "___clear_cache", referenced from:
160-
// _sljit_generate_code in libforeign.a(pcre2_jit_compile.o)
161-
// ld: symbol(s) not found for architecture arm64
162-
//
163-
// aarch64-apple-tvos https://bugreports.qt.io/browse/QTBUG-62993?gerritReviewStatus=All
164-
// aarch64-apple-darwin https://github.com/Homebrew/homebrew-core/pull/57419
165-
// x86_64-apple-ios disabled for device–simulator consistency (not tested)
166-
// x86_64-apple-tvos disabled for device–simulator consistency (not tested)
167-
// armv7-apple-ios assumed equivalent to aarch64-apple-ios (not tested)
168-
// armv7s-apple-ios assumed equivalent to aarch64-apple-ios (not tested)
169-
// i386-apple-ios assumed equivalent to aarch64-apple-ios (not tested)
170-
// x86_64-apple-ios-macabi disabled out of caution (not tested) (needs attention)
171-
//
172-
// We may want to monitor developments on the `aarch64-apple-darwin` front as they may end up
173-
// propagating to all `aarch64`-based targets and the `x86_64` equivalents.
174-
fn enable_jit(target: &str, builder: &mut cc::Build) {
175-
if !target.starts_with("aarch64-apple") &&
176-
!target.contains("apple-ios") &&
177-
!target.contains("apple-tvos") {
178-
builder.define("SUPPORT_JIT", "1");
179-
}
180-
}

0 commit comments

Comments
 (0)