-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·147 lines (130 loc) · 3.87 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/sh -ex
WASI_SDK=wasi-sdk-19.0
WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz
if ! [ -d ${WASI_SDK} ]; then curl -L ${WASI_SDK_URL} | tar xzf -; fi
# This script does a lot of really awful things to Yosys to make the WASM artifact smaller.
# That's necessary to reduce the startup latency, since currently wasmtime-py does not cache
# the compiled code.
cat >yosys-src/Makefile.conf <<END
export PATH := $(pwd)/${WASI_SDK}/bin:${PATH}
WASI_SYSROOT := $(pwd)/${WASI_SDK}/share/wasi-sysroot
CONFIG := wasi
PREFIX := /
ENABLE_TCL := 0
ENABLE_ABC := 0
ENABLE_GLOB := 0
ENABLE_PLUGINS := 0
ENABLE_READLINE := 0
ENABLE_EDITLINE := 0
ENABLE_VERIFIC := 0
ENABLE_COVER := 0
ENABLE_LIBYOSYS := 0
ENABLE_PROTOBUF := 0
ENABLE_ZLIB := 0
CXXFLAGS += -D_WASI_EMULATED_PROCESS_CLOCKS -flto
LDFLAGS += -lwasi-emulated-process-clocks -flto -Wl,--strip-all
END
cat >yosys-src/frontends/verilog/preproc_stub.cc <<END
#include "preproc.h"
YOSYS_NAMESPACE_BEGIN
struct define_body_t {};
define_map_t::define_map_t() {}
define_map_t::~define_map_t() {}
void define_map_t::clear() {}
YOSYS_NAMESPACE_END
END
cat >yosys-src/passes/cmds/design_stub.cc <<END
#include "kernel/yosys.h"
YOSYS_NAMESPACE_BEGIN
std::map<std::string, RTLIL::Design*> saved_designs;
std::vector<RTLIL::Design*> pushed_designs;
YOSYS_NAMESPACE_END
END
YOSYS_PYPI_VER=$(python3 setup.py --version)
YOSYS_GIT_REV=$(git -C yosys-src rev-parse --short HEAD | tr -d '\n')
YOSYS_VER_STR='Amaranth Yosys $(YOSYS_VER) '"(PyPI ver ${YOSYS_PYPI_VER}, git sha1 ${YOSYS_GIT_REV})"
YOSYS_OBJS="\
kernel/version_${YOSYS_GIT_REV}.cc \
kernel/driver.o \
kernel/register.o \
kernel/rtlil.o \
kernel/log.o \
kernel/calc.o \
kernel/mem.o \
kernel/ff.o \
kernel/fmt.o \
kernel/scopeinfo.o \
kernel/satgen.o \
kernel/qcsat.o \
kernel/yosys.o \
libs/bigint/BigInteger.o \
libs/bigint/BigUnsigned.o \
libs/sha1/sha1.o \
libs/ezsat/ezsat.o \
libs/ezsat/ezminisat.o \
libs/minisat/Options.o \
libs/minisat/SimpSolver.o \
libs/minisat/Solver.o \
libs/minisat/System.o \
frontends/ast/ast.o \
frontends/ast/simplify.o \
frontends/rtlil/rtlil_parser.tab.o \
frontends/rtlil/rtlil_lexer.o \
frontends/rtlil/rtlil_frontend.o \
frontends/verilog/preproc_stub.o \
frontends/verilog/const2ast.o \
passes/hierarchy/hierarchy.o \
passes/hierarchy/uniquify.o \
passes/hierarchy/submod.o \
passes/proc/proc.o \
passes/proc/proc_prune.o \
passes/proc/proc_clean.o \
passes/proc/proc_rmdead.o \
passes/proc/proc_init.o \
passes/proc/proc_arst.o \
passes/proc/proc_memwr.o \
passes/proc/proc_mux.o \
passes/proc/proc_dlatch.o \
passes/proc/proc_dff.o \
passes/proc/proc_rom.o \
passes/opt/opt.o \
passes/opt/opt_merge.o \
passes/opt/opt_mem.o \
passes/opt/opt_mem_feedback.o \
passes/opt/opt_mem_priority.o \
passes/opt/opt_mem_widen.o \
passes/opt/opt_muxtree.o \
passes/opt/opt_reduce.o \
passes/opt/opt_dff.o \
passes/opt/opt_share.o \
passes/opt/opt_clean.o \
passes/opt/opt_expr.o \
passes/opt/share.o \
passes/opt/wreduce.o \
passes/opt/opt_demorgan.o \
passes/opt/rmports.o \
passes/opt/opt_lut.o \
passes/opt/opt_lut_ins.o \
passes/opt/opt_ffinv.o \
passes/opt/pmux2shiftx.o \
passes/opt/muxpack.o \
passes/cmds/plugin.o \
passes/cmds/design_stub.o \
passes/cmds/select.o \
passes/cmds/delete.o \
passes/cmds/clean_zerowidth.o \
passes/memory/memory_collect.o \
passes/techmap/attrmap.o \
passes/techmap/flatten.o \
passes/techmap/bmuxmap.o \
passes/techmap/demuxmap.o \
passes/techmap/simplemap.o \
backends/rtlil/rtlil_backend.o \
backends/cxxrtl/cxxrtl_backend.o \
backends/verilog/verilog_backend.o \
"
make -C yosys-src GIT_REV="${YOSYS_GIT_REV}" YOSYS_VER_STR="${YOSYS_VER_STR}" OBJS="${YOSYS_OBJS}" PRETTY=0 CXX="ccache clang"
cp yosys-src/yosys.wasm amaranth_yosys/
rm -rf amaranth_yosys/share
mkdir -p amaranth_yosys/share/include/backends/cxxrtl
cp -r yosys-src/share/include/backends/cxxrtl/runtime amaranth_yosys/share/include/backends/cxxrtl/