Recent versions of the command line tools for Xcode appear to have changed the way the -pthread
argument to the compiler is handled such that it generates a warning if used in a call to the compiler that actually only links existing objects into an executable. When used to compile C or C++ into .o
files it’s fine.
This wouldn’t be a big deal but for the fact (as stated elsewhere) that I compile my own code with -Wall -Werror
. The warning then causes the link stage to fail. Unfortunately fixing this is not a simple case of removing -pthread
from my link command because it isn’t me who puts it there. In fact that flag is added by libtool
as it is also used during the compilation of one of the third-party libraries I’m linking against, libhidapi
.
I thought salvation had come my way last night when I discovered that clang
on OSX has another flag, -Qunused-arguments
, which is supposed to prevent the compiler issuing warnings about unused command line arguments. But here’s where I am now:
If I build the project as normal, with -Wall -Werror
, all the code compiles happily but fails at the link stage because of the -pthread
warning. If I repeat the command manually without that flag then the link stage works.
If I build the project only changing CFLAGS
to add -Qunused-arguments
then compilation again completes happily, but the link stage this time fails with hundreds of duplicate symbols, many of which appear to be inline functions from the libm
. Linking manually removing both this and the -pthread
flag fails the same way.
I can only assume that -Qunused-arguments
is causing some other side-effect, perhaps when configure
is run, but at the moment I just can’t find it.