LLVM and Pthreads

Hello,

I know clang supports -pthread option (here). Does this mean I can call pthread routines inside llvm code and which pthread library is used, the one for Linux OS or the one for Windows?

Thank you.
Iulia

I know clang supports -pthread option (here). Does this mean I can call
pthread routines inside llvm code

LLVM itself can run when pthreads isn't available, so while some parts
do use pthreads they have alternative implementations for other
systems. Take a look at Mutex.cpp for example: the default is Posix
but there's a Windows specific version in lib/Support/Windows.

and which pthread library is used, the one for Linux OS or the one for Windows?

There's never (to my knowledge) a situation where both of those are
valid answers: if you're running on Linux you'll use a Linux library,
if you're running on Windows you'll use a Windows library.

Tim.

I know clang supports -pthread option (here). Does this mean I can call
pthread routines inside llvm code

LLVM itself can run when pthreads isn’t available, so while some parts
do use pthreads they have alternative implementations for other
systems. Take a look at Mutex.cpp for example: the default is Posix
but there’s a Windows specific version in lib/Support/Windows.

and which pthread library is used, the one for Linux OS or the one for Windows?

There’s never (to my knowledge) a situation where both of those are
valid answers: if you’re running on Linux you’ll use a Linux library,
if you’re running on Windows you’ll use a Windows library.

Thank you. My question was: is PThreads library for Windows supported by LLVM?

Tim.

No, you cannot use pthreads in windows.

If you want to write multithreaded code you need to use (or create) a portable abstraction

Hello all,

I am returning to this subject after a while and I was looking for CBuilder::CreatePThreadCreateCall function below. I cannot find it anywere and I guess it has been rename or changed into a more generic one. I would want to insert a phtread call into the input source code. Which builder class to use for that instead of CBuilder class? If I insert the call into IR representation, do I need to insert the call also into machine representation?

Kind regards,

Hi Iulia,

The declaration Rob has shared was never part of mainline LLVM (afaik).
The implementation Rob provided should however still work.
Have you tried it?

There is no need to add/change anything in the machine representation.

Cheers,
  Johannes