1 |
commit: d005e3b069726d01579b86d32f6fe32c26573aa3 |
2 |
Author: Eric Joldasov <bratishkaerik <AT> getgoogleoff <DOT> me> |
3 |
AuthorDate: Tue Jul 26 21:25:12 2022 +0000 |
4 |
Commit: Jakov Smolić <jsmolic <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Aug 22 08:16:08 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d005e3b0 |
7 |
|
8 |
dev-lang/zig: block dev-lang/zig-bin, add risv stage0 patch for 0.9.1 |
9 |
|
10 |
Bug: https://bugs.gentoo.org/851732 |
11 |
Signed-off-by: Eric Joldasov <bratishkaerik <AT> getgoogleoff.me> |
12 |
Signed-off-by: Jakov Smolić <jsmolic <AT> gentoo.org> |
13 |
|
14 |
dev-lang/zig/files/zig-0.9.1-fix-riscv.patch | 47 ++++++++++++++++++++++++++++ |
15 |
dev-lang/zig/zig-0.9.1.ebuild | 26 +++++++-------- |
16 |
2 files changed, 59 insertions(+), 14 deletions(-) |
17 |
|
18 |
diff --git a/dev-lang/zig/files/zig-0.9.1-fix-riscv.patch b/dev-lang/zig/files/zig-0.9.1-fix-riscv.patch |
19 |
new file mode 100644 |
20 |
index 000000000000..372a68ea02ad |
21 |
--- /dev/null |
22 |
+++ b/dev-lang/zig/files/zig-0.9.1-fix-riscv.patch |
23 |
@@ -0,0 +1,47 @@ |
24 |
+https://github.com/ziglang/zig/commit/ca3c4ff2d0afcdc8fe86e7e7b41a967c88779729 |
25 |
+From: Shupei Fan <dymarkfan@×××××××.com> |
26 |
+zig0: properly set llvm_cpu_names and llvm_cpu_features for riscv |
27 |
+ |
28 |
+Bug: https://bugs.gentoo.org/851732 |
29 |
+ |
30 |
+--- a/src/stage1/zig0.cpp |
31 |
++++ b/src/stage1/zig0.cpp |
32 |
+@@ -160,6 +160,17 @@ static void get_native_target(ZigTarget *target) { |
33 |
+ } |
34 |
+ } |
35 |
+ |
36 |
++static const char* get_baseline_llvm_cpu_name(ZigLLVM_ArchType arch) { |
37 |
++ return ""; |
38 |
++} |
39 |
++ |
40 |
++static const char* get_baseline_llvm_cpu_features(ZigLLVM_ArchType arch) { |
41 |
++ switch (arch) { |
42 |
++ case ZigLLVM_riscv64: return "+a,+c,+d,+m"; |
43 |
++ default: return ""; |
44 |
++ } |
45 |
++} |
46 |
++ |
47 |
+ static Error target_parse_triple(struct ZigTarget *target, const char *zig_triple, const char *mcpu, |
48 |
+ const char *dynamic_linker) |
49 |
+ { |
50 |
+@@ -178,8 +189,8 @@ static Error target_parse_triple(struct ZigTarget *target, const char *zig_tripl |
51 |
+ } else if (strcmp(mcpu, "baseline") == 0) { |
52 |
+ target->is_native_os = false; |
53 |
+ target->is_native_cpu = false; |
54 |
+- target->llvm_cpu_name = ""; |
55 |
+- target->llvm_cpu_features = ""; |
56 |
++ target->llvm_cpu_name = get_baseline_llvm_cpu_name(target->arch); |
57 |
++ target->llvm_cpu_features = get_baseline_llvm_cpu_features(target->arch); |
58 |
+ } else { |
59 |
+ const char *msg = "stage0 can't handle CPU/features in the target"; |
60 |
+ stage2_panic(msg, strlen(msg)); |
61 |
+@@ -220,6 +231,9 @@ static Error target_parse_triple(struct ZigTarget *target, const char *zig_tripl |
62 |
+ const char *msg = "stage0 can't handle CPU/features in the target"; |
63 |
+ stage2_panic(msg, strlen(msg)); |
64 |
+ } |
65 |
++ |
66 |
++ target->llvm_cpu_name = get_baseline_llvm_cpu_name(target->arch); |
67 |
++ target->llvm_cpu_features = get_baseline_llvm_cpu_features(target->arch); |
68 |
+ } |
69 |
+ |
70 |
+ return ErrorNone; |
71 |
|
72 |
diff --git a/dev-lang/zig/zig-0.9.1.ebuild b/dev-lang/zig/zig-0.9.1.ebuild |
73 |
index 18dd79a4bbad..0c78b3e76b08 100644 |
74 |
--- a/dev-lang/zig/zig-0.9.1.ebuild |
75 |
+++ b/dev-lang/zig/zig-0.9.1.ebuild |
76 |
@@ -21,26 +21,24 @@ SLOT="0" |
77 |
IUSE="test +threads" |
78 |
RESTRICT="!test? ( test )" |
79 |
|
80 |
-PATCHES=("${FILESDIR}/${P}-fix-single-threaded.patch") |
81 |
+PATCHES=( |
82 |
+ "${FILESDIR}/${P}-fix-single-threaded.patch" |
83 |
+ "${FILESDIR}/${P}-fix-riscv.patch" |
84 |
+) |
85 |
|
86 |
BUILD_DIR="${S}/build" |
87 |
|
88 |
-# According to zig's author, zig builds that do not support all targets are not |
89 |
-# supported by the upstream project. |
90 |
-ALL_LLVM_TARGETS=( |
91 |
- AArch64 AMDGPU ARM AVR BPF Hexagon Lanai Mips MSP430 NVPTX |
92 |
- PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore |
93 |
-) |
94 |
-ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" ) |
95 |
-LLVM_TARGET_USEDEPS="${ALL_LLVM_TARGETS[@]}" |
96 |
- |
97 |
-RDEPEND=" |
98 |
+DEPEND=" |
99 |
sys-devel/clang:${LLVM_MAX_SLOT} |
100 |
>=sys-devel/lld-${LLVM_MAX_SLOT} |
101 |
<sys-devel/lld-$((${LLVM_MAX_SLOT} + 1)) |
102 |
- sys-devel/llvm:${LLVM_MAX_SLOT}[${LLVM_TARGET_USEDEPS// /,}] |
103 |
+ sys-devel/llvm:${LLVM_MAX_SLOT} |
104 |
+ >=sys-libs/zlib-1.2.12 |
105 |
+" |
106 |
+ |
107 |
+RDEPEND="${DEPEND} |
108 |
+ !dev-lang/zig-bin |
109 |
" |
110 |
-DEPEND="${RDEPEND}" |
111 |
|
112 |
llvm_check_deps() { |
113 |
has_version "sys-devel/clang:${LLVM_SLOT}" |
114 |
@@ -58,7 +56,7 @@ src_configure() { |
115 |
local mycmakeargs=( |
116 |
-DZIG_USE_CCACHE=OFF |
117 |
-DZIG_PREFER_CLANG_CPP_DYLIB=ON |
118 |
- -DZIG_SINGLE_THREADED="$(usex threads OFF ON)" |
119 |
+ -DZIG_SINGLE_THREADED="$(usex !threads)" |
120 |
) |
121 |
|
122 |
cmake_src_configure |