--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Main RISC-V profile directory.
+
+# This is not a complete profile. Use the subdirectories!
+
+ARCH="riscv"
+ACCEPT_KEYWORDS="riscv ~riscv"
+
+CHOST="riscv64-unknown-linux-gnu"
+
+# Since many people will want to test this in qemu...
+FEATURES="-pid-sandbox -network-sandbox -ipc-sandbox"
+
+# The following stuff is, e.g., defined in subdirs:
+# CFLAGS
+# CXXFLAGS
+# FFLAGS
+# FCFLAGS
+# ABI
+# DEFAULT_ABI
+# MULTILIB_ABIS
+# CHOST_riscv
+# LIBDIR_riscv
--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Even if someone makes Portage accept other keywords, here
+# we need specific versions / patches for riscv!
+sys-devel/gcc -amd64 -~amd64
+sys-libs/glibc -amd64 -~amd64
+
+# For the stages and qemu, we need static qemu *from* ~amd64
+app-emulation/qemu-riscv64-bin ~amd64
--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# This doesn't work for (any) riscv yet.
+dev-libs/libpcre2 jit
+dev-libs/libpcre jit
+dev-vcs/git pcre-jit
--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# For now we add the x86-64 qemu-riscv64 static binary to all
+# stages. This makes life somewhat simpler when working without
+# real hardware.
+app-emulation/qemu-riscv64-bin
--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# RISC-V rv64gc/lp64 no-multilib profile
+
+CFLAGS="-O2 -pipe -march=rv64gc -mabi=lp64"
+CXXFLAGS="${CFLAGS}"
+FFLAGS="${CFLAGS}"
+FCFLAGS="${CFLAGS}"
+
+# We have only one ABI
+MULTILIB_ABIS="lp64"
+
+# We hide the useflags for the ABIs
+USE_EXPAND_HIDDEN="ABI_RISCV"
--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Undo multilib forcing.
+sys-apps/sandbox -abi_riscv_lp64d
--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Mask multilib, since we do not want to use it.
+multilib
+
+# Mask the other multilib flags back for non-multilib profile.
+abi_riscv_lp64d
--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# RISC-V rv64gc/lp64d no-multilib profile
+
+CFLAGS="-O2 -pipe -march=rv64gc -mabi=lp64d"
+CXXFLAGS="${CFLAGS}"
+FFLAGS="${CFLAGS}"
+FCFLAGS="${CFLAGS}"
+
+# We have only one ABI
+MULTILIB_ABIS="lp64d"
+
+# We hide the useflags for the ABIs
+USE_EXPAND_HIDDEN="ABI_RISCV"
--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Undo multilib forcing.
+sys-apps/sandbox -abi_riscv_lp64
--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Mask multilib, since we do not want to use it.
+multilib
+
+# Mask the other multilib flags back for non-multilib profile.
+abi_riscv_lp64
--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# RISC-V profile for rv64gc multilib
+
+CFLAGS="-O2 -pipe -march=rv64gc"
+CXXFLAGS="${CFLAGS}"
+FFLAGS="${CFLAGS}"
+FCFLAGS="${CFLAGS}"
+
+# Multilib ABIs
+MULTILIB_ABIS="lp64d lp64"
+DEFAULT_ABI="lp64d"
+ABI="lp64d"
+
+# Library directories
+LIBDIR_lp64d="lib64/lp64d"
+LIBDIR_lp64="lib64/lp64"
+SYMLINK_LIB="no"
+
+# Flags for lp64d
+CFLAGS_lp64d="-mabi=lp64d"
+# LDFLAGS_lp64d
+
+# Flags for lp64
+CFLAGS_lp64="-mabi=lp64"
+# LDFLAGS_lp64
+
+# Enable lp64d by default
+ABI_RISCV="lp64d"
+
+# Unhide the riscv/rv64gc-specific USE_EXPANDs
+USE_EXPAND_HIDDEN="-ABI_RISCV"
+
+# Implicitly enable lp64d in ebuilds without multilib support
+IUSE_IMPLICIT="abi_riscv_lp64d"
+
+# Enable Python 3.7 since we can't use earlier versions
+PYTHON_TARGETS="python3_7"
+PYTHON_SINGLE_TARGET="python3_7"
--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Doesnt work properly with the two-level libdirs
+<dev-lang/python-3.7
--- /dev/null
+..
+../../../features/multilib
--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Force the flag corresponding to the default ABI.
+abi_riscv_lp64d
+
+# Right now we have only one Python available, so we must use it
+python_targets_python3_7
+python_single_target_python3_7
--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Unmask the multilib flags for this arch.
+-abi_riscv_lp64d
+-abi_riscv_lp64
+
+# Our Python has a lot of trouble with the two-level libdir.
+python_targets_python2_7
+python_targets_python3_5
+python_targets_python3_6
+python_single_target_python2_7
+python_single_target_python3_5
+python_single_target_python3_6
--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Force the flag which corresponds to ARCH.
+riscv
--- /dev/null
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Unmask the flag which corresponds to ARCH.
+-riscv
+
+# The required library has not been ported to riscv yet.
+seccomp