Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 28, 2025

When RT_USING_DM is enabled, both libcpu/risc-v/common64/cpuport.c and components/drivers/core/power.c define rt_hw_cpu_shutdown, causing linker failure.

Changes

  • Mark rt_hw_cpu_shutdown in libcpu/risc-v/common64/cpuport.c as rt_weak

This allows the power management implementation to override the default cpuport version when device manager is enabled, while maintaining the fallback for configurations without DM.

-void rt_hw_cpu_shutdown(void)
+rt_weak void rt_hw_cpu_shutdown(void)

Affects RISC-V 64-bit architectures: virt64, c906, c908, ur-cp100.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug] 当打开RT_USING_DM时rt_hw_cpu_shutdown 重复定义</issue_title>
<issue_description>### RT-Thread Version

upstream

Hardware Type/Architectures

riscv

Develop Toolchain

GCC

Describe the bug

Issue: Multiple definition of rt_hw_cpu_shutdown when RT_USING_DM is enabled.

Description:
When the device manager feature is enabled (RT_USING_DM), both rt-thread/libcpu/risc-v/common64/cpuport.c and rt-thread/components/drivers/core/power.c define rt_hw_cpu_shutdown, causing a linker error.

Solution:
Make the rt_hw_cpu_shutdown function in cpuport.c weak using the rt_weak attribute. This allows the power management implementation to override the default cpuport implementation when device manager is enabled.

Other additional context

No response</issue_description>

<agent_instructions>可以按照solution的方式进行修正。</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Fix multiple definition of rt_hw_cpu_shutdown with RT_USING_DM [risc-v][common64] Make rt_hw_cpu_shutdown weak to resolve multiple definition with RT_USING_DM Dec 28, 2025
Copilot AI requested a review from BernardXiong December 28, 2025 23:33
@github-actions github-actions bot added Arch: RISC-V BSP related with risc-v libcpu labels Dec 28, 2025
@github-actions
Copy link

📌 Code Review Assignment

🏷️ Tag: libcpu_riscv

Reviewers: @Yaochenger

Changed Files (Click to expand)
  • libcpu/risc-v/common64/cpuport.c

📊 Current Review Status (Last Updated: 2025-12-29 07:37 CST)


📝 Review Instructions

  1. 维护者可以通过单击此处来刷新审查状态: 🔄 刷新状态
    Maintainers can refresh the review status by clicking here: 🔄 Refresh Status

  2. 确认审核通过后评论 LGTM/lgtm
    Comment LGTM/lgtm after confirming approval

  3. PR合并前需至少一位维护者确认
    PR must be confirmed by at least one maintainer before merging

ℹ️ 刷新CI状态操作需要具备仓库写入权限。
ℹ️ Refresh CI status operation requires repository Write permission.

@BernardXiong BernardXiong marked this pull request as ready for review December 28, 2025 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: RISC-V BSP related with risc-v libcpu

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 当打开RT_USING_DM时rt_hw_cpu_shutdown 重复定义

3 participants