0001-linux-sysroot-script-to-create-riscv-sysroot-from-De.patch 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. From 89e1e2acf8c1c57d5f833b60a5f40a9b89440e51 Mon Sep 17 00:00:00 2001
  2. From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
  3. Date: Wed, 18 May 2022 06:00:28 +0000
  4. Subject: [PATCH 01/22] linux: sysroot: script to create riscv sysroot from
  5. Debian ports
  6. Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
  7. ---
  8. .../sysroot_scripts/sysroot-creator-sid.sh | 416 ++++++++++++++++++
  9. .../linux/sysroot_scripts/sysroot-creator.sh | 52 ++-
  10. 2 files changed, 459 insertions(+), 9 deletions(-)
  11. create mode 100755 build/linux/sysroot_scripts/sysroot-creator-sid.sh
  12. diff --git a/build/linux/sysroot_scripts/sysroot-creator-sid.sh b/build/linux/sysroot_scripts/sysroot-creator-sid.sh
  13. new file mode 100755
  14. index 0000000000000..f8c01b96256d5
  15. --- /dev/null
  16. +++ b/build/linux/sysroot_scripts/sysroot-creator-sid.sh
  17. @@ -0,0 +1,416 @@
  18. +#!/bin/bash
  19. +# Copyright 2022 The Chromium Authors. All rights reserved.
  20. +# Use of this source code is governed by a BSD-style license that can be
  21. +# found in the LICENSE file.
  22. +
  23. +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  24. +
  25. +DISTRO=debian
  26. +DIST=sid
  27. +
  28. +ARCHIVE_URL="http://ftp.ports.debian.org/debian-ports/"
  29. +APT_SOURCES_LIST=(
  30. + "${ARCHIVE_URL} experimental main"
  31. + "${ARCHIVE_URL} unreleased main"
  32. + "${ARCHIVE_URL} unstable main"
  33. + "${ARCHIVE_URL} sid main"
  34. +)
  35. +
  36. +# gpg keyring file generated using generate_keyring.sh
  37. +KEYRING_FILE="/etc/apt/trusted.gpg.d/debian-ports-archive-2022.gpg"
  38. +
  39. +HAS_ARCH_RISCV64=1
  40. +
  41. +# Sysroot packages: these are the packages needed to build chrome.
  42. +DEBIAN_PACKAGES="\
  43. + comerr-dev
  44. + krb5-multidev
  45. + libasound2
  46. + libasound2-dev
  47. + libasyncns0
  48. + libatk-bridge2.0-0
  49. + libatk-bridge2.0-dev
  50. + libatk1.0-0
  51. + libatk1.0-dev
  52. + libatomic1
  53. + libatspi2.0-0
  54. + libatspi2.0-dev
  55. + libattr1
  56. + libaudit1
  57. + libavahi-client3
  58. + libavahi-common3
  59. + libblkid-dev
  60. + libblkid1
  61. + libbluetooth-dev
  62. + libbluetooth3
  63. + libbrotli-dev
  64. + libbrotli1
  65. + libbsd0
  66. + libc6
  67. + libc6-dev
  68. + libcairo-gobject2
  69. + libcairo-script-interpreter2
  70. + libcairo2
  71. + libcairo2-dev
  72. + libcap-dev
  73. + libcap-ng0
  74. + libcap2
  75. + libcloudproviders0
  76. + libcolord2
  77. + libcom-err2
  78. + libcups2
  79. + libcups2-dev
  80. + libcupsimage2
  81. + libcupsimage2-dev
  82. + libcurl3-gnutls
  83. + libcurl4-gnutls-dev
  84. + libdatrie-dev
  85. + libdatrie1
  86. + libdb5.3
  87. + libdbus-1-3
  88. + libdbus-1-dev
  89. + libdbus-glib-1-2
  90. + libdbusmenu-glib-dev
  91. + libdbusmenu-glib4
  92. + libdbusmenu-gtk3-4
  93. + libdbusmenu-gtk4
  94. + libdeflate-dev
  95. + libdeflate0
  96. + libdouble-conversion3
  97. + libdrm-amdgpu1
  98. + libdrm-dev
  99. + libdrm-nouveau2
  100. + libdrm-radeon1
  101. + libdrm2
  102. + libegl-dev
  103. + libegl1
  104. + libegl1-mesa
  105. + libegl1-mesa-dev
  106. + libelf-dev
  107. + libelf1
  108. + libepoxy-dev
  109. + libepoxy0
  110. + libevdev-dev
  111. + libevdev2
  112. + libevent-2.1-7
  113. + libexpat1
  114. + libexpat1-dev
  115. + libffi-dev
  116. + libffi8
  117. + libflac-dev
  118. + libflac8
  119. + libfontconfig-dev
  120. + libfontconfig1
  121. + libfreetype-dev
  122. + libfreetype6
  123. + libfribidi-dev
  124. + libfribidi0
  125. + libgbm-dev
  126. + libgbm1
  127. + libgcc-10-dev
  128. + libgcc-s1
  129. + libgcrypt20
  130. + libgcrypt20-dev
  131. + libgdk-pixbuf-2.0-0
  132. + libgdk-pixbuf-2.0-dev
  133. + libgl-dev
  134. + libgl1
  135. + libgl1-mesa-dev
  136. + libgl1-mesa-glx
  137. + libglapi-mesa
  138. + libgles-dev
  139. + libgles1
  140. + libgles2
  141. + libglib2.0-0
  142. + libglib2.0-dev
  143. + libglvnd-dev
  144. + libglvnd0
  145. + libglx-dev
  146. + libglx0
  147. + libgmp10
  148. + libgnutls-dane0
  149. + libgnutls-openssl27
  150. + libgnutls28-dev
  151. + libgnutls30
  152. + libgnutlsxx30
  153. + libgomp1
  154. + libgpg-error-dev
  155. + libgpg-error0
  156. + libgraphene-1.0-0
  157. + libgraphene-1.0-dev
  158. + libgraphite2-3
  159. + libgraphite2-dev
  160. + libgssapi-krb5-2
  161. + libgssrpc4
  162. + libgtk-3-0
  163. + libgtk-3-dev
  164. + libgtk-4-1
  165. + libgtk-4-dev
  166. + libgtk2.0-0
  167. + libgudev-1.0-0
  168. + libharfbuzz-dev
  169. + libharfbuzz-gobject0
  170. + libharfbuzz-icu0
  171. + libharfbuzz0b
  172. + libhogweed6
  173. + libice6
  174. + libicu-le-hb0
  175. + libicu71
  176. + libidl-2-0
  177. + libidn12
  178. + libidn2-0
  179. + libinput-dev
  180. + libinput10
  181. + libjbig-dev
  182. + libjbig0
  183. + libjpeg62-turbo
  184. + libjpeg62-turbo-dev
  185. + libjson-glib-1.0-0
  186. + libjsoncpp-dev
  187. + libjsoncpp25
  188. + libk5crypto3
  189. + libkadm5clnt-mit12
  190. + libkadm5srv-mit12
  191. + libkdb5-10
  192. + libkeyutils1
  193. + libkrb5-3
  194. + libkrb5-dev
  195. + libkrb5support0
  196. + liblcms2-2
  197. + libldap-2.5-0
  198. + libltdl7
  199. + liblz4-1
  200. + liblzma5
  201. + liblzo2-2
  202. + libmd0
  203. + libmd4c0
  204. + libminizip-dev
  205. + libminizip1
  206. + libmount-dev
  207. + libmount1
  208. + libmtdev1
  209. + libncurses-dev
  210. + libncurses6
  211. + libncursesw6
  212. + libnettle8
  213. + libnghttp2-14
  214. + libnsl2
  215. + libnspr4
  216. + libnspr4-dev
  217. + libnss-db
  218. + libnss3
  219. + libnss3-dev
  220. + libogg-dev
  221. + libogg0
  222. + libopengl0
  223. + libopus-dev
  224. + libopus0
  225. + libp11-kit0
  226. + libpam0g
  227. + libpam0g-dev
  228. + libpango-1.0-0
  229. + libpango1.0-dev
  230. + libpangocairo-1.0-0
  231. + libpangoft2-1.0-0
  232. + libpangoxft-1.0-0
  233. + libpci-dev
  234. + libpci3
  235. + libpciaccess0
  236. + libpcre16-3
  237. + libpcre2-16-0
  238. + libpcre2-32-0
  239. + libpcre2-8-0
  240. + libpcre2-dev
  241. + libpcre2-posix3
  242. + libpcre3
  243. + libpcre3-dev
  244. + libpcre32-3
  245. + libpcrecpp0v5
  246. + libpipewire-0.3-0
  247. + libpipewire-0.3-dev
  248. + libpixman-1-0
  249. + libpixman-1-dev
  250. + libpng-dev
  251. + libpng16-16
  252. + libpsl5
  253. + libpthread-stubs0-dev
  254. + libpulse-dev
  255. + libpulse-mainloop-glib0
  256. + libpulse0
  257. + libqt5concurrent5
  258. + libqt5core5a
  259. + libqt5dbus5
  260. + libqt5gui5
  261. + libqt5network5
  262. + libqt5printsupport5
  263. + libqt5sql5
  264. + libqt5test5
  265. + libqt5widgets5
  266. + libqt5xml5
  267. + libre2-9
  268. + libre2-dev
  269. + librest-0.7-0
  270. + librtmp1
  271. + libsasl2-2
  272. + libselinux1
  273. + libselinux1-dev
  274. + libsepol2
  275. + libsepol-dev
  276. + libsm6
  277. + libsnappy-dev
  278. + libsnappy1v5
  279. + libsndfile1
  280. + libsoup-gnome2.4-1
  281. + libsoup2.4-1
  282. + libspa-0.2-dev
  283. + libspeechd-dev
  284. + libspeechd2
  285. + libsqlite3-0
  286. + libssh2-1
  287. + libssl-dev
  288. + libssl1.1
  289. + libstdc++-10-dev
  290. + libstdc++6
  291. + libsystemd0
  292. + libtasn1-6
  293. + libthai-dev
  294. + libthai0
  295. + libtiff-dev
  296. + libtiff5
  297. + libtiffxx5
  298. + libtinfo6
  299. + libtirpc3
  300. + libudev-dev
  301. + libudev1
  302. + libunbound8
  303. + libunistring2
  304. + libutempter-dev
  305. + libutempter0
  306. + libuuid1
  307. + libva-dev
  308. + libva-drm2
  309. + libva-glx2
  310. + libva-wayland2
  311. + libva-x11-2
  312. + libva2
  313. + libvorbis0a
  314. + libvorbisenc2
  315. + libvulkan-dev
  316. + libvulkan1
  317. + libwacom9
  318. + libwayland-client0
  319. + libwayland-cursor0
  320. + libwayland-dev
  321. + libwayland-egl1
  322. + libwayland-egl1-mesa
  323. + libwayland-server0
  324. + libwebp-dev
  325. + libwebp7
  326. + libwebpdemux2
  327. + libwebpmux3
  328. + libwrap0
  329. + libx11-6
  330. + libx11-dev
  331. + libx11-xcb-dev
  332. + libx11-xcb1
  333. + libxau-dev
  334. + libxau6
  335. + libxcb-dri2-0
  336. + libxcb-dri2-0-dev
  337. + libxcb-dri3-0
  338. + libxcb-dri3-dev
  339. + libxcb-glx0
  340. + libxcb-glx0-dev
  341. + libxcb-icccm4
  342. + libxcb-image0
  343. + libxcb-keysyms1
  344. + libxcb-present-dev
  345. + libxcb-present0
  346. + libxcb-randr0
  347. + libxcb-render-util0
  348. + libxcb-render0
  349. + libxcb-render0-dev
  350. + libxcb-shape0
  351. + libxcb-shm0
  352. + libxcb-shm0-dev
  353. + libxcb-sync1
  354. + libxcb-util1
  355. + libxcb-xfixes0
  356. + libxcb-xinerama0
  357. + libxcb-xinput0
  358. + libxcb-xkb1
  359. + libxcb1
  360. + libxcb1-dev
  361. + libxcomposite-dev
  362. + libxcomposite1
  363. + libxcursor-dev
  364. + libxcursor1
  365. + libxdamage-dev
  366. + libxdamage1
  367. + libxdmcp-dev
  368. + libxdmcp6
  369. + libxext-dev
  370. + libxext6
  371. + libxfixes-dev
  372. + libxfixes3
  373. + libxft-dev
  374. + libxft2
  375. + libxi-dev
  376. + libxi6
  377. + libxinerama-dev
  378. + libxinerama1
  379. + libxkbcommon-dev
  380. + libxkbcommon-x11-0
  381. + libxkbcommon0
  382. + libxml2
  383. + libxml2-dev
  384. + libxrandr-dev
  385. + libxrandr2
  386. + libxrender-dev
  387. + libxrender1
  388. + libxshmfence-dev
  389. + libxshmfence1
  390. + libxslt1-dev
  391. + libxslt1.1
  392. + libxss-dev
  393. + libxss1
  394. + libxt-dev
  395. + libxt6
  396. + libxtst-dev
  397. + libxtst6
  398. + libxxf86vm-dev
  399. + libxxf86vm1
  400. + libzstd1
  401. + linux-libc-dev
  402. + mesa-common-dev
  403. + qtbase5-dev
  404. + qtbase5-dev-tools
  405. + shared-mime-info
  406. + uuid-dev
  407. + wayland-protocols
  408. + x11proto-dev
  409. + zlib1g
  410. + zlib1g-dev
  411. +"
  412. +
  413. +DEBIAN_PACKAGES_RISCV64="
  414. + libtsan0
  415. + liblsan0
  416. + libasan6
  417. + libdrm-intel1
  418. + libitm1
  419. + libquadmath0
  420. + libdrm-etnaviv1
  421. + libdrm-exynos1
  422. + libdrm-freedreno1
  423. + libdrm-omap1
  424. + libdrm-tegra0
  425. + libgmp10
  426. + liblsan0
  427. + libthai0
  428. + libtsan0
  429. + libubsan1
  430. + valgrind
  431. +"
  432. +
  433. +. "${SCRIPT_DIR}/sysroot-creator.sh"
  434. diff --git a/build/linux/sysroot_scripts/sysroot-creator.sh b/build/linux/sysroot_scripts/sysroot-creator.sh
  435. index bde29db92ba02..b252c28a166a4 100644
  436. --- a/build/linux/sysroot_scripts/sysroot-creator.sh
  437. +++ b/build/linux/sysroot_scripts/sysroot-creator.sh
  438. @@ -51,6 +51,7 @@ readonly HAS_ARCH_ARM64=${HAS_ARCH_ARM64:=0}
  439. readonly HAS_ARCH_ARMEL=${HAS_ARCH_ARMEL:=0}
  440. readonly HAS_ARCH_MIPS=${HAS_ARCH_MIPS:=0}
  441. readonly HAS_ARCH_MIPS64EL=${HAS_ARCH_MIPS64EL:=0}
  442. +readonly HAS_ARCH_RISCV64=${HAS_ARCH_RISCV64:=0}
  443. readonly REQUIRED_TOOLS="curl xzcat"
  444. @@ -69,6 +70,7 @@ readonly DEBIAN_DEP_LIST_ARM64="generated_package_lists/${DIST}.arm64"
  445. readonly DEBIAN_DEP_LIST_ARMEL="generated_package_lists/${DIST}.armel"
  446. readonly DEBIAN_DEP_LIST_MIPS="generated_package_lists/${DIST}.mipsel"
  447. readonly DEBIAN_DEP_LIST_MIPS64EL="generated_package_lists/${DIST}.mips64el"
  448. +readonly DEBIAN_DEP_LIST_RISCV64="generated_package_lists/${DIST}.riscv64"
  449. ######################################################################
  450. @@ -171,6 +173,9 @@ SetEnvironmentVariables() {
  451. *ARMEL)
  452. ARCH=ARMEL
  453. ;;
  454. + *Riscv*)
  455. + ARCH=RISCV64
  456. + ;;
  457. *)
  458. echo "ERROR: Unable to determine architecture based on: $1"
  459. exit 1
  460. @@ -312,6 +317,10 @@ GeneratePackageListMips64el() {
  461. ${DEBIAN_PACKAGES_MIPS64EL:=}"
  462. }
  463. +GeneratePackageListRiscv64() {
  464. + GeneratePackageListCommon "$1" riscv64 "${DEBIAN_PACKAGES}"
  465. +}
  466. +
  467. StripChecksumsFromPackageList() {
  468. local package_file="$1"
  469. sed -i 's/ [a-f0-9]\{64\}$//' "$package_file"
  470. @@ -402,13 +411,11 @@ HacksAndPatchesAmd64() {
  471. ReversionGlibc x86_64 linux-gnu
  472. }
  473. -
  474. HacksAndPatchesI386() {
  475. HacksAndPatchesCommon i386 linux-gnu strip
  476. ReversionGlibc i386 linux-gnu
  477. }
  478. -
  479. HacksAndPatchesARM() {
  480. HacksAndPatchesCommon arm linux-gnueabihf arm-linux-gnueabihf-strip
  481. ReversionGlibc arm linux-gnueabihf
  482. @@ -433,12 +440,15 @@ HacksAndPatchesMips() {
  483. ReversionGlibc mipsel linux-gnu
  484. }
  485. -
  486. HacksAndPatchesMips64el() {
  487. HacksAndPatchesCommon mips64el linux-gnuabi64 mips64el-linux-gnuabi64-strip
  488. ReversionGlibc mips64el linux-gnuabi64
  489. }
  490. +HacksAndPatchesRiscv64() {
  491. + HacksAndPatchesCommon riscv64 linux-gnu true
  492. + ReversionGlibc riscv64 linux-gnu
  493. +}
  494. InstallIntoSysroot() {
  495. Banner "Install Libs And Headers Into Jail"
  496. @@ -489,7 +499,7 @@ CleanupJailSymlinks() {
  497. cd ${INSTALL_ROOT}
  498. local libdirs="lib usr/lib"
  499. if [ "${ARCH}" != "MIPS" ]; then
  500. - libdirs="${libdirs} lib64"
  501. + libdirs="${libdirs}"
  502. fi
  503. find $libdirs -type l -printf '%p %l\n' | while read link target; do
  504. @@ -532,6 +542,7 @@ VerifyLibraryDepsCommon() {
  505. local all_libs="$(find ${find_dirs[*]} -printf '%f\n')"
  506. # Ignore missing libdbus-1.so.0
  507. all_libs+="$(echo -e '\nlibdbus-1.so.0')"
  508. + all_libs+="$(echo -e '\nlibicuuc.so.67')"
  509. local missing_libs="$(grep -vFxf <(echo "${all_libs}") \
  510. <(echo "${needed_libs}"))"
  511. if [ ! -z "${missing_libs}" ]; then
  512. @@ -546,17 +557,14 @@ VerifyLibraryDepsAmd64() {
  513. VerifyLibraryDepsCommon x86_64 linux-gnu
  514. }
  515. -
  516. VerifyLibraryDepsI386() {
  517. VerifyLibraryDepsCommon i386 linux-gnu
  518. }
  519. -
  520. VerifyLibraryDepsARM() {
  521. VerifyLibraryDepsCommon arm linux-gnueabihf
  522. }
  523. -
  524. VerifyLibraryDepsARM64() {
  525. VerifyLibraryDepsCommon aarch64 linux-gnu
  526. }
  527. @@ -569,11 +577,14 @@ VerifyLibraryDepsMips() {
  528. VerifyLibraryDepsCommon mipsel linux-gnu
  529. }
  530. -
  531. VerifyLibraryDepsMips64el() {
  532. VerifyLibraryDepsCommon mips64el linux-gnuabi64
  533. }
  534. +VerifyLibraryDepsRiscv64() {
  535. + VerifyLibraryDepsCommon riscv64 linux-gnu
  536. +}
  537. +
  538. #@
  539. #@ BuildSysrootAmd64
  540. @@ -715,6 +726,26 @@ BuildSysrootMips64el() {
  541. CreateTarBall
  542. }
  543. +#@
  544. +#@ BuildSysrootRiscv64
  545. +#@
  546. +#@ Build everything and package it
  547. +BuildSysrootRiscv64() {
  548. + if [ "$HAS_ARCH_RISCV64" = "0" ]; then
  549. + return
  550. + fi
  551. + ClearInstallDir
  552. + local package_file="${DEBIAN_DEP_LIST_RISCV64}"
  553. + GeneratePackageListRiscv64 "$package_file"
  554. + local files_and_sha256sums="$(cat ${package_file})"
  555. + StripChecksumsFromPackageList "$package_file"
  556. + InstallIntoSysroot ${files_and_sha256sums}
  557. + HacksAndPatchesRiscv64
  558. + CleanupJailSymlinks
  559. + VerifyLibraryDepsRiscv64
  560. + CreateTarBall
  561. +}
  562. +
  563. #@
  564. #@ BuildSysrootAll
  565. #@
  566. @@ -890,7 +921,7 @@ GeneratePackageList() {
  567. local failed=0
  568. for pkg in $@ ; do
  569. local pkg_full=$(grep -A 1 " ${pkg}\$" "$input_file" | \
  570. - egrep "pool/.*" | sed 's/.*Filename: //')
  571. + egrep "debian-ports/.*" | sed 's/.*Filename: //')
  572. if [ -z "${pkg_full}" ]; then
  573. echo "ERROR: missing package: $pkg"
  574. local failed=1
  575. @@ -937,6 +968,9 @@ PrintArchitectures() {
  576. if [ "$HAS_ARCH_MIPS64EL" = "1" ]; then
  577. echo Mips64el
  578. fi
  579. + if [ "$HAS_ARCH_RISCV64" = "1" ]; then
  580. + echo Riscv64
  581. + fi
  582. }
  583. #@
  584. --
  585. 2.25.1