Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

-pthread option not supported when linking with clang++... #8210

Open Quuxplusone opened 14 years ago

Quuxplusone commented 14 years ago
Bugzilla Link PR7798
Status NEW
Importance P normal
Reported by Fons Rademakers (Fons.Rademakers@cern.ch)
Reported on 2010-08-03 10:46:17 -0700
Last modified on 2018-08-30 04:37:24 -0700
Version trunk
Hardware Macintosh All
CC daniel@zuster.org, dgregor@apple.com, eugeni.stepanov@gmail.com, jrose@belkadan.com, julien.isorce@gmail.com, llvm-bugs@justinbogner.com, llvm-bugs@lists.llvm.org, mikestump@comcast.net, rafael@espindo.la, samsonov@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also PR38772
Hi,

  when linking:

clang++ -O2 -m64 stress.o Event.o EventDict.o -L/Users/rdm/rooticc/lib -lCore -
lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -
lMatrix -lPhysics -lMathCore -lThread -pthread -Wl,-
rpath,/Users/rdm/rooticc/lib -lm -ldl  -o stress

I get the warning:

clang: warning: argument unused during compilation: '-pthread'

while with g++ this option is needed (adds -lpthread on non Mac systems) or at
least does not complain.

Cheers, Fons.
Quuxplusone commented 14 years ago

I assume this is on Darwin. The driver is correct that -pthread is unused, I suppose you want it to be suppressed because it might be used on some other platform.

I'm planning on doing some work to the unused argument diagnostics at some point, I'll think about what the best solution is then.

Quuxplusone commented 14 years ago
Hi,

 yes this is on Darwin and I assume the pthread lib is part of libSystem so -pthread during linking is mostly a noop, but since g++ accepts it during linking on Darwin, and since it is need on many other platforms, I would not mind silence acceptance.

Cheers, Fons.
Quuxplusone commented 14 years ago

This is a driver issue.

Quuxplusone commented 9 years ago
Any progress ? This is something really wanted when using libtool/autoconf on
darwin. (ex: macports)

To demonstrate the problem:

- case A: 1 step is ok:
clang -pthread test.c -o output (compile and link)

- case B: 2 steps is not ok:
clang -pthread test.c -c -o obj.o (compile)
clang -pthread obj.o -o output (link)
-> argument unused during compilation: '-pthread'

Most of the time -Werror is added so it cannot build. Then people are required
to add -Qunused-arguments or -Wno-error=unused-command-line-argument to
workaround this problem.

Both case A and B are working when using clang on linux without any warning
(and without any error if -Werror is added). Indeed adding option -v you can
see that clang on linux never pass -pthread to the linker ld.
So clang behaves differently between darwin and linux from user point of view.

Question:
Could you point out where in the linux driver (https://github.com/llvm-
mirror/clang/blob/master/lib/Driver/Tools.cpp ?) the -pthread
(options::OPT_pthread ?) is silent at link time ? gnutools::Link::ConstructJob
and darwin::Link::ConstructJob look quite different.
Quuxplusone commented 9 years ago

Possible related commits that could serve as example to fix this issue.

0a9f133c0448657c6485afb2a856746164298479

21bce1ccb777dd86284c99b5def73888fd144e99

009a77818c53799db2d150e835332df6f5542004

3667bbe0f235a8b3fc2496acc8f3136dfb559cc9

e0e6d3b5cf61dfefad3c0393f4786d2cf3d9c272

4d63f8bc2686d5d7580324407854f2ca7c128832

5345c391c65d1780a0d7b0102b7f735cc3f82732

Quuxplusone commented 8 years ago

Any plan to fix the problem ? See #3 and #4