[PATCH] D158375: Fix build for riscv32

Khem Raj via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 20 13:57:41 PDT 2023


raj.khem created this revision.
raj.khem added a reviewer: asb.
Herald added subscribers: sunshaoce, VincentWu, vkmr, mstojanovic, sameer.abuasal, pengfei, s.egerton, Jim, benna, psnobl, rogfer01, shiva0217, kito-cheng, simoncook, arichardson.
Herald added a project: All.
raj.khem requested review of this revision.
Herald added subscribers: llvm-commits, wangpc, eopXD, courbet.
Herald added a project: LLVM.

SYS_mmap is not available on RV32 and it fails to build

  | /mnt/b/yoe/master/build/tmp/work-shared/llvm-project-source-17.0.0-r0/git/llvm/tools/llvm-exegesis/lib/X86/Target.cpp:1116:19: error: use of undeclared identifier 'SYS_mmap'
  |  1116 |   generateSyscall(SYS_mmap, MmapCode);                                    
  |       |                   ^                                                                                                                                                               
  | /mnt/b/yoe/master/build/tmp/work-shared/llvm-project-source-17.0.0-r0/git/llvm/tools/llvm-exegesis/lib/X86/Target.cpp:1134:19: error: use of undeclared identifier 'SYS_mmap'
  |  1134 |   generateSyscall(SYS_mmap, GeneratedCode);                                                                                                                                       |       |                   ^                                                                 
  | 1 warning and 2 errors generated.        


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158375

Files:
  llvm/tools/llvm-exegesis/lib/X86/Target.cpp
  llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp


Index: llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp
===================================================================
--- llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp
+++ llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp
@@ -635,11 +635,11 @@
 #define MAP_FIXED_NOREPLACE MAP_FIXED
 #endif
 
-// 32 bit ARM doesn't have mmap and uses mmap2 instead. The only difference
-// between the two syscalls is that mmap2's offset parameter is in terms 4096
-// byte offsets rather than individual bytes, so for our purposes they are
-// effectively the same as all ofsets here are set to 0.
-#ifdef __arm__
+// 32 bit ARM and RISCV doesn't have mmap and uses mmap2 instead. The only
+// difference between the two syscalls is that mmap2's offset parameter is in
+// terms 4096 byte offsets rather than individual bytes, so for our purposes
+// they are effectively the same as all ofsets here are set to 0.
+#if defined(__arm__) || (defined(__riscv) && (__riscv_xlen == 32))
 #define SYS_mmap SYS_mmap2
 #endif
 
Index: llvm/tools/llvm-exegesis/lib/X86/Target.cpp
===================================================================
--- llvm/tools/llvm-exegesis/lib/X86/Target.cpp
+++ llvm/tools/llvm-exegesis/lib/X86/Target.cpp
@@ -1087,11 +1087,11 @@
 #define MAP_FIXED_NOREPLACE MAP_FIXED
 #endif
 
-// 32 bit ARM doesn't have mmap and uses mmap2 instead. The only difference
-// between the two syscalls is that mmap2's offset parameter is in terms 4096
-// byte offsets rather than individual bytes, so for our purposes they are
-// effectively the same as all ofsets here are set to 0.
-#ifdef __arm__
+// 32 bit ARM and RISCV doesn't have mmap and uses mmap2 instead. The only
+// difference between the two syscalls is that mmap2's offset parameter is in
+// terms 4096 byte offsets rather than individual bytes, so for our purposes
+// they are effectively the same as all ofsets here are set to 0.
+#if defined(__arm__) || (defined(__riscv) && (__riscv_xlen == 32))
 #define SYS_mmap SYS_mmap2
 #endif
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158375.551867.patch
Type: text/x-patch
Size: 2028 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230820/3a0fdf32/attachment.bin>


More information about the llvm-commits mailing list