From a12bf2d75314c2e3032b017f41e0785e0ed733d9 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 29 Jul 2020 16:14:51 -0700 Subject: [PATCH 1/2] Fancier TBB (Threaded Building Blocks) detection. Update documentation to mention that it's needed. --- profiler/build/unix/build.mk | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/profiler/build/unix/build.mk b/profiler/build/unix/build.mk index 101141f6..865c41a0 100644 --- a/profiler/build/unix/build.mk +++ b/profiler/build/unix/build.mk @@ -25,8 +25,14 @@ else LIBS += $(shell pkg-config --libs gtk+-2.0) -lGL endif -TBB := $(shell ld -ltbb -o /dev/null 2>/dev/null; echo $$?) -ifeq ($(TBB),0) +# Tracy does not use TBB directly, but the implementation of parallel algorithms +# in some versions of libstdc++ depends on TBB. When it does, you must +# explicitly link against -ltbb. +# +# Some distributions have pgk-config files for TBB, others don't. +ifeq (0,$(shell pkg-config --libs tbb >/dev/null 2>&1; echo $$?)) + LIBS += $(shell pkg-config --libs tbb) +else ifeq (0,$(shell ld -ltbb -o /dev/null 2>/dev/null; echo $$?)) LIBS += -ltbb endif From 652582b119848838035143a5d621ccbda599ddbf Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Fri, 31 Jul 2020 09:14:12 -0700 Subject: [PATCH 2/2] Factor out makefile TBB detection, apply to all tools. --- capture/build/unix/build.mk | 9 +++------ common/unix.mk | 16 ++++++++++++++++ csvexport/build/unix/build.mk | 9 +++------ import-chrome/build/unix/build.mk | 9 +++------ profiler/build/unix/build.mk | 17 ++++------------- update/build/unix/build.mk | 9 +++------ 6 files changed, 32 insertions(+), 37 deletions(-) create mode 100644 common/unix.mk diff --git a/capture/build/unix/build.mk b/capture/build/unix/build.mk index 5378e008..f7f65e8c 100644 --- a/capture/build/unix/build.mk +++ b/capture/build/unix/build.mk @@ -1,8 +1,10 @@ +include ../../../common/unix.mk + CFLAGS += CXXFLAGS := $(CFLAGS) -std=gnu++17 DEFINES += -DTRACY_NO_STATISTICS INCLUDES := $(shell pkg-config --cflags capstone) -LIBS := $(shell pkg-config --libs capstone) -lpthread +LIBS += $(shell pkg-config --libs capstone) -lpthread PROJECT := capture IMAGE := $(PROJECT)-$(BUILD) @@ -14,11 +16,6 @@ BASE2 := $(shell egrep 'ClCompile.*c"' ../win32/$(PROJECT).vcxproj | sed -e 's/. SRC := $(filter-out $(FILTER),$(BASE)) SRC2 := $(filter-out $(FILTER),$(BASE2)) -TBB := $(shell ld -ltbb -o /dev/null 2>/dev/null; echo $$?) -ifeq ($(TBB),0) - LIBS += -ltbb -endif - OBJDIRBASE := obj/$(BUILD) OBJDIR := $(OBJDIRBASE)/o/o/o diff --git a/common/unix.mk b/common/unix.mk new file mode 100644 index 00000000..dc0db5f3 --- /dev/null +++ b/common/unix.mk @@ -0,0 +1,16 @@ +# Common code needed by most Tracy Unix Makefiles. + +# Ensure LIBS is a simply-substituted variable, without changing its value. +LIBS := $(LIBS) + +# Tracy does not use TBB directly, but the implementation of parallel algorithms +# in some versions of libstdc++ depends on TBB. When it does, you must +# explicitly link against -ltbb. +# +# Some distributions have pgk-config files for TBB, others don't. +ifeq (0,$(shell pkg-config --libs tbb >/dev/null 2>&1; echo $$?)) + LIBS += $(shell pkg-config --libs tbb) +else ifeq (0,$(shell ld -ltbb -o /dev/null 2>/dev/null; echo $$?)) + LIBS += -ltbb +endif + diff --git a/csvexport/build/unix/build.mk b/csvexport/build/unix/build.mk index a7a67460..364b7c91 100644 --- a/csvexport/build/unix/build.mk +++ b/csvexport/build/unix/build.mk @@ -1,8 +1,10 @@ +include ../../../common/unix.mk + CFLAGS += CXXFLAGS := $(CFLAGS) -std=gnu++17 # DEFINES += -DTRACY_NO_STATISTICS INCLUDES := $(shell pkg-config --cflags capstone) -LIBS := $(shell pkg-config --libs capstone) -lpthread +LIBS += $(shell pkg-config --libs capstone) -lpthread PROJECT := csvexport IMAGE := $(PROJECT)-$(BUILD) @@ -14,11 +16,6 @@ BASE2 := $(shell egrep 'ClCompile.*c"' ../win32/$(PROJECT).vcxproj | sed -e 's/. SRC := $(filter-out $(FILTER),$(BASE)) SRC2 := $(filter-out $(FILTER),$(BASE2)) -TBB := $(shell ld -ltbb -o /dev/null 2>/dev/null; echo $$?) -ifeq ($(TBB),0) - LIBS += -ltbb -endif - OBJDIRBASE := obj/$(BUILD) OBJDIR := $(OBJDIRBASE)/o/o/o diff --git a/import-chrome/build/unix/build.mk b/import-chrome/build/unix/build.mk index fcd1f6b0..f540e858 100644 --- a/import-chrome/build/unix/build.mk +++ b/import-chrome/build/unix/build.mk @@ -1,8 +1,10 @@ +include ../../../common/unix.mk + CFLAGS += CXXFLAGS := $(CFLAGS) -std=gnu++17 DEFINES += -DTRACY_NO_STATISTICS INCLUDES := $(shell pkg-config --cflags capstone) -LIBS := $(shell pkg-config --libs capstone) -lpthread +LIBS += $(shell pkg-config --libs capstone) -lpthread PROJECT := import-chrome IMAGE := $(PROJECT)-$(BUILD) @@ -14,11 +16,6 @@ BASE2 := $(shell egrep 'ClCompile.*c"' ../win32/$(PROJECT).vcxproj | sed -e 's/. SRC := $(filter-out $(FILTER),$(BASE)) SRC2 := $(filter-out $(FILTER),$(BASE2)) -TBB := $(shell ld -ltbb -o /dev/null 2>/dev/null; echo $$?) -ifeq ($(TBB),0) - LIBS += -ltbb -endif - OBJDIRBASE := obj/$(BUILD) OBJDIR := $(OBJDIRBASE)/o/o/o diff --git a/profiler/build/unix/build.mk b/profiler/build/unix/build.mk index 865c41a0..c9e4e367 100644 --- a/profiler/build/unix/build.mk +++ b/profiler/build/unix/build.mk @@ -1,8 +1,10 @@ -CFLAGS += +include ../../../common/unix.mk + +CFLAGS += CXXFLAGS := $(CFLAGS) -std=c++17 DEFINES += -DIMGUI_IMPL_OPENGL_LOADER_GL3W INCLUDES := $(shell pkg-config --cflags glfw3 freetype2 capstone) -I../../../imgui -I../../libs/gl3w -LIBS := $(shell pkg-config --libs glfw3 freetype2 capstone) -lpthread -ldl +LIBS += $(shell pkg-config --libs glfw3 freetype2 capstone) -lpthread -ldl PROJECT := Tracy IMAGE := $(PROJECT)-$(BUILD) @@ -25,17 +27,6 @@ else LIBS += $(shell pkg-config --libs gtk+-2.0) -lGL endif -# Tracy does not use TBB directly, but the implementation of parallel algorithms -# in some versions of libstdc++ depends on TBB. When it does, you must -# explicitly link against -ltbb. -# -# Some distributions have pgk-config files for TBB, others don't. -ifeq (0,$(shell pkg-config --libs tbb >/dev/null 2>&1; echo $$?)) - LIBS += $(shell pkg-config --libs tbb) -else ifeq (0,$(shell ld -ltbb -o /dev/null 2>/dev/null; echo $$?)) - LIBS += -ltbb -endif - OBJDIRBASE := obj/$(BUILD) OBJDIR := $(OBJDIRBASE)/o/o/o diff --git a/update/build/unix/build.mk b/update/build/unix/build.mk index 371f1f1d..df07d64c 100644 --- a/update/build/unix/build.mk +++ b/update/build/unix/build.mk @@ -1,8 +1,10 @@ +include ../../../common/unix.mk + CFLAGS += CXXFLAGS := $(CFLAGS) -std=gnu++17 DEFINES += -DTRACY_NO_STATISTICS INCLUDES := $(shell pkg-config --cflags capstone) -LIBS := $(shell pkg-config --libs capstone) -lpthread +LIBS += $(shell pkg-config --libs capstone) -lpthread PROJECT := update IMAGE := $(PROJECT)-$(BUILD) @@ -14,11 +16,6 @@ BASE2 := $(shell egrep 'ClCompile.*c"' ../win32/$(PROJECT).vcxproj | sed -e 's/. SRC := $(filter-out $(FILTER),$(BASE)) SRC2 := $(filter-out $(FILTER),$(BASE2)) -TBB := $(shell ld -ltbb -o /dev/null 2>/dev/null; echo $$?) -ifeq ($(TBB),0) - LIBS += -ltbb -endif - OBJDIRBASE := obj/$(BUILD) OBJDIR := $(OBJDIRBASE)/o/o/o