已开启
添加RISC-V架构支持 #33
添加RISC-V架构支持 #33
已开启
bestsyi创建于 2025年7月24日
bestsyi
bestsyi
2025年7月24日

添加RISC-V架构支持

实现内容

为openGauss-embedded项目添加RISC-V 64位架构支持,使项目能够在RISC-V平台上成功编译和运行。

根因分析

openGauss-embedded项目原本只支持x86_64和ARM架构(aarch64),代码中包含了大量架构相关的指令和实现,如x86特有的SSE指令集、内存屏障(mfence)、自旋锁(pause指令)等,这些在RISC-V架构上不可用。
微信图片_20250724121937.png
微信图片_20250724122002.png
微信图片_20250724122005.png
微信图片_20250724122009.png
微信图片_20250724122012.png

实现方案

  1. 修改架构检测代码,在CMakeLists.txt中增加对RISC-V架构的识别和特定编译标志
  2. 为RISC-V架构提供CRC32校验和的软件实现替代方案
  3. 实现RISC-V架构特定的内存屏障和自旋锁操作
  4. 修改原子操作实现,使用RISC-V支持的原子指令
  5. 适配线程相关功能,如gettid系统调用的支持

具体修改文件包括:

  • src/storage/gstor/zekernel/common/cm_checksum.h
  • src/storage/gstor/zekernel/common/cm_checksum.c
  • src/storage/gstor/zekernel/common/cm_spinlock.h
  • src/storage/gstor/zekernel/common/cm_memory.h
  • src/storage/gstor/zekernel/common/cm_thread.c
  • src/storage/gstor/zekernel/common/cm_atomic.h
  • src/compute/sql/include/type/operator/fast_float.h
  • CMakeLists.txt及相关子目录的CMakeLists.txt

关联需求或issue

在RISC-V架构上编译运行openGauss-embedded,测试sql脚本。

开发自验报告

  1. 自验结果:在RISC-V 64位平台(riscv64)上成功编译并运行openGauss-embedded,所有功能正常
    1.png
    2.png
    3.png

  2. fastcheck测试用例:可添加RISC-V架构检测的测试用例,验证在该架构上所有组件是否正常工作

  3. 资料修改:需要在README.md中添加对RISC-V架构支持的说明,包括支持的版本和编译方法

  4. 升级场景:本次修改仅涉及编译时架构支持,不涉及系统表、日志格式或运行态数据格式变更

  5. 扩展场景:不影响在线扩容等扩展场景

  6. 异常场景考虑:

    • 确保在RISC-V架构上内存屏障、原子操作等关键功能正确实现
    • 保证并发场景下的正确性
    • 性能方面,部分操作使用软件实现替代硬件加速,可能有轻微影响
  7. 对其他模块影响:所有修改都有架构条件判断,不影响现有x86_64和aarch64架构的功能

  8. 补丁版本回合:不需要回合到补丁版本,仅为新增架构支持

其他说明

这是首次为openGauss-embedded添加RISC-V支持,后续可能需要进一步优化性能和稳定性。建议在各种负载下进行全面测试,特别是原子操作和内存屏障的实现对并发性能可能有影响。

likedislike
合并受阻
bestsyibestsyi
2025年7月24日 创建了 pull request,commit fad3cfee
opengauss_botopengauss_bot成员
2025年7月24日 添加了label:sig/Community
opengauss_botopengauss_bot成员
2025年7月24日 添加了label:stat/needs-squash
opengauss_bot
opengauss_bot成员
2025年7月24日 评论:

Welcome To openGauss Community

Hey @m0_73094631 , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands.

Contact Guide

If you have any questions, please contact the SIG: Community ,
and any of the committers: @CarrotGo, @Louisyzh, @caiwy110, @chendong76, @chenxiaobin19, @congzhou2603, @dodders, @feihongtaxueni, @guochuang_liyuxiang, @hwworkholic, @jemappellehc, @lizhen29, @muyulinzhong, @quemingjian, @shenzheng4, @shirley_zhengx, @superlchf, @telebby, @totaj, @wufeng0, @ywzq1161327784, @zengseliang .

likedislike
opengauss_botopengauss_bot成员
2025年7月24日 添加了label:codecheck-running
opengauss_botopengauss_bot成员
2025年7月24日 添加了label:opengauss-cla/yes
opengauss_bot
opengauss_bot成员
2025年7月24日 评论:

CLA Signature Pass

@m0_73094631, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
opengauss_botopengauss_bot成员
2025年7月24日 添加了label:needs-issue
opengauss_bot
opengauss_bot成员
2025年7月24日 评论:

Notice

@m0_73094631 , the pull request must be associated with at least one issue.
If it is already associated with an issue, but the needs-issue label also exists, you can comment on /check-issue to remove this label.

likedislike
opengauss_bot
opengauss_bot成员
2025年7月24日 评论:

开源片段扫描

Check Name Build Details Check Result Check Detail
sca #22934 ⚠️ 不通过 >>>
likedislike
opengauss_botopengauss_bot成员
2025年7月24日 添加了label:sca-failed
opengauss_bot
opengauss_bot成员
2025年7月24日 评论:

静态检查

Check Name Build Details Check Result Check Detail
CodeCheck #53819 ⚠️ 不通过 >>>
likedislike
opengauss_botopengauss_bot成员
2025年7月24日 添加了label:codecheck-failed
opengauss_botopengauss_bot成员
2025年7月24日 删除了label:codecheck-running
openLiBing-bot
openLiBing-bot成员
2025年7月24日 评论:
openLiBing-bot
openLiBing-bot成员
2025年7月24日 评论:
openLiBing-bot
openLiBing-bot成员
2025年7月24日 评论:
bestsyibestsyi
2025年7月25日 关联了issue: 在openGauss-embedded上适配RISC-V
opengauss_botopengauss_bot成员
2025年7月25日 删除了label:needs-issue
opengauss_botopengauss_bot成员
2025年7月31日 删除了label:sig/Community
opengauss_botopengauss_bot成员
2025年7月31日 添加了label:sig/Embedded
zengseliang
zengseliang成员
1月6日 评论:

/lgtm
/approve

likedislike
opengauss_botopengauss_bot成员
1月6日 添加了label:lgtm-zengseliang
opengauss_bot
opengauss_bot成员
1月6日 评论:

Review Code Feedback

  • The label lgtm-zengseliang was added to this pull request. It means that zengseliang reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
opengauss_botopengauss_bot成员
1月6日 添加了label:approved
opengauss_bot
opengauss_bot成员
1月6日 评论:

Review Code Feedback

  • The label approved was added to this pull request. It means that zengseliang reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
lizhen29
lizhen29成员
1月6日 评论:

/lgtm
/approve

likedislike
opengauss_botopengauss_bot成员
1月6日 添加了label:lgtm-lizhen29
opengauss_bot
opengauss_bot成员
1月6日 评论:

Review Code Feedback

  • The label lgtm-lizhen29 was added to this pull request. It means that lizhen29 reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
opengauss_bot
opengauss_bot成员
1月6日 评论:

Review Code Feedback

  • The label approved was added to this pull request. It means that lizhen29 reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
l1azzzy
l1azzzy成员
1月6日 评论:

/retest-sca

likedislike
l1azzzy
l1azzzy成员
1月6日 评论:

/retest-sca

likedislike
opengauss_bot
opengauss_bot成员
1月6日 评论:

开源片段扫描

Check Name Build Details Check Result Check Detail
sca #30256 ✅ 通过 >>>
likedislike
zengseliang
zengseliang成员
1月6日 评论:

/retest

likedislike
zengseliang
zengseliang成员
1月7日 评论:

/check-pr

likedislike
opengauss_bot
opengauss_bot成员
1月7日 评论:

Merge Verification Failed

@zengseliang, this pr is not mergeable and the reasons are below:

Missing Labels
  • the pull request needs codecheck-success label(s).
Label Usage Tips
  • codecheck-success: The static code check job is passed.
likedislike
zengseliang
zengseliang成员
1月7日 评论:

/retest-codecheck

likedislike