Browse Source

first commit

lqg 3 years ago
commit
36fa20770f
100 changed files with 5834 additions and 0 deletions
  1. 27 0
      .github/ISSUE_TEMPLATE.md
  2. 26 0
      .github/PULL_REQUEST_TEMPLATE.md
  3. 28 0
      .travis.yml
  4. 16 0
      CONTRIBUTORS
  5. 22 0
      LICENSE
  6. 124 0
      README.md
  7. 79 0
      conf/layer.conf
  8. 15 0
      conf/machine/ice.conf
  9. 68 0
      conf/machine/include/thead-base.inc
  10. 15 0
      conf/machine/light.conf
  11. 7 0
      conf/site.conf
  12. 68 0
      docs/Plasma-Mobile-on-Unleashed.md
  13. BIN
      docs/RISC-V-Plamo.jpg
  14. 1 0
      dynamic-layers/gnome-layer/recipes-support/packagegroups/packagegroup-gnome-desktop.bbappend
  15. 1 0
      dynamic-layers/multimedia-layer/recipes-multimedia/packagegroups/packagegroup-meta-multimedia.bbappend
  16. 42 0
      dynamic-layers/openembedded-layer/recipes-devtools/openocd/openocd/0001-bitbang-Make-bitbang_swd-extern-definition.patch
  17. 15 0
      dynamic-layers/openembedded-layer/recipes-devtools/openocd/openocd_csky.bb
  18. 89 0
      dynamic-layers/virt-layer/recipes-extended/xvisor/xvisor_%.bbappend
  19. 51 0
      recipes-bsp/u-boot/files/ice_evb_c910_defconfig.patch
  20. 44 0
      recipes-bsp/u-boot/files/tftp-mmc-boot.txt
  21. 4 0
      recipes-bsp/u-boot/files/uEnv.txt
  22. 16 0
      recipes-bsp/u-boot/u-boot_%.bbappend
  23. 58 0
      recipes-connectivity/openssl/files/0001-Add-support-for-io_pgetevents_time64-syscall.patch
  24. 5 0
      recipes-connectivity/openssl/openssl_1.1.1%.bbappend
  25. 2 0
      recipes-core/glibc/glibc_2.32.bbappend
  26. 28 0
      recipes-core/musl/musl/0001-Remove-ARMSUBARCH-relic-from-configure.patch
  27. 72 0
      recipes-core/musl/musl/0002-time64-Don-t-make-aliases-to-nonexistent-syscalls.patch
  28. 57 0
      recipes-core/musl/musl/0003-time64-Only-getrlimit-setrlimit-if-they-exist.patch
  29. 46 0
      recipes-core/musl/musl/0004-time64-Only-gettimeofday-settimeofday-if-exist.patch
  30. 94 0
      recipes-core/musl/musl/0005-Add-src-internal-statx.h.patch
  31. 209 0
      recipes-core/musl/musl/0006-Only-call-fstatat-if-defined.patch
  32. 183 0
      recipes-core/musl/musl/0007-Emulate-wait4-using-waitid.patch
  33. 26 0
      recipes-core/musl/musl/0008-riscv-Fall-back-to-syscall-__riscv_flush_icache.patch
  34. 33 0
      recipes-core/musl/musl/0009-riscv32-Target-and-subtarget-detection.patch
  35. 849 0
      recipes-core/musl/musl/0010-riscv32-add-arch-headers.patch
  36. 363 0
      recipes-core/musl/musl/0011-riscv32-Add-fenv-and-math.patch
  37. 26 0
      recipes-core/musl/musl/0012-riscv32-Add-dlsym.patch
  38. 158 0
      recipes-core/musl/musl/0013-riscv32-Add-jmp_buf-and-sigreturn.patch
  39. 120 0
      recipes-core/musl/musl/0014-riscv32-Add-thread-support.patch
  40. 201 0
      recipes-core/musl/musl/0015-Change-definitions-of-F_GETLK-F_SETLK-F_SETLKW.patch
  41. 33 0
      recipes-core/musl/musl/0016-riscv32-Wire-new-syscalls.patch
  42. 20 0
      recipes-core/musl/musl_%.bbappend
  43. 1 0
      recipes-core/packagegroups/packagegroup-core-eclipse-debug.bbappend
  44. 3 0
      recipes-core/packagegroups/packagegroup-core-tools-debug.bbappend
  45. 4 0
      recipes-core/packagegroups/packagegroup-core-tools-profile.bbappend
  46. 4 0
      recipes-core/packagegroups/packagegroup-core-tools-testapps.bbappend
  47. 1 0
      recipes-core/packagegroups/packagegroup-go-sdk-target.bbappend
  48. 3 0
      recipes-core/packagegroups/packagegroup-self-hosted.bbappend
  49. 186 0
      recipes-core/systemd/systemd/src/basic/architecture.c
  50. 246 0
      recipes-core/systemd/systemd/src/basic/architecture.h
  51. 25 0
      recipes-core/systemd/systemd_246.6.bbappend
  52. 27 0
      recipes-devtools/csky-tools/csky-fesvr.bb
  53. 25 0
      recipes-devtools/csky-tools/csky-spike.bb
  54. 12 0
      recipes-devtools/csky-tools/files/fesvr-makefile.patch
  55. 12 0
      recipes-devtools/csky-tools/files/spike-makefile.patch
  56. 55 0
      recipes-devtools/dpkg/dpkg/data/cputable
  57. 16 0
      recipes-devtools/dpkg/dpkg_1.20.5.bbappend
  58. 9 0
      recipes-devtools/elfutils/elfutils_0.181.bbappend
  59. 50 0
      recipes-devtools/elfutils/files/0001-dso-link-change.patch
  60. 36 0
      recipes-devtools/elfutils/files/0001-libasm-may-link-with-libbz2-if-found.patch
  61. 44 0
      recipes-devtools/elfutils/files/0001-libelf-elf_end.c-check-data_list.data.d.d_buf-before.patch
  62. 124 0
      recipes-devtools/elfutils/files/0001-musl-obstack-fts.patch
  63. 32 0
      recipes-devtools/elfutils/files/0001-ppc_initreg.c-Incliude-asm-ptrace.h-for-pt_regs-defi.patch
  64. 73 0
      recipes-devtools/elfutils/files/0001-skip-the-test-when-gcc-not-deployed.patch
  65. 28 0
      recipes-devtools/elfutils/files/0001-tests-Makefile.am-compile-test_nlist-with-standard-C.patch
  66. 40 0
      recipes-devtools/elfutils/files/0002-Fix-elf_cvt_gunhash-if-dest-and-src-are-same.patch
  67. 142 0
      recipes-devtools/elfutils/files/0002-musl-libs.patch
  68. 38 0
      recipes-devtools/elfutils/files/0003-fixheadercheck.patch
  69. 163 0
      recipes-devtools/elfutils/files/0003-musl-utils.patch
  70. 42 0
      recipes-devtools/elfutils/files/0004-Disable-the-test-to-convert-euc-jp.patch
  71. 36 0
      recipes-devtools/elfutils/files/0004-Fix-error-on-musl.patch
  72. 59 0
      recipes-devtools/elfutils/files/0006-Fix-build-on-aarch64-musl.patch
  73. 37 0
      recipes-devtools/elfutils/files/0015-config-eu.am-do-not-use-Werror.patch
  74. 76 0
      recipes-devtools/elfutils/files/ptest.patch
  75. 6 0
      recipes-devtools/elfutils/files/run-ptest
  76. 3 0
      recipes-devtools/libtool/libtool-cross_%.bbappend
  77. 3 0
      recipes-devtools/libtool/libtool-native_%.bbappend
  78. 12 0
      recipes-devtools/libtool/libtool/9999-fix-thead.patch
  79. 3 0
      recipes-devtools/libtool/libtool_%.bbappend
  80. 3 0
      recipes-devtools/libtool/nativesdk-libtool_%.bbappend
  81. 451 0
      recipes-devtools/meson/meson/envconfig.py
  82. 12 0
      recipes-devtools/meson/meson_0.55.1.bbappend
  83. 16 0
      recipes-devtools/python/python3-pycairo_1.20.0.bbappend
  84. 13 0
      recipes-devtools/python/python3-pygobject_3.38.0.bbappend
  85. 40 0
      recipes-extended/ghostscript/ghostscript/csky/objarch.h
  86. 1 0
      recipes-extended/ghostscript/ghostscript_%.bbappend
  87. 44 0
      recipes-extended/ltp/ltp/0001-Define-SYS_futex-on-32bit-arches-using-64-bit-time_t.patch
  88. 3 0
      recipes-extended/ltp/ltp_%.bbappend
  89. 34 0
      recipes-graphics/cairo/cairo/CVE-2018-19876.patch
  90. 19 0
      recipes-graphics/cairo/cairo/CVE-2019-6461.patch
  91. 20 0
      recipes-graphics/cairo/cairo/CVE-2019-6462.patch
  92. 22 0
      recipes-graphics/cairo/cairo/cairo-get_bitmap_surface-bsc1036789-CVE-2017-7475.diff
  93. 26 0
      recipes-graphics/cairo/cairo_1.16.0.bbappend
  94. 13 0
      recipes-graphics/mesa/mesa_20.2.1.bbappend
  95. 13 0
      recipes-graphics/xorg-lib/libxshmfence/rv32_sys_futex.patch
  96. 4 0
      recipes-graphics/xorg-lib/libxshmfence_1.3.bbappend
  97. 31 0
      recipes-kernel/linux/linux-thead_5.4.36.bb
  98. 46 0
      recipes-kernel/linux/linux-thead_5.4.36.bbappend
  99. 1 0
      recipes-kernel/linux/linux-yocto-dev.bbappend
  100. 5 0
      recipes-kernel/linux/linux-yocto_5.%.bbappend

+ 27 - 0
.github/ISSUE_TEMPLATE.md

@@ -0,0 +1,27 @@
+<!--
+If you are reporting a new issue, make sure that we do not have any duplicates
+already open. You can ensure this by searching the issue list for this
+repository. If there is a duplicate, please close your issue and add a comment
+to the existing issue instead.
+-->
+
+**Description**
+
+<!--
+Briefly describe the problem you are having in a few paragraphs.
+-->
+
+**Steps to reproduce the issue:**
+1.
+2.
+3.
+
+**Describe the results you received:**
+
+
+**Describe the results you expected:**
+
+
+**Additional information you deem important (e.g. issue happens only occasionally):**
+
+**Additional details (revisions used, host distro, etc.):**

+ 26 - 0
.github/PULL_REQUEST_TEMPLATE.md

@@ -0,0 +1,26 @@
+<!--
+Please make sure you've read and understood our contributing guidelines.
+
+For additional information on the contribution guidelines:
+https://wiki.yoctoproject.org/wiki/Contribution_Guidelines#General_Information
+
+If this PR fixes an issue, make sure your description includes "fixes #xxxx".
+
+If this PR connects to an issue, make sure your description includes "connected to #xxxx".
+
+Please provide the following information:
+-->
+
+**- <recipename>: Short log / Statement of what needed to be changed.**
+  
+**-(Optional pointers to external resources, such as defect tracking)**
+  
+**-The intent of your change.**
+  
+**-(Optional, if it's not clear from above) how your change resolves the
+issues in the first part.**
+  
+**-Tag line(s) at the end.**
+
+**-Signed-off-by: Random J Developer <random@developer.example.org>**
+

+ 28 - 0
.travis.yml

@@ -0,0 +1,28 @@
+dist: bionic
+sudo: required
+language: shell
+compiler:
+env:
+
+git:
+  depth: 3
+
+before_install:
+
+install:
+  - sudo apt-get install -y -qq diffstat texinfo chrpath
+script:
+  - cd ../
+  - git clone --depth=3 git://git.openembedded.org/openembedded-core
+  - cd openembedded-core
+  - mv ../meta-csky ./
+  - git clone --depth=3 git://git.openembedded.org/bitbake
+  - git clone --depth=3 git://git.openembedded.org/meta-openembedded
+  - source oe-init-build-env
+  - find ./conf/bblayers.conf -type f -exec sed -i "s|  \"|  $(pwd)/../meta-openembedded/meta-oe \\\ \\n  \"|g" {} +
+  - find ./conf/bblayers.conf -type f -exec sed -i "s|  \"|  $(pwd)/../meta-csky \\\ \\n  \"|g" {} +
+  - MACHINE=qemucsky timeout --foreground 55m bitbake core-image-minimal || if [ $? == 124 ]; then echo "Timeout"; else return 1; fi;
+  - MACHINE=freedom-u540 timeout --foreground 55m bitbake core-image-minimal || if [ $? == 124 ]; then echo "Timeout"; else return 1; fi
+
+after_success:
+

+ 16 - 0
CONTRIBUTORS

@@ -0,0 +1,16 @@
+List of meta-riscv contributors, sorted by Alphabetical order
+
+ * Alistair Francis <alistair.francis@wdc.com>
+ * Chin Huat Ang <chinhuat@gmail.com>
+ * Jeremy Puhlman <jpuhlman@mvista.com>
+ * Khem Raj <raj.khem@gmail.com>
+ * Mirza Krak <mirza.krak@endian.se>
+ * Moritz Fischer <moritz.fischer@ettus.com>
+ * Palmer Dabbelt <palmer@sifive.com>
+ * Ricardo Salveti <ricardo@foundries.io>
+ * Ricardo Salveti <ricardo@opensourcefoundries.com>
+ * sungwon.pino <sungwon.pino@gmail.com>
+ * Taras Kondratiuk <takondra@cisco.com>
+ * Trevor Woerner <twoerner@gmail.com>
+ * Vijai Kumar K <vijaikumar.kanagarajan@gmail.com>
+

+ 22 - 0
LICENSE

@@ -0,0 +1,22 @@
+MIT License
+
+Copyright (c) 2017-2020 is held by individual contributors, see the CONTRIBUTORS
+file and git log for more details.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 124 - 0
README.md

@@ -0,0 +1,124 @@
+# meta-csky
+CSKY Architecture Layer for OpenEmbedded/Yocto
+
+[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/csky/meta-csky/blob/kraj/master/COPYRIGHT)
+[![Build Status](https://travis-ci.org/csky/meta-csky.svg?branch=master)](https://travis-ci.org/csky/meta-csky)
+
+## Description
+
+This is the general hardware-specific BSP overlay for the CSKY based devices.
+
+More information can be found at: <https://csky.org/> (Official Site)
+
+The core BSP part of meta-csky should work with different
+OpenEmbedded/Yocto distributions and layer stacks, such as:
+
+* Distro-less (only with OE-Core).
+* Yoe Distro.
+* Yocto/Poky.
+
+## Dependencies
+
+This layer depends on:
+
+* URI: git://github.com/openembedded/openembedded-core
+  * branch: master
+  * revision: HEAD
+* URI: git://github.com/openembedded/bitbake
+  * branch: master
+  * revision: HEAD
+
+## Quick Start
+
+**Note: You only need this if you do not have an existing Yocto Project build environment.**
+
+Make sure to [install the `repo` command by Google](https://source.android.com/setup/downloading#installing-repo) first. 
+
+### Create workspace
+```text
+mkdir csky-yocto && cd csky-yocto
+repo init -u git://github.com/csky/meta-csky  -b master -m tools/manifests/csky-yocto.xml
+repo sync
+repo start work --all
+```
+### Update existing workspace
+
+In order to bring all the layers up to date with upstream
+
+```text
+cd csky-yocto
+repo sync
+repo rebase
+```
+
+### Setup Build Environment
+```text
+. ./meta-csky/setup.sh
+```
+
+## Available Machines
+
+The three different machines you can build for are:
+
+* qemucsky: The 32-bit CSKY machine
+* freedom-u540: The SiFive HiFive Unleashed board
+
+## Build Images
+
+A console-only image for the 64-bit QEMU machine
+```text
+MACHINE=qemucsky bitbake core-image-full-cmdline
+```
+
+To build an image to run on the HiFive Unleashed using Wayland run the following
+
+```text
+MACHINE=freedom-u540 bitbake core-image-weston
+```
+
+To build a full GUI equipped image running Plasma Mobile see the in-tree documentation [here](https://github.com/csky/meta-csky/blob/master/docs/Plasma-Mobile-on-Unleashed.md).
+
+## Running in QEMU
+
+Run the 32-bit machine in QEMU using the following command:
+
+```text
+MACHINE=qemucsky runqemu nographic
+```
+
+## Running on hardware
+
+### Setting up a TFTP server
+
+If you would like to boot the images from a TFTP server (optional) you should set your TFTP server address in your local.conf with the following line. Change ```127.0.0.1``` to the IP address of your TFTP server and copy the uImage to the server.
+
+```text
+TFTP_SERVER_IP = "127.0.0.1"
+```
+
+### Running with the Microsemi Expansion board
+
+To use the Microsemi expansion board with your HiFive Unleased add the following line to your local.conf. This tells the Unleashed to use a device tree with the PCIe device described:
+
+
+### Sparse Image Creation
+
+The output of the build can also be written to an SD card using bmaptool, the steps to do this are below:
+
+```text
+$ MACHINE=freedom-u540 wic create freedom-u540-opensbi -e core-image-minimal
+$ bmaptool create ./freedom-u540-opensbi-201812181337-mmcblk.direct > image.bmap
+$ sudo bmaptool copy --bmap image.bmap ./freedom-u540-opensbi-201812181337-mmcblk.direct /dev/sdX
+```
+
+### dding wic.gz
+
+The output of a ```freedom-u540``` build will be a ```<image>.wic.gz``` file. You can write this file to an sd card using:
+
+```text
+$ zcat <image>-<machine>.wic.gz | sudo dd of=/dev/sdX bs=4M iflag=fullblock oflag=direct conv=fsync status=progress
+```
+
+## Maintainer(s)
+
+* Khem Raj `<raj dot khem at gmail.com>`

+ 79 - 0
conf/layer.conf

@@ -0,0 +1,79 @@
+# We have a conf and classes directory, add to BBPATH
+BBPATH .= ":${LAYERDIR}"
+
+# We have a recipes-* directories, add to BBFILES
+BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
+	${LAYERDIR}/recipes-*/*/*.bbappend"
+
+BBFILE_COLLECTIONS += "csky-layer"
+BBFILE_PATTERN_csky-layer = "^${LAYERDIR}/"
+BBFILE_PRIORITY_csky-layer = "6"
+
+BBFILES_DYNAMIC += " \
+    virtualization-layer:${LAYERDIR}/dynamic-layers/virt-layer/*/*/*.bb \
+    virtualization-layer:${LAYERDIR}/dynamic-layers/virt-layer/*/*/*.bbappend \
+    openembedded-layer:${LAYERDIR}/dynamic-layers/openembedded-layer/*/*/*.bb \
+    openembedded-layer:${LAYERDIR}/dynamic-layers/openembedded-layer/*/*/*.bbappend \
+    gnome-layer:${LAYERDIR}/dynamic-layers/gnome-layer/*/*/*.bb \
+    gnome-layer:${LAYERDIR}/dynamic-layers/gnome-layer/*/*/*.bbappend \
+    multimedia-layer:${LAYERDIR}/dynamic-layers/multimedia-layer/*/*/*.bb \
+    multimedia-layer:${LAYERDIR}/dynamic-layers/multimedia-layer/*/*/*.bbappend \
+    \
+"
+
+LAYERSERIES_COMPAT_csky-layer = "gatesgarth hardknott"
+
+INSANE_SKIP_append_pn-cmocka_csky = " textrel"
+INSANE_SKIP_append_pn-xfsdump_csky = " textrel"
+INSANE_SKIP_append_pn-zabbix_csky = " textrel"
+INSANE_SKIP_append_pn-netdata_csky = " textrel"
+INSANE_SKIP_append_pn-tipcutils_csky = " textrel"
+INSANE_SKIP_append_pn-tvheadend_csky = " textrel"
+INSANE_SKIP_append_pn-monkey_csky = " textrel"
+INSANE_SKIP_append_pn-eudev_csky = " textrel"
+INSANE_SKIP_append_pn-dracut_csky = " textrel"
+INSANE_SKIP_append_pn-rt-tests_csky = " textrel"
+INSANE_SKIP_append_pn-gdb_csky = " textrel"
+INSANE_SKIP_append_pn-capnproto_csky = " textrel"
+INSANE_SKIP_append_pn-rdma-core_csky = " textrel"
+INSANE_SKIP_append_pn-util-linux_csky = " textrel"
+INSANE_SKIP_append_pn-ltp_csky = " textrel"
+INSANE_SKIP_append_pn-poppler_csky = " textrel"
+INSANE_SKIP_append_pn-qtbase_csky = " textrel"
+INSANE_SKIP_append_pn-gerbera_csky = " textrel"
+INSANE_SKIP_append_pn-opensaf_csky = " textrel"
+INSANE_SKIP_append_pn-doxygen_csky = " textrel"
+INSANE_SKIP_append_pn-opengl-es-cts_csky = " textrel"
+INSANE_SKIP_append_pn-perf_csky = " textrel"
+
+# These recipe dont _yet_ build for rv32
+COMPATIBLE_HOST_pn-openh264_csky = "null"
+# Need to port - tcf/cpudefs-mdep.h
+COMPATIBLE_HOST_pn-tcf-agent_csky = "null"
+# needs SYS_ppoll and SYS_pselect6
+COMPATIBLE_HOST_pn-lttng-tools_csky = "null"
+# LTTng-modules requires CONFIG_KPROBES on kernels >= 5.7.0
+COMPATIBLE_HOST_pn-lttng-modules_csky = "null"
+# Needs porting to rv32
+COMPATIBLE_HOST_pn-android-tools_csky = "null"
+# Needs porting to rv32
+COMPATIBLE_HOST_pn-strace_csky = "null"
+COMPATIBLE_HOST_pn-ostree_csky = "null"
+# Klibc needs porting in usr/klibc/arch/csky
+COMPATIBLE_HOST_pn-klibc_csky = "null"
+COMPATIBLE_HOST_pn-klibc-static-utils_csky = "null"
+COMPATIBLE_HOST_pn-klibc-utils_csky = "null"
+COMPATIBLE_HOST_pn-klcc-cross_csky = "null"
+COMPATIBLE_HOST_pn-kexecboot-klibc_csky = "null"
+COMPATIBLE_HOST_pn-ubi-utils-klibc_csky = "null"
+
+# needs syscalls addressed for rv32
+COMPATIBLE_HOST_pn-qemu_csky = "null"
+# Fails to configure
+COMPATIBLE_HOST_pn-samba_csky = "null"
+COMPATIBLE_HOST_pn-smbnetfs_csky = "null"
+COMPATIBLE_HOST_pn-gnome-control-center_csky = "null"
+COMPATIBLE_HOST_pn-thunar-shares-plugin_csky = "null"
+
+# sipe-mime.c:129:30: error: cast from 'GTypeInstance *' (aka 'struct _GTypeInstance *') to 'GMimeStreamFilter *' (aka 'struct _GMimeStreamFilter *') increases required al ignment from 4 to 8 [-Werror,-Wcast-align]
+COMPATIBLE_HOST_pn-pidgin-sipe_csky = "null"

+ 15 - 0
conf/machine/ice.conf

@@ -0,0 +1,15 @@
+#@TYPE: Machine
+#@NAME: xuantie
+#@SOC: XuanTie Light
+#@DESCRIPTION: Machine configuration for the HiFive Unleashed development board
+
+require conf/machine/include/thead-base.inc
+
+SERIAL_CONSOLES = "115200;ttySIF0"
+MACHINE_EXTRA_RRECOMMENDS += "kernel-modules"
+
+IMAGE_FSTYPES += "ext4"
+#KERNEL_DEVICETREE ?= "thead/light-c910.dtb"
+
+UBOOT_ENTRYPOINT = "0x80200000"
+UBOOT_DTB_LOADADDRESS = "0x82200000"

+ 68 - 0
conf/machine/include/thead-base.inc

@@ -0,0 +1,68 @@
+require conf/machine/include/csky/tune-csky.inc
+
+EXTERNAL_TOOLCHAIN ?= "${HOME}/.thead/csky-linux"
+TCMODE="external"
+TARGET_PREFIX="csky-linux-gnuabiv2-"
+TARGET_ARCH="csky"
+TARGET_OS="linux"
+QEMU_TOOLCHAIN_PATH="${HOME}/.thead/host/csky-qemu/bin/"
+EXTERNAL_TOOLCHAIN_SYSROOT="${EXTERNAL_TOOLCHAIN}/csky-buildroot-linux-gnuabiv2/sysroot"
+SDK_RDEPENDS = "${TOOLCHAIN_TARGET_TASK} ${TOOLCHAIN_HOST_TASK}"
+
+#INSANE_SKIP_${PN} += "glibc-so gobject-introspection-so"
+INSANE_SKIP_${PN} += "glibc-so gobject-introspection-so glibc-external"
+
+PREFERRED_PROVIDER_virtual/kernel ?= "linux-thead"
+PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot"
+PREFERRED_VERSION_openocd-native = "csky"
+PREFERRED_VERSION_openocd = "csky"
+
+# KERNEL_CLASSES  = "kernel-uimage"
+# KERNEL_IMAGETYPES = "itbImage"
+
+KERNEL_IMAGETYPE = "Image"
+KERNEL_IMAGETYPES += "uImage"
+KEEPUIMAGE = "no"
+
+# MACHINE_FEATURES = "usbgadget usbhost vfat alsa touchscreen"
+MACHINE_FEATURES = "screen keyboard ext2 ext3 serial"
+
+## This sets u-boot as the default OpenSBI payload
+CSKY_SBI_PAYLOAD ?= "u-boot.bin"
+
+#EXTRA_IMAGEDEPENDS += "opensbi"
+CSKY_SBI_PLAT = "thead/c860"
+
+EXTRA_IMAGEDEPENDS += "u-boot"
+UBOOT_MACHINE = "qemu-csky_defconfig"
+
+## Do not update fstab file when using wic images
+WIC_CREATE_EXTRA_ARGS ?= "--no-fstab-update"
+
+## wic default support
+WKS_FILE_DEPENDS ?= " \
+    opensbi \
+    e2fsprogs-native \
+    bmap-tools-native \
+"
+
+IMAGE_BOOT_FILES ?= " \
+    fw_payload.bin \
+    fitImage \
+    boot.scr.uimg \
+"
+
+WKS_FILE ?= "xuantie-opensbi.wks"
+
+BAD_RECOMMENDATIONS += "\
+    libcxx-dev \
+    libcxx-staticdev \
+    compiler-rt-dev \
+    compiler-rt-staticdev \
+"
+ASSUME_PROVIDED += "\
+    libcxx-dev \
+    libcxx-staticdev \
+    compiler-rt-dev \
+    compiler-rt-staticdev \
+"

+ 15 - 0
conf/machine/light.conf

@@ -0,0 +1,15 @@
+#@TYPE: Machine
+#@NAME: xuantie
+#@SOC: XuanTie Light
+#@DESCRIPTION: Machine configuration for the HiFive Unleashed development board
+
+require conf/machine/include/thead-base.inc
+
+SERIAL_CONSOLES = "115200;ttySIF0"
+MACHINE_EXTRA_RRECOMMENDS += "kernel-modules"
+
+IMAGE_FSTYPES += "ext4"
+KERNEL_DEVICETREE ?= "thead/light-c910.dtb"
+
+UBOOT_ENTRYPOINT = "0x80200000"
+UBOOT_DTB_LOADADDRESS = "0x82200000"

+ 7 - 0
conf/site.conf

@@ -0,0 +1,7 @@
+SCONF_VERSION = "1"
+SOURCE_MIRROR_URL ?= "http://yocto.oss-cn-beijing.aliyuncs.com"
+INHERIT += "own-mirrors"
+BB_GENERATE_MIRROR_TARBALLS = "1"
+# BB_NO_NETWORK = "1"
+
+# SSTATE_MIRRORS ?= "file://.* file:///home/zhuzhg/yocto-sstate-cache/PATH"

+ 68 - 0
docs/Plasma-Mobile-on-Unleashed.md

@@ -0,0 +1,68 @@
+# Running Plasma Mobile on the HiFive Unleased
+
+![RISC-V Plamo](RISC-V-Plamo.jpg)
+
+Written by: Alistair Francis <alistair.francis@wdc.com>
+
+## Dependencies
+
+To build plasma mobile you will need (as well as meta-riscv):
+
+* URI: git://github.com/openembedded/openembedded-core
+  * branch: master
+  * revision: HEAD
+* URI: git://github.com/openembedded/bitbake
+  * branch: master
+  * revision: HEAD
+* URI: git://git.yoctoproject.org/meta-java
+  * branch: master
+  * revision: HEAD
+* URI: git://github.com/meta-qt5/meta-qt5.git
+  * branch: master
+  * revision: HEAD
+* URI: git://github.com/KDE/yocto-meta-kf5.git
+  * branch: master
+  * revision: HEAD
+* URI: git://github.com/KDE/yocto-meta-kde.git
+  * branch: master
+  * revision: HEAD
+
+You will also need the HiFive Unleashed with the Microsemi expansion board. As well as that you need a PCIe GPU and PCIe to USB card (for inputs). This was tested using an AMD r600 series GPU. Your millage will vary depending on the GPU selected.
+
+
+## Setup Build Environment
+
+Follow the usual steps you use to build Yocto images. There are more details on the main meta-riscv README. It is probably best to ensure you can bitbake ```core-image-full-cmdline``` before attempting Plasma Mobile.
+
+Once you know you can build for the ```freedom-u540``` machine you should add these lines to your local.conf or distro:
+
+```
+## Required DISTRO_FEATURES
+DISTRO_FEATURES   += " wayland x11 kde opengl pam polkit xattr"
+
+## Create kde user for SDDM
+INHERIT += "extrausers"
+EXTRA_USERS_PARAMS = "useradd kde; \
+                      usermod -P kde kde;"
+
+## Use the Microsemi Expansion board DT in OpenSBI (passed to the kernel)
+RISCV_SBI_FDT_freedom-u540      = "HiFiveUnleashed-MicroSemi-Expansion.dtb"
+
+## Install GPU driver for the GPU being used, in this example it's a Radeon R5 230
+PACKAGECONFIG_append_pn-mesa    = " r600"
+```
+
+You can then start the build by running:
+```
+MACHINE=freedom-u540 bitbake core-image-plasma-mobile
+```
+
+## Deploying
+
+Follow the top-level README to flash the image to an SD card (you will probably need an SD card with more than 10GB of storage). Once you boot the device Plasma Mobile should start.
+
+## Known issues
+
+  * Sometimes the PCIe devices do not work on first boot. In case you can't detect the PCIe devices on the board try power cycling the board and then they should appear.
+
+Please feel free to raise issues for any problems that you encounter.

BIN
docs/RISC-V-Plamo.jpg


+ 1 - 0
dynamic-layers/gnome-layer/recipes-support/packagegroups/packagegroup-gnome-desktop.bbappend

@@ -0,0 +1 @@
+EXCLUDE_FROM_WORLD = "1"

+ 1 - 0
dynamic-layers/multimedia-layer/recipes-multimedia/packagegroups/packagegroup-meta-multimedia.bbappend

@@ -0,0 +1 @@
+EXCLUDE_FROM_WORLD = "1"

+ 42 - 0
dynamic-layers/openembedded-layer/recipes-devtools/openocd/openocd/0001-bitbang-Make-bitbang_swd-extern-definition.patch

@@ -0,0 +1,42 @@
+From 428f9f3c4a5be973e4c7fc1325ae9dbe41040df2 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 13 Aug 2020 17:47:35 -0700
+Subject: [PATCH] bitbang: Make bitbang_swd extern definition
+
+Fixes build with gcc10+
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/jtag/drivers/bitbang.c | 1 +
+ src/jtag/drivers/bitbang.h | 2 +-
+ 2 files changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/jtag/drivers/bitbang.c b/src/jtag/drivers/bitbang.c
+index b5078c080..f8612aade 100644
+--- a/src/jtag/drivers/bitbang.c
++++ b/src/jtag/drivers/bitbang.c
+@@ -43,6 +43,7 @@ static int bitbang_stableclocks(int num_cycles);
+ static void bitbang_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay_clk);
+ 
+ struct bitbang_interface *bitbang_interface;
++const struct swd_driver bitbang_swd;
+ 
+ /* DANGER!!!! clock absolutely *MUST* be 0 in idle or reset won't work!
+  *
+diff --git a/src/jtag/drivers/bitbang.h b/src/jtag/drivers/bitbang.h
+index 577717ebd..0faf5d9ae 100644
+--- a/src/jtag/drivers/bitbang.h
++++ b/src/jtag/drivers/bitbang.h
+@@ -57,7 +57,7 @@ struct bitbang_interface {
+ 	void (*swdio_drive)(bool on);
+ };
+ 
+-const struct swd_driver bitbang_swd;
++extern const struct swd_driver bitbang_swd;
+ 
+ extern bool swd_mode;
+ 
+-- 
+2.28.0
+

+ 15 - 0
dynamic-layers/openembedded-layer/recipes-devtools/openocd/openocd_csky.bb

@@ -0,0 +1,15 @@
+require recipes-devtools/openocd/openocd_git.bb
+
+PV = "csky"
+
+SRC_URI = " \
+    git://github.com/riscv/riscv-openocd.git;protocol=http;branch=riscv;name=openocd \
+    git://repo.or.cz/r/git2cl.git;protocol=http;destsuffix=tools/git2cl;name=git2cl \
+    git://repo.or.cz/r/jimtcl.git;protocol=http;destsuffix=git/jimtcl;name=jimtcl \
+    git://repo.or.cz/r/libjaylink.git;protocol=http;destsuffix=git/src/jtag/drivers/libjaylink;name=libjaylink \
+    file://0001-bitbang-Make-bitbang_swd-extern-definition.patch \
+"
+
+SRCREV_openocd = "03f943ae239f59727ef47e46fffc31dd405a642d"
+
+COMPATIBLE_HOST = "(x86_64.*|i.86.*|csky).*-linux"

+ 89 - 0
dynamic-layers/virt-layer/recipes-extended/xvisor/xvisor_%.bbappend

@@ -0,0 +1,89 @@
+XVISOR_PLAT_BASE = "`basename ${XVISOR_PLAT}`"
+
+do_compile[depends] += "virtual/kernel:do_deploy"
+
+xvisor_image_compile() {
+  ## Create the basic firmware image ##
+  cd ${S}/tests/${XVISOR_PLAT}/basic
+  oe_runmake
+
+  dtc -I dts -O dtb -o ${B}/build/tests/${XVISOR_PLAT}/${XVISOR_PLAT_BASE}-guest.dtb ${S}/tests/${XVISOR_PLAT}/${XVISOR_PLAT_BASE}-guest.dts
+
+  rm -f ${B}/vmm-disk-basic.img
+  mkfs.vfat -F 32 -S 512 -n VMM-BASIC-IMAGE -C ${B}/vmm-disk-basic.img 40960
+
+  mmd -i ${B}/vmm-disk-basic.img ::system
+  mcopy -i ${B}/vmm-disk-basic.img ${S}/docs/banner/roman.txt ::system/banner.txt
+  mcopy -i ${B}/vmm-disk-basic.img ${S}/docs/logo/xvisor_logo_name.ppm ::system/logo.ppm
+
+  mmd -i ${B}/vmm-disk-basic.img ::images
+  mmd -i ${B}/vmm-disk-basic.img ::images/riscv
+  mmd -i ${B}/vmm-disk-basic.img ::images/${XVISOR_PLAT}
+  mcopy -i ${B}/vmm-disk-basic.img ${B}/build/tests/${XVISOR_PLAT}/${XVISOR_PLAT_BASE}-guest.dtb ::images/${XVISOR_PLAT}-guest.dtb
+  mcopy -i ${B}/vmm-disk-basic.img ${B}/build/tests/${XVISOR_PLAT}/basic/firmware.bin ::images/${XVISOR_PLAT}/firmware.bin
+  mcopy -i ${B}/vmm-disk-basic.img ${S}/tests/${XVISOR_PLAT}/basic/nor_flash.list ::images/${XVISOR_PLAT}/nor_flash.list
+
+  mcopy -i ${B}/vmm-disk-basic.img ${S}/tests/${XVISOR_PLAT}/xscript/one_guest_${XVISOR_PLAT_BASE}.xscript ::boot.xscript
+
+  ## Create the Linux firmware image ##
+  install -d ${B}/build/tests/${XVISOR_PLAT}/linux
+  dtc -I dts -O dtb -o ${B}/build/tests/${XVISOR_PLAT}/linux/${XVISOR_PLAT_BASE}.dtb ${S}/tests/${XVISOR_PLAT}/linux/${XVISOR_PLAT_BASE}.dts
+
+  rm -f ${B}/vmm-disk-linux.img
+  mkfs.vfat -F 32 -S 512 -n VMM-LINUX-IMAGE -C ${B}/vmm-disk-linux.img 81920
+
+  mmd -i ${B}/vmm-disk-linux.img ::system
+  mcopy -i ${B}/vmm-disk-linux.img ${S}/docs/banner/roman.txt ::system/banner.txt
+  mcopy -i ${B}/vmm-disk-linux.img ${S}/docs/logo/xvisor_logo_name.ppm ::system/logo.ppm
+
+  mmd -i ${B}/vmm-disk-linux.img ::images
+  mmd -i ${B}/vmm-disk-linux.img ::images/riscv
+  mmd -i ${B}/vmm-disk-linux.img ::images/${XVISOR_PLAT}
+  mcopy -i ${B}/vmm-disk-linux.img ${B}/build/tests/${XVISOR_PLAT}/${XVISOR_PLAT_BASE}-guest.dtb ::images/${XVISOR_PLAT}-guest.dtb
+  mcopy -i ${B}/vmm-disk-linux.img ${B}/build/tests/${XVISOR_PLAT}/basic/firmware.bin ::images/${XVISOR_PLAT}/firmware.bin
+  mcopy -i ${B}/vmm-disk-linux.img ${S}/tests/${XVISOR_PLAT}/linux/nor_flash.list ::images/${XVISOR_PLAT}/nor_flash.list
+  mcopy -i ${B}/vmm-disk-linux.img ${S}/tests/${XVISOR_PLAT}/linux/cmdlist ::images/${XVISOR_PLAT}/cmdlist
+
+  mcopy -i ${B}/vmm-disk-linux.img ${S}/tests/${XVISOR_PLAT}/xscript/two_guest_${XVISOR_PLAT_BASE}.xscript ::boot.xscript
+
+  mcopy -i ${B}/vmm-disk-linux.img ${DEPLOY_DIR_IMAGE}/Image ::images/${XVISOR_PLAT}/Image
+  mcopy -i ${B}/vmm-disk-linux.img /scratch/alistair/software/tier4/buildroot-images/riscv64-rootfs.cpio ::images/${XVISOR_PLAT}/rootfs.img
+  mcopy -i ${B}/vmm-disk-linux.img ${B}/build/tests/${XVISOR_PLAT}/linux/${XVISOR_PLAT_BASE}.dtb ::images/${XVISOR_PLAT}/${XVISOR_PLAT_BASE}.dtb
+}
+
+do_compile_append_riscv32() {
+  xvisor_image_compile
+}
+
+do_compile_append_riscv64() {
+  xvisor_image_compile
+}
+
+do_install_append_riscv32() {
+  install -d ${D}
+  install -m 755 ${B}/vmm-disk-basic.img ${D}/
+  install -m 755 ${B}/vmm-disk-linux.img ${D}/
+}
+
+do_install_append_riscv64() {
+  install -d ${D}
+  install -m 755 ${B}/vmm-disk-basic.img ${D}/
+  install -m 755 ${B}/vmm-disk-linux.img ${D}/
+}
+
+do_deploy_append_riscv32() {
+  install -m 755 ${D}/vmm-disk-basic.img ${DEPLOY_DIR_IMAGE}
+  install -m 755 ${D}/vmm-disk-linux.img ${DEPLOY_DIR_IMAGE}
+}
+
+do_deploy_append_riscv64() {
+  install -m 755 ${D}/vmm-disk-basic.img ${DEPLOY_DIR_IMAGE}
+  install -m 755 ${D}/vmm-disk-linux.img ${DEPLOY_DIR_IMAGE}
+}
+
+FILES_${PN}_riscv32 += "/vmm.*"
+FILES_${PN}_riscv32 += "/vmm-disk-basic.img"
+FILES_${PN}_riscv32 += "/vmm-disk-linux.img"
+FILES_${PN}_riscv64 += "/vmm.*"
+FILES_${PN}_riscv64 += "/vmm-disk-basic.img"
+FILES_${PN}_riscv64 += "/vmm-disk-linux.img"

+ 51 - 0
recipes-bsp/u-boot/files/ice_evb_c910_defconfig.patch

@@ -0,0 +1,51 @@
+From 89b448a7b17627f90ddb74f2d4d3f8d653721142 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=E7=AD=89=E9=97=B2?= <zhiguo.zzg@alibaba-inc.com>
+Date: Tue, 15 Sep 2020 02:33:02 +0000
+Subject: [PATCH] update
+
+---
+ configs/ice_evb_c910_defconfig | 32 ++++++++++++++++++++++++++++++++
+ 1 file changed, 32 insertions(+)
+ create mode 100644 configs/ice_evb_c910_defconfig
+
+diff --git a/configs/ice_evb_c910_defconfig b/configs/ice_evb_c910_defconfig
+new file mode 100644
+index 0000000000..8fef4dcad7
+--- /dev/null
++++ b/configs/ice_evb_c910_defconfig
+@@ -0,0 +1,32 @@
++CONFIG_RISCV=y
++CONFIG_ENV_SIZE=0x20000
++CONFIG_NR_DRAM_BANKS=1
++CONFIG_TARGET_ICE_C910=y
++CONFIG_SYS_PROMPT="C910 # "
++CONFIG_ARCH_RV64I=y
++CONFIG_RISCV_SMODE=y
++CONFIG_DISTRO_DEFAULTS=y
++CONFIG_FIT=y
++CONFIG_DEFAULT_DEVICE_TREE="ice-c910"
++CONFIG_DISPLAY_CPUINFO=y
++CONFIG_DISPLAY_BOARDINFO=y
++CONFIG_OF_PRIOR_STAGE=y
++CONFIG_SYS_RELOC_GD_ENV_ADDR=y
++CONFIG_SYS_NS16550=y
++# CONFIG_EFI_LOADER is not set
++# CONFIG_PARTITIONS is not set
++CONFIG_OF_CONTROL=y
++CONFIG_CLK=y
++CONFIG_DM_MMC=y
++CONFIG_MMC_DW=y
++CONFIG_MMC_DW_SNPS=y
++CONFIG_DM_ETH=y
++CONFIG_ETH_DESIGNWARE=y
++CONFIG_PPL=y
++CONFIG_SPL=y
++# CONFIG_SPL_FRAMEWORK is not set
++# CONFIG_SPL_OF_CONTROL is not set
++# CONFIG_SPL_SERIAL_SUPPORT is not set
++# CONFIG_SPL_TIMER is not set
++CONFIG_SPL_LOAD_FIT=y
++CONFIG_IS_ASICF=y
+-- 
+2.17.1
+

+ 44 - 0
recipes-bsp/u-boot/files/tftp-mmc-boot.txt

@@ -0,0 +1,44 @@
+# This is the default TFTP and MMC u-boot boot script
+# The order is as follows:
+#  1. TFTP load a uEnv.txt
+#  2. TFTP boot a fitImage
+#  3. MMC load a uEnv.txt
+#  4. MMC load a fitImage
+#  5. TFTP load a uImage
+#  6. MMC load a fitImage
+
+# Setup the DHCP for a TFTP boot
+setenv serverip @SERVERIP@
+dhcp
+
+# See if we have a TFTP uEnv.txt file
+if tftpboot ${scriptaddr} uEnv.txt; then
+    env import -t ${scriptaddr} ${filesize}
+    run bootcmd
+fi;
+
+# Try to boot a fitImage from the TFTP server
+if tftpboot ${ramdisk_addr_r} fitImage; then
+  bootm ${ramdisk_addr_r}
+fi;
+
+# See if we have a MMC uEnv.txt file
+if fatload ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} /uEnv.txt; then
+    env import -t ${scriptaddr} ${filesize}
+    run bootcmd
+fi;
+
+# Try to boot a fitImage from the MMC
+if load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} fitImage; then
+  bootm ${ramdisk_addr_r}
+fi;
+
+# Fallback to a TFTP uImage
+if tftpboot ${kernel_addr_r} uImage; then
+  bootm ${kernel_addr_r} - ${fdt_addr_r}
+fi;
+
+# Finally fallback to a MMC uImage
+if load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} uImage; then
+  bootm ${kernel_addr_r} - ${fdt_addr_r}
+fi;

+ 4 - 0
recipes-bsp/u-boot/files/uEnv.txt

@@ -0,0 +1,4 @@
+bootcmd_otenv=load ${devtype} ${devnum}:3 ${scriptaddr} /boot/loader/uEnv.txt; env import -t ${scriptaddr} ${filesize}
+bootcmd_load_f=load ${devtype} ${devnum}:3 ${ramdisk_addr_r} "/boot"${kernel_image}
+bootcmd_run=bootm ${ramdisk_addr_r}
+bootcmd=run bootcmd_otenv; run bootcmd_load_f; run bootcmd_run

+ 16 - 0
recipes-bsp/u-boot/u-boot_%.bbappend

@@ -0,0 +1,16 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
+
+do_configure() {
+	    echo "u-boot->do_configure: Nothing to do!!"
+}
+
+do_compile() {
+	    echo "u-boot->do_compile: Nothing to do!!"
+}
+
+do_install() {
+	    echo "u-boot->do_install: Nothing to do!!"
+} 
+do_deploy() {
+	    echo "u-boot->do_deploy: Nothing to do!!"
+}

+ 58 - 0
recipes-connectivity/openssl/files/0001-Add-support-for-io_pgetevents_time64-syscall.patch

@@ -0,0 +1,58 @@
+From d1a1b797d961301fd58513e50ac5de9ad5b8bc08 Mon Sep 17 00:00:00 2001
+From: Alistair Francis <alistair.francis@wdc.com>
+Date: Thu, 29 Aug 2019 13:56:21 -0700
+Subject: [PATCH] Add support for io_pgetevents_time64 syscall
+
+32-bit architectures that are y2038 safe don't include syscalls that use
+32-bit time_t. Instead these architectures have suffixed syscalls that
+always use a 64-bit time_t. In the case of the io_getevents syscall the
+syscall has been replaced with the io_pgetevents_time64 syscall instead.
+
+This patch changes the io_getevents() function to use the correct
+syscall based on the avaliable syscalls and the time_t size. We will
+only use the new 64-bit time_t syscall if the architecture is using a
+64-bit time_t. This is to avoid having to deal with 32/64-bit
+conversions and relying on a 64-bit timespec struct on 32-bit time_t
+platforms. As of Linux 5.3 there are no 32-bit time_t architectures
+without __NR_io_getevents. In the future if a 32-bit time_t architecture
+wants to use the 64-bit syscalls we can handle the conversion.
+
+This fixes build failures on 32-bit RISC-V.
+
+Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
+Upstream-Status: Submitted [https://github.com/openssl/openssl/pull/9819]
+---
+ engines/e_afalg.c | 16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+diff --git a/engines/e_afalg.c b/engines/e_afalg.c
+index dacbe358cb..99516cb1bb 100644
+--- a/engines/e_afalg.c
++++ b/engines/e_afalg.c
+@@ -125,7 +125,23 @@ static ossl_inline int io_getevents(aio_context_t ctx, long min, long max,
+                                struct io_event *events,
+                                struct timespec *timeout)
+ {
++#if defined(__NR_io_getevents)
+     return syscall(__NR_io_getevents, ctx, min, max, events, timeout);
++#elif defined(__NR_io_pgetevents_time64)
++    /* Let's only support the 64 suffix syscalls for 64-bit time_t.
++     * This simplifies the code for us as we don't need to use a 64-bit
++     * version of timespec with a 32-bit time_t and handle converting
++     * between 64-bit and 32-bit times and check for overflows.
++     */
++    if (sizeof(timeout->tv_sec) == 8)
++        return syscall(__NR_io_pgetevents_time64, ctx, min, max, events, timeout, NULL);
++    else {
++        errno = ENOSYS;
++        return -1;
++    }
++#else
++# error "We require either the io_getevents syscall or __NR_io_pgetevents_time64."
++#endif
+ }
+ 
+ static void afalg_waitfd_cleanup(ASYNC_WAIT_CTX *ctx, const void *key,
+-- 
+2.23.0
+

+ 5 - 0
recipes-connectivity/openssl/openssl_1.1.1%.bbappend

@@ -0,0 +1,5 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
+
+SRC_URI_append_riscv32 = " \
+        file://0001-Add-support-for-io_pgetevents_time64-syscall.patch \
+    "

+ 2 - 0
recipes-core/glibc/glibc_2.32.bbappend

@@ -0,0 +1,2 @@
+SRCBRANCH_qemuriscv32 = "master"
+SRCREV_glibc_qemuriscv32 = "567b1705017a0876b1cf9661a20521ef1e4ddc54"

+ 28 - 0
recipes-core/musl/musl/0001-Remove-ARMSUBARCH-relic-from-configure.patch

@@ -0,0 +1,28 @@
+From 5ed61f2b51eea1bca9b549582f08d55ae40e7425 Mon Sep 17 00:00:00 2001
+From: Stefan O'Rear <sorear@fastmail.com>
+Date: Thu, 3 Sep 2020 03:17:45 -0400
+Subject: [PATCH 01/16] Remove ARMSUBARCH relic from configure
+
+---
+ configure | 5 -----
+ 1 file changed, 5 deletions(-)
+
+diff --git a/configure b/configure
+index 9abbbd66..acbfa8f2 100755
+--- a/configure
++++ b/configure
+@@ -727,11 +727,6 @@ fi
+ test "$SUBARCH" \
+ && printf "configured for %s variant: %s\n" "$ARCH" "$ARCH$SUBARCH"
+ 
+-case "$ARCH$SUBARCH" in
+-arm) ASMSUBARCH=el ;;
+-*) ASMSUBARCH=$SUBARCH ;;
+-esac
+-
+ #
+ # Some archs (powerpc) have different possible long double formats
+ # that the compiler can be configured for. The logic for whether this
+-- 
+2.29.2
+

+ 72 - 0
recipes-core/musl/musl/0002-time64-Don-t-make-aliases-to-nonexistent-syscalls.patch

@@ -0,0 +1,72 @@
+From 9fcf025503dfe3478c77cd07a3e29bd2598b42dd Mon Sep 17 00:00:00 2001
+From: Stefan O'Rear <sorear@fastmail.com>
+Date: Thu, 3 Sep 2020 03:27:03 -0400
+Subject: [PATCH 02/16] time64: Don't make aliases to nonexistent syscalls
+
+riscv32 and future architectures lack the _time32 variants entirely, so
+don't try to use their numbers.
+---
+ src/internal/syscall.h | 20 ++++++++++----------
+ 1 file changed, 10 insertions(+), 10 deletions(-)
+
+diff --git a/src/internal/syscall.h b/src/internal/syscall.h
+index d5f294d4..4f41e1dc 100644
+--- a/src/internal/syscall.h
++++ b/src/internal/syscall.h
+@@ -201,43 +201,43 @@ static inline long __alt_socketcall(int sys, int sock, int cp, long a, long b, l
+ #define SYS_sendfile SYS_sendfile64
+ #endif
+ 
+-#ifndef SYS_timer_settime
++#ifdef SYS_timer_settime32
+ #define SYS_timer_settime SYS_timer_settime32
+ #endif
+ 
+-#ifndef SYS_timer_gettime
++#ifdef SYS_timer_gettime32
+ #define SYS_timer_gettime SYS_timer_gettime32
+ #endif
+ 
+-#ifndef SYS_timerfd_settime
++#ifdef SYS_timerfd_settime32
+ #define SYS_timerfd_settime SYS_timerfd_settime32
+ #endif
+ 
+-#ifndef SYS_timerfd_gettime
++#ifdef SYS_timerfd_gettime32
+ #define SYS_timerfd_gettime SYS_timerfd_gettime32
+ #endif
+ 
+-#ifndef SYS_clock_settime
++#ifdef SYS_clock_settime32
+ #define SYS_clock_settime SYS_clock_settime32
+ #endif
+ 
+-#ifndef SYS_clock_gettime
++#ifdef SYS_clock_gettime32
+ #define SYS_clock_gettime SYS_clock_gettime32
+ #endif
+ 
+-#ifndef SYS_clock_getres
++#ifdef SYS_clock_getres_time32
+ #define SYS_clock_getres SYS_clock_getres_time32
+ #endif
+ 
+-#ifndef SYS_clock_nanosleep
++#ifdef SYS_clock_nanosleep_time32
+ #define SYS_clock_nanosleep SYS_clock_nanosleep_time32
+ #endif
+ 
+-#ifndef SYS_gettimeofday
++#ifdef SYS_gettimeofday_time32
+ #define SYS_gettimeofday SYS_gettimeofday_time32
+ #endif
+ 
+-#ifndef SYS_settimeofday
++#ifdef SYS_settimeofday_time32
+ #define SYS_settimeofday SYS_settimeofday_time32
+ #endif
+ 
+-- 
+2.29.2
+

+ 57 - 0
recipes-core/musl/musl/0003-time64-Only-getrlimit-setrlimit-if-they-exist.patch

@@ -0,0 +1,57 @@
+From 73f38d909e6a8573b33f7c0e0827a5b14e416533 Mon Sep 17 00:00:00 2001
+From: Stefan O'Rear <sorear@fastmail.com>
+Date: Thu, 3 Sep 2020 03:31:05 -0400
+Subject: [PATCH 03/16] time64: Only getrlimit/setrlimit if they exist
+
+riscv32 and future architectures only provide prlimit64.
+---
+ src/misc/getrlimit.c | 6 +++++-
+ src/misc/setrlimit.c | 2 ++
+ 2 files changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/src/misc/getrlimit.c b/src/misc/getrlimit.c
+index 2ab2f0f4..bf676307 100644
+--- a/src/misc/getrlimit.c
++++ b/src/misc/getrlimit.c
+@@ -6,12 +6,13 @@
+ 
+ int getrlimit(int resource, struct rlimit *rlim)
+ {
+-	unsigned long k_rlim[2];
+ 	int ret = syscall(SYS_prlimit64, 0, resource, 0, rlim);
+ 	if (!ret) {
+ 		FIX(rlim->rlim_cur);
+ 		FIX(rlim->rlim_max);
+ 	}
++#ifdef SYS_getrlimit
++	unsigned long k_rlim[2];
+ 	if (!ret || errno != ENOSYS)
+ 		return ret;
+ 	if (syscall(SYS_getrlimit, resource, k_rlim) < 0)
+@@ -21,6 +22,9 @@ int getrlimit(int resource, struct rlimit *rlim)
+ 	FIX(rlim->rlim_cur);
+ 	FIX(rlim->rlim_max);
+ 	return 0;
++#else
++	return ret;
++#endif
+ }
+ 
+ weak_alias(getrlimit, getrlimit64);
+diff --git a/src/misc/setrlimit.c b/src/misc/setrlimit.c
+index 8340aee0..4cf2c607 100644
+--- a/src/misc/setrlimit.c
++++ b/src/misc/setrlimit.c
+@@ -16,7 +16,9 @@ static void do_setrlimit(void *p)
+ {
+ 	struct ctx *c = p;
+ 	if (c->err>0) return;
++#ifdef SYS_setrlimit
+ 	c->err = -__syscall(SYS_setrlimit, c->res, c->lim);
++#endif
+ }
+ 
+ int setrlimit(int resource, const struct rlimit *rlim)
+-- 
+2.29.2
+

+ 46 - 0
recipes-core/musl/musl/0004-time64-Only-gettimeofday-settimeofday-if-exist.patch

@@ -0,0 +1,46 @@
+From 8519be9a302dae238d137775d13142716af04581 Mon Sep 17 00:00:00 2001
+From: Stefan O'Rear <sorear@fastmail.com>
+Date: Thu, 3 Sep 2020 03:33:10 -0400
+Subject: [PATCH 04/16] time64: Only gettimeofday/settimeofday if exist
+
+riscv64 and future architectures only provide the clock_ functions.
+---
+ src/time/clock_gettime.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/time/clock_gettime.c b/src/time/clock_gettime.c
+index 3e1d0975..c7e66a51 100644
+--- a/src/time/clock_gettime.c
++++ b/src/time/clock_gettime.c
+@@ -80,10 +80,12 @@ int __clock_gettime(clockid_t clk, struct timespec *ts)
+ 		return __syscall_ret(r);
+ 	long ts32[2];
+ 	r = __syscall(SYS_clock_gettime, clk, ts32);
++#ifdef SYS_gettimeofday
+ 	if (r==-ENOSYS && clk==CLOCK_REALTIME) {
+ 		r = __syscall(SYS_gettimeofday, ts32, 0);
+ 		ts32[1] *= 1000;
+ 	}
++#endif
+ 	if (!r) {
+ 		ts->tv_sec = ts32[0];
+ 		ts->tv_nsec = ts32[1];
+@@ -92,6 +94,7 @@ int __clock_gettime(clockid_t clk, struct timespec *ts)
+ 	return __syscall_ret(r);
+ #else
+ 	r = __syscall(SYS_clock_gettime, clk, ts);
++#ifdef SYS_gettimeofday
+ 	if (r == -ENOSYS) {
+ 		if (clk == CLOCK_REALTIME) {
+ 			__syscall(SYS_gettimeofday, ts, 0);
+@@ -100,6 +103,7 @@ int __clock_gettime(clockid_t clk, struct timespec *ts)
+ 		}
+ 		r = -EINVAL;
+ 	}
++#endif
+ 	return __syscall_ret(r);
+ #endif
+ }
+-- 
+2.29.2
+

+ 94 - 0
recipes-core/musl/musl/0005-Add-src-internal-statx.h.patch

@@ -0,0 +1,94 @@
+From eca94dccba29fb2862884472ae8d30672480f8f4 Mon Sep 17 00:00:00 2001
+From: Stefan O'Rear <sorear@fastmail.com>
+Date: Thu, 3 Sep 2020 03:45:08 -0400
+Subject: [PATCH 05/16] Add src/internal/statx.h
+
+We need to make internal syscalls to SYS_statx when SYS_fstatat is not
+available without changing the musl API.
+---
+ src/internal/statx.h | 28 ++++++++++++++++++++++++++++
+ src/stat/fstatat.c   | 28 ++--------------------------
+ 2 files changed, 30 insertions(+), 26 deletions(-)
+ create mode 100644 src/internal/statx.h
+
+diff --git a/src/internal/statx.h b/src/internal/statx.h
+new file mode 100644
+index 00000000..46b16f62
+--- /dev/null
++++ b/src/internal/statx.h
+@@ -0,0 +1,28 @@
++struct statx {
++	uint32_t stx_mask;
++	uint32_t stx_blksize;
++	uint64_t stx_attributes;
++	uint32_t stx_nlink;
++	uint32_t stx_uid;
++	uint32_t stx_gid;
++	uint16_t stx_mode;
++	uint16_t pad1;
++	uint64_t stx_ino;
++	uint64_t stx_size;
++	uint64_t stx_blocks;
++	uint64_t stx_attributes_mask;
++	struct {
++		int64_t tv_sec;
++		uint32_t tv_nsec;
++		int32_t pad;
++	} stx_atime, stx_btime, stx_ctime, stx_mtime;
++	uint32_t stx_rdev_major;
++	uint32_t stx_rdev_minor;
++	uint32_t stx_dev_major;
++	uint32_t stx_dev_minor;
++	uint64_t spare[14];
++};
++
++#define STATX_TYPE         0x001U
++#define STATX_SIZE         0x200U
++#define STATX_BASIC_STATS  0x7ffU
+diff --git a/src/stat/fstatat.c b/src/stat/fstatat.c
+index de165b5c..230a83fc 100644
+--- a/src/stat/fstatat.c
++++ b/src/stat/fstatat.c
+@@ -7,37 +7,13 @@
+ #include <sys/sysmacros.h>
+ #include "syscall.h"
+ #include "kstat.h"
+-
+-struct statx {
+-	uint32_t stx_mask;
+-	uint32_t stx_blksize;
+-	uint64_t stx_attributes;
+-	uint32_t stx_nlink;
+-	uint32_t stx_uid;
+-	uint32_t stx_gid;
+-	uint16_t stx_mode;
+-	uint16_t pad1;
+-	uint64_t stx_ino;
+-	uint64_t stx_size;
+-	uint64_t stx_blocks;
+-	uint64_t stx_attributes_mask;
+-	struct {
+-		int64_t tv_sec;
+-		uint32_t tv_nsec;
+-		int32_t pad;
+-	} stx_atime, stx_btime, stx_ctime, stx_mtime;
+-	uint32_t stx_rdev_major;
+-	uint32_t stx_rdev_minor;
+-	uint32_t stx_dev_major;
+-	uint32_t stx_dev_minor;
+-	uint64_t spare[14];
+-};
++#include "statx.h"
+ 
+ static int fstatat_statx(int fd, const char *restrict path, struct stat *restrict st, int flag)
+ {
+ 	struct statx stx;
+ 
+-	int ret = __syscall(SYS_statx, fd, path, flag, 0x7ff, &stx);
++	int ret = __syscall(SYS_statx, fd, path, flag, STATX_BASIC_STATS, &stx);
+ 	if (ret) return ret;
+ 
+ 	*st = (struct stat){
+-- 
+2.29.2
+

+ 209 - 0
recipes-core/musl/musl/0006-Only-call-fstatat-if-defined.patch

@@ -0,0 +1,209 @@
+From e7711de591aed7e3a182880c3c8f5b527c0c67e8 Mon Sep 17 00:00:00 2001
+From: Stefan O'Rear <sorear@fastmail.com>
+Date: Thu, 3 Sep 2020 03:59:59 -0400
+Subject: [PATCH 06/16] Only call fstatat if defined
+
+riscv32 and future architectures lack it.
+---
+ src/stat/fchmodat.c   | 23 ++++++++++++++++++++---
+ src/stat/fstatat.c    |  6 ++++++
+ src/stdio/tempnam.c   |  9 +++++++--
+ src/stdio/tmpnam.c    |  9 +++++++--
+ src/time/__map_file.c | 19 +++++++++++++++----
+ 5 files changed, 55 insertions(+), 11 deletions(-)
+
+diff --git a/src/stat/fchmodat.c b/src/stat/fchmodat.c
+index 4ee00b0a..857e84e5 100644
+--- a/src/stat/fchmodat.c
++++ b/src/stat/fchmodat.c
+@@ -1,8 +1,10 @@
+ #include <sys/stat.h>
+ #include <fcntl.h>
+ #include <errno.h>
++#include <stdint.h>
+ #include "syscall.h"
+ #include "kstat.h"
++#include "statx.h"
+ 
+ int fchmodat(int fd, const char *path, mode_t mode, int flag)
+ {
+@@ -11,13 +13,22 @@ int fchmodat(int fd, const char *path, mode_t mode, int flag)
+ 	if (flag != AT_SYMLINK_NOFOLLOW)
+ 		return __syscall_ret(-EINVAL);
+ 
+-	struct kstat st;
+ 	int ret, fd2;
+ 	char proc[15+3*sizeof(int)];
+ 
++#ifdef SYS_fstatat
++	struct kstat st;
+ 	if ((ret = __syscall(SYS_fstatat, fd, path, &st, flag)))
+ 		return __syscall_ret(ret);
+-	if (S_ISLNK(st.st_mode))
++	mode_t get_mode = st.st_mode;
++#else
++	struct statx st;
++	if ((ret = __syscall(SYS_statx, fd, path, flag, STATX_TYPE, &st)))
++		return __syscall_ret(ret);
++	mode_t get_mode = st.stx_mode;
++#endif
++
++	if (S_ISLNK(get_mode))
+ 		return __syscall_ret(-EOPNOTSUPP);
+ 
+ 	if ((fd2 = __syscall(SYS_openat, fd, path, O_RDONLY|O_PATH|O_NOFOLLOW|O_NOCTTY|O_CLOEXEC)) < 0) {
+@@ -27,9 +38,15 @@ int fchmodat(int fd, const char *path, mode_t mode, int flag)
+ 	}
+ 
+ 	__procfdname(proc, fd2);
++#ifdef SYS_fstatat
+ 	ret = __syscall(SYS_fstatat, AT_FDCWD, proc, &st, 0);
++	get_mode = st.st_mode;
++#else
++	ret = __syscall(SYS_statx, AT_FDCWD, proc, 0, STATX_TYPE, &st);
++	get_mode = st.stx_mode;
++#endif
+ 	if (!ret) {
+-		if (S_ISLNK(st.st_mode)) ret = -EOPNOTSUPP;
++		if (S_ISLNK(get_mode)) ret = -EOPNOTSUPP;
+ 		else ret = __syscall(SYS_fchmodat, AT_FDCWD, proc, mode);
+ 	}
+ 
+diff --git a/src/stat/fstatat.c b/src/stat/fstatat.c
+index 230a83fc..0486f21a 100644
+--- a/src/stat/fstatat.c
++++ b/src/stat/fstatat.c
+@@ -45,6 +45,7 @@ static int fstatat_statx(int fd, const char *restrict path, struct stat *restric
+ 	return 0;
+ }
+ 
++#ifdef SYS_fstatat
+ static int fstatat_kstat(int fd, const char *restrict path, struct stat *restrict st, int flag)
+ {
+ 	int ret;
+@@ -106,15 +107,20 @@ static int fstatat_kstat(int fd, const char *restrict path, struct stat *restric
+ 
+ 	return 0;
+ }
++#endif
+ 
+ int fstatat(int fd, const char *restrict path, struct stat *restrict st, int flag)
+ {
+ 	int ret;
++#ifdef SYS_fstatat
+ 	if (sizeof((struct kstat){0}.st_atime_sec) < sizeof(time_t)) {
+ 		ret = fstatat_statx(fd, path, st, flag);
+ 		if (ret!=-ENOSYS) return __syscall_ret(ret);
+ 	}
+ 	ret = fstatat_kstat(fd, path, st, flag);
++#else
++	ret = fstatat_statx(fd, path, st, flag);
++#endif
+ 	return __syscall_ret(ret);
+ }
+ 
+diff --git a/src/stdio/tempnam.c b/src/stdio/tempnam.c
+index 565df6b6..9469923b 100644
+--- a/src/stdio/tempnam.c
++++ b/src/stdio/tempnam.c
+@@ -5,8 +5,10 @@
+ #include <limits.h>
+ #include <string.h>
+ #include <stdlib.h>
++#include <stdint.h>
+ #include "syscall.h"
+ #include "kstat.h"
++#include "statx.h"
+ 
+ #define MAXTRIES 100
+ 
+@@ -37,11 +39,14 @@ char *tempnam(const char *dir, const char *pfx)
+ 
+ 	for (try=0; try<MAXTRIES; try++) {
+ 		__randname(s+l-6);
+-#ifdef SYS_lstat
++#if defined(SYS_lstat)
+ 		r = __syscall(SYS_lstat, s, &(struct kstat){0});
+-#else
++#elif defined(SYS_fstatat)
+ 		r = __syscall(SYS_fstatat, AT_FDCWD, s,
+ 			&(struct kstat){0}, AT_SYMLINK_NOFOLLOW);
++#else
++		r = __syscall(SYS_statx, AT_FDCWD, s, AT_SYMLINK_NOFOLLOW, 0,
++			&(struct statx){0});
+ #endif
+ 		if (r == -ENOENT) return strdup(s);
+ 	}
+diff --git a/src/stdio/tmpnam.c b/src/stdio/tmpnam.c
+index d667a836..9576241b 100644
+--- a/src/stdio/tmpnam.c
++++ b/src/stdio/tmpnam.c
+@@ -4,8 +4,10 @@
+ #include <sys/stat.h>
+ #include <string.h>
+ #include <stdlib.h>
++#include <stdint.h>
+ #include "syscall.h"
+ #include "kstat.h"
++#include "statx.h"
+ 
+ #define MAXTRIES 100
+ 
+@@ -17,11 +19,14 @@ char *tmpnam(char *buf)
+ 	int r;
+ 	for (try=0; try<MAXTRIES; try++) {
+ 		__randname(s+12);
+-#ifdef SYS_lstat
++#if defined(SYS_lstat)
+ 		r = __syscall(SYS_lstat, s, &(struct kstat){0});
+-#else
++#elif defined(SYS_fstatat)
+ 		r = __syscall(SYS_fstatat, AT_FDCWD, s,
+ 			&(struct kstat){0}, AT_SYMLINK_NOFOLLOW);
++#else
++		r = __syscall(SYS_statx, AT_FDCWD, s, AT_SYMLINK_NOFOLLOW, 0,
++			&(struct statx){0});
+ #endif
+ 		if (r == -ENOENT) return strcpy(buf ? buf : internal, s);
+ 	}
+diff --git a/src/time/__map_file.c b/src/time/__map_file.c
+index d3cefa82..542c8ce4 100644
+--- a/src/time/__map_file.c
++++ b/src/time/__map_file.c
+@@ -1,18 +1,29 @@
++#define _BSD_SOURCE
+ #include <sys/mman.h>
+ #include <fcntl.h>
+ #include <sys/stat.h>
++#include <stdint.h>
+ #include "syscall.h"
+ #include "kstat.h"
++#include "statx.h"
+ 
+ const char unsigned *__map_file(const char *pathname, size_t *size)
+ {
+-	struct kstat st;
+ 	const unsigned char *map = MAP_FAILED;
+ 	int fd = sys_open(pathname, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
+ 	if (fd < 0) return 0;
+-	if (!syscall(SYS_fstat, fd, &st)) {
+-		map = __mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
+-		*size = st.st_size;
++#ifdef SYS_fstat
++	struct kstat st;
++	int r = syscall(SYS_fstat, fd, &st);
++	size_t fsize = st.st_size;
++#else
++	struct statx st;
++	int r = syscall(SYS_statx, fd, "", AT_EMPTY_PATH, STATX_SIZE, &st);
++	size_t fsize = st.stx_size;
++#endif
++	if (!r) {
++		map = __mmap(0, fsize, PROT_READ, MAP_SHARED, fd, 0);
++		*size = fsize;
+ 	}
+ 	__syscall(SYS_close, fd);
+ 	return map == MAP_FAILED ? 0 : map;
+-- 
+2.29.2
+

+ 183 - 0
recipes-core/musl/musl/0007-Emulate-wait4-using-waitid.patch

@@ -0,0 +1,183 @@
+From 1a8f65f2b8d33dc09f6ccb6a7bd6ca85760cf720 Mon Sep 17 00:00:00 2001
+From: Stefan O'Rear <sorear@fastmail.com>
+Date: Thu, 3 Sep 2020 05:20:45 -0400
+Subject: [PATCH 07/16] Emulate wait4 using waitid
+
+riscv32 and future architectures lack wait4.
+
+waitpid is required by POSIX to be a cancellation point.  pclose is
+specified as undefined if a cancellation occurs, so it would be
+permitted for it to call a cancellable wait function; however, as a
+quality of implementation matter, pclose must close the pipe fd before
+it can wait (consider popen("yes","r")) and if the wait could be
+interrupted the pipe FILE would be left in an intermediate state that
+portable software cannot recover from, so the only useful behavior is
+for pclose to NOT be a cancellation point.  We therefore support both at
+a small cost in code size.
+
+wait4 is historically not a cancellation point in musl; we retain that
+since we need the non-cancellable version of __wait4 anyway.
+---
+ src/internal/__wait4.c | 55 ++++++++++++++++++++++++++++++++++++++++++
+ src/internal/syscall.h | 12 +++++++++
+ src/linux/wait4.c      |  2 +-
+ src/process/waitpid.c  |  2 +-
+ src/stdio/pclose.c     |  2 +-
+ src/unistd/faccessat.c |  6 ++++-
+ 6 files changed, 75 insertions(+), 4 deletions(-)
+ create mode 100644 src/internal/__wait4.c
+
+diff --git a/src/internal/__wait4.c b/src/internal/__wait4.c
+new file mode 100644
+index 00000000..04d7dc64
+--- /dev/null
++++ b/src/internal/__wait4.c
+@@ -0,0 +1,55 @@
++#include <sys/wait.h>
++#include "syscall.h"
++
++#ifndef SYS_wait4
++hidden pid_t __wait4(pid_t pid, int *status, int options, void *kru, int cp)
++{
++	idtype_t t;
++	int r;
++	siginfo_t info;
++
++	info.si_pid = 0;
++	if (pid < -1) {
++		t = P_PGID;
++		pid = -pid;
++	} else if (pid == -1) {
++		t = P_ALL;
++	} else if (pid == 0) {
++		t = P_PGID;
++	} else {
++		t = P_PID;
++	}
++
++	if (cp) r = __syscall_cp(SYS_waitid, t, pid, &info, options|WEXITED, kru);
++	else r = __syscall(SYS_waitid, t, pid, &info, options|WEXITED, kru);
++
++	if (r<0) return r;
++
++	if (info.si_pid && status) {
++		int sw=0;
++		switch (info.si_code) {
++		case CLD_CONTINUED:
++			sw = 0xffff;
++			break;
++		case CLD_DUMPED:
++			sw = info.si_status&0x7f | 0x80;
++			break;
++		case CLD_EXITED:
++			sw = (info.si_status&0xff) << 8;
++			break;
++		case CLD_KILLED:
++			sw = info.si_status&0x7f;
++			break;
++		case CLD_STOPPED:
++		case CLD_TRAPPED:
++			/* see ptrace(2); the high bits of si_status can contain */
++			/* PTRACE_EVENT_ values which must be preserved */
++			sw = (info.si_status << 8) + 0x7f;
++			break;
++		}
++		*status = sw;
++	}
++
++	return info.si_pid;
++}
++#endif
+diff --git a/src/internal/syscall.h b/src/internal/syscall.h
+index 4f41e1dc..27642938 100644
+--- a/src/internal/syscall.h
++++ b/src/internal/syscall.h
+@@ -5,6 +5,8 @@
+ #include <errno.h>
+ #include <sys/syscall.h>
+ #include "syscall_arch.h"
++#define __NEED_pid_t
++#include <bits/alltypes.h>
+ 
+ #ifndef SYSCALL_RLIM_INFINITY
+ #define SYSCALL_RLIM_INFINITY (~0ULL)
+@@ -395,4 +397,14 @@ hidden void __procfdname(char __buf[static 15+3*sizeof(int)], unsigned);
+ 
+ hidden void *__vdsosym(const char *, const char *);
+ 
++#ifdef SYS_wait4
++static inline pid_t __wait4(pid_t pid, int *status, int options, void *kru, int cp)
++{
++	if (cp) return __syscall_cp(SYS_wait4, pid, status, options, kru);
++	else return __syscall(SYS_wait4, pid, status, options, kru);
++}
++#else
++hidden pid_t __wait4(pid_t pid, int *status, int options, void *kru, int cp);
++#endif
++
+ #endif
+diff --git a/src/linux/wait4.c b/src/linux/wait4.c
+index 83650e34..32652dc2 100644
+--- a/src/linux/wait4.c
++++ b/src/linux/wait4.c
+@@ -26,7 +26,7 @@ pid_t wait4(pid_t pid, int *status, int options, struct rusage *ru)
+ 	}
+ #endif
+ 	char *dest = ru ? (char *)&ru->ru_maxrss - 4*sizeof(long) : 0;
+-	r = __syscall(SYS_wait4, pid, status, options, dest);
++	r = __wait4(pid, status, options, dest, 0);
+ 	if (r>0 && ru && sizeof(time_t) > sizeof(long)) {
+ 		long kru[4];
+ 		memcpy(kru, dest, 4*sizeof(long));
+diff --git a/src/process/waitpid.c b/src/process/waitpid.c
+index 1b65bf05..e5ff27ca 100644
+--- a/src/process/waitpid.c
++++ b/src/process/waitpid.c
+@@ -3,5 +3,5 @@
+ 
+ pid_t waitpid(pid_t pid, int *status, int options)
+ {
+-	return syscall_cp(SYS_wait4, pid, status, options, 0);
++	return __wait4(pid, status, options, 0, 1);
+ }
+diff --git a/src/stdio/pclose.c b/src/stdio/pclose.c
+index 080a4262..b60d8f2c 100644
+--- a/src/stdio/pclose.c
++++ b/src/stdio/pclose.c
+@@ -7,7 +7,7 @@ int pclose(FILE *f)
+ 	int status, r;
+ 	pid_t pid = f->pipe_pid;
+ 	fclose(f);
+-	while ((r=__syscall(SYS_wait4, pid, &status, 0, 0)) == -EINTR);
++	while ((r=__wait4(pid, &status, 0, 0, 0)) == -EINTR);
+ 	if (r<0) return __syscall_ret(r);
+ 	return status;
+ }
+diff --git a/src/unistd/faccessat.c b/src/unistd/faccessat.c
+index 557503eb..8e8689c1 100644
+--- a/src/unistd/faccessat.c
++++ b/src/unistd/faccessat.c
+@@ -39,7 +39,6 @@ int faccessat(int fd, const char *filename, int amode, int flag)
+ 	char stack[1024];
+ 	sigset_t set;
+ 	pid_t pid;
+-	int status;
+ 	int ret, p[2];
+ 
+ 	if (pipe2(p, O_CLOEXEC)) return __syscall_ret(-EBUSY);
+@@ -53,7 +52,12 @@ int faccessat(int fd, const char *filename, int amode, int flag)
+ 	if (pid<0 || __syscall(SYS_read, p[0], &ret, sizeof ret) != sizeof(ret))
+ 		ret = -EBUSY;
+ 	__syscall(SYS_close, p[0]);
++#ifdef SYS_wait4
++	int status;
+ 	__syscall(SYS_wait4, pid, &status, __WCLONE, 0);
++#else
++	__syscall(SYS_waitid, P_PID, pid, &(siginfo_t){0}, __WCLONE|WEXITED, 0);
++#endif
+ 
+ 	__restore_sigs(&set);
+ 
+-- 
+2.29.2
+

+ 26 - 0
recipes-core/musl/musl/0008-riscv-Fall-back-to-syscall-__riscv_flush_icache.patch

@@ -0,0 +1,26 @@
+From d7bc65df3f6f3026da2094143342e58cd6bdd321 Mon Sep 17 00:00:00 2001
+From: Stefan O'Rear <sorear@fastmail.com>
+Date: Thu, 3 Sep 2020 05:23:40 -0400
+Subject: [PATCH 08/16] riscv: Fall back to syscall __riscv_flush_icache
+
+Matches glibc behavior and fixes a case where we could fall off the
+function without returning a value.
+---
+ src/linux/cache.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/linux/cache.c b/src/linux/cache.c
+index 0eb051c2..9cacac2b 100644
+--- a/src/linux/cache.c
++++ b/src/linux/cache.c
+@@ -45,6 +45,7 @@ int __riscv_flush_icache(void *start, void *end, unsigned long int flags)
+ 		if (!r) return r;
+ 		if (r != -ENOSYS) return __syscall_ret(r);
+ 	}
++	return syscall(SYS_riscv_flush_icache, start, end, flags);
+ }
+ weak_alias(__riscv_flush_icache, riscv_flush_icache);
+ #endif
+-- 
+2.29.2
+

+ 33 - 0
recipes-core/musl/musl/0009-riscv32-Target-and-subtarget-detection.patch

@@ -0,0 +1,33 @@
+From 798f6231faa7f684962b6ff72d22aa9e268840ed Mon Sep 17 00:00:00 2001
+From: Stefan O'Rear <sorear@fastmail.com>
+Date: Thu, 3 Sep 2020 05:26:50 -0400
+Subject: [PATCH 09/16] riscv32: Target and subtarget detection
+
+---
+ configure | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/configure b/configure
+index acbfa8f2..2e217c7e 100755
+--- a/configure
++++ b/configure
+@@ -336,6 +336,7 @@ or1k*) ARCH=or1k ;;
+ powerpc64*|ppc64*) ARCH=powerpc64 ;;
+ powerpc*|ppc*) ARCH=powerpc ;;
+ riscv64*) ARCH=riscv64 ;;
++riscv32*) ARCH=riscv32 ;;
+ sh[1-9bel-]*|sh|superh*) ARCH=sh ;;
+ s390x*) ARCH=s390x ;;
+ unknown) fail "$0: unable to detect target arch; try $0 --target=..." ;;
+@@ -696,7 +697,7 @@ trycppif __LITTLE_ENDIAN__ "$t" && SUBARCH=${SUBARCH}le
+ trycppif _SOFT_FLOAT "$t" && fail "$0: error: soft-float not supported on powerpc64"
+ fi
+ 
+-if test "$ARCH" = "riscv64" ; then
++if test "$ARCH" = "riscv64" -o "$ARCH" = "riscv32" ; then
+ trycppif __riscv_float_abi_soft "$t" && SUBARCH=${SUBARCH}-sf
+ trycppif __riscv_float_abi_single "$t" && SUBARCH=${SUBARCH}-sp
+ fi
+-- 
+2.29.2
+

+ 849 - 0
recipes-core/musl/musl/0010-riscv32-add-arch-headers.patch

@@ -0,0 +1,849 @@
+From bf15d3589b0bc2bcbe9bf1c49bc993ca77e20951 Mon Sep 17 00:00:00 2001
+From: Stefan O'Rear <sorear@fastmail.com>
+Date: Thu, 3 Sep 2020 05:40:29 -0400
+Subject: [PATCH 10/16] riscv32: add arch headers
+
+These are mostly copied from riscv64.  _Addr and _Reg had to become int
+to avoid errors in libstdc++ when size_t and std::size_t mismatch.
+There is no kernel stat struct; the userspace stat matches glibc in the
+sizes and offsets of all fields (including glibc's __dev_t __pad1).  The
+jump buffer is 12 words larger to account for 12 saved double-precision
+floats; additionally it should be 64-bit aligned to save doubles.
+
+The syscall list was significantly revised by deleting all time32 and
+pre-statx syscalls, and renaming several syscalls that have different
+names depending on __BITS_PER_LONG, notably mmap2 and _llseek.
+
+futex was added as an alias to futex_time64 since it is widely used by
+software which does not pass time arguments.
+---
+ arch/riscv32/atomic_arch.h      |  21 +++
+ arch/riscv32/bits/alltypes.h.in |  18 ++
+ arch/riscv32/bits/fcntl.h       |  38 +++++
+ arch/riscv32/bits/fenv.h        |  17 ++
+ arch/riscv32/bits/float.h       |  16 ++
+ arch/riscv32/bits/posix.h       |   2 +
+ arch/riscv32/bits/setjmp.h      |   1 +
+ arch/riscv32/bits/signal.h      | 118 +++++++++++++
+ arch/riscv32/bits/stat.h        |  18 ++
+ arch/riscv32/bits/stdint.h      |  20 +++
+ arch/riscv32/bits/syscall.h.in  | 286 ++++++++++++++++++++++++++++++++
+ arch/riscv32/bits/user.h        |   5 +
+ arch/riscv32/crt_arch.h         |  19 +++
+ arch/riscv32/kstat.h            |   0
+ arch/riscv32/pthread_arch.h     |  13 ++
+ arch/riscv32/reloc.h            |  22 +++
+ arch/riscv32/syscall_arch.h     |  78 +++++++++
+ 17 files changed, 692 insertions(+)
+ create mode 100644 arch/riscv32/atomic_arch.h
+ create mode 100644 arch/riscv32/bits/alltypes.h.in
+ create mode 100644 arch/riscv32/bits/fcntl.h
+ create mode 100644 arch/riscv32/bits/fenv.h
+ create mode 100644 arch/riscv32/bits/float.h
+ create mode 100644 arch/riscv32/bits/posix.h
+ create mode 100644 arch/riscv32/bits/setjmp.h
+ create mode 100644 arch/riscv32/bits/signal.h
+ create mode 100644 arch/riscv32/bits/stat.h
+ create mode 100644 arch/riscv32/bits/stdint.h
+ create mode 100644 arch/riscv32/bits/syscall.h.in
+ create mode 100644 arch/riscv32/bits/user.h
+ create mode 100644 arch/riscv32/crt_arch.h
+ create mode 100644 arch/riscv32/kstat.h
+ create mode 100644 arch/riscv32/pthread_arch.h
+ create mode 100644 arch/riscv32/reloc.h
+ create mode 100644 arch/riscv32/syscall_arch.h
+
+diff --git a/arch/riscv32/atomic_arch.h b/arch/riscv32/atomic_arch.h
+new file mode 100644
+index 00000000..4d418f63
+--- /dev/null
++++ b/arch/riscv32/atomic_arch.h
+@@ -0,0 +1,21 @@
++#define a_barrier a_barrier
++static inline void a_barrier()
++{
++	__asm__ __volatile__ ("fence rw,rw" : : : "memory");
++}
++
++#define a_cas a_cas
++static inline int a_cas(volatile int *p, int t, int s)
++{
++	int old, tmp;
++	__asm__ __volatile__ (
++		"\n1:	lr.w.aqrl %0, (%2)\n"
++		"	bne %0, %3, 1f\n"
++		"	sc.w.aqrl %1, %4, (%2)\n"
++		"	bnez %1, 1b\n"
++		"1:"
++		: "=&r"(old), "=&r"(tmp)
++		: "r"(p), "r"((long)t), "r"((long)s)
++		: "memory");
++	return old;
++}
+diff --git a/arch/riscv32/bits/alltypes.h.in b/arch/riscv32/bits/alltypes.h.in
+new file mode 100644
+index 00000000..e2b6129e
+--- /dev/null
++++ b/arch/riscv32/bits/alltypes.h.in
+@@ -0,0 +1,18 @@
++#define _Addr int
++#define _Int64 long long
++#define _Reg int
++
++#define __BYTE_ORDER 1234
++#define __LONG_MAX 0x7fffffffL
++
++#ifndef __cplusplus
++TYPEDEF int wchar_t;
++#endif
++
++TYPEDEF int blksize_t;
++TYPEDEF unsigned int nlink_t;
++
++TYPEDEF float float_t;
++TYPEDEF double double_t;
++
++TYPEDEF struct { long long __ll; long double __ld; } max_align_t;
+diff --git a/arch/riscv32/bits/fcntl.h b/arch/riscv32/bits/fcntl.h
+new file mode 100644
+index 00000000..ecb4d18f
+--- /dev/null
++++ b/arch/riscv32/bits/fcntl.h
+@@ -0,0 +1,38 @@
++#define O_CREAT        0100
++#define O_EXCL         0200
++#define O_NOCTTY       0400
++#define O_TRUNC       01000
++#define O_APPEND      02000
++#define O_NONBLOCK    04000
++#define O_DSYNC      010000
++#define O_SYNC     04010000
++#define O_RSYNC    04010000
++#define O_DIRECTORY 0200000
++#define O_NOFOLLOW  0400000
++#define O_CLOEXEC  02000000
++
++#define O_ASYNC      020000
++#define O_DIRECT     040000
++#define O_LARGEFILE 0100000
++#define O_NOATIME  01000000
++#define O_PATH    010000000
++#define O_TMPFILE 020200000
++#define O_NDELAY O_NONBLOCK
++
++#define F_DUPFD  0
++#define F_GETFD  1
++#define F_SETFD  2
++#define F_GETFL  3
++#define F_SETFL  4
++#define F_GETLK  5
++#define F_SETLK  6
++#define F_SETLKW 7
++#define F_SETOWN 8
++#define F_GETOWN 9
++#define F_SETSIG 10
++#define F_GETSIG 11
++
++#define F_SETOWN_EX 15
++#define F_GETOWN_EX 16
++
++#define F_GETOWNER_UIDS 17
+diff --git a/arch/riscv32/bits/fenv.h b/arch/riscv32/bits/fenv.h
+new file mode 100644
+index 00000000..806ec40f
+--- /dev/null
++++ b/arch/riscv32/bits/fenv.h
+@@ -0,0 +1,17 @@
++#define FE_INVALID      16
++#define FE_DIVBYZERO    8
++#define FE_OVERFLOW     4
++#define FE_UNDERFLOW    2
++#define FE_INEXACT      1
++
++#define FE_ALL_EXCEPT   31
++
++#define FE_TONEAREST    0
++#define FE_DOWNWARD     2
++#define FE_UPWARD       3
++#define FE_TOWARDZERO   1
++
++typedef unsigned int fexcept_t;
++typedef unsigned int fenv_t;
++
++#define FE_DFL_ENV      ((const fenv_t *) -1)
+diff --git a/arch/riscv32/bits/float.h b/arch/riscv32/bits/float.h
+new file mode 100644
+index 00000000..719c7908
+--- /dev/null
++++ b/arch/riscv32/bits/float.h
+@@ -0,0 +1,16 @@
++#define FLT_EVAL_METHOD 0
++
++#define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L
++#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
++#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
++#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L
++
++#define LDBL_MANT_DIG 113
++#define LDBL_MIN_EXP (-16381)
++#define LDBL_MAX_EXP 16384
++
++#define LDBL_DIG 33
++#define LDBL_MIN_10_EXP (-4931)
++#define LDBL_MAX_10_EXP 4932
++
++#define DECIMAL_DIG 36
+diff --git a/arch/riscv32/bits/posix.h b/arch/riscv32/bits/posix.h
+new file mode 100644
+index 00000000..8897d37d
+--- /dev/null
++++ b/arch/riscv32/bits/posix.h
+@@ -0,0 +1,2 @@
++#define _POSIX_V6_ILP32_OFFBIG 1
++#define _POSIX_V7_ILP32_OFFBIG 1
+diff --git a/arch/riscv32/bits/setjmp.h b/arch/riscv32/bits/setjmp.h
+new file mode 100644
+index 00000000..51e96276
+--- /dev/null
++++ b/arch/riscv32/bits/setjmp.h
+@@ -0,0 +1 @@
++typedef unsigned long long __jmp_buf[19];
+diff --git a/arch/riscv32/bits/signal.h b/arch/riscv32/bits/signal.h
+new file mode 100644
+index 00000000..b006334f
+--- /dev/null
++++ b/arch/riscv32/bits/signal.h
+@@ -0,0 +1,118 @@
++#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
++ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
++
++#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
++# define MINSIGSTKSZ 2048
++# define SIGSTKSZ 8192
++#endif
++
++typedef unsigned long __riscv_mc_gp_state[32];
++
++struct __riscv_mc_f_ext_state {
++	unsigned int __f[32];
++	unsigned int __fcsr;
++};
++
++struct __riscv_mc_d_ext_state {
++	unsigned long long __f[32];
++	unsigned int __fcsr;
++};
++
++struct __riscv_mc_q_ext_state {
++	unsigned long long __f[64] __attribute__((aligned(16)));
++	unsigned int __fcsr;
++	unsigned int __reserved[3];
++};
++
++union __riscv_mc_fp_state {
++	struct __riscv_mc_f_ext_state __f;
++	struct __riscv_mc_d_ext_state __d;
++	struct __riscv_mc_q_ext_state __q;
++};
++
++typedef struct mcontext_t {
++	__riscv_mc_gp_state __gregs;
++	union __riscv_mc_fp_state __fpregs;
++} mcontext_t;
++
++#if defined(_GNU_SOURCE)
++#define REG_PC 0
++#define REG_RA 1
++#define REG_SP 2
++#define REG_TP 4
++#define REG_S0 8
++#define REG_A0 10
++#endif
++
++#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
++typedef unsigned long greg_t;
++typedef unsigned long gregset_t[32];
++typedef union __riscv_mc_fp_state fpregset_t;
++struct sigcontext {
++	gregset_t gregs;
++	fpregset_t fpregs;
++};
++#endif
++
++struct sigaltstack {
++	void *ss_sp;
++	int ss_flags;
++	size_t ss_size;
++};
++
++typedef struct ucontext_t
++{
++	unsigned long uc_flags;
++	struct ucontext_t *uc_link;
++	stack_t uc_stack;
++	sigset_t uc_sigmask;
++	mcontext_t uc_mcontext;
++} ucontext_t;
++
++#define SA_NOCLDSTOP 1
++#define SA_NOCLDWAIT 2
++#define SA_SIGINFO   4
++#define SA_ONSTACK   0x08000000
++#define SA_RESTART   0x10000000
++#define SA_NODEFER   0x40000000
++#define SA_RESETHAND 0x80000000
++#define SA_RESTORER  0x04000000
++
++#endif
++
++#define SIGHUP     1
++#define SIGINT     2
++#define SIGQUIT    3
++#define SIGILL     4
++#define SIGTRAP    5
++#define SIGABRT    6
++#define SIGIOT     SIGABRT
++#define SIGBUS     7
++#define SIGFPE     8
++#define SIGKILL    9
++#define SIGUSR1   10
++#define SIGSEGV   11
++#define SIGUSR2   12
++#define SIGPIPE   13
++#define SIGALRM   14
++#define SIGTERM   15
++#define SIGSTKFLT 16
++#define SIGCHLD   17
++#define SIGCONT   18
++#define SIGSTOP   19
++#define SIGTSTP   20
++#define SIGTTIN   21
++#define SIGTTOU   22
++#define SIGURG    23
++#define SIGXCPU   24
++#define SIGXFSZ   25
++#define SIGVTALRM 26
++#define SIGPROF   27
++#define SIGWINCH  28
++#define SIGIO     29
++#define SIGPOLL   SIGIO
++#define SIGPWR    30
++#define SIGSYS    31
++#define SIGUNUSED SIGSYS
++
++#define _NSIG     65
+diff --git a/arch/riscv32/bits/stat.h b/arch/riscv32/bits/stat.h
+new file mode 100644
+index 00000000..f6d9e864
+--- /dev/null
++++ b/arch/riscv32/bits/stat.h
+@@ -0,0 +1,18 @@
++struct stat {
++	dev_t st_dev;
++	ino_t st_ino;
++	mode_t st_mode;
++	nlink_t st_nlink;
++	uid_t st_uid;
++	gid_t st_gid;
++	dev_t st_rdev;
++	unsigned long long __pad;
++	off_t st_size;
++	blksize_t st_blksize;
++	int __pad2;
++	blkcnt_t st_blocks;
++	struct timespec st_atim;
++	struct timespec st_mtim;
++	struct timespec st_ctim;
++	unsigned __unused[2];
++};
+diff --git a/arch/riscv32/bits/stdint.h b/arch/riscv32/bits/stdint.h
+new file mode 100644
+index 00000000..d1b27121
+--- /dev/null
++++ b/arch/riscv32/bits/stdint.h
+@@ -0,0 +1,20 @@
++typedef int32_t int_fast16_t;
++typedef int32_t int_fast32_t;
++typedef uint32_t uint_fast16_t;
++typedef uint32_t uint_fast32_t;
++
++#define INT_FAST16_MIN  INT32_MIN
++#define INT_FAST32_MIN  INT32_MIN
++
++#define INT_FAST16_MAX  INT32_MAX
++#define INT_FAST32_MAX  INT32_MAX
++
++#define UINT_FAST16_MAX UINT32_MAX
++#define UINT_FAST32_MAX UINT32_MAX
++
++#define INTPTR_MIN      INT32_MIN
++#define INTPTR_MAX      INT32_MAX
++#define UINTPTR_MAX     UINT32_MAX
++#define PTRDIFF_MIN     INT32_MIN
++#define PTRDIFF_MAX     INT32_MAX
++#define SIZE_MAX        UINT32_MAX
+diff --git a/arch/riscv32/bits/syscall.h.in b/arch/riscv32/bits/syscall.h.in
+new file mode 100644
+index 00000000..852d2aaa
+--- /dev/null
++++ b/arch/riscv32/bits/syscall.h.in
+@@ -0,0 +1,286 @@
++#define __NR_io_setup 0
++#define __NR_io_destroy 1
++#define __NR_io_submit 2
++#define __NR_io_cancel 3
++#define __NR_setxattr 5
++#define __NR_lsetxattr 6
++#define __NR_fsetxattr 7
++#define __NR_getxattr 8
++#define __NR_lgetxattr 9
++#define __NR_fgetxattr 10
++#define __NR_listxattr 11
++#define __NR_llistxattr 12
++#define __NR_flistxattr 13
++#define __NR_removexattr 14
++#define __NR_lremovexattr 15
++#define __NR_fremovexattr 16
++#define __NR_getcwd 17
++#define __NR_lookup_dcookie 18
++#define __NR_eventfd2 19
++#define __NR_epoll_create1 20
++#define __NR_epoll_ctl 21
++#define __NR_epoll_pwait 22
++#define __NR_dup 23
++#define __NR_dup3 24
++#define __NR_fcntl64 25
++#define __NR_inotify_init1 26
++#define __NR_inotify_add_watch 27
++#define __NR_inotify_rm_watch 28
++#define __NR_ioctl 29
++#define __NR_ioprio_set 30
++#define __NR_ioprio_get 31
++#define __NR_flock 32
++#define __NR_mknodat 33
++#define __NR_mkdirat 34
++#define __NR_unlinkat 35
++#define __NR_symlinkat 36
++#define __NR_linkat 37
++#define __NR_umount2 39
++#define __NR_mount 40
++#define __NR_pivot_root 41
++#define __NR_nfsservctl 42
++#define __NR_statfs64 43
++#define __NR_fstatfs64 44
++#define __NR_truncate64 45
++#define __NR_ftruncate64 46
++#define __NR_fallocate 47
++#define __NR_faccessat 48
++#define __NR_chdir 49
++#define __NR_fchdir 50
++#define __NR_chroot 51
++#define __NR_fchmod 52
++#define __NR_fchmodat 53
++#define __NR_fchownat 54
++#define __NR_fchown 55
++#define __NR_openat 56
++#define __NR_close 57
++#define __NR_vhangup 58
++#define __NR_pipe2 59
++#define __NR_quotactl 60
++#define __NR_getdents64 61
++#define __NR__llseek 62
++#define __NR_read 63
++#define __NR_write 64
++#define __NR_readv 65
++#define __NR_writev 66
++#define __NR_pread64 67
++#define __NR_pwrite64 68
++#define __NR_preadv 69
++#define __NR_pwritev 70
++#define __NR_sendfile64 71
++#define __NR_signalfd4 74
++#define __NR_vmsplice 75
++#define __NR_splice 76
++#define __NR_tee 77
++#define __NR_readlinkat 78
++#define __NR_sync 81
++#define __NR_fsync 82
++#define __NR_fdatasync 83
++#define __NR_sync_file_range 84
++#define __NR_timerfd_create 85
++#define __NR_acct 89
++#define __NR_capget 90
++#define __NR_capset 91
++#define __NR_personality 92
++#define __NR_exit 93
++#define __NR_exit_group 94
++#define __NR_waitid 95
++#define __NR_set_tid_address 96
++#define __NR_unshare 97
++#define __NR_set_robust_list 99
++#define __NR_get_robust_list 100
++#define __NR_nanosleep 101
++#define __NR_getitimer 102
++#define __NR_setitimer 103
++#define __NR_kexec_load 104
++#define __NR_init_module 105
++#define __NR_delete_module 106
++#define __NR_timer_create 107
++#define __NR_timer_getoverrun 109
++#define __NR_timer_delete 111
++#define __NR_syslog 116
++#define __NR_ptrace 117
++#define __NR_sched_setparam 118
++#define __NR_sched_setscheduler 119
++#define __NR_sched_getscheduler 120
++#define __NR_sched_getparam 121
++#define __NR_sched_setaffinity 122
++#define __NR_sched_getaffinity 123
++#define __NR_sched_yield 124
++#define __NR_sched_get_priority_max 125
++#define __NR_sched_get_priority_min 126
++#define __NR_restart_syscall 128
++#define __NR_kill 129
++#define __NR_tkill 130
++#define __NR_tgkill 131
++#define __NR_sigaltstack 132
++#define __NR_rt_sigsuspend 133
++#define __NR_rt_sigaction 134
++#define __NR_rt_sigprocmask 135
++#define __NR_rt_sigpending 136
++#define __NR_rt_sigqueueinfo 138
++#define __NR_rt_sigreturn 139
++#define __NR_setpriority 140
++#define __NR_getpriority 141
++#define __NR_reboot 142
++#define __NR_setregid 143
++#define __NR_setgid 144
++#define __NR_setreuid 145
++#define __NR_setuid 146
++#define __NR_setresuid 147
++#define __NR_getresuid 148
++#define __NR_setresgid 149
++#define __NR_getresgid 150
++#define __NR_setfsuid 151
++#define __NR_setfsgid 152
++#define __NR_times 153
++#define __NR_setpgid 154
++#define __NR_getpgid 155
++#define __NR_getsid 156
++#define __NR_setsid 157
++#define __NR_getgroups 158
++#define __NR_setgroups 159
++#define __NR_uname 160
++#define __NR_sethostname 161
++#define __NR_setdomainname 162
++#define __NR_getrusage 165
++#define __NR_umask 166
++#define __NR_prctl 167
++#define __NR_getcpu 168
++#define __NR_getpid 172
++#define __NR_getppid 173
++#define __NR_getuid 174
++#define __NR_geteuid 175
++#define __NR_getgid 176
++#define __NR_getegid 177
++#define __NR_gettid 178
++#define __NR_sysinfo 179
++#define __NR_mq_open 180
++#define __NR_mq_unlink 181
++#define __NR_mq_notify 184
++#define __NR_mq_getsetattr 185
++#define __NR_msgget 186
++#define __NR_msgctl 187
++#define __NR_msgrcv 188
++#define __NR_msgsnd 189
++#define __NR_semget 190
++#define __NR_semctl 191
++#define __NR_semop 193
++#define __NR_shmget 194
++#define __NR_shmctl 195
++#define __NR_shmat 196
++#define __NR_shmdt 197
++#define __NR_socket 198
++#define __NR_socketpair 199
++#define __NR_bind 200
++#define __NR_listen 201
++#define __NR_accept 202
++#define __NR_connect 203
++#define __NR_getsockname 204
++#define __NR_getpeername 205
++#define __NR_sendto 206
++#define __NR_recvfrom 207
++#define __NR_setsockopt 208
++#define __NR_getsockopt 209
++#define __NR_shutdown 210
++#define __NR_sendmsg 211
++#define __NR_recvmsg 212
++#define __NR_readahead 213
++#define __NR_brk 214
++#define __NR_munmap 215
++#define __NR_mremap 216
++#define __NR_add_key 217
++#define __NR_request_key 218
++#define __NR_keyctl 219
++#define __NR_clone 220
++#define __NR_execve 221
++#define __NR_mmap2 222
++#define __NR_fadvise64_64 223
++#define __NR_swapon 224
++#define __NR_swapoff 225
++#define __NR_mprotect 226
++#define __NR_msync 227
++#define __NR_mlock 228
++#define __NR_munlock 229
++#define __NR_mlockall 230
++#define __NR_munlockall 231
++#define __NR_mincore 232
++#define __NR_madvise 233
++#define __NR_remap_file_pages 234
++#define __NR_mbind 235
++#define __NR_get_mempolicy 236
++#define __NR_set_mempolicy 237
++#define __NR_migrate_pages 238
++#define __NR_move_pages 239
++#define __NR_rt_tgsigqueueinfo 240
++#define __NR_perf_event_open 241
++#define __NR_accept4 242
++#define __NR_arch_specific_syscall 244
++#define __NR_prlimit64 261
++#define __NR_fanotify_init 262
++#define __NR_fanotify_mark 263
++#define __NR_name_to_handle_at 264
++#define __NR_open_by_handle_at 265
++#define __NR_syncfs 267
++#define __NR_setns 268
++#define __NR_sendmmsg 269
++#define __NR_process_vm_readv 270
++#define __NR_process_vm_writev 271
++#define __NR_kcmp 272
++#define __NR_finit_module 273
++#define __NR_sched_setattr 274
++#define __NR_sched_getattr 275
++#define __NR_renameat2 276
++#define __NR_seccomp 277
++#define __NR_getrandom 278
++#define __NR_memfd_create 279
++#define __NR_bpf 280
++#define __NR_execveat 281
++#define __NR_userfaultfd 282
++#define __NR_membarrier 283
++#define __NR_mlock2 284
++#define __NR_copy_file_range 285
++#define __NR_preadv2 286
++#define __NR_pwritev2 287
++#define __NR_pkey_mprotect 288
++#define __NR_pkey_alloc 289
++#define __NR_pkey_free 290
++#define __NR_statx 291
++#define __NR_rseq 293
++#define __NR_kexec_file_load 294
++#define __NR_clock_gettime64		403
++#define __NR_clock_settime64		404
++#define __NR_clock_adjtime64		405
++#define __NR_clock_getres_time64	406
++#define __NR_clock_nanosleep_time64	407
++#define __NR_timer_gettime64		408
++#define __NR_timer_settime64		409
++#define __NR_timerfd_gettime64		410
++#define __NR_timerfd_settime64		411
++#define __NR_utimensat_time64		412
++#define __NR_pselect6_time64		413
++#define __NR_ppoll_time64		414
++#define __NR_io_pgetevents_time64	416
++#define __NR_recvmmsg_time64		417
++#define __NR_mq_timedsend_time64	418
++#define __NR_mq_timedreceive_time64	419
++#define __NR_semtimedop_time64		420
++#define __NR_rt_sigtimedwait_time64	421
++#define __NR_futex_time64		422
++#define __NR_sched_rr_get_interval_time64 423
++#define __NR_pidfd_send_signal 424
++#define __NR_io_uring_setup 425
++#define __NR_io_uring_enter 426
++#define __NR_io_uring_register 427
++#define __NR_open_tree		428
++#define __NR_move_mount		429
++#define __NR_fsopen		430
++#define __NR_fsconfig		431
++#define __NR_fsmount		432
++#define __NR_fspick		433
++#define __NR_pidfd_open		434
++
++#define __NR_futex __NR_futex_time64
++
++#define __NR_sysriscv __NR_arch_specific_syscall
++#define __NR_riscv_flush_icache (__NR_sysriscv + 15)
+diff --git a/arch/riscv32/bits/user.h b/arch/riscv32/bits/user.h
+new file mode 100644
+index 00000000..2da743ea
+--- /dev/null
++++ b/arch/riscv32/bits/user.h
+@@ -0,0 +1,5 @@
++#include <signal.h>
++
++#define ELF_NGREG 32
++typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];
++typedef union __riscv_mc_fp_state elf_fpregset_t;
+diff --git a/arch/riscv32/crt_arch.h b/arch/riscv32/crt_arch.h
+new file mode 100644
+index 00000000..6b93fcfd
+--- /dev/null
++++ b/arch/riscv32/crt_arch.h
+@@ -0,0 +1,19 @@
++__asm__(
++".section .sdata,\"aw\"\n"
++".text\n"
++".global " START "\n"
++".type " START ",%function\n"
++START ":\n"
++".weak __global_pointer$\n"
++".hidden __global_pointer$\n"
++".option push\n"
++".option norelax\n\t"
++"lla gp, __global_pointer$\n"
++".option pop\n\t"
++"mv a0, sp\n"
++".weak _DYNAMIC\n"
++".hidden _DYNAMIC\n\t"
++"lla a1, _DYNAMIC\n\t"
++"andi sp, sp, -16\n\t"
++"tail " START "_c"
++);
+diff --git a/arch/riscv32/kstat.h b/arch/riscv32/kstat.h
+new file mode 100644
+index 00000000..e69de29b
+diff --git a/arch/riscv32/pthread_arch.h b/arch/riscv32/pthread_arch.h
+new file mode 100644
+index 00000000..a20d7fba
+--- /dev/null
++++ b/arch/riscv32/pthread_arch.h
+@@ -0,0 +1,13 @@
++static inline uintptr_t __get_tp()
++{
++	uintptr_t tp;
++	__asm__ __volatile__("mv %0, tp" : "=r"(tp));
++	return tp;
++}
++
++#define TLS_ABOVE_TP
++#define GAP_ABOVE_TP 0
++
++#define DTP_OFFSET 0x800
++
++#define MC_PC __gregs[0]
+diff --git a/arch/riscv32/reloc.h b/arch/riscv32/reloc.h
+new file mode 100644
+index 00000000..59d15f17
+--- /dev/null
++++ b/arch/riscv32/reloc.h
+@@ -0,0 +1,22 @@
++#if defined __riscv_float_abi_soft
++#define RISCV_FP_SUFFIX "-sf"
++#elif defined __riscv_float_abi_single
++#define RISCV_FP_SUFFIX "-sp"
++#elif defined __riscv_float_abi_double
++#define RISCV_FP_SUFFIX ""
++#endif
++
++#define LDSO_ARCH "riscv32" RISCV_FP_SUFFIX
++
++#define TPOFF_K 0
++
++#define REL_SYMBOLIC    R_RISCV_32
++#define REL_PLT         R_RISCV_JUMP_SLOT
++#define REL_RELATIVE    R_RISCV_RELATIVE
++#define REL_COPY        R_RISCV_COPY
++#define REL_DTPMOD      R_RISCV_TLS_DTPMOD32
++#define REL_DTPOFF      R_RISCV_TLS_DTPREL32
++#define REL_TPOFF       R_RISCV_TLS_TPREL32
++
++#define CRTJMP(pc,sp) __asm__ __volatile__( \
++	"mv sp, %1 ; jr %0" : : "r"(pc), "r"(sp) : "memory" )
+diff --git a/arch/riscv32/syscall_arch.h b/arch/riscv32/syscall_arch.h
+new file mode 100644
+index 00000000..9e916c76
+--- /dev/null
++++ b/arch/riscv32/syscall_arch.h
+@@ -0,0 +1,78 @@
++#define __SYSCALL_LL_E(x) \
++((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
++((union { long long ll; long l[2]; }){ .ll = x }).l[1]
++#define __SYSCALL_LL_O(x) __SYSCALL_LL_E((x))
++
++#define __asm_syscall(...) \
++	__asm__ __volatile__ ("ecall\n\t" \
++	: "=r"(a0) : __VA_ARGS__ : "memory"); \
++	return a0; \
++
++static inline long __syscall0(long n)
++{
++	register long a7 __asm__("a7") = n;
++	register long a0 __asm__("a0");
++	__asm_syscall("r"(a7))
++}
++
++static inline long __syscall1(long n, long a)
++{
++	register long a7 __asm__("a7") = n;
++	register long a0 __asm__("a0") = a;
++	__asm_syscall("r"(a7), "0"(a0))
++}
++
++static inline long __syscall2(long n, long a, long b)
++{
++	register long a7 __asm__("a7") = n;
++	register long a0 __asm__("a0") = a;
++	register long a1 __asm__("a1") = b;
++	__asm_syscall("r"(a7), "0"(a0), "r"(a1))
++}
++
++static inline long __syscall3(long n, long a, long b, long c)
++{
++	register long a7 __asm__("a7") = n;
++	register long a0 __asm__("a0") = a;
++	register long a1 __asm__("a1") = b;
++	register long a2 __asm__("a2") = c;
++	__asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2))
++}
++
++static inline long __syscall4(long n, long a, long b, long c, long d)
++{
++	register long a7 __asm__("a7") = n;
++	register long a0 __asm__("a0") = a;
++	register long a1 __asm__("a1") = b;
++	register long a2 __asm__("a2") = c;
++	register long a3 __asm__("a3") = d;
++	__asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2), "r"(a3))
++}
++
++static inline long __syscall5(long n, long a, long b, long c, long d, long e)
++{
++	register long a7 __asm__("a7") = n;
++	register long a0 __asm__("a0") = a;
++	register long a1 __asm__("a1") = b;
++	register long a2 __asm__("a2") = c;
++	register long a3 __asm__("a3") = d;
++	register long a4 __asm__("a4") = e;
++	__asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2), "r"(a3), "r"(a4))
++}
++
++static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
++{
++	register long a7 __asm__("a7") = n;
++	register long a0 __asm__("a0") = a;
++	register long a1 __asm__("a1") = b;
++	register long a2 __asm__("a2") = c;
++	register long a3 __asm__("a3") = d;
++	register long a4 __asm__("a4") = e;
++	register long a5 __asm__("a5") = f;
++	__asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5))
++}
++
++#define VDSO_USEFUL
++/* We don't have a clock_gettime function.
++#define VDSO_CGT_SYM "__vdso_clock_gettime"
++#define VDSO_CGT_VER "LINUX_2.6" */
+-- 
+2.29.2
+

+ 363 - 0
recipes-core/musl/musl/0011-riscv32-Add-fenv-and-math.patch

@@ -0,0 +1,363 @@
+From 748bf9c7b74ee056d4d4346f49ea6f824d845f08 Mon Sep 17 00:00:00 2001
+From: Stefan O'Rear <sorear@fastmail.com>
+Date: Thu, 3 Sep 2020 05:45:44 -0400
+Subject: [PATCH 11/16] riscv32: Add fenv and math
+
+These are identical to riscv64.
+---
+ src/fenv/riscv32/fenv-sf.c   |  3 ++
+ src/fenv/riscv32/fenv.S      | 56 ++++++++++++++++++++++++++++++++++++
+ src/math/riscv32/copysign.c  | 15 ++++++++++
+ src/math/riscv32/copysignf.c | 15 ++++++++++
+ src/math/riscv32/fabs.c      | 15 ++++++++++
+ src/math/riscv32/fabsf.c     | 15 ++++++++++
+ src/math/riscv32/fma.c       | 15 ++++++++++
+ src/math/riscv32/fmaf.c      | 15 ++++++++++
+ src/math/riscv32/fmax.c      | 15 ++++++++++
+ src/math/riscv32/fmaxf.c     | 15 ++++++++++
+ src/math/riscv32/fmin.c      | 15 ++++++++++
+ src/math/riscv32/fminf.c     | 15 ++++++++++
+ src/math/riscv32/sqrt.c      | 15 ++++++++++
+ src/math/riscv32/sqrtf.c     | 15 ++++++++++
+ 14 files changed, 239 insertions(+)
+ create mode 100644 src/fenv/riscv32/fenv-sf.c
+ create mode 100644 src/fenv/riscv32/fenv.S
+ create mode 100644 src/math/riscv32/copysign.c
+ create mode 100644 src/math/riscv32/copysignf.c
+ create mode 100644 src/math/riscv32/fabs.c
+ create mode 100644 src/math/riscv32/fabsf.c
+ create mode 100644 src/math/riscv32/fma.c
+ create mode 100644 src/math/riscv32/fmaf.c
+ create mode 100644 src/math/riscv32/fmax.c
+ create mode 100644 src/math/riscv32/fmaxf.c
+ create mode 100644 src/math/riscv32/fmin.c
+ create mode 100644 src/math/riscv32/fminf.c
+ create mode 100644 src/math/riscv32/sqrt.c
+ create mode 100644 src/math/riscv32/sqrtf.c
+
+diff --git a/src/fenv/riscv32/fenv-sf.c b/src/fenv/riscv32/fenv-sf.c
+new file mode 100644
+index 00000000..ecd3cb5c
+--- /dev/null
++++ b/src/fenv/riscv32/fenv-sf.c
+@@ -0,0 +1,3 @@
++#ifndef __riscv_flen
++#include "../fenv.c"
++#endif
+diff --git a/src/fenv/riscv32/fenv.S b/src/fenv/riscv32/fenv.S
+new file mode 100644
+index 00000000..0ea78bf9
+--- /dev/null
++++ b/src/fenv/riscv32/fenv.S
+@@ -0,0 +1,56 @@
++#ifdef __riscv_flen
++
++.global feclearexcept
++.type feclearexcept, %function
++feclearexcept:
++	csrc fflags, a0
++	li a0, 0
++	ret
++
++.global feraiseexcept
++.type feraiseexcept, %function
++feraiseexcept:
++	csrs fflags, a0
++	li a0, 0
++	ret
++
++.global fetestexcept
++.type fetestexcept, %function
++fetestexcept:
++	frflags t0
++	and a0, t0, a0
++	ret
++
++.global fegetround
++.type fegetround, %function
++fegetround:
++	frrm a0
++	ret
++
++.global __fesetround
++.type __fesetround, %function
++__fesetround:
++	fsrm t0, a0
++	li a0, 0
++	ret
++
++.global fegetenv
++.type fegetenv, %function
++fegetenv:
++	frcsr t0
++	sw t0, 0(a0)
++	li a0, 0
++	ret
++
++.global fesetenv
++.type fesetenv, %function
++fesetenv:
++	li t2, -1
++	li t1, 0
++	beq a0, t2, 1f
++	lw t1, 0(a0)
++1:	fscsr t1
++	li a0, 0
++	ret
++
++#endif
+diff --git a/src/math/riscv32/copysign.c b/src/math/riscv32/copysign.c
+new file mode 100644
+index 00000000..c7854178
+--- /dev/null
++++ b/src/math/riscv32/copysign.c
+@@ -0,0 +1,15 @@
++#include <math.h>
++
++#if __riscv_flen >= 64
++
++double copysign(double x, double y)
++{
++	__asm__ ("fsgnj.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
++	return x;
++}
++
++#else
++
++#include "../copysign.c"
++
++#endif
+diff --git a/src/math/riscv32/copysignf.c b/src/math/riscv32/copysignf.c
+new file mode 100644
+index 00000000..a125611a
+--- /dev/null
++++ b/src/math/riscv32/copysignf.c
+@@ -0,0 +1,15 @@
++#include <math.h>
++
++#if __riscv_flen >= 32
++
++float copysignf(float x, float y)
++{
++	__asm__ ("fsgnj.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
++	return x;
++}
++
++#else
++
++#include "../copysignf.c"
++
++#endif
+diff --git a/src/math/riscv32/fabs.c b/src/math/riscv32/fabs.c
+new file mode 100644
+index 00000000..5290b6f0
+--- /dev/null
++++ b/src/math/riscv32/fabs.c
+@@ -0,0 +1,15 @@
++#include <math.h>
++
++#if __riscv_flen >= 64
++
++double fabs(double x)
++{
++	__asm__ ("fabs.d %0, %1" : "=f"(x) : "f"(x));
++	return x;
++}
++
++#else
++
++#include "../fabs.c"
++
++#endif
+diff --git a/src/math/riscv32/fabsf.c b/src/math/riscv32/fabsf.c
+new file mode 100644
+index 00000000..f5032e35
+--- /dev/null
++++ b/src/math/riscv32/fabsf.c
+@@ -0,0 +1,15 @@
++#include <math.h>
++
++#if __riscv_flen >= 32
++
++float fabsf(float x)
++{
++	__asm__ ("fabs.s %0, %1" : "=f"(x) : "f"(x));
++	return x;
++}
++
++#else
++
++#include "../fabsf.c"
++
++#endif
+diff --git a/src/math/riscv32/fma.c b/src/math/riscv32/fma.c
+new file mode 100644
+index 00000000..99b05713
+--- /dev/null
++++ b/src/math/riscv32/fma.c
+@@ -0,0 +1,15 @@
++#include <math.h>
++
++#if __riscv_flen >= 64
++
++double fma(double x, double y, double z)
++{
++	__asm__ ("fmadd.d %0, %1, %2, %3" : "=f"(x) : "f"(x), "f"(y), "f"(z));
++	return x;
++}
++
++#else
++
++#include "../fma.c"
++
++#endif
+diff --git a/src/math/riscv32/fmaf.c b/src/math/riscv32/fmaf.c
+new file mode 100644
+index 00000000..f9dc47ed
+--- /dev/null
++++ b/src/math/riscv32/fmaf.c
+@@ -0,0 +1,15 @@
++#include <math.h>
++
++#if __riscv_flen >= 32
++
++float fmaf(float x, float y, float z)
++{
++	__asm__ ("fmadd.s %0, %1, %2, %3" : "=f"(x) : "f"(x), "f"(y), "f"(z));
++	return x;
++}
++
++#else
++
++#include "../fmaf.c"
++
++#endif
+diff --git a/src/math/riscv32/fmax.c b/src/math/riscv32/fmax.c
+new file mode 100644
+index 00000000..023709cd
+--- /dev/null
++++ b/src/math/riscv32/fmax.c
+@@ -0,0 +1,15 @@
++#include <math.h>
++
++#if __riscv_flen >= 64
++
++double fmax(double x, double y)
++{
++	__asm__ ("fmax.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
++	return x;
++}
++
++#else
++
++#include "../fmax.c"
++
++#endif
+diff --git a/src/math/riscv32/fmaxf.c b/src/math/riscv32/fmaxf.c
+new file mode 100644
+index 00000000..863d2bd1
+--- /dev/null
++++ b/src/math/riscv32/fmaxf.c
+@@ -0,0 +1,15 @@
++#include <math.h>
++
++#if __riscv_flen >= 32
++
++float fmaxf(float x, float y)
++{
++	__asm__ ("fmax.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
++	return x;
++}
++
++#else
++
++#include "../fmaxf.c"
++
++#endif
+diff --git a/src/math/riscv32/fmin.c b/src/math/riscv32/fmin.c
+new file mode 100644
+index 00000000..a4e3b067
+--- /dev/null
++++ b/src/math/riscv32/fmin.c
+@@ -0,0 +1,15 @@
++#include <math.h>
++
++#if __riscv_flen >= 64
++
++double fmin(double x, double y)
++{
++	__asm__ ("fmin.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
++	return x;
++}
++
++#else
++
++#include "../fmin.c"
++
++#endif
+diff --git a/src/math/riscv32/fminf.c b/src/math/riscv32/fminf.c
+new file mode 100644
+index 00000000..32156e80
+--- /dev/null
++++ b/src/math/riscv32/fminf.c
+@@ -0,0 +1,15 @@
++#include <math.h>
++
++#if __riscv_flen >= 32
++
++float fminf(float x, float y)
++{
++	__asm__ ("fmin.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
++	return x;
++}
++
++#else
++
++#include "../fminf.c"
++
++#endif
+diff --git a/src/math/riscv32/sqrt.c b/src/math/riscv32/sqrt.c
+new file mode 100644
+index 00000000..867a504c
+--- /dev/null
++++ b/src/math/riscv32/sqrt.c
+@@ -0,0 +1,15 @@
++#include <math.h>
++
++#if __riscv_flen >= 64
++
++double sqrt(double x)
++{
++	__asm__ ("fsqrt.d %0, %1" : "=f"(x) : "f"(x));
++	return x;
++}
++
++#else
++
++#include "../sqrt.c"
++
++#endif
+diff --git a/src/math/riscv32/sqrtf.c b/src/math/riscv32/sqrtf.c
+new file mode 100644
+index 00000000..610c2cf8
+--- /dev/null
++++ b/src/math/riscv32/sqrtf.c
+@@ -0,0 +1,15 @@
++#include <math.h>
++
++#if __riscv_flen >= 32
++
++float sqrtf(float x)
++{
++	__asm__ ("fsqrt.s %0, %1" : "=f"(x) : "f"(x));
++	return x;
++}
++
++#else
++
++#include "../sqrtf.c"
++
++#endif
+-- 
+2.29.2
+

+ 26 - 0
recipes-core/musl/musl/0012-riscv32-Add-dlsym.patch

@@ -0,0 +1,26 @@
+From 0bb97d2cf32b62aa276414c68b90d6fa319cf16c Mon Sep 17 00:00:00 2001
+From: Stefan O'Rear <sorear@fastmail.com>
+Date: Thu, 3 Sep 2020 05:46:33 -0400
+Subject: [PATCH 12/16] riscv32: Add dlsym
+
+Identical to riscv64.
+---
+ src/ldso/riscv32/dlsym.s | 6 ++++++
+ 1 file changed, 6 insertions(+)
+ create mode 100644 src/ldso/riscv32/dlsym.s
+
+diff --git a/src/ldso/riscv32/dlsym.s b/src/ldso/riscv32/dlsym.s
+new file mode 100644
+index 00000000..2bafd72d
+--- /dev/null
++++ b/src/ldso/riscv32/dlsym.s
+@@ -0,0 +1,6 @@
++.global dlsym
++.hidden __dlsym
++.type dlsym, %function
++dlsym:
++	mv a2, ra
++	tail __dlsym
+-- 
+2.29.2
+

+ 158 - 0
recipes-core/musl/musl/0013-riscv32-Add-jmp_buf-and-sigreturn.patch

@@ -0,0 +1,158 @@
+From 0b4555370e3b615453ce002a375809870fe8d8ed Mon Sep 17 00:00:00 2001
+From: Stefan O'Rear <sorear@fastmail.com>
+Date: Thu, 3 Sep 2020 05:54:44 -0400
+Subject: [PATCH 13/16] riscv32: Add jmp_buf and sigreturn
+
+Largely copied from riscv64 but required recalculation of offsets.
+---
+ src/setjmp/riscv32/longjmp.S   | 42 ++++++++++++++++++++++++++++++++++
+ src/setjmp/riscv32/setjmp.S    | 41 +++++++++++++++++++++++++++++++++
+ src/signal/riscv32/restore.s   |  8 +++++++
+ src/signal/riscv32/sigsetjmp.s | 23 +++++++++++++++++++
+ 4 files changed, 114 insertions(+)
+ create mode 100644 src/setjmp/riscv32/longjmp.S
+ create mode 100644 src/setjmp/riscv32/setjmp.S
+ create mode 100644 src/signal/riscv32/restore.s
+ create mode 100644 src/signal/riscv32/sigsetjmp.s
+
+diff --git a/src/setjmp/riscv32/longjmp.S b/src/setjmp/riscv32/longjmp.S
+new file mode 100644
+index 00000000..f9cb3318
+--- /dev/null
++++ b/src/setjmp/riscv32/longjmp.S
+@@ -0,0 +1,42 @@
++.global __longjmp
++.global _longjmp
++.global longjmp
++.type __longjmp, %function
++.type _longjmp,  %function
++.type longjmp,   %function
++__longjmp:
++_longjmp:
++longjmp:
++	lw s0,    0(a0)
++	lw s1,    4(a0)
++	lw s2,    8(a0)
++	lw s3,    12(a0)
++	lw s4,    16(a0)
++	lw s5,    20(a0)
++	lw s6,    24(a0)
++	lw s7,    28(a0)
++	lw s8,    32(a0)
++	lw s9,    36(a0)
++	lw s10,   40(a0)
++	lw s11,   44(a0)
++	lw sp,    48(a0)
++	lw ra,    52(a0)
++
++#ifndef __riscv_float_abi_soft
++	fld fs0,  56(a0)
++	fld fs1,  64(a0)
++	fld fs2,  72(a0)
++	fld fs3,  80(a0)
++	fld fs4,  88(a0)
++	fld fs5,  96(a0)
++	fld fs6,  104(a0)
++	fld fs7,  112(a0)
++	fld fs8,  120(a0)
++	fld fs9,  128(a0)
++	fld fs10, 136(a0)
++	fld fs11, 144(a0)
++#endif
++
++	seqz a0, a1
++	add a0, a0, a1
++	ret
+diff --git a/src/setjmp/riscv32/setjmp.S b/src/setjmp/riscv32/setjmp.S
+new file mode 100644
+index 00000000..8a75cf55
+--- /dev/null
++++ b/src/setjmp/riscv32/setjmp.S
+@@ -0,0 +1,41 @@
++.global __setjmp
++.global _setjmp
++.global setjmp
++.type __setjmp, %function
++.type _setjmp,  %function
++.type setjmp,   %function
++__setjmp:
++_setjmp:
++setjmp:
++	sw s0,    0(a0)
++	sw s1,    4(a0)
++	sw s2,    8(a0)
++	sw s3,    12(a0)
++	sw s4,    16(a0)
++	sw s5,    20(a0)
++	sw s6,    24(a0)
++	sw s7,    28(a0)
++	sw s8,    32(a0)
++	sw s9,    36(a0)
++	sw s10,   40(a0)
++	sw s11,   44(a0)
++	sw sp,    48(a0)
++	sw ra,    52(a0)
++
++#ifndef __riscv_float_abi_soft
++	fsd fs0,  56(a0)
++	fsd fs1,  64(a0)
++	fsd fs2,  72(a0)
++	fsd fs3,  80(a0)
++	fsd fs4,  88(a0)
++	fsd fs5,  96(a0)
++	fsd fs6,  104(a0)
++	fsd fs7,  112(a0)
++	fsd fs8,  120(a0)
++	fsd fs9,  128(a0)
++	fsd fs10, 136(a0)
++	fsd fs11, 144(a0)
++#endif
++
++	li a0, 0
++	ret
+diff --git a/src/signal/riscv32/restore.s b/src/signal/riscv32/restore.s
+new file mode 100644
+index 00000000..40012c75
+--- /dev/null
++++ b/src/signal/riscv32/restore.s
+@@ -0,0 +1,8 @@
++.global __restore
++.type __restore, %function
++__restore:
++.global __restore_rt
++.type __restore_rt, %function
++__restore_rt:
++	li a7, 139 # SYS_rt_sigreturn
++	ecall
+diff --git a/src/signal/riscv32/sigsetjmp.s b/src/signal/riscv32/sigsetjmp.s
+new file mode 100644
+index 00000000..c1caeab1
+--- /dev/null
++++ b/src/signal/riscv32/sigsetjmp.s
+@@ -0,0 +1,23 @@
++.global sigsetjmp
++.global __sigsetjmp
++.type sigsetjmp, %function
++.type __sigsetjmp, %function
++sigsetjmp:
++__sigsetjmp:
++	bnez a1, 1f
++	tail setjmp
++1:
++
++	sw ra, 152(a0)
++	sw s0, 164(a0)
++	mv s0, a0
++
++	call setjmp
++
++	mv a1, a0
++	mv a0, s0
++	lw s0, 164(a0)
++	lw ra, 152(a0)
++
++.hidden __sigsetjmp_tail
++	tail __sigsetjmp_tail
+-- 
+2.29.2
+

+ 120 - 0
recipes-core/musl/musl/0014-riscv32-Add-thread-support.patch

@@ -0,0 +1,120 @@
+From 09cfd9ee37e253d5ec1afc7ff7df652529e766c6 Mon Sep 17 00:00:00 2001
+From: Stefan O'Rear <sorear@fastmail.com>
+Date: Thu, 3 Sep 2020 05:56:46 -0400
+Subject: [PATCH 14/16] riscv32: Add thread support
+
+Identical to riscv64 except for stack offsets in clone.
+---
+ src/thread/riscv32/__set_thread_area.s |  6 +++++
+ src/thread/riscv32/__unmapself.s       |  7 ++++++
+ src/thread/riscv32/clone.s             | 34 ++++++++++++++++++++++++++
+ src/thread/riscv32/syscall_cp.s        | 29 ++++++++++++++++++++++
+ 4 files changed, 76 insertions(+)
+ create mode 100644 src/thread/riscv32/__set_thread_area.s
+ create mode 100644 src/thread/riscv32/__unmapself.s
+ create mode 100644 src/thread/riscv32/clone.s
+ create mode 100644 src/thread/riscv32/syscall_cp.s
+
+diff --git a/src/thread/riscv32/__set_thread_area.s b/src/thread/riscv32/__set_thread_area.s
+new file mode 100644
+index 00000000..828154d2
+--- /dev/null
++++ b/src/thread/riscv32/__set_thread_area.s
+@@ -0,0 +1,6 @@
++.global __set_thread_area
++.type   __set_thread_area, %function
++__set_thread_area:
++	mv tp, a0
++	li a0, 0
++	ret
+diff --git a/src/thread/riscv32/__unmapself.s b/src/thread/riscv32/__unmapself.s
+new file mode 100644
+index 00000000..2849119c
+--- /dev/null
++++ b/src/thread/riscv32/__unmapself.s
+@@ -0,0 +1,7 @@
++.global __unmapself
++.type __unmapself, %function
++__unmapself:
++	li a7, 215 # SYS_munmap
++	ecall
++	li a7, 93  # SYS_exit
++	ecall
+diff --git a/src/thread/riscv32/clone.s b/src/thread/riscv32/clone.s
+new file mode 100644
+index 00000000..3102239d
+--- /dev/null
++++ b/src/thread/riscv32/clone.s
+@@ -0,0 +1,34 @@
++# __clone(func, stack, flags, arg, ptid, tls, ctid)
++#           a0,    a1,    a2,  a3,   a4,  a5,   a6
++
++# syscall(SYS_clone, flags, stack, ptid, tls, ctid)
++#                a7     a0,    a1,   a2,  a3,   a4
++
++.global __clone
++.type  __clone, %function
++__clone:
++	# Save func and arg to stack
++	addi a1, a1, -16
++	sw a0, 0(a1)
++	sw a3, 4(a1)
++
++	# Call SYS_clone
++	mv a0, a2
++	mv a2, a4
++	mv a3, a5
++	mv a4, a6
++	li a7, 220 # SYS_clone
++	ecall
++
++	beqz a0, 1f
++	# Parent
++	ret
++
++	# Child
++1:      lw a1, 0(sp)
++	lw a0, 4(sp)
++	jalr a1
++
++	# Exit
++	li a7, 93 # SYS_exit
++	ecall
+diff --git a/src/thread/riscv32/syscall_cp.s b/src/thread/riscv32/syscall_cp.s
+new file mode 100644
+index 00000000..079d1ba0
+--- /dev/null
++++ b/src/thread/riscv32/syscall_cp.s
+@@ -0,0 +1,29 @@
++.global __cp_begin
++.hidden __cp_begin
++.global __cp_end
++.hidden __cp_end
++.global __cp_cancel
++.hidden __cp_cancel
++.hidden __cancel
++.global __syscall_cp_asm
++.hidden __syscall_cp_asm
++.type __syscall_cp_asm, %function
++__syscall_cp_asm:
++__cp_begin:
++	lw t0, 0(a0)
++	bnez t0, __cp_cancel
++
++	mv t0, a1
++	mv a0, a2
++	mv a1, a3
++	mv a2, a4
++	mv a3, a5
++	mv a4, a6
++	mv a5, a7
++	lw a6, 0(sp)
++	mv a7, t0
++	ecall
++__cp_end:
++	ret
++__cp_cancel:
++	tail __cancel
+-- 
+2.29.2
+

+ 201 - 0
recipes-core/musl/musl/0015-Change-definitions-of-F_GETLK-F_SETLK-F_SETLKW.patch

@@ -0,0 +1,201 @@
+From fb2d200423299843818884801e2598dd643ec834 Mon Sep 17 00:00:00 2001
+From: Stefan O'Rear <sorear@fastmail.com>
+Date: Wed, 9 Sep 2020 11:57:54 -0700
+Subject: [PATCH 15/16] Change definitions of F_GETLK, F_SETLK, F_SETLKW
+
+* gdb HEAD wants ELF_NFPREG, so I set it in bits/user.h to the value
+  gdb needs.  (glibc does #define ELF_NFPREG NFPREG and expects gdb
+  to define NFPREG. I don't get this.)
+
+* Restore accidentally removed errno setting in waitpid, fixes a gdb
+  assertion failure.
+
+* Zero IPC_64 because the kernel only recognizes one set of IPC commands.
+
+* Copy the IPC_TIME64 bits from arch/arm/bits to trigger the musl code
+  for fixing time64 IPC_STAT results.  I'm not super happy with this,
+  maybe there should be a new mechanism in musl for fixing IPC_STAT for
+  unconditionally-time64 architectures.
+
+* riscv32 _does_ provide both F_GETLK and F_GETLK32; make sure we use
+  the right one.
+
+Signed-off-by: Stefan O'Rear <sorear@fastmail.com>
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ arch/riscv32/bits/fcntl.h   |  7 ++++---
+ arch/riscv32/bits/ipcstat.h |  1 +
+ arch/riscv32/bits/msg.h     | 18 ++++++++++++++++++
+ arch/riscv32/bits/sem.h     | 18 ++++++++++++++++++
+ arch/riscv32/bits/shm.h     | 31 +++++++++++++++++++++++++++++++
+ arch/riscv32/bits/user.h    |  1 +
+ arch/riscv32/syscall_arch.h |  2 ++
+ arch/riscv64/bits/user.h    |  1 +
+ src/process/waitpid.c       |  2 +-
+ 9 files changed, 77 insertions(+), 4 deletions(-)
+ create mode 100644 arch/riscv32/bits/ipcstat.h
+ create mode 100644 arch/riscv32/bits/msg.h
+ create mode 100644 arch/riscv32/bits/sem.h
+ create mode 100644 arch/riscv32/bits/shm.h
+
+diff --git a/arch/riscv32/bits/fcntl.h b/arch/riscv32/bits/fcntl.h
+index ecb4d18f..66f84fac 100644
+--- a/arch/riscv32/bits/fcntl.h
++++ b/arch/riscv32/bits/fcntl.h
+@@ -24,14 +24,15 @@
+ #define F_SETFD  2
+ #define F_GETFL  3
+ #define F_SETFL  4
+-#define F_GETLK  5
+-#define F_SETLK  6
+-#define F_SETLKW 7
+ #define F_SETOWN 8
+ #define F_GETOWN 9
+ #define F_SETSIG 10
+ #define F_GETSIG 11
+ 
++#define F_GETLK  12
++#define F_SETLK  13
++#define F_SETLKW 14
++
+ #define F_SETOWN_EX 15
+ #define F_GETOWN_EX 16
+ 
+diff --git a/arch/riscv32/bits/ipcstat.h b/arch/riscv32/bits/ipcstat.h
+new file mode 100644
+index 00000000..4f4fcb0c
+--- /dev/null
++++ b/arch/riscv32/bits/ipcstat.h
+@@ -0,0 +1 @@
++#define IPC_STAT 0x102
+diff --git a/arch/riscv32/bits/msg.h b/arch/riscv32/bits/msg.h
+new file mode 100644
+index 00000000..7bbbb2bf
+--- /dev/null
++++ b/arch/riscv32/bits/msg.h
+@@ -0,0 +1,18 @@
++struct msqid_ds {
++	struct ipc_perm msg_perm;
++	unsigned long __msg_stime_lo;
++	unsigned long __msg_stime_hi;
++	unsigned long __msg_rtime_lo;
++	unsigned long __msg_rtime_hi;
++	unsigned long __msg_ctime_lo;
++	unsigned long __msg_ctime_hi;
++	unsigned long msg_cbytes;
++	msgqnum_t msg_qnum;
++	msglen_t msg_qbytes;
++	pid_t msg_lspid;
++	pid_t msg_lrpid;
++	unsigned long __unused[2];
++	time_t msg_stime;
++	time_t msg_rtime;
++	time_t msg_ctime;
++};
+diff --git a/arch/riscv32/bits/sem.h b/arch/riscv32/bits/sem.h
+new file mode 100644
+index 00000000..544e3d2a
+--- /dev/null
++++ b/arch/riscv32/bits/sem.h
+@@ -0,0 +1,18 @@
++struct semid_ds {
++	struct ipc_perm sem_perm;
++	unsigned long __sem_otime_lo;
++	unsigned long __sem_otime_hi;
++	unsigned long __sem_ctime_lo;
++	unsigned long __sem_ctime_hi;
++#if __BYTE_ORDER == __LITTLE_ENDIAN
++	unsigned short sem_nsems;
++	char __sem_nsems_pad[sizeof(long)-sizeof(short)];
++#else
++	char __sem_nsems_pad[sizeof(long)-sizeof(short)];
++	unsigned short sem_nsems;
++#endif
++	long __unused3;
++	long __unused4;
++	time_t sem_otime;
++	time_t sem_ctime;
++};
+diff --git a/arch/riscv32/bits/shm.h b/arch/riscv32/bits/shm.h
+new file mode 100644
+index 00000000..725fb469
+--- /dev/null
++++ b/arch/riscv32/bits/shm.h
+@@ -0,0 +1,31 @@
++#define SHMLBA 4096
++
++struct shmid_ds {
++	struct ipc_perm shm_perm;
++	size_t shm_segsz;
++	unsigned long __shm_atime_lo;
++	unsigned long __shm_atime_hi;
++	unsigned long __shm_dtime_lo;
++	unsigned long __shm_dtime_hi;
++	unsigned long __shm_ctime_lo;
++	unsigned long __shm_ctime_hi;
++	pid_t shm_cpid;
++	pid_t shm_lpid;
++	unsigned long shm_nattch;
++	unsigned long __pad1;
++	unsigned long __pad2;
++	unsigned long __pad3;
++	time_t shm_atime;
++	time_t shm_dtime;
++	time_t shm_ctime;
++};
++
++struct shminfo {
++	unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
++};
++
++struct shm_info {
++	int __used_ids;
++	unsigned long shm_tot, shm_rss, shm_swp;
++	unsigned long __swap_attempts, __swap_successes;
++};
+diff --git a/arch/riscv32/bits/user.h b/arch/riscv32/bits/user.h
+index 2da743ea..0d37de0b 100644
+--- a/arch/riscv32/bits/user.h
++++ b/arch/riscv32/bits/user.h
+@@ -1,5 +1,6 @@
+ #include <signal.h>
+ 
+ #define ELF_NGREG 32
++#define ELF_NFPREG 33
+ typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];
+ typedef union __riscv_mc_fp_state elf_fpregset_t;
+diff --git a/arch/riscv32/syscall_arch.h b/arch/riscv32/syscall_arch.h
+index 9e916c76..c507f15f 100644
+--- a/arch/riscv32/syscall_arch.h
++++ b/arch/riscv32/syscall_arch.h
+@@ -76,3 +76,5 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo
+ /* We don't have a clock_gettime function.
+ #define VDSO_CGT_SYM "__vdso_clock_gettime"
+ #define VDSO_CGT_VER "LINUX_2.6" */
++
++#define IPC_64 0
+diff --git a/arch/riscv64/bits/user.h b/arch/riscv64/bits/user.h
+index 2da743ea..0d37de0b 100644
+--- a/arch/riscv64/bits/user.h
++++ b/arch/riscv64/bits/user.h
+@@ -1,5 +1,6 @@
+ #include <signal.h>
+ 
+ #define ELF_NGREG 32
++#define ELF_NFPREG 33
+ typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];
+ typedef union __riscv_mc_fp_state elf_fpregset_t;
+diff --git a/src/process/waitpid.c b/src/process/waitpid.c
+index e5ff27ca..9de4073f 100644
+--- a/src/process/waitpid.c
++++ b/src/process/waitpid.c
+@@ -3,5 +3,5 @@
+ 
+ pid_t waitpid(pid_t pid, int *status, int options)
+ {
+-	return __wait4(pid, status, options, 0, 1);
++	return __syscall_ret(__wait4(pid, status, options, 0, 1));
+ }
+-- 
+2.29.2
+

+ 33 - 0
recipes-core/musl/musl/0016-riscv32-Wire-new-syscalls.patch

@@ -0,0 +1,33 @@
+From 9fb8b132642520042ab4734ac1f0abce688bbea9 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Fri, 30 Oct 2020 12:16:29 -0700
+Subject: [PATCH 16/16] riscv32: Wire new syscalls
+
+- add __NR_faccessat2 from linux v5.8
+- add pidfd_getfd and openat2 syscall numbers from linux v5.6
+- add clone3 syscall number from linux v5.3
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ arch/riscv32/bits/syscall.h.in | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/arch/riscv32/bits/syscall.h.in b/arch/riscv32/bits/syscall.h.in
+index 852d2aaa..4b145fa3 100644
+--- a/arch/riscv32/bits/syscall.h.in
++++ b/arch/riscv32/bits/syscall.h.in
+@@ -279,7 +279,10 @@
+ #define __NR_fsmount		432
+ #define __NR_fspick		433
+ #define __NR_pidfd_open		434
+-
++#define __NR_clone3		435
++#define __NR_openat2		437
++#define __NR_pidfd_getfd	438
++#define __NR_faccessat2		439
+ #define __NR_futex __NR_futex_time64
+ 
+ #define __NR_sysriscv __NR_arch_specific_syscall
+-- 
+2.29.2
+

+ 20 - 0
recipes-core/musl/musl_%.bbappend

@@ -0,0 +1,20 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI_append_riscv32 = "\
+    file://0001-Remove-ARMSUBARCH-relic-from-configure.patch \
+    file://0002-time64-Don-t-make-aliases-to-nonexistent-syscalls.patch \
+    file://0003-time64-Only-getrlimit-setrlimit-if-they-exist.patch \
+    file://0004-time64-Only-gettimeofday-settimeofday-if-exist.patch \
+    file://0005-Add-src-internal-statx.h.patch \
+    file://0006-Only-call-fstatat-if-defined.patch \
+    file://0007-Emulate-wait4-using-waitid.patch \
+    file://0008-riscv-Fall-back-to-syscall-__riscv_flush_icache.patch \
+    file://0009-riscv32-Target-and-subtarget-detection.patch \
+    file://0010-riscv32-add-arch-headers.patch \
+    file://0011-riscv32-Add-fenv-and-math.patch \
+    file://0012-riscv32-Add-dlsym.patch \
+    file://0013-riscv32-Add-jmp_buf-and-sigreturn.patch \
+    file://0014-riscv32-Add-thread-support.patch \
+    file://0015-Change-definitions-of-F_GETLK-F_SETLK-F_SETLKW.patch \
+    file://0016-riscv32-Wire-new-syscalls.patch \
+"

+ 1 - 0
recipes-core/packagegroups/packagegroup-core-eclipse-debug.bbappend

@@ -0,0 +1 @@
+EXCLUDE_FROM_WORLD = "1"

+ 3 - 0
recipes-core/packagegroups/packagegroup-core-tools-debug.bbappend

@@ -0,0 +1,3 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+RDEPENDS_${PN}_remove_csky = "strace"
+

+ 4 - 0
recipes-core/packagegroups/packagegroup-core-tools-profile.bbappend

@@ -0,0 +1,4 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SYSTEMTAP_csky = ""
+VALGRIND_csky = ""

+ 4 - 0
recipes-core/packagegroups/packagegroup-core-tools-testapps.bbappend

@@ -0,0 +1,4 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+KEXECTOOLS_csky = ""
+GSTEXAMPLES_csky = ""

+ 1 - 0
recipes-core/packagegroups/packagegroup-go-sdk-target.bbappend

@@ -0,0 +1 @@
+COMPATIBLE_HOST_csky = "csky*"

+ 3 - 0
recipes-core/packagegroups/packagegroup-self-hosted.bbappend

@@ -0,0 +1,3 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+RDEPENDS_packagegroup-self-hosted-debug_remove_csky = "strace tcf-agent"

+ 186 - 0
recipes-core/systemd/systemd/src/basic/architecture.c

@@ -0,0 +1,186 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
+#include <sys/utsname.h>
+
+#include "architecture.h"
+#include "macro.h"
+#include "string-table.h"
+#include "string-util.h"
+
+int uname_architecture(void) {
+
+        /* Return a sanitized enum identifying the architecture we are
+         * running on. This is based on uname(), and the user may
+         * hence control what this returns by using
+         * personality(). This puts the user in control on systems
+         * that can run binaries of multiple architectures.
+         *
+         * We do not translate the string returned by uname()
+         * 1:1. Instead we try to clean it up and break down the
+         * confusion on x86 and arm in particular.
+         *
+         * We do not try to distinguish CPUs not CPU features, but
+         * actual architectures, i.e. that have genuinely different
+         * code. */
+
+        static const struct {
+                const char *machine;
+                int arch;
+        } arch_map[] = {
+#if defined(__x86_64__) || defined(__i386__)
+                { "x86_64",     ARCHITECTURE_X86_64   },
+                { "i686",       ARCHITECTURE_X86      },
+                { "i586",       ARCHITECTURE_X86      },
+                { "i486",       ARCHITECTURE_X86      },
+                { "i386",       ARCHITECTURE_X86      },
+#elif defined(__powerpc__) || defined(__powerpc64__)
+                { "ppc64",      ARCHITECTURE_PPC64    },
+                { "ppc64le",    ARCHITECTURE_PPC64_LE },
+                { "ppc",        ARCHITECTURE_PPC      },
+                { "ppcle",      ARCHITECTURE_PPC_LE   },
+#elif defined(__ia64__)
+                { "ia64",       ARCHITECTURE_IA64     },
+#elif defined(__hppa__) || defined(__hppa64__)
+                { "parisc64",   ARCHITECTURE_PARISC64 },
+                { "parisc",     ARCHITECTURE_PARISC   },
+#elif defined(__s390__) || defined(__s390x__)
+                { "s390x",      ARCHITECTURE_S390X    },
+                { "s390",       ARCHITECTURE_S390     },
+#elif defined(__sparc__)
+                { "sparc64",    ARCHITECTURE_SPARC64  },
+                { "sparc",      ARCHITECTURE_SPARC    },
+#elif defined(__mips__) || defined(__mips64__)
+                { "mips64",     ARCHITECTURE_MIPS64   },
+                { "mips",       ARCHITECTURE_MIPS     },
+#elif defined(__alpha__)
+                { "alpha" ,     ARCHITECTURE_ALPHA    },
+#elif defined(__arm__) || defined(__aarch64__)
+                { "aarch64",    ARCHITECTURE_ARM64    },
+                { "aarch64_be", ARCHITECTURE_ARM64_BE },
+                { "armv4l",     ARCHITECTURE_ARM      },
+                { "armv4b",     ARCHITECTURE_ARM_BE   },
+                { "armv4tl",    ARCHITECTURE_ARM      },
+                { "armv4tb",    ARCHITECTURE_ARM_BE   },
+                { "armv5tl",    ARCHITECTURE_ARM      },
+                { "armv5tb",    ARCHITECTURE_ARM_BE   },
+                { "armv5tel",   ARCHITECTURE_ARM      },
+                { "armv5teb" ,  ARCHITECTURE_ARM_BE   },
+                { "armv5tejl",  ARCHITECTURE_ARM      },
+                { "armv5tejb",  ARCHITECTURE_ARM_BE   },
+                { "armv6l",     ARCHITECTURE_ARM      },
+                { "armv6b",     ARCHITECTURE_ARM_BE   },
+                { "armv7l",     ARCHITECTURE_ARM      },
+                { "armv7b",     ARCHITECTURE_ARM_BE   },
+                { "armv7ml",    ARCHITECTURE_ARM      },
+                { "armv7mb",    ARCHITECTURE_ARM_BE   },
+                { "armv4l",     ARCHITECTURE_ARM      },
+                { "armv4b",     ARCHITECTURE_ARM_BE   },
+                { "armv4tl",    ARCHITECTURE_ARM      },
+                { "armv4tb",    ARCHITECTURE_ARM_BE   },
+                { "armv5tl",    ARCHITECTURE_ARM      },
+                { "armv5tb",    ARCHITECTURE_ARM_BE   },
+                { "armv5tel",   ARCHITECTURE_ARM      },
+                { "armv5teb",   ARCHITECTURE_ARM_BE   },
+                { "armv5tejl",  ARCHITECTURE_ARM      },
+                { "armv5tejb",  ARCHITECTURE_ARM_BE   },
+                { "armv6l",     ARCHITECTURE_ARM      },
+                { "armv6b",     ARCHITECTURE_ARM_BE   },
+                { "armv7l",     ARCHITECTURE_ARM      },
+                { "armv7b",     ARCHITECTURE_ARM_BE   },
+                { "armv7ml",    ARCHITECTURE_ARM      },
+                { "armv7mb",    ARCHITECTURE_ARM_BE   },
+                { "armv8l",     ARCHITECTURE_ARM      },
+                { "armv8b",     ARCHITECTURE_ARM_BE   },
+#elif defined(__sh__) || defined(__sh64__)
+                { "sh5",        ARCHITECTURE_SH64     },
+                { "sh2",        ARCHITECTURE_SH       },
+                { "sh2a",       ARCHITECTURE_SH       },
+                { "sh3",        ARCHITECTURE_SH       },
+                { "sh4",        ARCHITECTURE_SH       },
+                { "sh4a",       ARCHITECTURE_SH       },
+#elif defined(__m68k__)
+                { "m68k",       ARCHITECTURE_M68K     },
+#elif defined(__tilegx__)
+                { "tilegx",     ARCHITECTURE_TILEGX   },
+#elif defined(__cris__)
+                { "crisv32",    ARCHITECTURE_CRIS     },
+#elif defined(__nios2__)
+                { "nios2",      ARCHITECTURE_NIOS2    },
+#elif defined(__riscv__) || defined(__riscv)
+        /* __riscv__ is obsolete, remove in 2018 */
+                { "riscv32",    ARCHITECTURE_RISCV32  },
+                { "riscv64",    ARCHITECTURE_RISCV64  },
+#  if __SIZEOF_POINTER__ == 4
+                { "riscv",      ARCHITECTURE_RISCV32  },
+#  elif __SIZEOF_POINTER__ == 8
+                { "riscv",      ARCHITECTURE_RISCV64  },
+#  endif
+#elif defined(__csky__) || defined(__csky)
+				{ "csky32",    ARCHITECTURE_CSKY32  },
+				{ "csky64",    ARCHITECTURE_CSKY64  },
+ #  if __SIZEOF_POINTER__ == 4
+                { "csky",      ARCHITECTURE_CSKY32  },
+#  elif __SIZEOF_POINTER__ == 8
+                { "csky",      ARCHITECTURE_CSKY64  },
+ #  endif
+#elif defined(__arc__)
+                { "arc",        ARCHITECTURE_ARC      },
+                { "arceb",      ARCHITECTURE_ARC_BE   },
+#else
+#error "Please register your architecture here!"
+#endif
+        };
+
+        static int cached = _ARCHITECTURE_INVALID;
+        struct utsname u;
+        unsigned i;
+
+        if (cached != _ARCHITECTURE_INVALID)
+                return cached;
+
+        assert_se(uname(&u) >= 0);
+
+        for (i = 0; i < ELEMENTSOF(arch_map); i++)
+                if (streq(arch_map[i].machine, u.machine))
+                        return cached = arch_map[i].arch;
+
+        assert_not_reached("Couldn't identify architecture. You need to patch systemd.");
+        return _ARCHITECTURE_INVALID;
+}
+
+static const char *const architecture_table[_ARCHITECTURE_MAX] = {
+        [ARCHITECTURE_X86] = "x86",
+        [ARCHITECTURE_X86_64] = "x86-64",
+        [ARCHITECTURE_PPC] = "ppc",
+        [ARCHITECTURE_PPC_LE] = "ppc-le",
+        [ARCHITECTURE_PPC64] = "ppc64",
+        [ARCHITECTURE_PPC64_LE] = "ppc64-le",
+        [ARCHITECTURE_IA64] = "ia64",
+        [ARCHITECTURE_PARISC] = "parisc",
+        [ARCHITECTURE_PARISC64] = "parisc64",
+        [ARCHITECTURE_S390] = "s390",
+        [ARCHITECTURE_S390X] = "s390x",
+        [ARCHITECTURE_SPARC] = "sparc",
+        [ARCHITECTURE_SPARC64] = "sparc64",
+        [ARCHITECTURE_MIPS] = "mips",
+        [ARCHITECTURE_MIPS_LE] = "mips-le",
+        [ARCHITECTURE_MIPS64] = "mips64",
+        [ARCHITECTURE_MIPS64_LE] = "mips64-le",
+        [ARCHITECTURE_ALPHA] = "alpha",
+        [ARCHITECTURE_ARM] = "arm",
+        [ARCHITECTURE_ARM_BE] = "arm-be",
+        [ARCHITECTURE_ARM64] = "arm64",
+        [ARCHITECTURE_ARM64_BE] = "arm64-be",
+        [ARCHITECTURE_SH] = "sh",
+        [ARCHITECTURE_SH64] = "sh64",
+        [ARCHITECTURE_M68K] = "m68k",
+        [ARCHITECTURE_TILEGX] = "tilegx",
+        [ARCHITECTURE_CRIS] = "cris",
+        [ARCHITECTURE_NIOS2] = "nios2",
+        [ARCHITECTURE_RISCV32] = "riscv32",
+        [ARCHITECTURE_RISCV64] = "riscv64",
+        [ARCHITECTURE_ARC] = "arc",
+        [ARCHITECTURE_ARC_BE] = "arc-be",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(architecture, int);

+ 246 - 0
recipes-core/systemd/systemd/src/basic/architecture.h

@@ -0,0 +1,246 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+#pragma once
+
+#include <endian.h>
+
+#include "macro.h"
+#include "util.h"
+
+/* A cleaned up architecture definition. We don't want to get lost in
+ * processor features, models, generations or even ABIs. Hence we
+ * focus on general family, and distinguish word width and
+ * endianness. */
+
+enum {
+        ARCHITECTURE_X86 = 0,
+        ARCHITECTURE_X86_64,
+        ARCHITECTURE_PPC,
+        ARCHITECTURE_PPC_LE,
+        ARCHITECTURE_PPC64,
+        ARCHITECTURE_PPC64_LE,
+        ARCHITECTURE_IA64,
+        ARCHITECTURE_PARISC,
+        ARCHITECTURE_PARISC64,
+        ARCHITECTURE_S390,
+        ARCHITECTURE_S390X,
+        ARCHITECTURE_SPARC,
+        ARCHITECTURE_SPARC64,
+        ARCHITECTURE_MIPS,
+        ARCHITECTURE_MIPS_LE,
+        ARCHITECTURE_MIPS64,
+        ARCHITECTURE_MIPS64_LE,
+        ARCHITECTURE_ALPHA,
+        ARCHITECTURE_ARM,
+        ARCHITECTURE_ARM_BE,
+        ARCHITECTURE_ARM64,
+        ARCHITECTURE_ARM64_BE,
+        ARCHITECTURE_SH,
+        ARCHITECTURE_SH64,
+        ARCHITECTURE_M68K,
+        ARCHITECTURE_TILEGX,
+        ARCHITECTURE_CRIS,
+        ARCHITECTURE_NIOS2,
+        ARCHITECTURE_RISCV32,
+        ARCHITECTURE_RISCV64,
+        ARCHITECTURE_CSKY32,
+        ARCHITECTURE_CSKY64,
+        ARCHITECTURE_ARC,
+        ARCHITECTURE_ARC_BE,
+        _ARCHITECTURE_MAX,
+        _ARCHITECTURE_INVALID = -1
+};
+
+int uname_architecture(void);
+
+/*
+ * LIB_ARCH_TUPLE should resolve to the local library path
+ * architecture tuple systemd is built for, according to the Debian
+ * tuple list:
+ *
+ * https://wiki.debian.org/Multiarch/Tuples
+ *
+ * This is used in library search paths that should understand
+ * Debian's paths on all distributions.
+ */
+
+#if defined(__x86_64__)
+#  define native_architecture() ARCHITECTURE_X86_64
+#  if defined(__ILP32__)
+#    define LIB_ARCH_TUPLE "x86_64-linux-gnux32"
+#  else
+#    define LIB_ARCH_TUPLE "x86_64-linux-gnu"
+#  endif
+#  define SECONDARY_ARCHITECTURE ARCHITECTURE_X86
+#elif defined(__i386__)
+#  define native_architecture() ARCHITECTURE_X86
+#  define LIB_ARCH_TUPLE "i386-linux-gnu"
+#elif defined(__powerpc64__)
+#  if __BYTE_ORDER == __BIG_ENDIAN
+#    define native_architecture() ARCHITECTURE_PPC64
+#    define LIB_ARCH_TUPLE "ppc64-linux-gnu"
+#    define SECONDARY_ARCHITECTURE ARCHITECTURE_PPC
+#  else
+#    define native_architecture() ARCHITECTURE_PPC64_LE
+#    define LIB_ARCH_TUPLE  "powerpc64le-linux-gnu"
+#    define SECONDARY_ARCHITECTURE ARCHITECTURE_PPC_LE
+#  endif
+#elif defined(__powerpc__)
+#  if __BYTE_ORDER == __BIG_ENDIAN
+#    define native_architecture() ARCHITECTURE_PPC
+#    if defined(__NO_FPRS__)
+#      define LIB_ARCH_TUPLE "powerpc-linux-gnuspe"
+#    else
+#      define LIB_ARCH_TUPLE "powerpc-linux-gnu"
+#    endif
+#  else
+#    define native_architecture() ARCHITECTURE_PPC_LE
+#    error "Missing LIB_ARCH_TUPLE for PPCLE"
+#  endif
+#elif defined(__ia64__)
+#  define native_architecture() ARCHITECTURE_IA64
+#  define LIB_ARCH_TUPLE "ia64-linux-gnu"
+#elif defined(__hppa64__)
+#  define native_architecture() ARCHITECTURE_PARISC64
+#  error "Missing LIB_ARCH_TUPLE for HPPA64"
+#elif defined(__hppa__)
+#  define native_architecture() ARCHITECTURE_PARISC
+#  define LIB_ARCH_TUPLE "hppa‑linux‑gnu"
+#elif defined(__s390x__)
+#  define native_architecture() ARCHITECTURE_S390X
+#  define LIB_ARCH_TUPLE "s390x-linux-gnu"
+#  define SECONDARY_ARCHITECTURE ARCHITECTURE_S390
+#elif defined(__s390__)
+#  define native_architecture() ARCHITECTURE_S390
+#  define LIB_ARCH_TUPLE "s390-linux-gnu"
+#elif defined(__sparc__) && defined (__arch64__)
+#  define native_architecture() ARCHITECTURE_SPARC64
+#  define LIB_ARCH_TUPLE "sparc64-linux-gnu"
+#elif defined(__sparc__)
+#  define native_architecture() ARCHITECTURE_SPARC
+#  define LIB_ARCH_TUPLE "sparc-linux-gnu"
+#elif defined(__mips64) && defined(__LP64__)
+#  if __BYTE_ORDER == __BIG_ENDIAN
+#    define native_architecture() ARCHITECTURE_MIPS64
+#    define LIB_ARCH_TUPLE "mips64-linux-gnuabi64"
+#  else
+#    define native_architecture() ARCHITECTURE_MIPS64_LE
+#    define LIB_ARCH_TUPLE "mips64el-linux-gnuabi64"
+#  endif
+#elif defined(__mips64)
+#  if __BYTE_ORDER == __BIG_ENDIAN
+#    define native_architecture() ARCHITECTURE_MIPS64
+#    define LIB_ARCH_TUPLE "mips64-linux-gnuabin32"
+#  else
+#    define native_architecture() ARCHITECTURE_MIPS64_LE
+#    define LIB_ARCH_TUPLE "mips64el-linux-gnuabin32"
+#  endif
+#elif defined(__mips__)
+#  if __BYTE_ORDER == __BIG_ENDIAN
+#    define native_architecture() ARCHITECTURE_MIPS
+#    define LIB_ARCH_TUPLE "mips-linux-gnu"
+#  else
+#    define native_architecture() ARCHITECTURE_MIPS_LE
+#    define LIB_ARCH_TUPLE "mipsel-linux-gnu"
+#  endif
+#elif defined(__alpha__)
+#  define native_architecture() ARCHITECTURE_ALPHA
+#  define LIB_ARCH_TUPLE "alpha-linux-gnu"
+#elif defined(__aarch64__)
+#  if __BYTE_ORDER == __BIG_ENDIAN
+#    define native_architecture() ARCHITECTURE_ARM64_BE
+#    define LIB_ARCH_TUPLE "aarch64_be-linux-gnu"
+#  else
+#    define native_architecture() ARCHITECTURE_ARM64
+#    define LIB_ARCH_TUPLE "aarch64-linux-gnu"
+#    define SECONDARY_ARCHITECTURE ARCHITECTURE_ARM
+#  endif
+#elif defined(__arm__)
+#  if __BYTE_ORDER == __BIG_ENDIAN
+#    define native_architecture() ARCHITECTURE_ARM_BE
+#    if defined(__ARM_EABI__)
+#      if defined(__ARM_PCS_VFP)
+#        define LIB_ARCH_TUPLE "armeb-linux-gnueabihf"
+#      else
+#        define LIB_ARCH_TUPLE "armeb-linux-gnueabi"
+#      endif
+#    else
+#      define LIB_ARCH_TUPLE "armeb-linux-gnu"
+#    endif
+#  else
+#    define native_architecture() ARCHITECTURE_ARM
+#    if defined(__ARM_EABI__)
+#      if defined(__ARM_PCS_VFP)
+#        define LIB_ARCH_TUPLE "arm-linux-gnueabihf"
+#      else
+#        define LIB_ARCH_TUPLE "arm-linux-gnueabi"
+#      endif
+#    else
+#      define LIB_ARCH_TUPLE "arm-linux-gnu"
+#    endif
+#  endif
+#elif defined(__sh64__)
+#  define native_architecture() ARCHITECTURE_SH64
+#  error "Missing LIB_ARCH_TUPLE for SH64"
+#elif defined(__sh__)
+#  define native_architecture() ARCHITECTURE_SH
+#  if defined(__SH1__)
+#    define LIB_ARCH_TUPLE "sh1-linux-gnu"
+#  elif defined(__SH2__)
+#    define LIB_ARCH_TUPLE "sh2-linux-gnu"
+#  elif defined(__SH2A__)
+#    define LIB_ARCH_TUPLE "sh2a-linux-gnu"
+#  elif defined(__SH2E__)
+#    define LIB_ARCH_TUPLE "sh2e-linux-gnu"
+#  elif defined(__SH3__)
+#    define LIB_ARCH_TUPLE "sh3-linux-gnu"
+#  elif defined(__SH3E__)
+#    define LIB_ARCH_TUPLE "sh3e-linux-gnu"
+#  elif defined(__SH4__) && !defined(__SH4A__)
+#    define LIB_ARCH_TUPLE "sh4-linux-gnu"
+#  elif defined(__SH4A__)
+#    define LIB_ARCH_TUPLE "sh4a-linux-gnu"
+#  endif
+#elif defined(__m68k__)
+#  define native_architecture() ARCHITECTURE_M68K
+#  define LIB_ARCH_TUPLE "m68k-linux-gnu"
+#elif defined(__tilegx__)
+#  define native_architecture() ARCHITECTURE_TILEGX
+#  define LIB_ARCH_TUPLE "tilegx-linux-gnu"
+#elif defined(__cris__)
+#  define native_architecture() ARCHITECTURE_CRIS
+#  error "Missing LIB_ARCH_TUPLE for CRIS"
+#elif defined(__nios2__)
+#  define native_architecture() ARCHITECTURE_NIOS2
+#  define LIB_ARCH_TUPLE "nios2-linux-gnu"
+#elif defined(__riscv__) || defined(__riscv)
+        /* __riscv__ is obsolete, remove in 2018 */
+#  if __SIZEOF_POINTER__ == 4
+#    define native_architecture() ARCHITECTURE_RISCV32
+#    define LIB_ARCH_TUPLE "riscv32-linux-gnu"
+#  elif __SIZEOF_POINTER__ == 8
+#    define native_architecture() ARCHITECTURE_RISCV64
+#    define LIB_ARCH_TUPLE "riscv64-linux-gnu"
+#  else
+#    error "Unrecognized riscv architecture variant"
+#  endif
+#elif defined(__csky__) || defined(__csky)
+#  if __SIZEOF_POINTER__ == 4
+#    define native_architecture() ARCHITECTURE_CSKY32
+#    define LIB_ARCH_TUPLE "csky-linux-gnu"
+#  else
+#    error "Unrecognized csky architecture variant"
+#  endif
+#elif defined(__arc__)
+#  if __BYTE_ORDER == __BIG_ENDIAN
+#    define native_architecture() ARCHITECTURE_ARC_BE
+#    define LIB_ARCH_TUPLE "arceb-linux"
+#  else
+#    define native_architecture() ARCHITECTURE_ARC
+#    define LIB_ARCH_TUPLE "arc-linux"
+#  endif
+#else
+#  error "Please register your architecture here!"
+#endif
+
+const char *architecture_to_string(int a) _const_;
+int architecture_from_string(const char *s) _pure_;

+ 25 - 0
recipes-core/systemd/systemd_246.6.bbappend

@@ -0,0 +1,25 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI_append_csky = "file://src/basic/architecture.h \
+                       file://src/basic/architecture.c \
+					   "
+
+S = "${WORKDIR}/git"
+
+do_configure_prepend_csky() {
+    echo "THISDIR= ${THISDIR}/${PN}"
+	echo "PN=${PN}"
+	echo "PV=${PV}"
+	if [ -d "${WORKDIR}/src" -a -d "${S}" ]; then
+        cp -rf ${WORKDIR}/src ${S}/
+    fi  
+}
+
+pkg_postinst_udev-hwdb () {
+	if test -n "$D"; then
+      	echo	"$INTERCEPT_DIR/postinst_intercept update_udev_hwdb ${PKG} mlprefix=${MLPREFIX} binprefix=${MLPREFIX} rootlibexecdir="${rootlibexecdir}" PREFERRED_PROVIDER_udev="${PREFERRED_PROVIDER_udev}""
+	else
+		udevadm hwdb --update
+	fi
+}
+

+ 27 - 0
recipes-devtools/csky-tools/csky-fesvr.bb

@@ -0,0 +1,27 @@
+SUMMARY = "RISC-V Front-end Server"
+DESCRIPTION = "RISC-V Front-end Server"
+LICENSE = "GPLv2+"
+
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe"
+
+SRCREV = "8d108a0a647901550d95925549337c2c3aec9ac8"
+SRC_URI = "git://github.com/riscv/riscv-fesvr.git \
+           file://fesvr-makefile.patch"
+
+inherit autotools gettext cross-canadian
+
+BBCLASSEXTEND = "native nativesdk"
+
+S = "${WORKDIR}/git"
+
+do_configure_prepend () {
+        if [ ! -e ${S}/acinclude.m4 ]; then
+                cp ${S}/aclocal.m4 ${S}/acinclude.m4
+        fi
+}
+
+do_install_append () {
+        # Make install doesn't properly install these
+        oe_libinstall -so libfesvr ${D}${libdir}
+}
+COMPATIBLE_HOST_class-target = "(csky).*-linux"

+ 25 - 0
recipes-devtools/csky-tools/csky-spike.bb

@@ -0,0 +1,25 @@
+SUMMARY = "RISC-V Spike ISA Simulator"
+DESCRIPTION = "RISC-V Spike ISA Simulator"
+LICENSE = "GPLv2+"
+
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe"
+
+SRCREV = "65c8ac48af16235097084b413c10c7bff576b331"
+SRC_URI = "git://github.com/riscv/riscv-isa-sim.git \
+           file://spike-makefile.patch"
+
+DEPENDS = "riscv-fesvr dtc-native"
+RDEPENDS_nativesdk-riscv-spike = "nativesdk-riscv-fesvr"
+
+inherit autotools cross-canadian
+
+S = "${WORKDIR}/git"
+
+do_configure_prepend () {
+	touch ${S}/softfloat/softfloat.ac
+        if [ ! -e ${S}/acinclude.m4 ]; then
+                cp ${S}/aclocal.m4 ${S}/acinclude.m4
+        fi
+}
+BBCLASSEXTEND = "native nativesdk"
+COMPATIBLE_HOST_class-target = "(csky).*-linux"

+ 12 - 0
recipes-devtools/csky-tools/files/fesvr-makefile.patch

@@ -0,0 +1,12 @@
+diff -rupN git/Makefile.in git-new/Makefile.in
+--- git/Makefile.in	2015-09-17 16:31:32.061178794 -0700
++++ git-new/Makefile.in	2015-09-17 16:42:54.166647463 -0700
+@@ -99,7 +99,7 @@ comma := ,
+ LD            := $(CXX)
+ LDFLAGS       := @LDFLAGS@
+ LIBS          := @LIBS@
+-LINK          := $(LD) -L. $(LDFLAGS) -Wl,-rpath,$(install_libs_dir) $(patsubst -L%,-Wl$(comma)-rpath$(comma)%,$(filter -L%,$(LDFLAGS)))
++LINK          := $(LD) -L. $(LDFLAGS)
+ 
+ # Library creation
+ 

+ 12 - 0
recipes-devtools/csky-tools/files/spike-makefile.patch

@@ -0,0 +1,12 @@
+diff -rupN git/Makefile.in git-new/Makefile.in
+--- git/Makefile.in	2015-09-17 01:12:32.219540348 -0700
++++ git-new/Makefile.in	2015-09-26 18:55:54.162112314 -0700
+@@ -99,7 +99,7 @@ comma := ,
+ LD            := $(CXX)
+ LDFLAGS       := @LDFLAGS@
+ LIBS          := @LIBS@
+-LINK          := $(LD) -L. $(LDFLAGS) -Wl,-rpath,$(install_libs_dir) $(patsubst -L%,-Wl$(comma)-rpath$(comma)%,$(filter -L%,$(LDFLAGS)))
++LINK          := $(LD) -L. $(LDFLAGS)
+ 
+ # Library creation
+ 

+ 55 - 0
recipes-devtools/dpkg/dpkg/data/cputable

@@ -0,0 +1,55 @@
+# Version=1.0
+#
+# This file contains the table of known CPU names.
+#
+# Architecture names are formed as a combination of the system name
+# (from ostable) and CPU name (from this table) after mapping from
+# the Debian arch tuple (from tupletable).
+#
+# - Column 1 is the Debian name for the CPU, used to form the cpu part in
+#   the Debian arch tuple.
+# - Column 2 is the GNU name for the CPU, used to output build, host and
+#   target variables in ‘dpkg-architecture’.
+# - Column 3 is an extended regular expression used to match against the
+#   CPU part of the output of the GNU config.guess script.
+# - Column 4 is the size (in bits) of pointers.
+# - Column 5 is the endianness (byte ordering in numbers).
+#
+# <Debian name>	<GNU name>	<config.guess regex>	<Bits>	<Endianness>
+i386		i686		(i[34567]86|pentium)	32	little
+ia64		ia64		ia64			64	little
+alpha		alpha		alpha.*			64	little
+amd64		x86_64		(amd64|x86_64)		64	little
+armeb		armeb		arm.*b			32	big
+arm		arm		arm.*			32	little
+arm64		aarch64		aarch64			64	little
+avr32		avr32		avr32			32	big
+hppa		hppa		hppa.*			32	big
+m32r		m32r		m32r			32	big
+m68k		m68k		m68k			32	big
+mips		mips		mips(eb)?		32	big
+mipsel		mipsel		mipsel			32	little
+mipsr6		mipsisa32r6	mipsisa32r6		32	big
+mipsr6el	mipsisa32r6el	mipsisa32r6el		32	little
+mips64		mips64		mips64			64	big
+mips64el	mips64el	mips64el		64	little
+mips64r6	mipsisa64r6	mipsisa64r6		64	big
+mips64r6el	mipsisa64r6el	mipsisa64r6el		64	little
+nios2		nios2		nios2			32	little
+or1k		or1k		or1k			32	big
+powerpc		powerpc		(powerpc|ppc)		32	big
+powerpcel	powerpcle	powerpcle		32	little
+ppc64		powerpc64	(powerpc|ppc)64		64	big
+ppc64el		powerpc64le	powerpc64le		64	little
+csky		csky		csky			32	little
+riscv32		riscv32		riscv32			32	little
+riscv64		riscv64		riscv64			64	little
+s390		s390		s390			32	big
+s390x		s390x		s390x			64	big
+sh3		sh3		sh3			32	little
+sh3eb		sh3eb		sh3eb			32	big
+sh4		sh4		sh4			32	little
+sh4eb		sh4eb		sh4eb			32	big
+sparc		sparc		sparc			32	big
+sparc64		sparc64		sparc64			64	big
+tilegx		tilegx		tilegx			64	little

+ 16 - 0
recipes-devtools/dpkg/dpkg_1.20.5.bbappend

@@ -0,0 +1,16 @@
+
+SUMMARY = "Package maintenance system from Debian"
+LICENSE = "GPLv2.0+"
+SECTION = "base"
+
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI_append_csky = "file://data/cputable \
+           "
+S = "${WORKDIR}/git"
+
+do_configure_prepend_csky() {
+	if [ -d "${WORKDIR}/data" -a -d "${S}" ]; then
+	    cp -rf ${WORKDIR}/data ${S}/
+	fi
+}

+ 9 - 0
recipes-devtools/elfutils/elfutils_0.181.bbappend

@@ -0,0 +1,9 @@
+SUMMARY = "Utilities and libraries for handling compiled object files"
+HOMEPAGE = "https://sourceware.org/elfutils"
+SECTION = "base"
+LICENSE = "GPLv2 & LGPLv3+ & GPLv3+"
+
+CFLAGS += " -Wno-error"
+CPPFLAGS += "-Wno-error"
+
+EXTRA_OECONF_append_csky = " --disable-textrelcheck"

+ 50 - 0
recipes-devtools/elfutils/files/0001-dso-link-change.patch

@@ -0,0 +1,50 @@
+From ec9a7742734aae5417c0ebbffce66ac353e6cae7 Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Tue, 15 Aug 2017 17:10:57 +0800
+Subject: [PATCH] dso link change
+
+Upstream-Status: Pending
+
+This patch makes the link to the dependencies of libdw explicit, as
+recent ld no longer implicitly links them. See
+http://lists.fedoraproject.org/pipermail/devel/2010-March/133601.html
+as a similar example of the error message you can encounter without this
+patch, and https://fedoraproject.org/wiki/UnderstandingDSOLinkChange and
+https://fedoraproject.org/wiki/Features/ChangeInImplicitDSOLinking for
+more details.
+
+Rebase to 0.170
+
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+
+---
+ src/Makefile.am   | 2 +-
+ tests/Makefile.am | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/Makefile.am b/src/Makefile.am
+index e462e7d..ea1215b 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -45,7 +45,7 @@ libdw = ../libdw/libdw.a -lz $(zip_LIBS) $(libelf) -ldl -lpthread
+ libelf = ../libelf/libelf.a -lz
+ else
+ libasm = ../libasm/libasm.so
+-libdw = ../libdw/libdw.so
++libdw = ../libdw/libdw.so $(zip_LIBS) $(libelf) $(libebl) -ldl
+ libelf = ../libelf/libelf.so
+ endif
+ libebl = ../libebl/libebl.a ../backends/libebl_backends.a ../libcpu/libcpu.a
+diff --git a/tests/Makefile.am b/tests/Makefile.am
+index eab4ae6..f59a01f 100644
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -516,7 +516,7 @@ libdw = ../libdw/libdw.a -lz $(zip_LIBS) $(libelf) $(libebl) -ldl -lpthread
+ libelf = ../libelf/libelf.a -lz
+ libasm = ../libasm/libasm.a
+ else
+-libdw = ../libdw/libdw.so
++libdw = ../libdw/libdw.so $(zip_LIBS) $(libelf) $(libebl) -ldl
+ libelf = ../libelf/libelf.so
+ libasm = ../libasm/libasm.so
+ endif

+ 36 - 0
recipes-devtools/elfutils/files/0001-libasm-may-link-with-libbz2-if-found.patch

@@ -0,0 +1,36 @@
+From 8e5fff8b1d819e0870fb22b27950bb5f10c7a272 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 4 Oct 2017 22:30:46 -0700
+Subject: [PATCH] libasm may link with libbz2 if found
+
+This can fail to link binaries like objdump
+where indirect libraries may be not found by linker
+
+| /mnt/a/oe/build/tmp/work/riscv64-bec-linux/elfutils/0.170-r0/recipe-sysroot/usr/lib/libbz2.so.1: error adding symbols: DSO missing from command line
+| collect2: error: ld returned 1 exit status
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+---
+ src/Makefile.am | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/Makefile.am b/src/Makefile.am
+index ea1215b..13d9bda 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -40,11 +40,11 @@ EXTRA_DIST += make-debug-archive.in
+ CLEANFILES += make-debug-archive
+ 
+ if BUILD_STATIC
+-libasm = ../libasm/libasm.a
++libasm = ../libasm/libasm.a $(zip_LIBS)
+ libdw = ../libdw/libdw.a -lz $(zip_LIBS) $(libelf) -ldl -lpthread
+ libelf = ../libelf/libelf.a -lz
+ else
+-libasm = ../libasm/libasm.so
++libasm = ../libasm/libasm.so $(zip_LIBS)
+ libdw = ../libdw/libdw.so $(zip_LIBS) $(libelf) $(libebl) -ldl
+ libelf = ../libelf/libelf.so
+ endif

+ 44 - 0
recipes-devtools/elfutils/files/0001-libelf-elf_end.c-check-data_list.data.d.d_buf-before.patch

@@ -0,0 +1,44 @@
+From e571cbd0c20085ec71969971f19280b5de95cfb7 Mon Sep 17 00:00:00 2001
+From: Robert Yang <liezhi.yang@windriver.com>
+Date: Thu, 16 Aug 2018 09:58:26 +0800
+Subject: [PATCH] libelf/elf_end.c: check data_list.data.d.d_buf before free it
+
+The one which actually saves the data is data_list.data.d.d_buf, so check it
+before free rawdata_base.
+
+This can fix a segmentation fault when prelink libqb_1.0.3:
+prelink: /usr/lib/libqb.so.0.18.2: Symbol section index outside of section numbers
+
+The segmentation fault happens when prelink call elf_end().
+
+Upstream-Status: Submitted [https://sourceware.org/ml/elfutils-devel/2018-q3/msg00085.html]
+
+Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
+
+---
+ libelf/elf_end.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/libelf/elf_end.c b/libelf/elf_end.c
+index 160f0b8..5280a70 100644
+--- a/libelf/elf_end.c
++++ b/libelf/elf_end.c
+@@ -160,14 +160,16 @@ elf_end (Elf *elf)
+ 		   architecture doesn't require overly stringent
+ 		   alignment the raw data buffer is the same as the
+ 		   one used for presenting to the caller.  */
+-		if (scn->data_base != scn->rawdata_base)
++		if ((scn->data_base != scn->rawdata_base)
++		    && (scn->data_list.data.d.d_buf != NULL))
+ 		  free (scn->data_base);
+ 
+ 		/* The section data is allocated if we couldn't mmap
+ 		   the file.  Or if we had to decompress.  */
+-		if (elf->map_address == NULL
++		if ((elf->map_address == NULL
+ 		    || scn->rawdata_base == scn->zdata_base
+ 		    || (scn->flags & ELF_F_MALLOCED) != 0)
++		    && (scn->data_list.data.d.d_buf != NULL))
+ 		  free (scn->rawdata_base);
+ 
+ 		/* Free the list of data buffers for the section.

+ 124 - 0
recipes-devtools/elfutils/files/0001-musl-obstack-fts.patch

@@ -0,0 +1,124 @@
+From 1a62bb8e8f2cb0f180c749946a48114e8f391b55 Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Fri, 23 Aug 2019 10:17:25 +0800
+Subject: [PATCH] musl-obstack-fts
+
+Look for libfts and libobstack during configure, these
+libraries are external to libc when using musl, whereas
+on glibc these libraries are provided in libc itself.
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Upstream-Status: Inappropriate [workaround for musl]
+
+Rebase to 0.177
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+
+---
+ configure.ac      | 54 +++++++++++++++++++++++++++++++++++++++++++++++
+ libdw/Makefile.am |  2 +-
+ src/Makefile.am   |  6 +++---
+ 3 files changed, 58 insertions(+), 4 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index ab9c751..b057d86 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -538,6 +538,60 @@ else
+ fi
+ AC_SUBST([argp_LDADD])
+ 
++dnl Check if we have fts available from our libc
++AC_LINK_IFELSE(
++	[AC_LANG_PROGRAM(
++		[#if !defined(__x86_64__)
++		#undef  _FILE_OFFSET_BITS
++		#define _FILE_OFFSET_BITS 32
++		#endif
++		#include <fts.h>],
++		[FTS* fts = 0; return fts_close(fts); return 0;]
++		)],
++	[libc_has_fts="true"],
++	[libc_has_fts="false"]
++)
++
++dnl If our libc doesn't provide fts, then test for libfts
++if test "$libc_has_fts" = "false" ; then
++	AC_MSG_WARN("libc does not have fts")
++	AC_CHECK_LIB([fts], [fts_close], [have_fts="true"], [have_fts="false"])
++
++	if test "$have_fts" = "false"; then
++		AC_MSG_ERROR("no libfts found")
++	else
++		fts_LDADD="-lfts"
++	fi
++else
++	fts_LDADD=""
++fi
++AC_SUBST([fts_LDADD])
++
++dnl Check if we have obstack available from our libc
++AC_LINK_IFELSE(
++	[AC_LANG_PROGRAM(
++		[#include <obstack.h>],
++		[_obstack_begin(0, 0, 0, NULL, NULL); return 0;]
++		)],
++	[libc_has_obstack="true"],
++	[libc_has_obstack="false"]
++)
++
++dnl If our libc doesn't provide obstack, then test for libobstack
++if test "$libc_has_obstack" = "false" ; then
++	AC_MSG_WARN("libc does not have obstack")
++	AC_CHECK_LIB([obstack], [_obstack_begin], [have_obstack="true"], [have_obstack="false"])
++
++	if test "$have_obstack" = "false"; then
++		AC_MSG_ERROR("no libobstack found")
++	else
++		obstack_LDADD="-lobstack"
++	fi
++else
++	obstack_LDADD=""
++fi
++AC_SUBST([obstack_LDADD])
++
+ dnl The directories with content.
+ 
+ dnl Documentation.
+diff --git a/libdw/Makefile.am b/libdw/Makefile.am
+index 33b5838..ff92e02 100644
+--- a/libdw/Makefile.am
++++ b/libdw/Makefile.am
+@@ -109,7 +109,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a ../backends/libebl_backends_pic.a \
+ 		../libcpu/libcpu_pic.a libdw_pic.a ../libdwelf/libdwelf_pic.a \
+ 		../libdwfl/libdwfl_pic.a
+ libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
+-libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS) -pthread
++libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(fts_LDADD) $(zip_LIBS) -pthread
+ libdw_so_SOURCES =
+ libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
+ 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
+diff --git a/src/Makefile.am b/src/Makefile.am
+index 13d9bda..d5a4f7d 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -69,7 +69,7 @@ ar_no_Wstack_usage = yes
+ unstrip_no_Wstack_usage = yes
+ 
+ readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD)
+-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \
++nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(obstack_LDADD) \
+ 	   $(demanglelib)
+ size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+ strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+@@ -78,9 +78,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+ objdump_LDADD  = $(libasm) $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+-ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LDADD)
+ strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
+-ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
++ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LDADD)
+ unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
+ stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib)
+ elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)

+ 32 - 0
recipes-devtools/elfutils/files/0001-ppc_initreg.c-Incliude-asm-ptrace.h-for-pt_regs-defi.patch

@@ -0,0 +1,32 @@
+From 2e2232d0935bf8ef6e66ebffba3be68a73b5b3e5 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 8 Sep 2019 15:57:59 -0700
+Subject: [PATCH] ppc_initreg.c: Incliude asm/ptrace.h for pt_regs definition
+
+Fixes
+| ../../elfutils-0.176/backends/ppc_initreg.c:79:22: error: field 'r' has incomplete type
+|       struct pt_regs r;
+|                      ^
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ backends/ppc_initreg.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/backends/ppc_initreg.c b/backends/ppc_initreg.c
+index 0e0d359..e5cca7e 100644
+--- a/backends/ppc_initreg.c
++++ b/backends/ppc_initreg.c
+@@ -33,6 +33,7 @@
+ #include <stdlib.h>
+ #if defined(__powerpc__) && defined(__linux__)
+ # include <sys/ptrace.h>
++# include <asm/ptrace.h>
+ # include <sys/user.h>
+ #endif
+ 
+-- 
+2.23.0
+

+ 73 - 0
recipes-devtools/elfutils/files/0001-skip-the-test-when-gcc-not-deployed.patch

@@ -0,0 +1,73 @@
+From e82a055f85e398cb03a4eaf5faf351a3a1f19344 Mon Sep 17 00:00:00 2001
+From: Mingli Yu <Mingli.Yu@windriver.com>
+Date: Tue, 21 May 2019 15:20:34 +0800
+Subject: [PATCH v2] skip the test when gcc not deployed
+
+Skip the tests which depend on gcc when
+gcc not deployed.
+
+Upstream-Status: Submitted[https://sourceware.org/ml/elfutils-devel/2019-q2/msg00091.html]
+
+Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
+---
+ tests/run-disasm-x86-64.sh | 2 ++
+ tests/run-disasm-x86.sh    | 2 ++
+ tests/run-strip-g.sh       | 2 ++
+ tests/run-strip-nothing.sh | 2 ++
+ 4 files changed, 8 insertions(+)
+
+diff --git a/tests/run-disasm-x86-64.sh b/tests/run-disasm-x86-64.sh
+index a6be62b..c3ef238 100755
+--- a/tests/run-disasm-x86-64.sh
++++ b/tests/run-disasm-x86-64.sh
+@@ -22,6 +22,8 @@ case "`uname -m`" in
+   x86_64)
+     tempfiles testfile45.o
+     testfiles testfile45.S testfile45.expect
++    # skip the case if no gcc deployed
++    which gcc || exit 77
+     gcc -m64 -c -o testfile45.o testfile45.S
+     testrun_compare ${abs_top_builddir}/src/objdump -d testfile45.o < testfile45.expect
+     ;;
+diff --git a/tests/run-disasm-x86.sh b/tests/run-disasm-x86.sh
+index 28a3df7..544fc28 100755
+--- a/tests/run-disasm-x86.sh
++++ b/tests/run-disasm-x86.sh
+@@ -22,6 +22,8 @@ case "`uname -m`" in
+   x86_64 | i?86 )
+     tempfiles testfile44.o
+     testfiles testfile44.S testfile44.expect
++    # skip the case if no gcc deployed
++    which gcc || exit 77
+     gcc -m32 -c -o testfile44.o testfile44.S
+     testrun_compare ${abs_top_builddir}/src/objdump -d testfile44.o < testfile44.expect
+     ;;
+diff --git a/tests/run-strip-g.sh b/tests/run-strip-g.sh
+index 1303819..a943dec 100755
+--- a/tests/run-strip-g.sh
++++ b/tests/run-strip-g.sh
+@@ -24,6 +24,8 @@
+ 
+ tempfiles a.out strip.out debug.out readelf.out
+ 
++# skip the test if gcc deployed
++which gcc || exit 77
+ echo Create debug a.out.
+ echo "int main() { return 1; }" | gcc -g -xc -
+ 
+diff --git a/tests/run-strip-nothing.sh b/tests/run-strip-nothing.sh
+index 914fdfb..d03f734 100755
+--- a/tests/run-strip-nothing.sh
++++ b/tests/run-strip-nothing.sh
+@@ -22,6 +22,8 @@
+ 
+ tempfiles a.out strip.out debug.out
+ 
++# skip the case if no gcc deployed
++which gcc || exit 77
+ # Create no-debug a.out.
+ echo "int main() { return 1; }" | gcc -s -xc -
+ 
+-- 
+2.7.4
+

+ 28 - 0
recipes-devtools/elfutils/files/0001-tests-Makefile.am-compile-test_nlist-with-standard-C.patch

@@ -0,0 +1,28 @@
+From fa265ff686cb60e19aa607bda3752b6b2ee87a14 Mon Sep 17 00:00:00 2001
+From: Alexander Kanavin <alex.kanavin@gmail.com>
+Date: Tue, 23 Jun 2020 07:49:35 +0000
+Subject: [PATCH] tests/Makefile.am: compile test_nlist with standard CFLAGS
+
+Otherwise, it will contain build paths in it and wont
+be reproducible.
+
+Upstream-Status: Inappropriate [oe-core specific]
+Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
+
+---
+ tests/Makefile.am | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tests/Makefile.am b/tests/Makefile.am
+index 05fc9b4..11de0fc 100644
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -92,7 +92,7 @@ endif
+ test-nlist$(EXEEXT): test-nlist.c
+ 	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ 	  $(AM_CPPFLAGS) $(CPPFLAGS) \
+-	  $(test_nlist_CFLAGS) $(GCOV_FLAGS) -o $@ $< $(test_nlist_LDADD)
++	  $(CFLAGS) $(GCOV_FLAGS) -o $@ $< $(test_nlist_LDADD)
+ 
+ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \
+ 	update1 update2 update3 update4 \

+ 40 - 0
recipes-devtools/elfutils/files/0002-Fix-elf_cvt_gunhash-if-dest-and-src-are-same.patch

@@ -0,0 +1,40 @@
+From f8e4118b60a9b54950437006a82b4047f38f5347 Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Tue, 15 Aug 2017 17:13:59 +0800
+Subject: [PATCH] Fix elf_cvt_gunhash if dest and src are same.
+
+Upstream-Status: Pending
+
+The 'dest' and 'src' can be same, we need to save the value of src32[2]
+before swaping it.
+
+Signed-off-by: Baoshan Pang <BaoShan.Pang@windriver.com>
+
+Rebase to 0.170
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+
+---
+ libelf/gnuhash_xlate.h | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/libelf/gnuhash_xlate.h b/libelf/gnuhash_xlate.h
+index 6faf113..04d9ca1 100644
+--- a/libelf/gnuhash_xlate.h
++++ b/libelf/gnuhash_xlate.h
+@@ -40,6 +40,7 @@ elf_cvt_gnuhash (void *dest, const void *src, size_t len, int encode)
+      words.  We must detangle them here.   */
+   Elf32_Word *dest32 = dest;
+   const Elf32_Word *src32 = src;
++  Elf32_Word save_src32_2 = src32[2]; // dest could be equal to src
+ 
+   /* First four control words, 32 bits.  */
+   for (unsigned int cnt = 0; cnt < 4; ++cnt)
+@@ -50,7 +51,7 @@ elf_cvt_gnuhash (void *dest, const void *src, size_t len, int encode)
+       len -= 4;
+     }
+ 
+-  Elf32_Word bitmask_words = encode ? src32[2] : dest32[2];
++  Elf32_Word bitmask_words = encode ? save_src32_2 : dest32[2];
+ 
+   /* Now the 64 bit words.  */
+   Elf64_Xword *dest64 = (Elf64_Xword *) &dest32[4];

+ 142 - 0
recipes-devtools/elfutils/files/0002-musl-libs.patch

@@ -0,0 +1,142 @@
+From 2e1f8ca0b67c1d1991c14d509938c347e09bae94 Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Fri, 23 Aug 2019 10:18:47 +0800
+Subject: [PATCH] musl-libs
+
+Collection of fixes needed to compile libelf and other libraries
+provided by elfutils for musl targets
+
+error is glibc specific API, so this patch will mostly not accepted
+upstream given that elfutils has been closely tied to glibc
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Upstream-Status: Inappropriate [workaround for musl]
+
+Rebase to 0.177
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+
+---
+ lib/error.h                    | 27 +++++++++++++++++++++++++++
+ lib/fixedsizehash.h            |  1 -
+ lib/libeu.h                    |  1 +
+ libdwfl/dwfl_error.c           |  9 +++++++++
+ libdwfl/linux-kernel-modules.c |  1 +
+ libelf/elf.h                   |  9 ++++++---
+ 6 files changed, 44 insertions(+), 4 deletions(-)
+ create mode 100644 lib/error.h
+
+diff --git a/lib/error.h b/lib/error.h
+new file mode 100644
+index 0000000..ef06827
+--- /dev/null
++++ b/lib/error.h
+@@ -0,0 +1,27 @@
++#ifndef _ERROR_H_
++#define _ERROR_H_
++
++#include <stdarg.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <errno.h>
++
++static unsigned int error_message_count = 0;
++
++static inline void error(int status, int errnum, const char* format, ...)
++{
++	va_list ap;
++	fprintf(stderr, "%s: ", program_invocation_name);
++	va_start(ap, format);
++	vfprintf(stderr, format, ap);
++	va_end(ap);
++	if (errnum)
++		fprintf(stderr, ": %s", strerror(errnum));
++	fprintf(stderr, "\n");
++	error_message_count++;
++	if (status)
++		exit(status);
++}
++
++#endif	/* _ERROR_H_ */
+diff --git a/lib/fixedsizehash.h b/lib/fixedsizehash.h
+index dac2a5f..43016fc 100644
+--- a/lib/fixedsizehash.h
++++ b/lib/fixedsizehash.h
+@@ -30,7 +30,6 @@
+ #include <errno.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <sys/cdefs.h>
+ 
+ #include <system.h>
+ 
+diff --git a/lib/libeu.h b/lib/libeu.h
+index ecb4d01..edc85e3 100644
+--- a/lib/libeu.h
++++ b/lib/libeu.h
+@@ -29,6 +29,7 @@
+ #ifndef LIBEU_H
+ #define LIBEU_H
+ 
++#include "system.h"
+ #include <stddef.h>
+ #include <stdint.h>
+ 
+diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
+index 7bcf61c..11dcc8b 100644
+--- a/libdwfl/dwfl_error.c
++++ b/libdwfl/dwfl_error.c
+@@ -154,7 +154,16 @@ dwfl_errmsg (int error)
+   switch (error &~ 0xffff)
+     {
+     case OTHER_ERROR (ERRNO):
++#if defined(__GLIBC__)
+       return strerror_r (error & 0xffff, "bad", 0);
++#else
++      {
++        static __thread char buf[128] = "";
++        if (strerror_r (error & 0xffff, buf, sizeof(buf)) == 0)
++          return buf;
++      }
++      return "strerror_r() failed";
++#endif
+     case OTHER_ERROR (LIBELF):
+       return elf_errmsg (error & 0xffff);
+     case OTHER_ERROR (LIBDW):
+diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
+index 0434f1e..5afaee8 100644
+--- a/libdwfl/linux-kernel-modules.c
++++ b/libdwfl/linux-kernel-modules.c
+@@ -50,6 +50,7 @@
+ #include <sys/utsname.h>
+ #include <fcntl.h>
+ #include <unistd.h>
++#include "system.h"
+ 
+ /* If fts.h is included before config.h, its indirect inclusions may not
+    give us the right LFS aliases of these functions, so map them manually.  */
+diff --git a/libelf/elf.h b/libelf/elf.h
+index 197b557..8e5b94c 100644
+--- a/libelf/elf.h
++++ b/libelf/elf.h
+@@ -21,7 +21,9 @@
+ 
+ #include <features.h>
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ 
+ /* Standard ELF types.  */
+ 
+@@ -4103,6 +4105,7 @@ enum
+ #define R_ARC_TLS_LE_S9		0x4a
+ #define R_ARC_TLS_LE_32		0x4b
+ 
+-__END_DECLS
+-
++#ifdef __cplusplus
++}
++#endif
+ #endif	/* elf.h */

+ 38 - 0
recipes-devtools/elfutils/files/0003-fixheadercheck.patch

@@ -0,0 +1,38 @@
+From dd7c8c730457def5f62ebd43022b2f06df8c6ed9 Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Tue, 15 Aug 2017 17:17:20 +0800
+Subject: [PATCH] fixheadercheck
+
+For some binaries we can get a invalid section alignment, for example if
+sh_align = 1 and sh_addralign is 0. In the case of a zero size section
+like
+".note.GNU-stack", this is irrelavent as far as I can tell and we
+shouldn't
+error in this case.
+
+RP 2014/6/11
+
+Upstream-Status: Pending
+
+Rebase to 0.170
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+
+---
+ libelf/elf32_updatenull.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c
+index 3e9ef61..5351518 100644
+--- a/libelf/elf32_updatenull.c
++++ b/libelf/elf32_updatenull.c
+@@ -339,8 +339,8 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
+ 		     we test for the alignment of the section being large
+ 		     enough for the largest alignment required by a data
+ 		     block.  */
+-		  if (unlikely (! powerof2 (shdr->sh_addralign))
+-		      || unlikely ((shdr->sh_addralign ?: 1) < sh_align))
++		  if (shdr->sh_size && (unlikely (! powerof2 (shdr->sh_addralign))
++		      || unlikely ((shdr->sh_addralign ?: 1) < sh_align)))
+ 		    {
+ 		      __libelf_seterrno (ELF_E_INVALID_ALIGN);
+ 		      return -1;

+ 163 - 0
recipes-devtools/elfutils/files/0003-musl-utils.patch

@@ -0,0 +1,163 @@
+From 9b237f19f82d5ab1e0702637fece1866b1ef6681 Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Fri, 23 Aug 2019 10:19:48 +0800
+Subject: [PATCH] musl-utils
+
+Provide missing defines which otherwise are available on glibc system headers
+
+Alter the error API to match posix version
+use qsort instead of qsort_r which is glibc specific API
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Upstream-Status: Inappropriate [workaround for musl]
+
+Rebase to 0.177
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+
+---
+ src/arlib.h       |  6 ++++++
+ src/elfcompress.c |  7 +++++++
+ src/readelf.c     | 20 ++++++++++++--------
+ src/strip.c       |  7 +++++++
+ src/unstrip.c     |  9 +++++++++
+ 5 files changed, 41 insertions(+), 8 deletions(-)
+
+diff --git a/src/arlib.h b/src/arlib.h
+index e117166..8326f6c 100644
+--- a/src/arlib.h
++++ b/src/arlib.h
+@@ -29,6 +29,12 @@
+ #include <stdint.h>
+ #include <sys/types.h>
+ 
++#if !defined(ALLPERMS)
++# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
++#endif
++#if !defined(DEFFILEMODE)
++# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/
++#endif
+ 
+ /* State of -D/-U flags.  */
+ extern bool arlib_deterministic_output;
+diff --git a/src/elfcompress.c b/src/elfcompress.c
+index 6ba6af4..0c7674b 100644
+--- a/src/elfcompress.c
++++ b/src/elfcompress.c
+@@ -37,6 +37,13 @@
+ #include "libeu.h"
+ #include "printversion.h"
+ 
++#if !defined(ALLPERMS)
++# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) /* 07777 */
++#endif
++#if !defined(FNM_EXTMATCH)
++# define FNM_EXTMATCH (0)
++#endif
++
+ /* Name and version of program.  */
+ ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
+ 
+diff --git a/src/readelf.c b/src/readelf.c
+index 685d0b1..a842b10 100644
+--- a/src/readelf.c
++++ b/src/readelf.c
+@@ -4829,10 +4829,11 @@ listptr_base (struct listptr *p)
+   return cudie_base (&cu);
+ }
+ 
++static const char *listptr_name;
++
+ static int
+-compare_listptr (const void *a, const void *b, void *arg)
++compare_listptr (const void *a, const void *b)
+ {
+-  const char *name = arg;
+   struct listptr *p1 = (void *) a;
+   struct listptr *p2 = (void *) b;
+ 
+@@ -4848,21 +4849,21 @@ compare_listptr (const void *a, const void *b, void *arg)
+ 	  p1->warned = p2->warned = true;
+ 	  error (0, 0,
+ 		 gettext ("%s %#" PRIx64 " used with different address sizes"),
+-		 name, (uint64_t) p1->offset);
++		 listptr_name, (uint64_t) p1->offset);
+ 	}
+       if (p1->dwarf64 != p2->dwarf64)
+ 	{
+ 	  p1->warned = p2->warned = true;
+ 	  error (0, 0,
+ 		 gettext ("%s %#" PRIx64 " used with different offset sizes"),
+-		 name, (uint64_t) p1->offset);
++		 listptr_name, (uint64_t) p1->offset);
+ 	}
+       if (listptr_base (p1) != listptr_base (p2))
+ 	{
+ 	  p1->warned = p2->warned = true;
+ 	  error (0, 0,
+ 		 gettext ("%s %#" PRIx64 " used with different base addresses"),
+-		 name, (uint64_t) p1->offset);
++		 listptr_name, (uint64_t) p1->offset);
+ 	}
+       if (p1->attr != p2 ->attr)
+ 	{
+@@ -4870,7 +4871,7 @@ compare_listptr (const void *a, const void *b, void *arg)
+ 	  error (0, 0,
+ 		 gettext ("%s %#" PRIx64
+ 			  " used with different attribute %s and %s"),
+-		 name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
++		 listptr_name, (uint64_t) p1->offset, dwarf_attr_name (p2->attr),
+ 		 dwarf_attr_name (p2->attr));
+ 	}
+     }
+@@ -4942,8 +4943,11 @@ static void
+ sort_listptr (struct listptr_table *table, const char *name)
+ {
+   if (table->n > 0)
+-    qsort_r (table->table, table->n, sizeof table->table[0],
+-	     &compare_listptr, (void *) name);
++    {
++      listptr_name = name;
++      qsort (table->table, table->n, sizeof table->table[0],
++	    &compare_listptr);
++    }
+ }
+ 
+ static bool
+diff --git a/src/strip.c b/src/strip.c
+index 48792a7..198a2e4 100644
+--- a/src/strip.c
++++ b/src/strip.c
+@@ -46,6 +46,13 @@
+ #include <system.h>
+ #include <printversion.h>
+ 
++#if !defined(ACCESSPERMS)
++# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
++#endif
++#if !defined(FNM_EXTMATCH)
++# define FNM_EXTMATCH (0)
++#endif
++
+ typedef uint8_t GElf_Byte;
+ 
+ /* Name and version of program.  */
+diff --git a/src/unstrip.c b/src/unstrip.c
+index 9b8c09a..1fb5063 100644
+--- a/src/unstrip.c
++++ b/src/unstrip.c
+@@ -56,6 +56,15 @@
+ # define _(str) gettext (str)
+ #endif
+ 
++#ifndef strndupa
++#define strndupa(s, n) \
++       ({const char *__in = (s); \
++         size_t __len = strnlen (__in, (n)) + 1; \
++         char *__out = (char *) alloca (__len); \
++         __out[__len-1] = '\0'; \
++         (char *) memcpy (__out, __in, __len-1);})
++#endif
++
+ /* Name and version of program.  */
+ ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
+ 

+ 42 - 0
recipes-devtools/elfutils/files/0004-Disable-the-test-to-convert-euc-jp.patch

@@ -0,0 +1,42 @@
+From e4ede22e28eaa38d81667ddcb19541ece1a83cf8 Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Tue, 15 Aug 2017 17:24:06 +0800
+Subject: [PATCH] Disable the test to convert euc-jp
+
+Remove the test "Test against HP-UX 11.11 bug:
+No converter from EUC-JP to UTF-8 is provided"
+since we don't support HP-UX and if the euc-jp is not
+installed on the host, the dependence will be built without
+iconv support and will cause guild-native building fail.
+
+Upstream-Status: Inappropriate [OE specific]
+
+Signed-off-by: Roy Li <rongqing.li@windriver.com>
+
+Rebase to 0.170
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+
+---
+ m4/iconv.m4 | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/m4/iconv.m4 b/m4/iconv.m4
+index a503646..299f1eb 100644
+--- a/m4/iconv.m4
++++ b/m4/iconv.m4
+@@ -159,6 +159,7 @@ int main ()
+       }
+   }
+ #endif
++#if 0
+   /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
+      provided.  */
+   if (/* Try standardized names.  */
+@@ -170,6 +171,7 @@ int main ()
+       /* Try HP-UX names.  */
+       && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
+     result |= 16;
++#endif
+   return result;
+ }]])],
+         [am_cv_func_iconv_works=yes],

+ 36 - 0
recipes-devtools/elfutils/files/0004-Fix-error-on-musl.patch

@@ -0,0 +1,36 @@
+From d3dc5f98f653342af97ebfbdf3479ee1f0d0cf38 Mon Sep 17 00:00:00 2001
+From: Richard Purdie <richard.purdie@linuxfoundation.org>
+Date: Wed, 1 May 2019 22:15:03 +0100
+Subject: [PATCH] Fix error on musl:
+
+| ../../elfutils-0.176/tests/elfstrmerge.c: In function 'main':
+| ../../elfutils-0.176/tests/elfstrmerge.c:370:60: error: 'ALLPERMS' undeclared (first use in this function); did you mean 'EPERM'?
+|        fdnew = open (fnew, O_WRONLY | O_CREAT, st.st_mode & ALLPERMS);
+|                                                             ^~~~~~~~
+|                                                             EPERM
+| ../../elfutils-0.176/tests/elfstrmerge.c:370:60: note: each undeclared identifier is reported only once for each function it appears in
+
+Upstream-Status: Inappropriate [workaround in musl]
+
+Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
+
+---
+ tests/elfstrmerge.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/tests/elfstrmerge.c b/tests/elfstrmerge.c
+index ba0d68d..1d2447f 100644
+--- a/tests/elfstrmerge.c
++++ b/tests/elfstrmerge.c
+@@ -33,6 +33,11 @@
+ #include ELFUTILS_HEADER(dwelf)
+ #include "elf-knowledge.h"
+ 
++/* for musl */
++#ifndef ALLPERMS
++# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)/* 07777 */
++#endif
++
+ /* The original ELF file.  */
+ static int fd = -1;
+ static Elf *elf = NULL;

+ 59 - 0
recipes-devtools/elfutils/files/0006-Fix-build-on-aarch64-musl.patch

@@ -0,0 +1,59 @@
+From 578f370c7e7a9f056aefa062b34590b0aa13bce5 Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Tue, 15 Aug 2017 17:27:30 +0800
+Subject: [PATCH] Fix build on aarch64/musl
+
+Errors
+
+invalid operands to binary & (have 'long double' and 'unsigned int')
+
+error: redefinition
+ of 'struct iovec'
+ struct iovec { void *iov_base; size_t iov_len; };
+        ^
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+Rebase to 0.170
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+
+---
+ backends/aarch64_initreg.c | 4 ++--
+ backends/arm_initreg.c     | 2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/backends/aarch64_initreg.c b/backends/aarch64_initreg.c
+index daf6f37..6445276 100644
+--- a/backends/aarch64_initreg.c
++++ b/backends/aarch64_initreg.c
+@@ -33,7 +33,7 @@
+ #include "system.h"
+ #include <assert.h>
+ #if defined(__aarch64__) && defined(__linux__)
+-# include <linux/uio.h>
++# include <sys/uio.h>
+ # include <sys/user.h>
+ # include <sys/ptrace.h>
+ /* Deal with old glibc defining user_pt_regs instead of user_regs_struct.  */
+@@ -82,7 +82,7 @@ aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
+ 
+   Dwarf_Word dwarf_fregs[32];
+   for (int r = 0; r < 32; r++)
+-    dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
++    dwarf_fregs[r] = (unsigned int)fregs.vregs[r] & 0xFFFFFFFF;
+ 
+   if (! setfunc (64, 32, dwarf_fregs, arg))
+     return false;
+diff --git a/backends/arm_initreg.c b/backends/arm_initreg.c
+index efcabaf..062bb9e 100644
+--- a/backends/arm_initreg.c
++++ b/backends/arm_initreg.c
+@@ -38,7 +38,7 @@
+ #endif
+ 
+ #ifdef __aarch64__
+-# include <linux/uio.h>
++# include <sys/uio.h>
+ # include <sys/user.h>
+ # include <sys/ptrace.h>
+ /* Deal with old glibc defining user_pt_regs instead of user_regs_struct.  */

+ 37 - 0
recipes-devtools/elfutils/files/0015-config-eu.am-do-not-use-Werror.patch

@@ -0,0 +1,37 @@
+From 9b7554a3e21ccb455b3661a6b4e767636c2c5cf3 Mon Sep 17 00:00:00 2001
+From: Alexander Kanavin <alex.kanavin@gmail.com>
+Date: Mon, 22 Jun 2020 21:35:16 +0000
+Subject: [PATCH] config/eu.am: do not use -Werror
+
+Due to re-definition of error() on musl, gcc starts throwing
+errors where none happen with glibc. Since upstream is not
+likely to be interested in musl builds, lets just disable
+Werror.
+
+Upstream-Status: Inappropriate [oe core specific]
+Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
+
+---
+ config/eu.am | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/config/eu.am b/config/eu.am
+index 6c3c444..3bc0dc9 100644
+--- a/config/eu.am
++++ b/config/eu.am
+@@ -73,7 +73,6 @@ AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
+ 	    -Wold-style-definition -Wstrict-prototypes -Wtrampolines \
+ 	    $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \
+ 	    $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \
+-	    $(if $($(*F)_no_Werror),,-Werror) \
+ 	    $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
+ 	    $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
+ 	    $(if $($(*F)_no_Wpacked_not_aligned),-Wno-packed-not-aligned,) \
+@@ -83,7 +82,6 @@ AM_CXXFLAGS = -std=c++11 -Wall -Wshadow \
+ 	   -Wtrampolines \
+ 	   $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \
+ 	   $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \
+-	   $(if $($(*F)_no_Werror),,-Werror) \
+ 	   $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
+ 	   $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
+ 	   $(if $($(*F)_no_Wpacked_not_aligned),-Wno-packed-not-aligned,) \

+ 76 - 0
recipes-devtools/elfutils/files/ptest.patch

@@ -0,0 +1,76 @@
+Changes to allow ptest to run standalone on target:
+
+a) Run the tests serially
+b) Use the standalone test mode which allows the tests to be run in their
+  'installled' locations on target (but not any of the standalone build pieces)
+c) We want to use the binaries from their installed locations so the run-subr
+   script needs tweaking to run them like that. The rpath conditional isn't
+   enough since we want the second entry in the case statement.
+d) Add an oecheck make target which we can use to build the test binaries we need
+
+Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
+
+Upstream-Status: Inappropriate [oe specific]
+
+Index: elfutils-0.176/configure.ac
+===================================================================
+--- elfutils-0.176.orig/configure.ac
++++ elfutils-0.176/configure.ac
+@@ -45,7 +45,7 @@ AC_COPYRIGHT([Copyright (C) 1996-2018 Th
+ AC_PREREQ(2.63)			dnl Minimum Autoconf version required.
+ 
+ dnl We use GNU make extensions; automake 1.10 defaults to -Wportability.
+-AM_INIT_AUTOMAKE([gnits 1.11 -Wno-portability dist-bzip2 no-dist-gzip parallel-tests])
++AM_INIT_AUTOMAKE([gnits 1.11 -Wno-portability dist-bzip2 no-dist-gzip serial-tests])
+ AM_MAINTAINER_MODE
+ 
+ AM_SILENT_RULES([yes])
+Index: elfutils-0.176/tests/Makefile.am
+===================================================================
+--- elfutils-0.176.orig/tests/Makefile.am
++++ elfutils-0.176/tests/Makefile.am
+@@ -445,10 +445,10 @@ installed_TESTS_ENVIRONMENT = libdir=$(D
+ installed_LOG_COMPILER = $(abs_srcdir)/test-wrapper.sh \
+ 			 installed $(tests_rpath) \
+ 			 '$(program_transform_name)'
+-if STANDALONE
++if !STANDALONE
+ TESTS_ENVIRONMENT = $(installed_TESTS_ENVIRONMENT)
+ LOG_COMPILER = $(installed_LOG_COMPILER)
+-else !STANDALONE
++else STANDALONE
+ TESTS_ENVIRONMENT = LC_ALL=C; LANG=C; VALGRIND_CMD=$(valgrind_cmd); \
+ 		    abs_srcdir=$(abs_srcdir);  abs_builddir=$(abs_builddir); \
+ 		    abs_top_builddir=$(abs_top_builddir); \
+@@ -463,7 +463,7 @@ installcheck-local:
+ 	$(MAKE) $(AM_MAKEFLAGS) \
+ 		TESTS_ENVIRONMENT="$(installed_TESTS_ENVIRONMENT)" \
+ 		LOG_COMPILER="$(installed_LOG_COMPILER)" check-TESTS
+-endif !STANDALONE
++endif STANDALONE
+ 
+ if STANDALONE
+ libdw = -ldw
+@@ -612,3 +612,5 @@ check: check-am coverage
+ coverage:
+ 	-$(srcdir)/coverage.sh
+ endif
++oecheck:
++	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+Index: elfutils-0.176/tests/test-subr.sh
+===================================================================
+--- elfutils-0.176.orig/tests/test-subr.sh
++++ elfutils-0.176/tests/test-subr.sh
+@@ -91,12 +91,6 @@ installed_testrun()
+   program="$1"
+   shift
+   case "$program" in
+-  ${abs_builddir}/*)
+-    if [ "x$elfutils_tests_rpath" != xno ]; then
+-      echo >&2 installcheck not possible with --enable-tests-rpath
+-      exit 77
+-    fi
+-    ;;
+   ${abs_top_builddir}/src/*)
+     program=${bindir}/`program_transform ${program##*/}`
+     ;;

+ 6 - 0
recipes-devtools/elfutils/files/run-ptest

@@ -0,0 +1,6 @@
+#!/bin/sh
+#
+#This script is used to run elfutils test suites
+cd tests
+
+make -k runtest-TESTS abs_srcdir=$PWD abs_builddir=$PWD srcdir=$PWD top_srcdir=$PWD/../ abs_top_builddir=$PWD/../ elfutils_testrun=installed elfutils_tests_rpath=no program_transform_name=s,^,eu-,

+ 3 - 0
recipes-devtools/libtool/libtool-cross_%.bbappend

@@ -0,0 +1,3 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/libtool:"
+
+SRC_URI += "file://9999-fix-thead.patch"

+ 3 - 0
recipes-devtools/libtool/libtool-native_%.bbappend

@@ -0,0 +1,3 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/libtool:"
+
+SRC_URI += "file://9999-fix-thead.patch"

+ 12 - 0
recipes-devtools/libtool/libtool/9999-fix-thead.patch

@@ -0,0 +1,12 @@
+diff -Nur libtool-2.4.6/m4/libtool.m4 libtool-2.4.6-fix/m4/libtool.m4
+--- libtool-2.4.6/m4/libtool.m4	2020-09-16 12:50:36.486764205 +0000
++++ libtool-2.4.6-fix/m4/libtool.m4	2020-09-16 13:46:53.272622322 +0000
+@@ -2303,7 +2303,7 @@
+     mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;;
+     *) lt_sed_strip_eq='s|=/|/|g' ;;
+   esac
+-  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
++  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq -e "s/lib\/\.\.\/lib64xthead\/lp64d/lib64xthead\/lp64d/g" -e "s/lp64d\/\.\.\/lib64xthead\/lp64d/lp64d/g" -e "s/lib64xthead\/lib64xthead/lib64xthead/g"`
+   case $lt_search_path_spec in
+   *\;*)
+     # if the path contains ";" then we assume it to be the separator

+ 3 - 0
recipes-devtools/libtool/libtool_%.bbappend

@@ -0,0 +1,3 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/libtool:"
+
+SRC_URI += "file://9999-fix-thead.patch"

+ 3 - 0
recipes-devtools/libtool/nativesdk-libtool_%.bbappend

@@ -0,0 +1,3 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/libtool:"
+
+SRC_URI += "file://9999-fix-thead.patch"

+ 451 - 0
recipes-devtools/meson/meson/envconfig.py

@@ -0,0 +1,451 @@
+# Copyright 2012-2016 The Meson development team
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+#     http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os, subprocess
+import typing as T
+
+from . import mesonlib
+from .mesonlib import EnvironmentException, MachineChoice, PerMachine, split_args
+from . import mlog
+
+_T = T.TypeVar('_T')
+
+
+# These classes contains all the data pulled from configuration files (native
+# and cross file currently), and also assists with the reading environment
+# variables.
+#
+# At this time there isn't an ironclad difference between this an other sources
+# of state like `coredata`. But one rough guide is much what is in `coredata` is
+# the *output* of the configuration process: the final decisions after tests.
+# This, on the other hand has *inputs*. The config files are parsed, but
+# otherwise minimally transformed. When more complex fallbacks (environment
+# detection) exist, they are defined elsewhere as functions that construct
+# instances of these classes.
+###lqg
+
+known_cpu_families = (
+    'allarch',
+    'aarch64',
+    'alpha',
+    'arc',
+    'arm',
+    'avr',
+    'c2000',
+    'dspic',
+    'e2k',
+    'ia64',
+    'm68k',
+    'microblaze',
+    'mips',
+    'mips64',
+    'parisc',
+    'pic24',
+    'ppc',
+    'ppc64',
+    'riscv32',
+    'riscv64',
+    'csky',
+    'rl78',
+    'rx',
+    's390',
+    's390x',
+    'sh4',
+    'sparc',
+    'sparc64',
+    'wasm32',
+    'wasm64',
+    'x86',
+    'x86_64',
+)
+
+# It would feel more natural to call this "64_BIT_CPU_FAMILES", but
+# python identifiers cannot start with numbers
+CPU_FAMILES_64_BIT = [
+    'aarch64',
+    'alpha',
+    'ia64',
+    'mips64',
+    'ppc64',
+    'riscv64',
+    's390x',
+    'sparc64',
+    'wasm64',
+    'x86_64',
+]
+
+def get_env_var_pair(for_machine: MachineChoice,
+                     is_cross: bool,
+                     var_name: str) -> T.Tuple[T.Optional[str], T.Optional[str]]:
+    """
+    Returns the exact env var and the value.
+    """
+    candidates = PerMachine(
+        # The prefixed build version takes priority, but if we are native
+        # compiling we fall back on the unprefixed host version. This
+        # allows native builds to never need to worry about the 'BUILD_*'
+        # ones.
+        ([var_name + '_FOR_BUILD'] if is_cross else [var_name]),
+        # Always just the unprefixed host verions
+        [var_name]
+    )[for_machine]
+    for var in candidates:
+        value = os.environ.get(var)
+        if value is not None:
+            break
+    else:
+        formatted = ', '.join(['{!r}'.format(var) for var in candidates])
+        mlog.debug('None of {} are defined in the environment, not changing global flags.'.format(formatted))
+        return None
+    mlog.log('Using {!r} from environment with value: {!r}'.format(var, value))
+    return var, value
+
+def get_env_var(for_machine: MachineChoice,
+                is_cross: bool,
+                var_name: str) -> T.Tuple[T.Optional[str], T.Optional[str]]:
+    ret = get_env_var_pair(for_machine, is_cross, var_name)
+    if ret is None:
+        return None
+    else:
+        var, value = ret
+        return value
+
+class Properties:
+    def __init__(
+            self,
+            properties: T.Optional[T.Dict[str, T.Union[str, T.List[str]]]] = None,
+    ):
+        self.properties = properties or {}  # type: T.Dict[str, T.Union[str, T.List[str]]]
+
+    def has_stdlib(self, language: str) -> bool:
+        return language + '_stdlib' in self.properties
+
+    # Some of get_stdlib, get_root, get_sys_root are wider than is actually
+    # true, but without heterogenious dict annotations it's not practical to
+    # narrow them
+    def get_stdlib(self, language: str) -> T.Union[str, T.List[str]]:
+        return self.properties[language + '_stdlib']
+
+    def get_root(self) -> T.Optional[T.Union[str, T.List[str]]]:
+        return self.properties.get('root', None)
+
+    def get_sys_root(self) -> T.Optional[T.Union[str, T.List[str]]]:
+        return self.properties.get('sys_root', None)
+
+    def get_pkg_config_libdir(self) -> T.Optional[T.List[str]]:
+        p = self.properties.get('pkg_config_libdir', None)
+        if p is None:
+            return p
+        return mesonlib.listify(p)
+
+    def __eq__(self, other: T.Any) -> 'T.Union[bool, NotImplemented]':
+        if isinstance(other, type(self)):
+            return self.properties == other.properties
+        return NotImplemented
+
+    # TODO consider removing so Properties is less freeform
+    def __getitem__(self, key: str) -> T.Any:
+        return self.properties[key]
+
+    # TODO consider removing so Properties is less freeform
+    def __contains__(self, item: T.Any) -> bool:
+        return item in self.properties
+
+    # TODO consider removing, for same reasons as above
+    def get(self, key: str, default: T.Any = None) -> T.Any:
+        return self.properties.get(key, default)
+
+class MachineInfo:
+    def __init__(self, system: str, cpu_family: str, cpu: str, endian: str):
+        self.system = system
+        self.cpu_family = cpu_family
+        self.cpu = cpu
+        self.endian = endian
+        self.is_64_bit = cpu_family in CPU_FAMILES_64_BIT  # type: bool
+
+    def __eq__(self, other: T.Any) -> 'T.Union[bool, NotImplemented]':
+        if self.__class__ is not other.__class__:
+            return NotImplemented
+        return \
+            self.system == other.system and \
+            self.cpu_family == other.cpu_family and \
+            self.cpu == other.cpu and \
+            self.endian == other.endian
+
+    def __ne__(self, other: T.Any) -> 'T.Union[bool, NotImplemented]':
+        if self.__class__ is not other.__class__:
+            return NotImplemented
+        return not self.__eq__(other)
+
+    def __repr__(self) -> str:
+        return '<MachineInfo: {} {} ({})>'.format(self.system, self.cpu_family, self.cpu)
+
+    @classmethod
+    def from_literal(cls, literal: T.Dict[str, str]) -> 'MachineInfo':
+        minimum_literal = {'cpu', 'cpu_family', 'endian', 'system'}
+        if set(literal) < minimum_literal:
+            raise EnvironmentException(
+                'Machine info is currently {}\n'.format(literal) +
+                'but is missing {}.'.format(minimum_literal - set(literal)))
+
+        cpu_family = literal['cpu_family']
+        if cpu_family not in known_cpu_families:
+            raise EnvironmentException('Unknown CPU family {}, see https://wiki.yoctoproject.org/wiki/Meson/UnknownCPU for directions.'.format(cpu_family))
+
+        endian = literal['endian']
+        if endian not in ('little', 'big'):
+            mlog.warning('Unknown endian {}'.format(endian))
+
+        return cls(literal['system'], cpu_family, literal['cpu'], endian)
+
+    def is_windows(self) -> bool:
+        """
+        Machine is windows?
+        """
+        return self.system == 'windows' or 'mingw' in self.system
+
+    def is_cygwin(self) -> bool:
+        """
+        Machine is cygwin?
+        """
+        return self.system.startswith('cygwin')
+
+    def is_linux(self) -> bool:
+        """
+        Machine is linux?
+        """
+        return self.system == 'linux'
+
+    def is_darwin(self) -> bool:
+        """
+        Machine is Darwin (iOS/tvOS/OS X)?
+        """
+        return self.system in {'darwin', 'ios', 'tvos'}
+
+    def is_android(self) -> bool:
+        """
+        Machine is Android?
+        """
+        return self.system == 'android'
+
+    def is_haiku(self) -> bool:
+        """
+        Machine is Haiku?
+        """
+        return self.system == 'haiku'
+
+    def is_netbsd(self) -> bool:
+        """
+        Machine is NetBSD?
+        """
+        return self.system == 'netbsd'
+
+    def is_openbsd(self) -> bool:
+        """
+        Machine is OpenBSD?
+        """
+        return self.system == 'openbsd'
+
+    def is_dragonflybsd(self) -> bool:
+        """Machine is DragonflyBSD?"""
+        return self.system == 'dragonfly'
+
+    def is_freebsd(self) -> bool:
+        """Machine is FreeBSD?"""
+        return self.system == 'freebsd'
+
+    def is_sunos(self) -> bool:
+        """Machine is illumos or Solaris?"""
+        return self.system == 'sunos'
+
+    def is_hurd(self) -> bool:
+        """
+        Machine is GNU/Hurd?
+        """
+        return self.system == 'gnu'
+
+    def is_irix(self) -> bool:
+        """Machine is IRIX?"""
+        return self.system.startswith('irix')
+
+    # Various prefixes and suffixes for import libraries, shared libraries,
+    # static libraries, and executables.
+    # Versioning is added to these names in the backends as-needed.
+    def get_exe_suffix(self) -> str:
+        if self.is_windows() or self.is_cygwin():
+            return 'exe'
+        else:
+            return ''
+
+    def get_object_suffix(self) -> str:
+        if self.is_windows():
+            return 'obj'
+        else:
+            return 'o'
+
+    def libdir_layout_is_win(self) -> bool:
+        return self.is_windows() or self.is_cygwin()
+
+class BinaryTable:
+    def __init__(
+            self,
+            binaries: T.Optional[T.Dict[str, T.Union[str, T.List[str]]]] = None,
+    ):
+        self.binaries = binaries or {}  # type: T.Dict[str, T.Union[str, T.List[str]]]
+        for name, command in self.binaries.items():
+            if not isinstance(command, (list, str)):
+                # TODO generalize message
+                raise mesonlib.MesonException(
+                    'Invalid type {!r} for binary {!r} in cross file'
+                    ''.format(command, name))
+
+    # Map from language identifiers to environment variables.
+    evarMap = {
+        # Compilers
+        'c': 'CC',
+        'cpp': 'CXX',
+        'cs': 'CSC',
+        'd': 'DC',
+        'fortran': 'FC',
+        'objc': 'OBJC',
+        'objcpp': 'OBJCXX',
+        'rust': 'RUSTC',
+        'vala': 'VALAC',
+
+        # Linkers
+        'c_ld': 'CC_LD',
+        'cpp_ld': 'CXX_LD',
+        'd_ld': 'DC_LD',
+        'fortran_ld': 'FC_LD',
+        'objc_ld': 'OBJC_LD',
+        'objcpp_ld': 'OBJCXX_LD',
+        'rust_ld': 'RUSTC_LD',
+
+        # Binutils
+        'strip': 'STRIP',
+        'ar': 'AR',
+        'windres': 'WINDRES',
+
+        # Other tools
+        'cmake': 'CMAKE',
+        'qmake': 'QMAKE',
+        'pkgconfig': 'PKG_CONFIG',
+    }  # type: T.Dict[str, str]
+
+    # Deprecated environment variables mapped from the new variable to the old one
+    # Deprecated in 0.54.0
+    DEPRECATION_MAP = {
+        'DC_LD': 'D_LD',
+        'FC_LD': 'F_LD',
+        'RUSTC_LD': 'RUST_LD',
+        'OBJCXX_LD': 'OBJCPP_LD',
+    }  # type: T.Dict[str, str]
+
+    @staticmethod
+    def detect_ccache() -> T.List[str]:
+        try:
+            subprocess.check_call(['ccache', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        except (OSError, subprocess.CalledProcessError):
+            return []
+        return ['ccache']
+
+    @classmethod
+    def parse_entry(cls, entry: T.Union[str, T.List[str]]) -> T.Tuple[T.List[str], T.List[str]]:
+        compiler = mesonlib.stringlistify(entry)
+        # Ensure ccache exists and remove it if it doesn't
+        if compiler[0] == 'ccache':
+            compiler = compiler[1:]
+            ccache = cls.detect_ccache()
+        else:
+            ccache = []
+        # Return value has to be a list of compiler 'choices'
+        return compiler, ccache
+
+    def lookup_entry(self,
+                     for_machine: MachineChoice,
+                     is_cross: bool,
+                     name: str) -> T.Optional[T.List[str]]:
+        """Lookup binary in cross/native file and fallback to environment.
+
+        Returns command with args as list if found, Returns `None` if nothing is
+        found.
+        """
+        # Try explicit map, don't fall back on env var
+        # Try explict map, then env vars
+        for _ in [()]: # a trick to get `break`
+            raw_command = self.binaries.get(name)
+            if raw_command is not None:
+                command = mesonlib.stringlistify(raw_command)
+                break # found
+            evar = self.evarMap.get(name)
+            if evar is not None:
+                raw_command = get_env_var(for_machine, is_cross, evar)
+                if raw_command is None:
+                    deprecated = self.DEPRECATION_MAP.get(evar)
+                    if deprecated is not None:
+                        raw_command = get_env_var(for_machine, is_cross, deprecated)
+                        if raw_command is not None:
+                            mlog.deprecation(
+                                'The', deprecated, 'environment variable is deprecated in favor of',
+                                evar, once=True)
+                if raw_command is not None:
+                    command = split_args(raw_command)
+                    break # found
+            command = None
+
+
+        # Do not return empty or blank string entries
+        if command is not None and (len(command) == 0 or len(command[0].strip()) == 0):
+            command = None
+        return command
+
+class Directories:
+
+    """Data class that holds information about directories for native and cross
+    builds.
+    """
+
+    def __init__(self, bindir: T.Optional[str] = None, datadir: T.Optional[str] = None,
+                 includedir: T.Optional[str] = None, infodir: T.Optional[str] = None,
+                 libdir: T.Optional[str] = None, libexecdir: T.Optional[str] = None,
+                 localedir: T.Optional[str] = None, localstatedir: T.Optional[str] = None,
+                 mandir: T.Optional[str] = None, prefix: T.Optional[str] = None,
+                 sbindir: T.Optional[str] = None, sharedstatedir: T.Optional[str] = None,
+                 sysconfdir: T.Optional[str] = None):
+        self.bindir = bindir
+        self.datadir = datadir
+        self.includedir = includedir
+        self.infodir = infodir
+        self.libdir = libdir
+        self.libexecdir = libexecdir
+        self.localedir = localedir
+        self.localstatedir = localstatedir
+        self.mandir = mandir
+        self.prefix = prefix
+        self.sbindir = sbindir
+        self.sharedstatedir = sharedstatedir
+        self.sysconfdir = sysconfdir
+
+    def __contains__(self, key: str) -> bool:
+        return hasattr(self, key)
+
+    def __getitem__(self, key: str) -> T.Optional[str]:
+        # Mypy can't figure out what to do with getattr here, so we'll case for it
+        return T.cast(T.Optional[str], getattr(self, key))
+
+    def __setitem__(self, key: str, value: T.Optional[str]) -> None:
+        setattr(self, key, value)
+
+    def __iter__(self) -> T.Iterator[T.Tuple[str, str]]:
+        return iter(self.__dict__.items())

+ 12 - 0
recipes-devtools/meson/meson_0.55.1.bbappend

@@ -0,0 +1,12 @@
+HOMEPAGE = "http://mesonbuild.com"
+SUMMARY = "A high performance build system"
+
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI_append = "file://envconfig.py \
+			     "
+do_configure() {
+    if [ -f "${WORKDIR}/envconfig.py" -a -d "${WORKDIR}/meson-${PV}/mesonbuild" ]; then
+	    cp -rf ${WORKDIR}/envconfig.py ${WORKDIR}/meson-${PV}/mesonbuild
+	fi
+}

+ 16 - 0
recipes-devtools/python/python3-pycairo_1.20.0.bbappend

@@ -0,0 +1,16 @@
+SUMMARY = "Python bindings for the Cairo canvas library"
+B = "${WORKDIR}/build"
+
+do_configure() {
+    echo "${SUMMARY}->do_configure: Nothing to do!!"
+}
+
+do_compile() {
+    echo "${SUMMARY}->do_compile: Nothing to do!!"
+}
+
+do_install() {
+    echo "${SUMMARY}->do_install: Nothing to do!!"
+}
+
+inherit pkgconfig

+ 13 - 0
recipes-devtools/python/python3-pygobject_3.38.0.bbappend

@@ -0,0 +1,13 @@
+SUMMARY = "Python GObject bindings"
+
+do_configure() {
+	    echo "${SUMMARY}->do_configure: Nothing to do!!"
+}
+
+do_compile() {
+	    echo "${SUMMARY}->do_compile: Nothing to do!!"
+}
+
+do_install() {
+	    echo "${SUMMARY}->do_install: Nothing to do!!"
+}

+ 40 - 0
recipes-extended/ghostscript/ghostscript/csky/objarch.h

@@ -0,0 +1,40 @@
+/* Parameters derived from machine and compiler architecture. */
+/* This file is generated mechanically by genarch.c. */
+
+	 /* ---------------- Scalar alignments ---------------- */
+
+#define ARCH_ALIGN_SHORT_MOD 2
+#define ARCH_ALIGN_INT_MOD 4
+#define ARCH_ALIGN_LONG_MOD 4
+#define ARCH_ALIGN_PTR_MOD 4
+#define ARCH_ALIGN_FLOAT_MOD 4
+#define ARCH_ALIGN_DOUBLE_MOD 8
+
+	 /* ---------------- Scalar sizes ---------------- */
+
+#define ARCH_LOG2_SIZEOF_CHAR 0
+#define ARCH_LOG2_SIZEOF_SHORT 1
+#define ARCH_LOG2_SIZEOF_INT 2
+#define ARCH_LOG2_SIZEOF_LONG 2
+#define ARCH_LOG2_SIZEOF_LONG_LONG 3
+#define ARCH_SIZEOF_GX_COLOR_INDEX 8
+#define ARCH_SIZEOF_PTR 4
+#define ARCH_SIZEOF_FLOAT 4
+#define ARCH_SIZEOF_DOUBLE 8
+#define ARCH_FLOAT_MANTISSA_BITS 24
+#define ARCH_DOUBLE_MANTISSA_BITS 53
+
+	 /* ---------------- Unsigned max values ---------------- */
+
+#define ARCH_MAX_UCHAR ((unsigned char)0xff + (unsigned char)0)
+#define ARCH_MAX_USHORT ((unsigned short)0xffff + (unsigned short)0)
+#define ARCH_MAX_UINT ((unsigned int)~0 + (unsigned int)0)
+#define ARCH_MAX_ULONG ((unsigned long)~0L + (unsigned long)0)
+
+	 /* ---------------- Miscellaneous ---------------- */
+
+#define ARCH_IS_BIG_ENDIAN 0
+#define ARCH_PTRS_ARE_SIGNED 0
+#define ARCH_FLOATS_ARE_IEEE 1
+#define ARCH_ARITH_RSHIFT 2
+#define ARCH_DIV_NEG_POS_TRUNCATES 1

+ 1 - 0
recipes-extended/ghostscript/ghostscript_%.bbappend

@@ -0,0 +1 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"

+ 44 - 0
recipes-extended/ltp/ltp/0001-Define-SYS_futex-on-32bit-arches-using-64-bit-time_t.patch

@@ -0,0 +1,44 @@
+From a20107ab47554798e0de0347dd4d7259f01675af Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 15 Nov 2020 16:33:45 -0800
+Subject: [PATCH] Define SYS_futex on 32bit arches using 64-bit time_t
+
+Newer 32bit arches like RISCV32 and ARC are using 64bit time_t
+from get go unlike other 32bit architecture therefore aliasing __NR_futex to
+__NR_futex_time64 helps avoid the below errors
+
+tst_checkpoint.c:99:17: error: use of undeclared identifier 'SYS_futex'
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+[ moved definitions to lapi/futex.h ]
+Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
+---
+ include/lapi/futex.h                      | 4 ++++
+ testcases/kernel/syscalls/clone/clone08.c | 1 +
+ 2 files changed, 5 insertions(+)
+
+diff --git a/include/lapi/futex.h b/include/lapi/futex.h
+index 72209e4c98..00b26c3559 100644
+--- a/include/lapi/futex.h
++++ b/include/lapi/futex.h
+@@ -10,4 +10,8 @@
+ 
+ typedef volatile uint32_t futex_t;
+ 
++#if !defined(SYS_futex) && defined(SYS_futex_time64)
++#define SYS_futex SYS_futex_time64
++#endif
++
+ #endif /* LAPI_FUTEX_H__ */
+diff --git a/testcases/kernel/syscalls/clone/clone08.c b/testcases/kernel/syscalls/clone/clone08.c
+index 8e115b0421..3de1fe9bbd 100644
+--- a/testcases/kernel/syscalls/clone/clone08.c
++++ b/testcases/kernel/syscalls/clone/clone08.c
+@@ -16,6 +16,7 @@
+ #include "tst_test.h"
+ #include "clone_platform.h"
+ #include "lapi/syscalls.h"
++#include "lapi/futex.h"
+ 
+ static pid_t ptid, ctid, tgid;
+ static void *child_stack;

+ 3 - 0
recipes-extended/ltp/ltp_%.bbappend

@@ -0,0 +1,3 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI_append_riscv32 = " file://0001-Define-SYS_futex-on-32bit-arches-using-64-bit-time_t.patch"

+ 34 - 0
recipes-graphics/cairo/cairo/CVE-2018-19876.patch

@@ -0,0 +1,34 @@
+CVE: CVE-2018-19876
+Upstream-Status: Backport
+Signed-off-by: Ross Burton <ross.burton@intel.com>
+
+From 90e85c2493fdfa3551f202ff10282463f1e36645 Mon Sep 17 00:00:00 2001
+From: Carlos Garcia Campos <cgarcia@igalia.com>
+Date: Mon, 19 Nov 2018 12:33:07 +0100
+Subject: [PATCH] ft: Use FT_Done_MM_Var instead of free when available in
+ cairo_ft_apply_variations
+
+Fixes a crash when using freetype >= 2.9
+---
+ src/cairo-ft-font.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
+index 325dd61b4..981973f78 100644
+--- a/src/cairo-ft-font.c
++++ b/src/cairo-ft-font.c
+@@ -2393,7 +2393,11 @@ skip:
+ done:
+         free (coords);
+         free (current_coords);
++#if HAVE_FT_DONE_MM_VAR
++        FT_Done_MM_Var (face->glyph->library, ft_mm_var);
++#else
+         free (ft_mm_var);
++#endif
+     }
+ }
+ 
+-- 
+2.11.0
+

+ 19 - 0
recipes-graphics/cairo/cairo/CVE-2019-6461.patch

@@ -0,0 +1,19 @@
+There is a potential infinite-loop in function _arc_error_normalized().
+
+CVE: CVE-2019-6461
+Upstream-Status: Pending
+Signed-off-by: Ross Burton <ross.burton@intel.com>
+
+diff --git a/src/cairo-arc.c b/src/cairo-arc.c
+index 390397bae..f9249dbeb 100644
+--- a/src/cairo-arc.c
++++ b/src/cairo-arc.c
+@@ -99,7 +99,7 @@ _arc_max_angle_for_tolerance_normalized (double tolerance)
+     do {
+ 	angle = M_PI / i++;
+ 	error = _arc_error_normalized (angle);
+-    } while (error > tolerance);
++    } while (error > tolerance && error > __DBL_EPSILON__);
+ 
+     return angle;
+ }

+ 20 - 0
recipes-graphics/cairo/cairo/CVE-2019-6462.patch

@@ -0,0 +1,20 @@
+There is an assertion in function _cairo_arc_in_direction().
+
+CVE: CVE-2019-6462
+Upstream-Status: Pending
+Signed-off-by: Ross Burton <ross.burton@intel.com>
+
+diff --git a/src/cairo-arc.c b/src/cairo-arc.c
+index 390397bae..1bde774a4 100644
+--- a/src/cairo-arc.c
++++ b/src/cairo-arc.c
+@@ -186,7 +186,8 @@ _cairo_arc_in_direction (cairo_t	  *cr,
+     if (cairo_status (cr))
+         return;
+ 
+-    assert (angle_max >= angle_min);
++    if (angle_max < angle_min)
++       return;
+ 
+     if (angle_max - angle_min > 2 * M_PI * MAX_FULL_CIRCLES) {
+ 	angle_max = fmod (angle_max - angle_min, 2 * M_PI);

+ 22 - 0
recipes-graphics/cairo/cairo/cairo-get_bitmap_surface-bsc1036789-CVE-2017-7475.diff

@@ -0,0 +1,22 @@
+Cairo: Fix Denial-of-Service Attack due to Logical Problem in Program
+
+https://bugs.freedesktop.org/show_bug.cgi?id=100763
+
+CVE: CVE-2017-7475
+Upstream-Status: Submitted
+
+Signed-off-by: Fan Xin <fan.xin@jp.fujitsu.com>
+
+Index: cairo-1.15.4/src/cairo-ft-font.c
+===================================================================
+--- cairo-1.15.4.orig/src/cairo-ft-font.c
++++ cairo-1.15.4/src/cairo-ft-font.c
+@@ -1149,7 +1149,7 @@ _get_bitmap_surface (FT_Bitmap		     *bi
+     width = bitmap->width;
+     height = bitmap->rows;
+ 
+-    if (width == 0 || height == 0) {
++    if (width == 0 || height == 0 || bitmap->buffer == NULL) {
+ 	*surface = (cairo_image_surface_t *)
+ 	    cairo_image_surface_create_for_data (NULL, format, 0, 0, 0);
+ 	return (*surface)->base.status;

+ 26 - 0
recipes-graphics/cairo/cairo_1.16.0.bbappend

@@ -0,0 +1,26 @@
+SUMMARY = "The Cairo 2D vector graphics library"
+DESCRIPTION = "Cairo is a multi-platform library providing anti-aliased \
+vector-based rendering for multiple target backends. Paths consist \
+of line segments and cubic splines and can be rendered at any width \
+with various join and cap styles. All colors may be specified with \
+optional translucence (opacity/alpha) and combined using the \
+extended Porter/Duff compositing algebra as found in the X Render \
+Extension."
+
+
+do_configure () {
+	echo "Cairo->do_configure: Nothing to do !!"
+}
+
+do_compile () {
+	echo "Cairo->do_compile: Nothing to do !!"
+}
+
+do_install () {
+	echo "Cairo->do_install: Nothing to do !!"
+}
+
+do_install_append () {
+	echo "Cairo->do_install_append: Nothing to do !!"
+}
+

+ 13 - 0
recipes-graphics/mesa/mesa_20.2.1.bbappend

@@ -0,0 +1,13 @@
+SUMMARY = "A free implementation of the OpenGL API"
+
+do_compile() {
+	    echo "${SUMMARY}->do_compile: Nothing to do!!"
+}       
+ 
+do_install() {
+	    echo "${SUMMARY}->do_install: Nothing to do!!"
+}       
+ 
+do_install_append() {
+	    echo "${SUMMARY}->do_install_append: Nothing to do!!"
+}   

+ 13 - 0
recipes-graphics/xorg-lib/libxshmfence/rv32_sys_futex.patch

@@ -0,0 +1,13 @@
+--- a/src/xshmfence_futex.h
++++ b/src/xshmfence_futex.h
+@@ -47,6 +47,10 @@ static inline int futex_wait(int32_t *ad
+ 
+ #else
+ 
++#if !defined(__NR_futex) && defined(__riscv) && __riscv_xlen == 32
++# define __NR_futex __NR_futex_time64
++#endif
++
+ #include <stdint.h>
+ #include <values.h>
+ #include <linux/futex.h>

+ 4 - 0
recipes-graphics/xorg-lib/libxshmfence_1.3.bbappend

@@ -0,0 +1,4 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI_append_riscv32 = " file://rv32_sys_futex.patch"
+

+ 31 - 0
recipes-kernel/linux/linux-thead_5.4.36.bb

@@ -0,0 +1,31 @@
+inherit kernel
+require recipes-kernel/linux/linux-yocto.inc
+
+LIC_FILES_CHKSUM = "file://COPYING;md5=bbea815ee2795b2f4230826c0c6b8814"
+
+FILESEXTRAPATHS_prepend := "${THISDIR}/files/xuantie-c910:"
+
+SRC_URI = " \
+    https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-${PV}.tar.xz;name=kernel "
+
+SRC_URI[kernel.md5sum] = "4c4edf3e7d127e4f1a471aa3a370f3e7"
+SRC_URI[kernel.sha256sum] = "b9faea98122e8316af8fb428c942e81797b5d28a8fc59a24a4e47959e3765b8d"
+
+
+LINUX_VERSION ?= "${PV}"
+LINUX_VERSION_EXTENSION ?= "-thead"
+
+SRCREV="${AUTOREV}"
+
+DEPENDS += "elfutils-native"
+
+COMPATIBLE_MACHINE = "${MACHINE}"
+
+S = "${WORKDIR}/linux-${PV}"
+
+# KBUILD_DEFCONFIG_qemu64-c910 = "qemux-c910_defconfig"
+# KBUILD_DEFCONFIG_light-c910 = "light-c910_defconfig"
+# KBUILD_DEFCONFIG_ice-c910 = "ice-c910_defconfig"
+
+KCONFIG_MODE="--alldefconfig"
+

+ 46 - 0
recipes-kernel/linux/linux-thead_5.4.36.bbappend

@@ -0,0 +1,46 @@
+do_configure() {
+	    echo "linux->do_configure: Nothing to do!!"
+}
+
+do_compile() {
+	    echo "linux->do_compile: Nothing to do!!"
+}
+
+do_install() {
+	    echo "linux->do_install: Nothing to do!!"
+}
+do_kernel_metadata() {
+        echo "linux->do_kernel_metadata: Nothing to do!!"
+}
+
+do_kernel_configme() {
+        echo "linux->do_kernel_configme: Nothing to do!!"
+}
+
+do_kernel_configcheck() {
+	    echo "linux->do_kernel_configcheck: Nothing to do!!"
+}
+
+do_shared_workdir() {
+	    echo "linux->do_shared_workdiri: Nothing to do!!"
+}
+
+do_kernel_link_images() {
+        echo "linux->do_kernel_link_images: Nothing to do!!"
+}
+
+do_uboot_mkimage() {
+        echo "linux->do_uboot_mkimage: Nothing to do!!"
+}
+
+do_package() {
+        echo "linux->do_package: Nothing to do!!"
+}
+
+do_deploy() {
+        echo "linux->do_deploy: Nothing to do!!"
+}
+
+do_package_write_deb() {
+        echo "linux->do_package_write_deb: Nothing to do!!"
+}

+ 1 - 0
recipes-kernel/linux/linux-yocto-dev.bbappend

@@ -0,0 +1 @@
+COMPATIBLE_MACHINE_append = "|qemuriscv32"

+ 5 - 0
recipes-kernel/linux/linux-yocto_5.%.bbappend

@@ -0,0 +1,5 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
+
+COMPATIBLE_MACHINE_append = "|qemuriscv32"
+
+SRC_URI_append_riscv32 = " file://0001-perf-Alias-SYS_futex-with-SYS_futex_time64-on-32-bit.patch"

Some files were not shown because too many files changed in this diff