Skip to content

Commit d86dd12

Browse files
committed
Make clang_rt optional
This patch replaces the `assert(false)` in `template("clang_lib")` to silently skip clang_rt on CPUs where it is not supported. See #93 (comment)
1 parent 03bf41f commit d86dd12

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

patches/clang_rt.patch

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
diff --git a/config/clang/BUILD.gn b/config/clang/BUILD.gn
2+
index c38670a..5911f4b 100644
3+
--- a/config/clang/BUILD.gn
4+
+++ b/config/clang/BUILD.gn
5+
@@ -183,7 +183,7 @@ template("clang_lib") {
6+
} else if (current_cpu == "arm64") {
7+
_suffix = "-aarch64"
8+
} else {
9+
- assert(false) # Unhandled cpu type
10+
+ # Unhandled cpu type
11+
}
12+
} else if (is_apple) {
13+
_dir = "darwin"
14+
@@ -205,7 +205,7 @@ template("clang_lib") {
15+
} else if (current_cpu == "s390x") {
16+
_dir = "s390x-unknown-linux-gnu"
17+
} else {
18+
- assert(false) # Unhandled cpu type
19+
+ # Unhandled cpu type
20+
}
21+
} else if (is_fuchsia) {
22+
if (current_cpu == "x64") {
23+
@@ -213,7 +213,7 @@ template("clang_lib") {
24+
} else if (current_cpu == "arm64") {
25+
_dir = "aarch64-unknown-fuchsia"
26+
} else {
27+
- assert(false) # Unhandled cpu type
28+
+ # Unhandled cpu type
29+
}
30+
} else if (is_android) {
31+
_dir = "linux"
32+
@@ -228,15 +228,20 @@ template("clang_lib") {
33+
} else if (current_cpu == "riscv64") {
34+
_suffix = "-riscv64-android"
35+
} else {
36+
- assert(false) # Unhandled cpu type
37+
+ # Unhandled cpu type
38+
}
39+
} else {
40+
- assert(false) # Unhandled target platform
41+
+ # Unhandled target platform
42+
}
43+
44+
_clang_lib_dir = "$clang_base_path/lib/clang/$clang_version/lib"
45+
_lib_file = "${_prefix}clang_rt.${_libname}${_suffix}.${_ext}"
46+
- libs = [ "$_clang_lib_dir/$_dir/$_lib_file" ]
47+
+ if (_dir != "") {
48+
+ libs = [ "$_clang_lib_dir/$_dir/$_lib_file" ]
49+
+ } else {
50+
+ print("WARNING: No clang runtime library for $target_os/$current_cpu")
51+
+ print("$_clang_lib_dir/????/$_lib_file")
52+
+ }
53+
}
54+
}
55+
}

steps/03-patch.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ case "$BUILD_TYPE" in
2626
esac
2727

2828
apply_patch "$PATCHES/public_headers.patch"
29+
apply_patch "$PATCHES/clang_rt.patch" build
2930

3031
[ "$ENABLE_V8" == "true" ] && apply_patch "$PATCHES/v8/pdfium.patch"
3132

0 commit comments

Comments
 (0)