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

オープン
#11,339 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
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 のビルドを再現し、競合している型宣言を比較します。pthread の型の競合なしで Smart configuration がビルドできれば完了です。

索引モデルが 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時間
マージ済み PR(30日)
79

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

RT-Thread/rt-thread のほかの issue

RT-Thread/rt-thread の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。