diff options
author | Alex Kiernan <alex.kiernan@gmail.com> | 2023-06-02 16:59:21 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-06-07 23:41:19 +0100 |
commit | 5035a8588bb27e029661a500215dd4e83f023ac6 (patch) | |
tree | 7533ff770d065030aafaf4a8aeaf1866bbbb3fdd /meta/recipes-devtools/rust/rust_1.70.0.bb | |
parent | 4a02a2a57a962f228eb1445f65c123c93a0403c6 (diff) | |
download | poky-5035a8588bb27e029661a500215dd4e83f023ac6.tar.gz |
rust: Upgrade 1.69.0 -> 1.70.0
Drop 0035-cmake-Enable-64bit-off_t-on-32bit-glibc-systems.patch as this
is merged upstream in rust-llvm.
https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html
(From OE-Core rev: d1af583c290eb0cff5e36363f7531832a863a1a8)
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/rust/rust_1.70.0.bb')
-rw-r--r-- | meta/recipes-devtools/rust/rust_1.70.0.bb | 352 |
1 files changed, 352 insertions, 0 deletions
diff --git a/meta/recipes-devtools/rust/rust_1.70.0.bb b/meta/recipes-devtools/rust/rust_1.70.0.bb new file mode 100644 index 0000000000..83f9bec68a --- /dev/null +++ b/meta/recipes-devtools/rust/rust_1.70.0.bb | |||
@@ -0,0 +1,352 @@ | |||
1 | SUMMARY = "Rust compiler and runtime libaries" | ||
2 | HOMEPAGE = "http://www.rust-lang.org" | ||
3 | SECTION = "devel" | ||
4 | LICENSE = "(MIT | Apache-2.0) & Unicode-TOU" | ||
5 | LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=c2cccf560306876da3913d79062a54b9" | ||
6 | |||
7 | inherit rust | ||
8 | inherit cargo_common | ||
9 | |||
10 | DEPENDS += "file-native python3-native" | ||
11 | DEPENDS:append:class-native = " rust-llvm-native" | ||
12 | DEPENDS:append:class-nativesdk = " nativesdk-rust-llvm" | ||
13 | |||
14 | DEPENDS += "rust-llvm (=${PV})" | ||
15 | |||
16 | RDEPENDS:${PN}:append:class-target = " gcc g++ binutils" | ||
17 | |||
18 | # Otherwise we'll depend on what we provide | ||
19 | INHIBIT_DEFAULT_RUST_DEPS:class-native = "1" | ||
20 | # We don't need to depend on gcc-native because yocto assumes it exists | ||
21 | PROVIDES:class-native = "virtual/${TARGET_PREFIX}rust" | ||
22 | |||
23 | S = "${RUSTSRC}" | ||
24 | |||
25 | # Use at your own risk, accepted values are stable, beta and nightly | ||
26 | RUST_CHANNEL ?= "stable" | ||
27 | PV .= "${@bb.utils.contains('RUST_CHANNEL', 'stable', '', '-${RUST_CHANNEL}', d)}" | ||
28 | |||
29 | export FORCE_CRATE_HASH="${BB_TASKHASH}" | ||
30 | |||
31 | RUST_ALTERNATE_EXE_PATH ?= "${STAGING_LIBDIR}/llvm-rust/bin/llvm-config" | ||
32 | RUST_ALTERNATE_EXE_PATH_NATIVE = "${STAGING_LIBDIR_NATIVE}/llvm-rust/bin/llvm-config" | ||
33 | |||
34 | # We don't want to use bitbakes vendoring because the rust sources do their | ||
35 | # own vendoring. | ||
36 | CARGO_DISABLE_BITBAKE_VENDORING = "1" | ||
37 | |||
38 | # We can't use RUST_BUILD_SYS here because that may be "musl" if | ||
39 | # TCLIBC="musl". Snapshots are always -unknown-linux-gnu | ||
40 | setup_cargo_environment () { | ||
41 | # The first step is to build bootstrap and some early stage tools, | ||
42 | # these are build for the same target as the snapshot, e.g. | ||
43 | # x86_64-unknown-linux-gnu. | ||
44 | # Later stages are build for the native target (i.e. target.x86_64-linux) | ||
45 | cargo_common_do_configure | ||
46 | } | ||
47 | |||
48 | inherit rust-target-config | ||
49 | |||
50 | do_rust_setup_snapshot () { | ||
51 | for installer in "${WORKDIR}/rust-snapshot-components/"*"/install.sh"; do | ||
52 | "${installer}" --prefix="${WORKDIR}/rust-snapshot" --disable-ldconfig | ||
53 | done | ||
54 | |||
55 | # Some versions of rust (e.g. 1.18.0) tries to find cargo in stage0/bin/cargo | ||
56 | # and fail without it there. | ||
57 | mkdir -p ${RUSTSRC}/build/${BUILD_SYS} | ||
58 | ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${BUILD_SYS}/stage0 | ||
59 | |||
60 | # Need to use uninative's loader if enabled/present since the library paths | ||
61 | # are used internally by rust and result in symbol mismatches if we don't | ||
62 | if [ ! -z "${UNINATIVE_LOADER}" -a -e "${UNINATIVE_LOADER}" ]; then | ||
63 | for bin in cargo rustc rustdoc; do | ||
64 | patchelf-uninative ${WORKDIR}/rust-snapshot/bin/$bin --set-interpreter ${UNINATIVE_LOADER} | ||
65 | done | ||
66 | fi | ||
67 | } | ||
68 | addtask rust_setup_snapshot after do_unpack before do_configure | ||
69 | do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot" | ||
70 | do_rust_setup_snapshot[vardepsexclude] += "UNINATIVE_LOADER" | ||
71 | |||
72 | python do_configure() { | ||
73 | import json | ||
74 | try: | ||
75 | import configparser | ||
76 | except ImportError: | ||
77 | import ConfigParser as configparser | ||
78 | |||
79 | # toml is rather similar to standard ini like format except it likes values | ||
80 | # that look more JSON like. So for our purposes simply escaping all values | ||
81 | # as JSON seem to work fine. | ||
82 | |||
83 | e = lambda s: json.dumps(s) | ||
84 | |||
85 | config = configparser.RawConfigParser() | ||
86 | |||
87 | # [target.ARCH-poky-linux] | ||
88 | host_section = "target.{}".format(d.getVar('RUST_HOST_SYS')) | ||
89 | config.add_section(host_section) | ||
90 | |||
91 | llvm_config_target = d.expand("${RUST_ALTERNATE_EXE_PATH}") | ||
92 | llvm_config_build = d.expand("${RUST_ALTERNATE_EXE_PATH_NATIVE}") | ||
93 | config.set(host_section, "llvm-config", e(llvm_config_target)) | ||
94 | |||
95 | config.set(host_section, "cxx", e(d.expand("${RUST_TARGET_CXX}"))) | ||
96 | config.set(host_section, "cc", e(d.expand("${RUST_TARGET_CC}"))) | ||
97 | config.set(host_section, "linker", e(d.expand("${RUST_TARGET_CCLD}"))) | ||
98 | if "musl" in host_section: | ||
99 | config.set(host_section, "musl-root", e(d.expand("${STAGING_DIR_HOST}${exec_prefix}"))) | ||
100 | |||
101 | # If we don't do this rust-native will compile it's own llvm for BUILD. | ||
102 | # [target.${BUILD_ARCH}-unknown-linux-gnu] | ||
103 | build_section = "target.{}".format(d.getVar('RUST_BUILD_SYS')) | ||
104 | if build_section != host_section: | ||
105 | config.add_section(build_section) | ||
106 | |||
107 | config.set(build_section, "llvm-config", e(llvm_config_build)) | ||
108 | |||
109 | config.set(build_section, "cxx", e(d.expand("${RUST_BUILD_CXX}"))) | ||
110 | config.set(build_section, "cc", e(d.expand("${RUST_BUILD_CC}"))) | ||
111 | config.set(build_section, "linker", e(d.expand("${RUST_BUILD_CCLD}"))) | ||
112 | |||
113 | target_section = "target.{}".format(d.getVar('RUST_TARGET_SYS')) | ||
114 | if target_section != host_section and target_section != build_section: | ||
115 | config.add_section(target_section) | ||
116 | |||
117 | config.set(target_section, "llvm-config", e(llvm_config_target)) | ||
118 | |||
119 | config.set(target_section, "cxx", e(d.expand("${RUST_TARGET_CXX}"))) | ||
120 | config.set(target_section, "cc", e(d.expand("${RUST_TARGET_CC}"))) | ||
121 | config.set(target_section, "linker", e(d.expand("${RUST_TARGET_CCLD}"))) | ||
122 | |||
123 | # [llvm] | ||
124 | config.add_section("llvm") | ||
125 | config.set("llvm", "static-libstdcpp", e(False)) | ||
126 | if "llvm" in (d.getVar('TC_CXX_RUNTIME') or ""): | ||
127 | config.set("llvm", "use-libcxx", e(True)) | ||
128 | |||
129 | # [rust] | ||
130 | config.add_section("rust") | ||
131 | config.set("rust", "rpath", e(True)) | ||
132 | config.set("rust", "channel", e(d.expand("${RUST_CHANNEL}"))) | ||
133 | |||
134 | # Whether or not to optimize the compiler and standard library | ||
135 | config.set("rust", "optimize", e(True)) | ||
136 | |||
137 | # Emits extraneous output from tests to ensure that failures of the test | ||
138 | # harness are debuggable just from logfiles | ||
139 | config.set("rust", "verbose-tests", e(True)) | ||
140 | |||
141 | # [build] | ||
142 | config.add_section("build") | ||
143 | config.set("build", "submodules", e(False)) | ||
144 | config.set("build", "docs", e(False)) | ||
145 | |||
146 | rustc = d.expand("${WORKDIR}/rust-snapshot/bin/rustc") | ||
147 | config.set("build", "rustc", e(rustc)) | ||
148 | |||
149 | # Support for the profiler runtime to generate e.g. coverage report, | ||
150 | # PGO etc. | ||
151 | config.set("build", "profiler", e(True)) | ||
152 | |||
153 | cargo = d.expand("${WORKDIR}/rust-snapshot/bin/cargo") | ||
154 | config.set("build", "cargo", e(cargo)) | ||
155 | |||
156 | config.set("build", "vendor", e(True)) | ||
157 | |||
158 | if not "targets" in locals(): | ||
159 | targets = [d.getVar("RUST_TARGET_SYS")] | ||
160 | config.set("build", "target", e(targets)) | ||
161 | |||
162 | if not "hosts" in locals(): | ||
163 | hosts = [d.getVar("RUST_HOST_SYS")] | ||
164 | config.set("build", "host", e(hosts)) | ||
165 | |||
166 | # We can't use BUILD_SYS since that is something the rust snapshot knows | ||
167 | # nothing about when trying to build some stage0 tools (like fabricate) | ||
168 | config.set("build", "build", e(d.getVar("RUST_BUILD_SYS"))) | ||
169 | |||
170 | # [install] | ||
171 | config.add_section("install") | ||
172 | # ./x.py install doesn't have any notion of "destdir" | ||
173 | # but we can prepend ${D} to all the directories instead | ||
174 | config.set("install", "prefix", e(d.getVar("D") + d.getVar("prefix"))) | ||
175 | config.set("install", "bindir", e(d.getVar("D") + d.getVar("bindir"))) | ||
176 | config.set("install", "libdir", e(d.getVar("D") + d.getVar("libdir"))) | ||
177 | config.set("install", "datadir", e(d.getVar("D") + d.getVar("datadir"))) | ||
178 | config.set("install", "mandir", e(d.getVar("D") + d.getVar("mandir"))) | ||
179 | |||
180 | with open("config.toml", "w") as f: | ||
181 | f.write('changelog-seen = 2\n\n') | ||
182 | config.write(f) | ||
183 | |||
184 | # set up ${WORKDIR}/cargo_home | ||
185 | bb.build.exec_func("setup_cargo_environment", d) | ||
186 | } | ||
187 | |||
188 | rust_runx () { | ||
189 | echo "COMPILE ${PN}" "$@" | ||
190 | |||
191 | # CFLAGS, LDFLAGS, CXXFLAGS, CPPFLAGS are used by rust's build for a | ||
192 | # wide range of targets (not just TARGET). Yocto's settings for them will | ||
193 | # be inappropriate, avoid using. | ||
194 | unset CFLAGS | ||
195 | unset LDFLAGS | ||
196 | unset CXXFLAGS | ||
197 | unset CPPFLAGS | ||
198 | |||
199 | export RUSTFLAGS="${RUST_DEBUG_REMAP}" | ||
200 | |||
201 | # Copy the natively built llvm-config into the target so we can run it. Horrible, | ||
202 | # but works! | ||
203 | if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} != ${RUST_ALTERNATE_EXE_PATH} -a ! -f ${RUST_ALTERNATE_EXE_PATH} ]; then | ||
204 | mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}` | ||
205 | cp ${RUST_ALTERNATE_EXE_PATH_NATIVE} ${RUST_ALTERNATE_EXE_PATH} | ||
206 | chrpath -d ${RUST_ALTERNATE_EXE_PATH} | ||
207 | fi | ||
208 | |||
209 | oe_cargo_fix_env | ||
210 | |||
211 | python3 src/bootstrap/bootstrap.py ${@oe.utils.parallel_make_argument(d, '-j %d')} "$@" --verbose | ||
212 | } | ||
213 | rust_runx[vardepsexclude] += "PARALLEL_MAKE" | ||
214 | |||
215 | require rust-source.inc | ||
216 | require rust-snapshot.inc | ||
217 | |||
218 | INSANE_SKIP:${PN}:class-native = "already-stripped" | ||
219 | FILES:${PN} += "${libdir}/rustlib" | ||
220 | FILES:${PN} += "${libdir}/*.so" | ||
221 | FILES:${PN}-dev = "" | ||
222 | |||
223 | do_compile () { | ||
224 | } | ||
225 | |||
226 | ALLOW_EMPTY:${PN} = "1" | ||
227 | |||
228 | PACKAGES =+ "${PN}-tools-clippy ${PN}-tools-rustfmt" | ||
229 | FILES:${PN}-tools-clippy = "${bindir}/cargo-clippy ${bindir}/clippy-driver" | ||
230 | FILES:${PN}-tools-rustfmt = "${bindir}/rustfmt" | ||
231 | RDEPENDS:${PN}-tools-clippy = "${PN}" | ||
232 | RDEPENDS:${PN}-tools-rustfmt = "${PN}" | ||
233 | |||
234 | SUMMARY:${PN}-tools-clippy = "A collection of lints to catch common mistakes and improve your Rust code" | ||
235 | SUMMARY:${PN}-tools-rustfmt = "A tool for formatting Rust code according to style guidelines" | ||
236 | |||
237 | do_install () { | ||
238 | rust_do_install | ||
239 | } | ||
240 | |||
241 | rust_do_install() { | ||
242 | rust_runx install | ||
243 | } | ||
244 | |||
245 | rust_do_install:class-nativesdk() { | ||
246 | export PSEUDO_UNLOAD=1 | ||
247 | rust_runx install | ||
248 | rust_runx install clippy | ||
249 | rust_runx install rustfmt | ||
250 | unset PSEUDO_UNLOAD | ||
251 | |||
252 | install -d ${D}${bindir} | ||
253 | for i in cargo-clippy clippy-driver rustfmt; do | ||
254 | cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} | ||
255 | chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i | ||
256 | done | ||
257 | |||
258 | chown root:root ${D}/ -R | ||
259 | rm ${D}${libdir}/rustlib/uninstall.sh | ||
260 | rm ${D}${libdir}/rustlib/install.log | ||
261 | rm ${D}${libdir}/rustlib/manifest* | ||
262 | } | ||
263 | |||
264 | EXTRA_TOOLS ?= "cargo-clippy clippy-driver rustfmt" | ||
265 | rust_do_install:class-target() { | ||
266 | export PSEUDO_UNLOAD=1 | ||
267 | rust_runx install | ||
268 | rust_runx install clippy | ||
269 | rust_runx install rustfmt | ||
270 | unset PSEUDO_UNLOAD | ||
271 | |||
272 | install -d ${D}${bindir} | ||
273 | for i in ${EXTRA_TOOLS}; do | ||
274 | cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir} | ||
275 | chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i | ||
276 | done | ||
277 | |||
278 | install -d ${D}${libdir}/rustlib/${RUST_HOST_SYS} | ||
279 | install -m 0644 ${WORKDIR}/rust-targets/${RUST_HOST_SYS}.json ${D}${libdir}/rustlib/${RUST_HOST_SYS}/target.json | ||
280 | |||
281 | chown root:root ${D}/ -R | ||
282 | rm ${D}${libdir}/rustlib/uninstall.sh | ||
283 | rm ${D}${libdir}/rustlib/install.log | ||
284 | rm ${D}${libdir}/rustlib/manifest* | ||
285 | } | ||
286 | |||
287 | addtask do_update_snapshot after do_patch | ||
288 | do_update_snapshot[nostamp] = "1" | ||
289 | |||
290 | # Run with `bitbake -c update_snapshot rust` to update `rust-snapshot.inc` | ||
291 | # with the checksums for the rust snapshot associated with this rustc-src | ||
292 | # tarball. | ||
293 | python do_update_snapshot() { | ||
294 | import json | ||
295 | import re | ||
296 | import sys | ||
297 | |||
298 | from collections import defaultdict | ||
299 | |||
300 | with open(os.path.join(d.getVar("S"), "src", "stage0.json")) as f: | ||
301 | j = json.load(f) | ||
302 | |||
303 | config_dist_server = j['config']['dist_server'] | ||
304 | compiler_date = j['compiler']['date'] | ||
305 | compiler_version = j['compiler']['version'] | ||
306 | |||
307 | src_uri = defaultdict(list) | ||
308 | for k, v in j['checksums_sha256'].items(): | ||
309 | m = re.search(f"dist/{compiler_date}/(?P<component>.*)-{compiler_version}-(?P<arch>.*)-unknown-linux-gnu\\.tar\\.xz", k) | ||
310 | if m: | ||
311 | component = m.group('component') | ||
312 | arch = m.group('arch') | ||
313 | src_uri[arch].append(f"SRC_URI[{component}-snapshot-{arch}.sha256sum] = \"{v}\"") | ||
314 | |||
315 | snapshot = """\ | ||
316 | ## This is information on the rust-snapshot (binary) used to build our current release. | ||
317 | ## snapshot info is taken from rust/src/stage0.json | ||
318 | ## Rust is self-hosting and bootstraps itself with a pre-built previous version of itself. | ||
319 | ## The exact (previous) version that has been used is specified in the source tarball. | ||
320 | ## The version is replicated here. | ||
321 | |||
322 | SNAPSHOT_VERSION = "%s" | ||
323 | |||
324 | """ % compiler_version | ||
325 | |||
326 | for arch, components in src_uri.items(): | ||
327 | snapshot += "\n".join(components) + "\n\n" | ||
328 | |||
329 | snapshot += """\ | ||
330 | SRC_URI += " \\ | ||
331 | ${RUST_DIST_SERVER}/dist/${RUST_STD_SNAPSHOT}.tar.xz;name=rust-std-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \\ | ||
332 | ${RUST_DIST_SERVER}/dist/${RUSTC_SNAPSHOT}.tar.xz;name=rustc-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \\ | ||
333 | ${RUST_DIST_SERVER}/dist/${CARGO_SNAPSHOT}.tar.xz;name=cargo-snapshot-${RUST_BUILD_ARCH};subdir=rust-snapshot-components \\ | ||
334 | " | ||
335 | |||
336 | RUST_DIST_SERVER = "%s" | ||
337 | |||
338 | RUST_STD_SNAPSHOT = "rust-std-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" | ||
339 | RUSTC_SNAPSHOT = "rustc-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" | ||
340 | CARGO_SNAPSHOT = "cargo-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu" | ||
341 | """ % config_dist_server | ||
342 | |||
343 | with open(os.path.join(d.getVar("THISDIR"), "rust-snapshot.inc"), "w") as f: | ||
344 | f.write(snapshot) | ||
345 | } | ||
346 | |||
347 | RUSTLIB_DEP:class-nativesdk = "" | ||
348 | |||
349 | # musl builds include libunwind.a | ||
350 | INSANE_SKIP:${PN} = "staticdev" | ||
351 | |||
352 | BBCLASSEXTEND = "native nativesdk" | ||