Repository navigation
fix\[kernel]: resolve rt\_sched\_\* implicit declaration warnings in Eclipse/Studio builds - #11930
AZE-BlackCore wants to merge 1 commit into
Conversation
…pse/Studio builds The rt_sched_* scheduler APIs in include/rtsched.h are guarded by __RT_KERNEL_SOURCE__ / __RT_IPC_SOURCE__. The gcc/armclang branch of src/SConscript injects the macro via LOCAL_CPPDEFINES, which is honored by scons command-line builds but is NOT collected by the Eclipse project generator (tools/targets/eclipse.py) that RT-Thread Studio runs before each make build. As a result, Studio builds of dist-exported projects report 24 -Wimplicit-function-declaration warnings (clock.c 1, ipc.c 7, thread.c 12, timer.c 1, scheduler_comm.c 3). Move __RT_KERNEL_SOURCE__ into the global CPPDEFINES of the Kernel group, matching the existing msvc branch. The macro then lands in the generated rtconfig_preinc.h automatically and the warnings disappear, with no change to scons command-line build behavior or generated firmware. Verified: Studio rebuild 0 errors / 0 warnings; firmware size unchanged.
|
|
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: kernelReviewers: @GorrayLi @ReviewSun @hamburger-os @lianux-mm @wdfk-prog @xu18838022837 Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-10-25 17:04 CST)
📝 Review Instructions
|
…pse/Studio builds
The rt_sched_* scheduler APIs in include/rtsched.h are guarded by RT_KERNEL_SOURCE / RT_IPC_SOURCE. The gcc/armclang branch of src/SConscript injects the macro via LOCAL_CPPDEFINES, which is honored by scons command-line builds but is NOT collected by the Eclipse project generator (tools/targets/eclipse.py) that RT-Thread Studio runs before each make build. As a result, Studio builds of dist-exported projects report 24 -Wimplicit-function-declaration warnings (clock.c 1, ipc.c 7, thread.c 12, timer.c 1, scheduler_comm.c 3).
Move RT_KERNEL_SOURCE into the global CPPDEFINES of the Kernel group, matching the existing msvc branch. The macro then lands in the generated rtconfig_preinc.h automatically and the warnings disappear, with no change to scons command-line build behavior or generated firmware.
Verified: Studio rebuild 0 errors / 0 warnings; firmware size unchanged.
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
通过
scons --dist-ide导出的项目在 RT-Thread Studio / Eclipse(构建前运行scons --target=eclipse)下使用 gcc/armclang 工具链编译时,内核 5 个源文件(src/clock.c、src/ipc.c、src/thread.c、src/timer.c、src/scheduler_comm.c)报 24 条-Wimplicit-function-declaration警告(rt_sched_*内部调度 API 隐式声明)。该问题在最新 master(
a59e72fb5c)上已独立复现;且 GCC 14 起-Wimplicit-function-declaration默认升级为 error,同一问题在 GCC 14+/15 工具链下会导致编译失败,直接阻断构建。修复可同时消除警告并避免新工具链下的硬错误。你的解决方案是什么 (what is your solution)
根因:
include/rtsched.h中rt_sched_*声明被#if defined(__RT_KERNEL_SOURCE__) || defined(__RT_IPC_SOURCE__)包裹;scons 命令行构建通过src/SConscript的LOCAL_CPPDEFINES注入该宏,但 Studio 构建链路的 Eclipse 工程生成器(tools/targets/eclipse.py)只收集全局project['CPPDEFINES']写入rtconfig_preinc.h,不收集LOCAL_CPPDEFINES,导致 preinc 缺宏、声明不可见。修复:
src/SConscriptgcc/armclang 分支将__RT_KERNEL_SOURCE__从LOCAL_CPPDEFINES移入 Kernel 组全局CPPDEFINES(与既有 msvc 分支写法一致,一行改动):效果:
scons --target=eclipse每次生成的rtconfig_preinc.h自动包含#define __RT_KERNEL_SOURCE__,Studio make 构建经-include可见声明,警告清零。宏仍只作用于 Kernel 组内文件,scons 命令行构建编译参数不变,固件逐字节一致,无 API/ABI/ 运行时影响请提供验证的bsp和config (provide the config and bsp)
bsp/stm32/stm32l475-atk-pandorasrc/SConscript)纯构建层修改,不涉及任何配置项,验证使用bsp/stm32/stm32l475-atk-pandora默认配置即可复现(无需改动 .config)。复现 / 验证方式:scons --dist-ide --project-name=stm32l475-atk-pandora导出后,在 RT-Thread Studio 中 Clean + 重新构建。测试情况(已确认,板卡:stm32l475-atk-pandora):① Studio 同参命令行(
-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O0 -Wall -std=gnu99 -include rtconfig_preinc.h+ 完整包含路径,GCC 5.4.1)编译 5 个内核文件:修复前 24 警告 → 修复后 0 警告;② RT-Thread Studio 实测:Clean 后重新构建 0 errors / 0 warnings,固件 96.64 KB Flash / 6.58 KB RAM,与修复前逐字节一致;③ scons 命令行构建回归通过;④ 最新 master 对照:问题独立复现(GCC 5.4.1 下 24 警告、GCC 15.2.1 下编译失败);⑤ dev 导出项目内 A/B 对照:仅切换 SConscript 一处,不带修复 24 警告 → 带修复 0 警告。]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up