[Bug] smart版本启用RT_USING_PTHREADS配置后,无法通过编译,类型冲突

未關閉
#11,339 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
c

研究方向

從 components/libc/posix/pthreads/pthread.h 和 pthread.c 開始,接著檢查經過 rttypes.h 以及 bits/alltypes.h 中 musl 標頭檔的 include 鏈。使用 arm-linux-musleabi-gcc 7.3.0 重現 RT_USING_PTHREADS 建置,並比較互相衝突的型別宣告。當 smart 設定能在沒有 pthread 型別衝突的情況下完成建置時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

RT-Thread Version

v5.2.2 Release

Hardware Type/Architectures

arm

Develop Toolchain

GCC

Describe the bug

编译器类型是arm-linux-musleabi-gcc,版本信息如下:

arm-linux-musleabi-gcc (GCC) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

build date: Jan  6 2023 18:24:13
musl  sha: 3536b4bc84df4672ac3b3747e36e3fa1332efc9b
build sha: 3536b4bc84df4672ac3b3747e36e3fa1332efc9b
build job: 434371

启用RT_USING_PTHREADS配置后,components/libc/posix/pthreads组件就无法通过编译:

/home/Tiimmi/codes/rtthread/rtthread/components/libc/posix/pthreads/pthread.h:37:14: error: conflicting types for 'pthread_t'
 typedef long pthread_t;
              ^~~~~~~~~
In file included from /home/Tiimmi/codes/rtthread/env/arm-linux-musleabi-linux-gnu/arm-linux-musleabi/include/sys/types.h:57:0,
                 from /home/Tiimmi/codes/rtthread/rtthread/include/rttypes.h:20,
                 from /home/Tiimmi/codes/rtthread/rtthread/include/rtsched.h:14,
                 from /home/Tiimmi/codes/rtthread/rtthread/include/rtdef.h:68,
                 from /home/Tiimmi/codes/rtthread/rtthread/include/rthw.h:23,
                 from /home/Tiimmi/codes/rtthread/rtthread/components/libc/posix/pthreads/pthread.c:16:
/home/Tiimmi/codes/rtthread/env/arm-linux-musleabi-linux-gnu/arm-linux-musleabi/include/bits/alltypes.h:301:28: note: previous declaration of 'pthread_t' was here
 typedef struct __pthread * pthread_t;
                            ^~~~~~~~~
In file included from /home/Tiimmi/codes/rtthread/rtthread/components/libc/posix/pthreads/pthread.c:17:0:
/home/Tiimmi/codes/rtthread/rtthread/components/libc/posix/pthreads/pthread.h:38:14: error: conflicting types for 'pthread_condattr_t'
 typedef long pthread_condattr_t;
              ^~~~~~~~~~~~~~~~~~
In file included from /home/Tiimmi/codes/rtthread/env/arm-linux-musleabi-linux-gnu/arm-linux-musleabi/include/sys/types.h:57:0,
                 from /home/Tiimmi/codes/rtthread/rtthread/include/rttypes.h:20,
                 from /home/Tiimmi/codes/rtthread/rtthread/include/rtsched.h:14,
                 from /home/Tiimmi/codes/rtthread/rtthread/include/rtdef.h:68,
                 from /home/Tiimmi/codes/rtthread/rtthread/include/rthw.h:23,
                 from /home/Tiimmi/codes/rtthread/rtthread/components/libc/posix/pthreads/pthread.c:16:
/home/Tiimmi/codes/rtthread/env/arm-linux-musleabi-linux-gnu/arm-linux-musleabi/include/bits/alltypes.h:327:37: note: previous declaration of 'pthread_condattr_t' was here
 typedef struct { unsigned __attr; } pthread_condattr_t;
                                     ^~~~~~~~~~~~~~~~~~
In file included from /home/Tiimmi/codes/rtthread/rtthread/components/libc/posix/pthreads/pthread.c:17:0:
/home/Tiimmi/codes/rtthread/rtthread/components/libc/posix/pthreads/pthread.h:39:14: error: conflicting types for 'pthread_rwlockattr_t'
 typedef long pthread_rwlockattr_t;
              ^~~~~~~~~~~~~~~~~~~~
In file included from /home/Tiimmi/codes/rtthread/env/arm-linux-musleabi-linux-gnu/arm-linux-musleabi/include/sys/types.h:57:0,
                 from /home/Tiimmi/codes/rtthread/rtthread/include/rttypes.h:20,
                 from /home/Tiimmi/codes/rtthread/rtthread/include/rtsched.h:14,
                 from /home/Tiimmi/codes/rtthread/rtthread/include/rtdef.h:68,
                 from /home/Tiimmi/codes/rtthread/rtthread/include/rthw.h:23,
                 from /home/Tiimmi/codes/rtthread/rtthread/components/libc/posix/pthreads/pthread.c:16:
/home/Tiimmi/codes/rtthread/env/arm-linux-musleabi-linux-gnu/arm-linux-musleabi/include/bits/alltypes.h:337:40: note: previous declaration of 'pthread_rwlockattr_t' was here
 typedef struct { unsigned __attr[2]; } pthread_rwlockattr_t;

节选了部分报错信息,剩余的报错基本都是rtthread中定义的类型与编译器头文件中定义的类型冲突了。

在网上搜索好像都没看到有人说过这个问题,只有一个2019年的issue:#3070

但是也没说解决方法。

smart版本的lwp组件强制要求musllibc,更换其他类型编译器会报:“No compatible lwp set status provided for this libc”

但是musl编译器的头文件定义的pthread类型和rtthread里的pthread.h头文件里定义的类型冲突。如何能够仍smart版本也能启用RT_USING_PTHREADS配置?

还是smart版本上使用pthread不需要启用这个配置?或者smart版本的pthread就是有问题的?

Other additional context

No response

主要語言
C
星號
12.4k
分支
5.5k
平均合併
3 天 7 小時
30 天內合併 PR
79

環境準備

在 Codespaces 中開啟

在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

RT-Thread/rt-thread 的其他 Issue

查看 RT-Thread/rt-thread 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。