mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.56k stars 1.61k forks source link

How does "threads" dependency detection work? #7775

Open phillipjohnston opened 4 years ago

phillipjohnston commented 4 years ago

Hello,

I'm checking for the threads dependency in the build:

libthread = dependency('threads', native: false, required: false)

Meson says this is found:

Run-time dependency threads found: YES
Build-time dependency threads found: YES

But the compiler doesn't actually support pthread:

arm-none-eabi-c++: error: unrecognized command line option '-pthread'

My first question is - what logic is actually used to check for pthread support?

dcbaker commented 4 years ago

Basically we assume that a given os has threads. We probably should do a check for pthreads instead of hard coding

phillipjohnston commented 4 years ago

Got it. In this particular case there is no OS :).

dcbaker commented 4 years ago

I'm assuming you're doing a cross build, what do you have for your host_machine in the cross file?

phillipjohnston commented 4 years ago

I always set system to none for all of my microcontroller cross files. For example:

[host_machine]
system = 'none'
cpu_family = 'arm'
cpu = 'cortex-m4'
endian = 'little'
jscott0 commented 2 years ago

To check for the presence of POSIX threads, one can do getconf _POSIX_THREADS. Perhaps this could be used?

afxgroup commented 1 year ago

I have the same problem using a cross compiler for AmigaOS4. -pthread is not supported. Is there a way to remove the flag and use -lpthread instead?

thesamesam commented 5 months ago

There's a lot of substantive discussion in https://github.com/mesonbuild/meson/pull/13124 too (and previously https://github.com/mesonbuild/meson/pull/7174).