Skip to content

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

@laijunyong

Description

@laijunyong

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions