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>
This commit is contained in:
Stephan Bergmann 2019-04-25 11:48:39 +02:00
parent 1029d2a3ea
commit b1141fa610
38 changed files with 11 additions and 65 deletions

View file

@ -45,7 +45,6 @@ $(eval $(call gb_Executable_use_static_libraries,canvasdemo,\
ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
$(eval $(call gb_Executable_add_libs,canvasdemo,\
-lm $(DLOPEN_LIBS) \
-lpthread \
-lX11 \
))

View file

@ -24,7 +24,7 @@ $(eval $(call gb_Library_set_include,mysqlc,\
$(eval $(call gb_Library_add_libs,mysqlc,\
$(if $(filter-out WNT,$(OS)),$(if $(filter HAIKU MACOSX SOLARIS,$(OS)),\
-lz -lm,-rdynamic -lz -lcrypt -lm)) \
$(if $(filter LINUX,$(OS)),-lpthread -ldl,) \
$(if $(filter LINUX,$(OS)),-ldl,) \
))
$(eval $(call gb_Library_use_sdk_api,mysqlc))

View file

@ -61,7 +61,6 @@ $(eval $(call gb_Library_add_libs,postgresql-sdbc-impl,\
$(if $(WITH_GSSAPI),$(GSSAPI_LIBS)) \
$(if $(WITH_KRB5),$(KRB5_LIBS)) \
$(if $(filter-out MACOSX,$(OS)),-ldl) \
$(if $(filter-out MACOSX,$(OS)),-lpthread) \
))
endif

View file

@ -66,7 +66,6 @@ endif
$(eval $(call gb_CppunitTest_add_libs,desktop_app,\
-lm $(DLOPEN_LIBS) \
-lpthread \
-lX11 \
))
endif

View file

@ -40,7 +40,6 @@ ifeq ($(OS),LINUX)
$(eval $(call gb_CppunitTest_add_libs,desktop_lok_init,\
-lm \
-ldl \
-lpthread \
))
endif

View file

@ -26,7 +26,6 @@ $(eval $(call gb_Library_add_defs,crashreport,\
$(eval $(call gb_Library_add_libs,crashreport,\
$(if $(filter LINUX %BSD SOLARIS, $(OS)), \
$(DLOPEN_LIBS) \
-lpthread \
) \
))

View file

@ -19,7 +19,6 @@ $(eval $(call gb_Library_set_include,sofficeapp,\
$(eval $(call gb_Library_add_libs,sofficeapp,\
$(if $(filter LINUX %BSD SOLARIS, $(OS)), \
$(DLOPEN_LIBS) \
-lpthread \
) \
))
@ -135,7 +134,6 @@ $(eval $(call gb_Library_add_exception_objects,sofficeapp,\
ifeq ($(DISABLE_GUI),TRUE)
$(eval $(call gb_Library_add_libs,sofficeapp,\
-lm $(DLOPEN_LIBS) \
-lpthread \
))
else
ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
@ -147,7 +145,6 @@ endif
$(eval $(call gb_Library_add_libs,sofficeapp,\
-lm $(DLOPEN_LIBS) \
-lpthread \
-lX11 \
))
endif

View file

@ -48,7 +48,6 @@ ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,clucene,\
-lm \
-ldl \
-lpthread \
))
endif

View file

@ -572,7 +572,6 @@ ifneq (,$(filter LINUX ANDROID,$(OS)))
$(eval $(call gb_Library_add_libs,pdfium,\
-ldl \
-lrt \
-lpthread \
))
$(eval $(call gb_Library_use_external,pdfium,freetype))

View file

@ -74,10 +74,6 @@ $(eval $(call gb_Library_use_system_darwin_frameworks,jpipe, \
))
endif
$(eval $(call gb_Library_add_libs,jpipe, \
$(if $(filter-out $(OS),ANDROID),-lpthread) \
))
$(call gb_LinkTarget_get_target,$(call gb_Library_get_linktarget,jpipe)): \
gb_CC := $(filter-out -fsanitize%,$(gb_CC))
$(call gb_LinkTarget_get_target,$(call gb_Library_get_linktarget,jpipe)): \

View file

@ -28,7 +28,6 @@ ifeq ($(OS),LINUX)
$(eval $(call gb_CppunitTest_add_libs,libreofficekit_tiledrendering,\
-lm \
-ldl \
-lpthread \
))
endif

View file

@ -43,7 +43,6 @@ $(eval $(call gb_Executable_use_libraries,gtktiledviewer,\
ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
$(eval $(call gb_Executable_add_libs,gtktiledviewer,\
-lm $(DLOPEN_LIBS) \
-lpthread \
))
endif

View file

@ -24,7 +24,6 @@ $(eval $(call gb_Executable_use_libraries,tilebench,\
$(eval $(call gb_Executable_add_libs,tilebench,\
-lm $(DLOPEN_LIBS) \
-lpthread \
))
$(eval $(call gb_Executable_add_exception_objects,tilebench,\

View file

@ -57,7 +57,6 @@ $(eval $(call gb_Executable_add_libs,test_updater_dialog,\
-lXrender \
-lSM \
-lICE \
-lpthread \
))
endif

View file

@ -70,7 +70,6 @@ $(eval $(call gb_Executable_add_libs,updater,\
-lXrender \
-lSM \
-lICE \
-lpthread \
))
endif

View file

@ -56,9 +56,6 @@ $(eval $(call gb_Library_use_system_win32_libs,sal,\
))
$(eval $(call gb_Library_add_libs,sal,\
$(if $(filter-out ANDROID HAIKU WNT,$(OS)), \
-lpthread \
) \
$(if $(filter LINUX,$(OS)), \
-ldl \
-lrt \

View file

@ -118,12 +118,6 @@ $(eval $(call gb_CppunitTest_add_libs,sc_ucalc,\
))
endif
ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
$(eval $(call gb_CppunitTest_add_libs,sc_ucalc,\
-lpthread \
))
endif
$(eval $(call gb_CppunitTest_use_configuration,sc_ucalc))
# vim: set noet sw=4 ts=4:

View file

@ -718,12 +718,6 @@ $(eval $(call gb_Library_add_libs,sc,\
))
endif
ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
$(eval $(call gb_Library_add_libs,sc,\
-lpthread \
))
endif
$(eval $(call gb_SdiTarget_SdiTarget,sc/sdi/scslots,sc/sdi/scalc))
$(eval $(call gb_SdiTarget_set_include,sc/sdi/scslots,\

View file

@ -16,7 +16,6 @@ $(eval $(call gb_Executable_set_include,libtest,\
ifeq ($(OS),LINUX)
$(eval $(call gb_Executable_add_libs,libtest,\
-ldl \
-pthread \
))
endif

View file

@ -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:

View file

@ -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)) \

View file

@ -111,11 +111,6 @@ $(eval $(call gb_Library_use_externals,svl,\
nss3 \
plc4 \
))
ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,svl, \
-lpthread \
))
endif
endif # BUILD_TYPE=DESKTOP
endif

View file

@ -64,13 +64,11 @@ endif
ifeq ($(DISABLE_GUI),TRUE)
$(eval $(call gb_Executable_add_libs,gengal,\
$(DLOPEN_LIBS) \
-lpthread \
))
else
ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
$(eval $(call gb_Executable_add_libs,gengal,\
$(DLOPEN_LIBS) \
-lpthread \
-lX11 \
))

View file

@ -37,7 +37,6 @@ $(eval $(call gb_Executable_use_static_libraries,icontest,\
ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
$(eval $(call gb_Executable_add_libs,icontest,\
-lm $(DLOPEN_LIBS) \
-lpthread \
-lX11 \
))

View file

@ -92,7 +92,6 @@ ifeq ($(OS),LINUX)
$(eval $(call gb_Executable_add_libs,lo_kde5filepicker,\
-lm \
-ldl \
-lpthread \
))
endif

View file

@ -43,7 +43,6 @@ $(eval $(call gb_Executable_use_static_libraries,mtfdemo,\
ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
$(eval $(call gb_Executable_add_libs,mtfdemo,\
-lm $(DLOPEN_LIBS) \
-lpthread \
-lX11 \
))

View file

@ -37,7 +37,6 @@ $(eval $(call gb_Executable_add_exception_objects,ui-previewer,\
ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
$(eval $(call gb_Executable_add_libs,ui-previewer,\
-lm $(DLOPEN_LIBS) \
-lpthread \
-lX11 \
))

View file

@ -53,7 +53,6 @@ $(eval $(call gb_Executable_use_static_libraries,vcldemo,\
ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
$(eval $(call gb_Executable_add_libs,vcldemo,\
-lm $(DLOPEN_LIBS) \
-lpthread \
-lX11 \
))

View file

@ -45,7 +45,6 @@ ifeq ($(OS),LINUX)
$(eval $(call gb_Executable_add_libs,visualbackendtest,\
-lm \
-ldl \
-lpthread \
-lX11 \
))

View file

@ -66,7 +66,6 @@ $(eval $(call gb_Library_add_exception_objects,desktop_detector,\
ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
$(eval $(call gb_Library_add_libs,desktop_detector,\
-lm $(DLOPEN_LIBS) \
-lpthread \
))
endif

View file

@ -545,11 +545,6 @@ $(eval $(call gb_Library_use_externals,vcl,\
freetype \
fontconfig \
))
ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
$(eval $(call gb_Library_add_libs,vcl,\
-lpthread \
))
endif
else # ! DISABLE_GUI
@ -578,7 +573,6 @@ endif
ifeq ($(OS), $(filter LINUX %BSD SOLARIS, $(OS)))
$(eval $(call gb_Library_add_libs,vcl,\
-lm $(DLOPEN_LIBS) \
-lpthread \
-lX11 \
-lXext \
))

View file

@ -145,7 +145,6 @@ ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,vclplug_gen,\
-lm \
-ldl \
-lpthread \
))
endif

View file

@ -126,7 +126,6 @@ ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,vclplug_gtk,\
-lm \
-ldl \
-lpthread \
))
endif

View file

@ -116,7 +116,6 @@ ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,vclplug_gtk3,\
-lm \
-ldl \
-lpthread \
))
endif

View file

@ -124,7 +124,6 @@ ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,vclplug_gtk3_kde5,\
-lm \
-ldl \
-lpthread \
))
endif

View file

@ -89,7 +89,6 @@ ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,vclplug_kde5,\
-lm \
-ldl \
-lpthread \
))
endif

View file

@ -114,7 +114,6 @@ ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,vclplug_qt5,\
-lm \
-ldl \
-lpthread \
))
endif

View file

@ -31,7 +31,6 @@ $(eval $(call gb_StaticLibrary_use_api,glxtest,\
$(eval $(call gb_StaticLibrary_add_libs,glxtest,\
-lm $(DLOPEN_LIBS) \
-lpthread \
-lX11 \
))