diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-04-25 11:48:39 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-04-25 21:27:43 +0200 |
commit | b1141fa61073b3f24e1a3574afa55a954e5a153d (patch) | |
tree | 38099f5da3eb398436c1e2b85d77b955d6a886ea /solenv | |
parent | 1029d2a3ea3e6ec6f9b8a90a00e2b2b595fef5f2 (diff) |
Cut down on -pthread/-lpthread proliferation
Building against libstdc++ effectively always requires -pthread anyway (as
various standard C++ headers require it, see the comment added to
solenv/gbuild/platform/unxgcc.mk), so many explicit uses of -pthread/-lpthread
can be removed.
Doing a (partial) test build on Linux with Clang -stdlib=libc++ suggests that
libc++ indeed doesn't need -pthread as libstdc++ does.
The remaining uses of -pthread/-lpthread are mostly in configure.ac for the
various BSDs (which somebody else might want to clean up now), and related to
external projects. I tried to be careful to remove -pthread/-lpthread from
makefiles only when C++ object files are involved (so -pthread will now be
included on the link command line by default).
Change-Id: I936e082839cb9a434bd273ce5a1f187a4245dfa1
Reviewed-on: https://gerrit.libreoffice.org/71291
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'solenv')
-rw-r--r-- | solenv/gbuild/platform/linux.mk | 2 | ||||
-rw-r--r-- | solenv/gbuild/platform/unxgcc.mk | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/solenv/gbuild/platform/linux.mk b/solenv/gbuild/platform/linux.mk index 727418b8ea61..77d4dbe679e8 100644 --- a/solenv/gbuild/platform/linux.mk +++ b/solenv/gbuild/platform/linux.mk @@ -18,7 +18,7 @@ gb_LinkTarget_LDFLAGS += $(gb__LinkTarget_LDFLAGS_zdefs) include $(GBUILDDIR)/platform/unxgcc.mk ifeq ($(DISABLE_DYNLOADING),TRUE) -gb_STDLIBS := -lpthread -ldl +gb_STDLIBS := -ldl endif # vim: set noet sw=4 ts=4: diff --git a/solenv/gbuild/platform/unxgcc.mk b/solenv/gbuild/platform/unxgcc.mk index 27edd2932589..0cd205891d2e 100644 --- a/solenv/gbuild/platform/unxgcc.mk +++ b/solenv/gbuild/platform/unxgcc.mk @@ -42,12 +42,20 @@ gb_CFLAGS := \ -Wdeclaration-after-statement \ -Wshadow \ +# At least libstdc++ (which is approximated here with !HAVE_LIBCXX) needs -pthread when including +# various C++ headers like <thread>, see <https://gcc.gnu.org/onlinedocs/gcc-8.3.0/libstdc++/manual/ +# manual/using.html#manual.intro.using.flags>: +ifeq ($(HAVE_LIBCXX),) +gb_CXX_LINKFLAGS := -pthread +endif + gb_CXXFLAGS := \ $(gb_CXXFLAGS_COMMON) \ -fPIC \ -Wshadow \ -Woverloaded-virtual \ $(CXXFLAGS_CXX11) \ + $(gb_CXX_LINKFLAGS) \ # enable debug STL @@ -112,7 +120,7 @@ gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) # contains .c sources: define gb_LinkTarget__command_dynamiclink $(call gb_Helper_abbreviate_dirs,\ - $(if $(CXXOBJECTS)$(GENCXXOBJECTS)$(EXTRAOBJECTLISTS)$(filter-out XTRUE,X$(ENABLE_RUNTIME_OPTIMIZATIONS)),$(gb_CXX),$(gb_CC)) \ + $(if $(CXXOBJECTS)$(GENCXXOBJECTS)$(EXTRAOBJECTLISTS)$(filter-out XTRUE,X$(ENABLE_RUNTIME_OPTIMIZATIONS)),$(gb_CXX) $(gb_CXX_LINKFLAGS),$(gb_CC)) \ $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \ $(gb_LTOFLAGS) \ $(if $(SOVERSIONSCRIPT),-Wl$(COMMA)--soname=$(notdir $(1)) \ |