GNOME Bugzilla – Bug 747730
osx: fails to build tests/examples/streams/rtpool-test
Last modified: 2015-06-13 23:41:32 UTC
It fails with "clang: error: argument unused during compilation: -pthread" because -pthread option is only accepted by the compiler, not the linker. Also see http://stackoverflow.com/questions/17841140/os-x-clang-pthread . clangs --help | grep pthread: "-pthread Support POSIX threads in generated code" PTHREAD_LIBS does not contain -pthread, only PTHREAD_CFLAGS contains -pthread. But the problem is that automake passes rtpool_test_CFLAGS to the linker: rtpool_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(rtpool_test_CFLAGS) \ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ rtpool-test$(EXEEXT): $(rtpool_test_OBJECTS) $(rtpool_test_DEPENDENCIES) $(EXTRA_rtpool_test_DEPENDENCIES) @rm -f rtpool-test$(EXEEXT) $(AM_V_CCLD)$(rtpool_test_LINK) $(rtpool_test_OBJECTS) $(rtpool_test_LDADD) $(LIBS) So in the end -pthread is passed to the linker which result to an error. We could argue to just remove -Werror but maybe it's better to find a way to avoid forwarding -pthread to the linker, see following patch.
Created attachment 301407 [details] [review] examples: fix rtpool-test build on osx with clang $ gcc --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn) Target: x86_64-apple-darwin14.1.0 Thread model: posix In generated Makefile it now looks like: rtpool-test$(EXEEXT): $(rtpool_test_OBJECTS) $(rtpool_test_DEPENDENCIES) $(EXTRA_rtpool_test_DEPENDENCIES) @rm -f rtpool-test$(EXEEXT) $(AM_V_GEN)$(rtpool_test_LINK) $(rtpool_test_OBJECTS) $(rtpool_test_LDADD) $(LIBS)
This sounds like a bug in automake, it should not pass CFLAGS to the linker at all (or CPPFLAGS for that matter). I'd prefer to rather fix automake than working around this all over the place in our code.
Some infos: http://lists.gnu.org/archive/html/autoconf-archive-maintainers/2013-06/msg00021.html http://stackoverflow.com/questions/17055279/autotools-for-pthreads-not-setting-correct-linker-flags
*** Bug 737030 has been marked as a duplicate of this bug. ***
Duplicate of bug #747954?
Yes (initially I thought it should be fixed separately.)
*** This bug has been marked as a duplicate of bug 747954 ***