Skip to content

Commit 00a66de

Browse files
mkrupcaleBurntSushi
authored andcommitted
bench: add libc++'s std::regex
This commit adds a new `libcxx` feature that enables testing libc++'s implementation of `std::regex` when combined with the `re-stdcpp` feature. See also: https://libcxx.llvm.org/docs/UsingLibcxx.html
1 parent f9cd75c commit 00a66de

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

bench/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ re-pcre2 = []
4848
re-onig = ["onig"]
4949
re-stdcpp = []
5050
re-re2 = []
51+
libcxx = []
5152
re-dphobos = []
5253
re-dphobos-dmd = ["re-dphobos"]
5354
re-dphobos-dmd-ct = ["re-dphobos-dmd"]

bench/build.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,20 @@ fn main() {
2020
}
2121
if env::var("CARGO_FEATURE_RE_STDCPP").is_ok() {
2222
// stdcpp is a C++ library, so we need to compile our shim layer.
23-
cc::Build::new()
24-
.cpp(true)
25-
.file("src/ffi/stdcpp.cpp")
26-
.compile("libcstdcpp.a");
23+
if !env::var("CARGO_FEATURE_LIBCXX").is_ok() {
24+
// use default stdlib
25+
cc::Build::new()
26+
.cpp(true)
27+
.file("src/ffi/stdcpp.cpp")
28+
.compile("libcstdcpp.a");
29+
} else {
30+
// use libc++ stdlib
31+
cc::Build::new()
32+
.cpp(true)
33+
.file("src/ffi/stdcpp.cpp")
34+
.cpp_link_stdlib("c++")
35+
.compile("libcstdcpp.a");
36+
}
2737
}
2838
if env::var("CARGO_FEATURE_RE_RE2").is_ok() {
2939
// RE2 is a C++ library, so we need to compile our shim layer.

bench/run

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
usage() {
4-
echo "Usage: $(basename $0) [dphobos-dmd | dphobos-ldc | dphobos-dmd-ct | dphobos-ldc-ct | rust | rust-bytes | pcre1 | pcre2 | stdcpp | re2 | onig | tcl ]" >&2
4+
echo "Usage: $(basename $0) [dphobos-dmd | dphobos-ldc | dphobos-dmd-ct | dphobos-ldc-ct | rust | rust-bytes | pcre1 | pcre2 | stdcpp | stdcpp-libcxx | re2 | onig | tcl ]" >&2
55
exit 1
66
}
77

@@ -33,6 +33,9 @@ case $which in
3333
stdcpp)
3434
exec cargo bench --bench bench --features re-stdcpp "$@"
3535
;;
36+
stdcpp-libcxx)
37+
exec cargo bench --bench bench --features 're-stdcpp libcxx' "$@"
38+
;;
3639
re2)
3740
exec cargo bench --bench bench --features re-re2 "$@"
3841
;;

0 commit comments

Comments
 (0)