Skip to content

Commit

Permalink
RISC-V (#15053)
Browse files Browse the repository at this point in the history
  • Loading branch information
SSE4 authored Nov 3, 2023
1 parent f057798 commit 87fc478
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions conan/internal/api/detect_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def detect_arch():
return "armv8"
elif "ARM64" in machine:
return "armv8"
elif 'riscv64' in machine:
return "riscv64"
elif "riscv32" in machine:
return 'riscv32'
elif "64" in machine:
return "x86_64"
elif "86" in machine:
Expand Down
4 changes: 4 additions & 0 deletions conan/tools/gnu/get_gnu_triplet.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def _get_gnu_triplet(os_, arch, compiler=None):
elif "e2k" in arch:
# https://lists.gnu.org/archive/html/config-patches/2015-03/msg00000.html
machine = "e2k-unknown"
elif "riscv64" in arch:
machine = 'riscv64'
elif 'riscv32' in arch:
machine = "riscv32"

if machine is None:
raise ConanException("Unknown '%s' machine, Conan doesn't know how to "
Expand Down
5 changes: 3 additions & 2 deletions conan/tools/meson/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from conan.api.output import ConanOutput
from conan.tools.build.flags import cppstd_msvc_flag
from conans.errors import ConanException
from conans.model.options import _PackageOption

__all__ = ["to_meson_machine", "to_meson_value", "to_cppstd_flag"]
Expand Down Expand Up @@ -50,7 +49,9 @@
'sparcv9': ('sparc64', 'sparc64', 'big'),
'wasm': ('wasm32', 'wasm32', 'little'),
'x86': ('x86', 'x86', 'little'),
'x86_64': ('x86_64', 'x86_64', 'little')
'x86_64': ('x86_64', 'x86_64', 'little'),
'riscv32': ('riscv32', 'riscv32', 'little'),
'riscv64': ('riscv64', 'riscv32', 'little')
}


Expand Down
1 change: 1 addition & 0 deletions conans/client/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
sparc, sparcv9,
mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le,
e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7,
riscv64, riscv32,
xtensalx6, xtensalx106, xtensalx7]
compiler:
sun-cc:
Expand Down
2 changes: 2 additions & 0 deletions conans/test/unittests/tools/gnu/test_triplets.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
["Linux", "e2k-v5", None, "e2k-unknown-linux-gnu"],
["Linux", "e2k-v6", None, "e2k-unknown-linux-gnu"],
["Linux", "e2k-v7", None, "e2k-unknown-linux-gnu"],
["Linux", "riscv32", None, "riscv32-linux-gnu"],
["Linux", "riscv64", None, "riscv64-linux-gnu"],
])
def test_get_gnu_triplet(os_, arch, compiler, expected_triplet):
triplet = _get_gnu_triplet(os_, arch, compiler)
Expand Down
4 changes: 3 additions & 1 deletion conans/test/unittests/util/detected_architecture_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class DetectedArchitectureTest(unittest.TestCase):
['s390x', 's390x'],
['arm64', "armv8"],
['aarch64', 'armv8'],
['ARM64', 'armv8']
['ARM64', 'armv8'],
["riscv64", 'riscv64'],
['riscv32', "riscv32"]
])
def test_various(self, mocked_machine, expected_arch):

Expand Down

0 comments on commit 87fc478

Please sign in to comment.