From 3d9f3b910796ba83ffa9b56e521a673bd048f931 Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Fri, 8 Jan 2021 07:27:17 -0800 Subject: [PATCH 01/20] Build with CMake --- CMakeLists.txt | 29 ++++++ Makefile | 24 ----- README.md | 10 +- benchmark.mk | 25 ----- benchmarks/CMakeLists.txt | 18 ++++ benchmarks/Makefile | 16 --- benchmarks/histogram/CMakeLists.txt | 23 +++++ benchmarks/histogram/Makefile | 20 ---- benchmarks/kmeans/CMakeLists.txt | 5 + benchmarks/kmeans/Makefile | 9 -- benchmarks/linear_regression/CMakeLists.txt | 23 +++++ benchmarks/linear_regression/Makefile | 20 ---- benchmarks/matrix_multiply/CMakeLists.txt | 30 ++++++ benchmarks/matrix_multiply/Makefile | 25 ----- .../matrix_multiply/matrix_multiply-pthread.c | 10 +- benchmarks/pbzip2/CMakeLists.txt | 13 +++ benchmarks/pbzip2/Makefile | 35 ------- benchmarks/pca/CMakeLists.txt | 4 + benchmarks/pca/Makefile | 9 -- benchmarks/producer_consumer/CMakeLists.txt | 4 + benchmarks/producer_consumer/Makefile | 6 -- benchmarks/sqlite-modified/CMakeLists.txt | 5 + benchmarks/sqlite-modified/Makefile | 6 -- benchmarks/sqlite/CMakeLists.txt | 5 + benchmarks/sqlite/Makefile | 6 -- benchmarks/string_match/CMakeLists.txt | 23 +++++ benchmarks/string_match/Makefile | 20 ---- benchmarks/toy/CMakeLists.txt | 4 + benchmarks/toy/Makefile | 6 -- benchmarks/word_count/CMakeLists.txt | 23 +++++ benchmarks/word_count/Makefile | 20 ---- common.mk | 99 ------------------- conanfile.txt | 9 ++ coz | 2 +- coz-profilerConfig.cmake.in | 9 +- libcoz/CMakeLists.txt | 23 +++++ libcoz/Makefile | 14 --- viewer/Makefile | 9 -- 38 files changed, 257 insertions(+), 384 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile delete mode 100644 benchmark.mk create mode 100644 benchmarks/CMakeLists.txt delete mode 100644 benchmarks/Makefile create mode 100644 benchmarks/histogram/CMakeLists.txt delete mode 100644 benchmarks/histogram/Makefile create mode 100644 benchmarks/kmeans/CMakeLists.txt delete mode 100644 benchmarks/kmeans/Makefile create mode 100644 benchmarks/linear_regression/CMakeLists.txt delete mode 100644 benchmarks/linear_regression/Makefile create mode 100644 benchmarks/matrix_multiply/CMakeLists.txt delete mode 100644 benchmarks/matrix_multiply/Makefile create mode 100644 benchmarks/pbzip2/CMakeLists.txt delete mode 100644 benchmarks/pbzip2/Makefile create mode 100644 benchmarks/pca/CMakeLists.txt delete mode 100644 benchmarks/pca/Makefile create mode 100644 benchmarks/producer_consumer/CMakeLists.txt delete mode 100644 benchmarks/producer_consumer/Makefile create mode 100644 benchmarks/sqlite-modified/CMakeLists.txt delete mode 100644 benchmarks/sqlite-modified/Makefile create mode 100644 benchmarks/sqlite/CMakeLists.txt delete mode 100644 benchmarks/sqlite/Makefile create mode 100644 benchmarks/string_match/CMakeLists.txt delete mode 100644 benchmarks/string_match/Makefile create mode 100644 benchmarks/toy/CMakeLists.txt delete mode 100644 benchmarks/toy/Makefile create mode 100644 benchmarks/word_count/CMakeLists.txt delete mode 100644 benchmarks/word_count/Makefile delete mode 100644 common.mk create mode 100644 conanfile.txt create mode 100644 libcoz/CMakeLists.txt delete mode 100644 libcoz/Makefile delete mode 100644 viewer/Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..07f3cf3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.1) +project(coz C CXX) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +list(APPEND CMAKE_MODULE_PATH ${PROJECT_BINARY_DIR}) + +include(GNUInstallDirs) +find_package(Threads REQUIRED) +find_package(libelfin REQUIRED) + +file(GLOB_RECURSE sources libcoz/*.cpp) +file(GLOB_RECURSE headers include/*.h) + +install(PROGRAMS coz DESTINATION bin) +install(FILES LICENSE.md DESTINATION licenses) + +add_subdirectory(libcoz) + +option(BUILD_BENCHMARKS "Build benchmarks" OFF) +if(BUILD_BENCHMARKS) + find_package(SQLite3 REQUIRED) + find_package(BZip2 REQUIRED) + add_subdirectory(benchmarks) +endif() + +configure_file(coz-profilerConfig.cmake.in coz-profilerConfig.cmake @ONLY) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/coz-profilerConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) diff --git a/Makefile b/Makefile deleted file mode 100644 index a66cbd9..0000000 --- a/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -ROOT := . -DIRS := libcoz viewer - -include $(ROOT)/common.mk - -update-gh-pages:: all - @echo $(LOG_PREFIX) Pushing profiler viewer to gh-pages branch $(LOG_SUFFIX) - @git push origin `git subtree split --prefix viewer master 2> /dev/null`:gh-pages - -install:: all - @echo $(LOG_PREFIX) Installing coz to prefix $(prefix) $(LOG_SUFFIX) - @sed 's@destdir@"${DESTDIR}${prefix}"@g' coz-profilerConfig.cmake.in > coz-profilerConfig.cmake - @$(INSTALL) -D coz $(DESTDIR)$(bindir)/coz - @$(INSTALL) -D coz-profilerConfig.cmake $(DESTDIR)$(pkglibdir)/coz-profilerConfig.cmake - @$(INSTALL) -D libcoz/libcoz.so $(DESTDIR)$(pkglibdir)/libcoz.so - @$(INSTALL) -D include/coz.h $(DESTDIR)$(incdir)/coz.h - @mkdir -p $(DESTDIR)$(man1dir) - @$(RST2MAN) docs/coz.rst $(DESTDIR)$(man1dir)/coz.1 - -bench bench_small bench_large:: - @$(MAKE) -C benchmarks $@ - -check:: - @$(MAKE) -C benchmarks check diff --git a/README.md b/README.md index f411ba4..0d41605 100644 --- a/README.md +++ b/README.md @@ -32,16 +32,20 @@ To build Coz from source, you will need: - A copy of the source code for this project - A compiler with C++0x support (clang++ or g++) - A Python interpreter (Python 3.x is required) -- The libelfin development libraries (Use release 0.2 or the latest from . _Version 0.3 does not work_.) +- The libelfin development libraries (Use latest from . _Version 0.3 does not work_.) - The `rst2man` command (for building documentation) - NodeJS and npm (for building the profiler viewer) -Once you have all dependencies in place, run `make` to build Coz. On Debian-based distributions, the following commands should take care of the entire process: +Once you have all dependencies in place, build Coz with CMake. On Debian-based distributions, the following commands should take care of the entire process: ``` -$ sudo apt-get install clang docutils-common libelfin-dev nodejs npm python3 +$ sudo apt-get install build-essential cmake docutils-common libelfin-dev nodejs npm python3 +$ pip install conan --user $ git clone https://github.com/plasma-umass/coz.git $ cd coz +$ mkdir build && cd build +$ conan install .. +$ cmake .. $ make ``` diff --git a/benchmark.mk b/benchmark.mk deleted file mode 100644 index 9b805df..0000000 --- a/benchmark.mk +++ /dev/null @@ -1,25 +0,0 @@ -include $(ROOT)/common.mk - -LIBS += -Wl,--push-state,--no-as-needed -ldl -Wl,--pop-state - -RECURSIVE_TARGETS += bench bench_large bench_small - -ifeq ($(USE_SYSTEM_COZ),) -CFLAGS += -gdwarf-3 -I$(ROOT)/include -CXXFLAGS += -gdwarf-3 -I$(ROOT)/include -endif - -# Set up build targets for benchmarking -large_inputs: - -small_inputs: - -bench:: bench_large - -bench_large:: $(OTHER_TARGETS) large_inputs - @echo $(LOG_PREFIX) Running benchmark on large input $(LOG_SUFFIX) - $(COZ) run $(COZ_ARGS) --- ./$< $(BENCH_LARGE_ARGS) - -bench_small:: $(OTHER_TARGETS) small_inputs - @echo $(LOG_PREFIX) Running benchmark on small input $(LOG_SUFFIX) - $(COZ) run $(COZ_ARGS) --- ./$< $(BENCH_SMALL_ARGS) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt new file mode 100644 index 0000000..7182564 --- /dev/null +++ b/benchmarks/CMakeLists.txt @@ -0,0 +1,18 @@ +function(add_coz_run_target name) + set(one_value_args "") + set(multi_value_args COMMAND) + set(options "") + cmake_parse_arguments(COZ_RUN "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN}) + + add_custom_target(${name} + COMMENT "Running coz for ${name}" + COMMAND ${PROJECT_SOURCE_DIR}/coz run --- ${COZ_RUN_COMMAND} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + DEPENDS coz) +endfunction() + +file(GLOB cmake_files */CMakeLists.txt) +foreach(filepath ${cmake_files}) + get_filename_component(dir ${filepath} DIRECTORY) + add_subdirectory(${dir}) +endforeach(filepath) diff --git a/benchmarks/Makefile b/benchmarks/Makefile deleted file mode 100644 index 21f6ea5..0000000 --- a/benchmarks/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -ROOT := .. -DIRS := histogram kmeans linear_regression matrix_multiply \ - pbzip2 pca producer_consumer string_match sqlite \ - sqlite-modified toy word_count - -include $(ROOT)/common.mk - -check:: - @$(MAKE) -C kmeans - @$(RM) -f profile.coz - ../coz run --- kmeans/kmeans - @grep -q "time=" profile.coz || { echo failure: valid profile.coz not generated; exit 1; } - @grep -q "throughput-point" profile.coz || { echo failure: throughput-point not found in profile; exit 1; } - @grep -q -P "samples\tlocation=" profile.coz || { echo failure: samples not found in profile; exit 1; } - @echo success: benchmark generated valid profile.coz - @$(RM) -f profile.coz diff --git a/benchmarks/histogram/CMakeLists.txt b/benchmarks/histogram/CMakeLists.txt new file mode 100644 index 0000000..59c48d7 --- /dev/null +++ b/benchmarks/histogram/CMakeLists.txt @@ -0,0 +1,23 @@ +add_executable(histogram histogram-pthread.c) +target_link_libraries(histogram PRIVATE coz-instrumentation pthread) + +add_custom_command( + COMMENT "Downloading histogram inputs" + OUTPUT + histogram_datafiles/small.bmp + histogram_datafiles/large.bmp + COMMAND wget -cq http://csl.stanford.edu/~christos/data/histogram.tar.gz + COMMAND tar xzf histogram.tar.gz) + +add_custom_target(histogram_datafiles + DEPENDS + histogram_datafiles/small.bmp + histogram_datafiles/large.bmp) + +add_coz_run_target(run_histogram_large + COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/histogram_datafiles/large.bmp) +add_dependencies(run_histogram_large histogram_datafiles) + +add_coz_run_target(run_histogram_small + COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/histogram_datafiles/small.bmp) +add_dependencies(run_histogram_small histogram_datafiles) diff --git a/benchmarks/histogram/Makefile b/benchmarks/histogram/Makefile deleted file mode 100644 index d30838e..0000000 --- a/benchmarks/histogram/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -ROOT := ../.. -TARGETS := histogram -LIBS := -lpthread -Wl,--no-as-needed -ldl -CFLAGS := -g -O2 -gdwarf-3 - -include $(ROOT)/benchmark.mk - -BENCH_LARGE_ARGS := histogram_datafiles/large.bmp -BENCH_SMALL_ARGS := histogram_datafiles/small.bmp - -large_inputs: histogram_datafiles/large.bmp - -small_inputs: histogram_datafiles/small.bmp - -histogram_datafiles/%: - @echo $(LOG_PREFIX) Downloading histogram inputs $(LOG_SUFFIX) - @wget -c http://csl.stanford.edu/~christos/data/histogram.tar.gz - @echo $(LOG_PREFIX) Unpacking histogram inputs $(LOG_SUFFIX) - @tar xzf histogram.tar.gz - @rm histogram.tar.gz diff --git a/benchmarks/kmeans/CMakeLists.txt b/benchmarks/kmeans/CMakeLists.txt new file mode 100644 index 0000000..cf4e9eb --- /dev/null +++ b/benchmarks/kmeans/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(kmeans kmeans-pthread.c) +target_link_libraries(kmeans PRIVATE coz-instrumentation pthread) + +add_coz_run_target(run_kmeans_small COMMAND $ -d 3 -c 100 -p 10000 -s 100) +add_coz_run_target(run_kmeans_large COMMAND $ -d 3 -c 100 -p 100000 -s 1000) diff --git a/benchmarks/kmeans/Makefile b/benchmarks/kmeans/Makefile deleted file mode 100644 index 885c517..0000000 --- a/benchmarks/kmeans/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -ROOT := ../.. -TARGETS := kmeans -LIBS := -lpthread -CFLAGS := -g -O2 - -include $(ROOT)/benchmark.mk - -BENCH_LARGE_ARGS := -d 3 -c 100 -p 100000 -s 1000 -BENCH_SMALL_ARGS := -d 3 -c 100 -p 10000 -s 100 diff --git a/benchmarks/linear_regression/CMakeLists.txt b/benchmarks/linear_regression/CMakeLists.txt new file mode 100644 index 0000000..6201b64 --- /dev/null +++ b/benchmarks/linear_regression/CMakeLists.txt @@ -0,0 +1,23 @@ +add_executable(linear_regression linear_regression-pthread.c) +target_link_libraries(linear_regression PRIVATE coz-instrumentation pthread) + +add_custom_command( + COMMENT "Downloading linear_regression inputs" + OUTPUT + linear_regression_datafiles/key_file_500MB.txt + linear_regression_datafiles/key_file_50MB.txt + COMMAND wget -cq http://csl.stanford.edu/~christos/data/linear_regression.tar.gz + COMMAND tar xzf linear_regression.tar.gz) + +add_custom_target(linear_regression_datafiles + DEPENDS + linear_regression_datafiles/key_file_500MB.txt + linear_regression_datafiles/key_file_50MB.txt) + +add_coz_run_target(run_linear_regression_large + COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/linear_regression_datafiles/key_file_500MB.txt) +add_dependencies(run_linear_regression_large linear_regression_datafiles) + +add_coz_run_target(run_linear_regression_small + COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/linear_regression_datafiles/key_file_50MB.txt) +add_dependencies(run_linear_regression_small linear_regression_datafiles) diff --git a/benchmarks/linear_regression/Makefile b/benchmarks/linear_regression/Makefile deleted file mode 100644 index de9e1d4..0000000 --- a/benchmarks/linear_regression/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -ROOT := ../.. -TARGETS := linear_regression -LIBS := -lpthread -CFLAGS := -g -O2 - -include $(ROOT)/benchmark.mk - -BENCH_LARGE_ARGS := linear_regression_datafiles/key_file_500MB.txt -BENCH_SMALL_ARGS := linear_regression_datafiles/key_file_50MB.txt - -large_inputs: linear_regression_datafiles/key_file_500MB.txt - -small_inputs: linear_regression_datafiles/key_file_50MB.txt - -linear_regression_datafiles/%: - @echo $(LOG_PREFIX) Downloading linear_regression inputs $(LOG_SUFFIX) - @wget -c http://csl.stanford.edu/~christos/data/linear_regression.tar.gz - @echo $(LOG_PREFIX) Unpacking linear_regression inputs $(LOG_SUFFIX) - @tar xzf linear_regression.tar.gz - @rm linear_regression.tar.gz diff --git a/benchmarks/matrix_multiply/CMakeLists.txt b/benchmarks/matrix_multiply/CMakeLists.txt new file mode 100644 index 0000000..a20be63 --- /dev/null +++ b/benchmarks/matrix_multiply/CMakeLists.txt @@ -0,0 +1,30 @@ +add_executable(matrix_multiply matrix_multiply-pthread.c) +target_link_libraries(matrix_multiply PRIVATE coz-instrumentation pthread) + +add_custom_command( + COMMENT "Generating bench input" + OUTPUT ${PROJECT_BINARY_DIR}/matrix_file_A_1000.txt ${PROJECT_BINARY_DIR}/matrix_file_B_1000.txt + BYPRODUCTS ${PROJECT_BINARY_DIR}/matrix_file_out_pthreads_1000.txt + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/matrix_multiply 1000 -create_files > /dev/null + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + DEPENDS matrix_multiply) +add_custom_target(matrix_multiply_large_datafiles + DEPENDS ${PROJECT_BINARY_DIR}/matrix_file_A_1000.txt ${PROJECT_BINARY_DIR}/matrix_file_B_1000.txt) + +add_custom_command( + COMMENT "Generating test input" + OUTPUT ${PROJECT_BINARY_DIR}/matrix_file_A_400.txt ${PROJECT_BINARY_DIR}/matrix_file_B_400.txt + BYPRODUCTS ${PROJECT_BINARY_DIR}/matrix_file_out_pthreads_400.txt + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/matrix_multiply 400 -create_files > /dev/null + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + DEPENDS matrix_multiply) +add_custom_target(matrix_multiply_small_datafiles + DEPENDS ${PROJECT_BINARY_DIR}/matrix_file_A_400.txt ${PROJECT_BINARY_DIR}/matrix_file_B_400.txt) + +add_coz_run_target(run_matrix_multiply_large + COMMAND $ 1000 > /dev/null) +add_dependencies(run_matrix_multiply_large matrix_multiply_large_datafiles) + +add_coz_run_target(run_matrix_multiply_small + COMMAND $ 400 > /dev/null) +add_dependencies(run_matrix_multiply_small matrix_multiply_small_datafiles) diff --git a/benchmarks/matrix_multiply/Makefile b/benchmarks/matrix_multiply/Makefile deleted file mode 100644 index 8ada893..0000000 --- a/benchmarks/matrix_multiply/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -ROOT := ../.. -TARGETS := matrix_multiply -LIBS := -lpthread -CFLAGS := -g -O2 -Wno-format - -include $(ROOT)/benchmark.mk - -BENCH_LARGE_ARGS := 1000 > /dev/null -BENCH_SMALL_ARGS := 400 > /dev/null - -large_inputs: .input_large - -small_inputs: .input_small - -.input_large: matrix_multiply - @echo $(LOG_PREFIX) Generating bench input $(LOG_SUFFIX) - @./matrix_multiply 1000 1000 > /dev/null - @rm -f .input_small - @touch .input_large - -.input_small: matrix_multiply - @echo $(LOG_PREFIX) Generating test input $(LOG_SUFFIX) - @./matrix_multiply 400 400 > /dev/null - @rm -f .input_large - @touch .input_small diff --git a/benchmarks/matrix_multiply/matrix_multiply-pthread.c b/benchmarks/matrix_multiply/matrix_multiply-pthread.c index c02de87..fc37201 100644 --- a/benchmarks/matrix_multiply/matrix_multiply-pthread.c +++ b/benchmarks/matrix_multiply/matrix_multiply-pthread.c @@ -171,7 +171,7 @@ int main(int argc, char *argv[]) { char * fdata_A, *fdata_B; int matrix_len; struct stat finfo_A, finfo_B; - char * fname_A, *fname_B,*fname_out; + char fname_A[512], fname_B[512], fname_out[512]; int *matrix_A_ptr, *matrix_B_ptr; struct timeval starttime,endtime; @@ -181,14 +181,14 @@ int main(int argc, char *argv[]) { // Make sure a filename is specified if (argv[1] == NULL) { - printf("USAGE: %s [side of matrix] [size of Row block]\n", argv[0]); + printf("USAGE: %s size_of_matrix [-create_files]\n", argv[0]); exit(1); } - fname_A = "matrix_file_A.txt"; - fname_B = "matrix_file_B.txt"; - fname_out = "matrix_file_out_pthreads.txt"; CHECK_ERROR ( (matrix_len = atoi(argv[1])) < 0); + sprintf(fname_A, "matrix_file_A_%d.txt", matrix_len); + sprintf(fname_B, "matrix_file_B_%d.txt", matrix_len); + sprintf(fname_out, "matrix_file_out_pthreads_%d.txt", matrix_len); file_size = ((matrix_len*matrix_len))*sizeof(int); fprintf(stderr, "***** file size is %d\n", file_size); diff --git a/benchmarks/pbzip2/CMakeLists.txt b/benchmarks/pbzip2/CMakeLists.txt new file mode 100644 index 0000000..ca30c89 --- /dev/null +++ b/benchmarks/pbzip2/CMakeLists.txt @@ -0,0 +1,13 @@ +ADd_executable(pbzip2 BZ2StreamScanner.cpp ErrorContext.cpp pbzip2.cpp) +target_link_libraries(pbzip2 PRIVATE BZip2::BZip2 coz-instrumentation pthread) + +set(datafiles ${CMAKE_CURRENT_BINARY_DIR}/../linear_regression/linear_regression_datafiles) + +add_coz_run_target(run_pbzip2_large + COMMAND $ -c < ${datafiles}/key_file_500MB.txt > ${CMAKE_CURRENT_BINARY_DIR}/key_file_500MB_compressed.bz2) +add_dependencies(run_pbzip2_large linear_regression_datafiles) + +add_coz_run_target(run_pbzip2_small + COMMAND $ -c < ${datafiles}/key_file_50MB.txt > ${CMAKE_CURRENT_BINARY_DIR}/key_file_50MB_compressed.bz2) +add_dependencies(run_pbzip2_small linear_regression_datafiles) + diff --git a/benchmarks/pbzip2/Makefile b/benchmarks/pbzip2/Makefile deleted file mode 100644 index b1e3eb7..0000000 --- a/benchmarks/pbzip2/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -ROOT := ../.. -TARGETS := pbzip2 -LIBS := -lbz2 -lpthread -CXXFLAGS := -g -O2 -Wno-format -Ibzip2-1.0.6 -LDFLAGS := -Lbzip2-1.0.6 - -include $(ROOT)/benchmark.mk - -# pbzip2 depends on the libbz2 library -pbzip2: bzip2-1.0.6/libbz2.a - -# Download and build libbz2 -bzip2-1.0.6/libbz2.a: - @echo $(LOG_PREFIX) Downloading libbz2 $(LOG_SUFFIX) - @wget -c https://sourceware.org/pub/bzip2/bzip2-1.0.6.tar.gz - @echo $(LOG_PREFIX) Unpacking libbz2 $(LOG_SUFFIX) - @tar xzf bzip2-1.0.6.tar.gz - @echo $(LOG_PREFIX) Building libbz2 $(LOG_SUFFIX) - @cd bzip2-1.0.6; $(MAKE) CFLAGS=-g > /dev/null - @rm bzip2-1.0.6.tar.gz - -BENCH_LARGE_ARGS := -c < data/key_file_500MB.txt > data/key_file_500MB_compressed.bz2 -BENCH_SMALL_ARGS := -c < data/key_file_50MB.txt > data/key_file_50MB_compressed.bz2 - -large_inputs: data/key_file_500MB.txt - -small_inputs: data/key_file_50MB.txt - -data/%: - @echo $(LOG_PREFIX) Downloading pbzip2 inputs $(LOG_SUFFIX) - @wget -c http://csl.stanford.edu/~christos/data/linear_regression.tar.gz - @echo $(LOG_PREFIX) Unpacking pbzip2 inputs $(LOG_SUFFIX) - @tar xzf linear_regression.tar.gz - @rm linear_regression.tar.gz - @mv linear_regression_datafiles data diff --git a/benchmarks/pca/CMakeLists.txt b/benchmarks/pca/CMakeLists.txt new file mode 100644 index 0000000..d898777 --- /dev/null +++ b/benchmarks/pca/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(pca pca-pthread.c) +target_link_libraries(pca PRIVATE coz-instrumentation pthread) + +add_coz_run_target(run_pca COMMAND $ > /dev/null) diff --git a/benchmarks/pca/Makefile b/benchmarks/pca/Makefile deleted file mode 100644 index 5c4e5dc..0000000 --- a/benchmarks/pca/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -ROOT := ../.. -TARGETS := pca -LIBS := -lpthread -CFLAGS := -g -O2 - -include $(ROOT)/benchmark.mk - -BENCH_LARGE_ARGS := > /dev/null -BENCH_SMALL_ARGS := > /dev/null diff --git a/benchmarks/producer_consumer/CMakeLists.txt b/benchmarks/producer_consumer/CMakeLists.txt new file mode 100644 index 0000000..4ab3a77 --- /dev/null +++ b/benchmarks/producer_consumer/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(producer_consumer producer_consumer.cpp) +target_link_libraries(producer_consumer PRIVATE coz-instrumentation pthread) + +add_coz_run_target(run_producer_consumer COMMAND $) diff --git a/benchmarks/producer_consumer/Makefile b/benchmarks/producer_consumer/Makefile deleted file mode 100644 index c3f636a..0000000 --- a/benchmarks/producer_consumer/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -ROOT := ../.. -TARGETS := producer_consumer -LIBS := -lpthread -CXXFLAGS := -g -O2 - -include $(ROOT)/benchmark.mk diff --git a/benchmarks/sqlite-modified/CMakeLists.txt b/benchmarks/sqlite-modified/CMakeLists.txt new file mode 100644 index 0000000..0d178b3 --- /dev/null +++ b/benchmarks/sqlite-modified/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(sqlite-bench-modified main.c sqlite3.c) +target_compile_definitions(sqlite-bench-modified PRIVATE SQLITE_THREADSAFE=2) +target_link_libraries(sqlite-bench-modified PRIVATE SQLite::SQLite3 coz-instrumentation pthread) + +add_coz_run_target(run_sqlite_bench_modified COMMAND $) diff --git a/benchmarks/sqlite-modified/Makefile b/benchmarks/sqlite-modified/Makefile deleted file mode 100644 index bc5994a..0000000 --- a/benchmarks/sqlite-modified/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -ROOT := ../.. -TARGETS := sqlite-bench -LIBS := -lpthread -ldl -CFLAGS := -g -O2 -DSQLITE_THREADSAFE=2 -I. - -include $(ROOT)/benchmark.mk diff --git a/benchmarks/sqlite/CMakeLists.txt b/benchmarks/sqlite/CMakeLists.txt new file mode 100644 index 0000000..d3a1fba --- /dev/null +++ b/benchmarks/sqlite/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(sqlite-bench main.c sqlite3.c) +target_compile_definitions(sqlite-bench PRIVATE SQLITE_THREADSAFE=2) +target_link_libraries(sqlite-bench PRIVATE SQLite::SQLite3 coz-instrumentation pthread) + +add_coz_run_target(run_sqlite_bench COMMAND $) diff --git a/benchmarks/sqlite/Makefile b/benchmarks/sqlite/Makefile deleted file mode 100644 index bc5994a..0000000 --- a/benchmarks/sqlite/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -ROOT := ../.. -TARGETS := sqlite-bench -LIBS := -lpthread -ldl -CFLAGS := -g -O2 -DSQLITE_THREADSAFE=2 -I. - -include $(ROOT)/benchmark.mk diff --git a/benchmarks/string_match/CMakeLists.txt b/benchmarks/string_match/CMakeLists.txt new file mode 100644 index 0000000..0eec4e3 --- /dev/null +++ b/benchmarks/string_match/CMakeLists.txt @@ -0,0 +1,23 @@ +add_executable(string_match string_match-pthread.c) +target_link_libraries(string_match PRIVATE coz-instrumentation pthread) + +add_custom_command( + COMMENT "Downloading string_match inputs" + OUTPUT + string_match_datafiles/key_file_500MB.txt + string_match_datafiles/key_file_50MB.txt + COMMAND wget -cq http://csl.stanford.edu/~christos/data/string_match.tar.gz + COMMAND tar xzf string_match.tar.gz) + +add_custom_target(string_match_datafiles + DEPENDS + string_match_datafiles/key_file_500MB.txt + string_match_datafiles/key_file_50MB.txt) + +add_coz_run_target(run_string_match_large + COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/string_match_datafiles/key_file_500MB.txt) +add_dependencies(run_string_match_large string_match_datafiles) + +add_coz_run_target(run_string_match_small + COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/string_match_datafiles/key_file_50MB.txt) +add_dependencies(run_string_match_small string_match_datafiles) diff --git a/benchmarks/string_match/Makefile b/benchmarks/string_match/Makefile deleted file mode 100644 index 9f9d038..0000000 --- a/benchmarks/string_match/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -ROOT := ../.. -TARGETS := string_match -LIBS := -lpthread -CFLAGS := -g -O2 - -include $(ROOT)/benchmark.mk - -BENCH_LARGE_ARGS := string_match_datafiles/key_file_500MB.txt > /dev/null -BENCH_SMALL_ARGS := string_match_datafiles/key_file_50MB.txt > /dev/null - -large_inputs: string_match_datafiles/key_file_500MB.txt - -small_inputs: string_match_datafiles/key_file_50MB.txt - -string_match_datafiles/%: - @echo $(LOG_PREFIX) Downloading string_match inputs $(LOG_SUFFIX) - @wget -c http://csl.stanford.edu/~christos/data/string_match.tar.gz - @echo $(LOG_PREFIX) Unpacking string_match inputs $(LOG_SUFFIX) - @tar xzf string_match.tar.gz - @rm string_match.tar.gz diff --git a/benchmarks/toy/CMakeLists.txt b/benchmarks/toy/CMakeLists.txt new file mode 100644 index 0000000..eb4112c --- /dev/null +++ b/benchmarks/toy/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(toy toy.cpp) +target_link_libraries(toy PRIVATE coz-instrumentation pthread) + +add_coz_run_target(run_toy COMMAND $) diff --git a/benchmarks/toy/Makefile b/benchmarks/toy/Makefile deleted file mode 100644 index 1611722..0000000 --- a/benchmarks/toy/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -ROOT := ../.. -TARGETS := toy -LIBS := -lpthread -CXXFLAGS := --std=c++11 -g -O2 - -include $(ROOT)/benchmark.mk diff --git a/benchmarks/word_count/CMakeLists.txt b/benchmarks/word_count/CMakeLists.txt new file mode 100644 index 0000000..3d4a38e --- /dev/null +++ b/benchmarks/word_count/CMakeLists.txt @@ -0,0 +1,23 @@ +add_executable(word_count sort-pthread.c word_count-pthread.c) +target_link_libraries(word_count PRIVATE coz-instrumentation pthread) + +add_custom_command( + COMMENT "Downloading word_count inputs" + OUTPUT + word_count_datafiles/word_100MB.txt + word_count_datafiles/word_10MB.txt + COMMAND wget -cq http://csl.stanford.edu/~christos/data/word_count.tar.gz + COMMAND tar xzf word_count.tar.gz) + +add_custom_target(word_count_datafiles + DEPENDS + word_count_datafiles/word_100MB.txt + word_count_datafiles/word_10MB.txt) + +add_coz_run_target(run_word_count_large + COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/word_count_datafiles/word_100MB.txt) +add_dependencies(run_word_count_large word_count_datafiles) + +add_coz_run_target(run_word_count_small + COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/word_count_datafiles/word_10MB.txt) +add_dependencies(run_word_count_small word_count_datafiles) diff --git a/benchmarks/word_count/Makefile b/benchmarks/word_count/Makefile deleted file mode 100644 index 58d92e6..0000000 --- a/benchmarks/word_count/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -ROOT := ../.. -TARGETS := word_count -LIBS := -lpthread -CFLAGS := -g -O2 - -include $(ROOT)/benchmark.mk - -BENCH_LARGE_ARGS := word_count_datafiles/word_100MB.txt -BENCH_SMALL_ARGS := word_count_datafiles/word_10MB.txt - -large_inputs: word_count_datafiles/word_100MB.txt - -small_inputs: word_count_datafiles/word_10MB.txt - -word_count_datafiles/%: - @echo $(LOG_PREFIX) Downloading word_count inputs $(LOG_SUFFIX) - @wget -c http://csl.stanford.edu/~christos/data/word_count.tar.gz - @echo $(LOG_PREFIX) Unpacking word_count inputs $(LOG_SUFFIX) - @tar xzf word_count.tar.gz - @rm word_count.tar.gz diff --git a/common.mk b/common.mk deleted file mode 100644 index 6f0c411..0000000 --- a/common.mk +++ /dev/null @@ -1,99 +0,0 @@ -DESTDIR ?= -prefix ?= /usr -bindir := $(prefix)/bin -pkglibdir := $(prefix)/lib/coz-profiler -incdir := $(prefix)/include -mandir := $(prefix)/share/man -man1dir := $(mandir)/man1 - -INSTALL = install -RST2MAN = rst2man - -# Build with clang by default -CC ?= clang -CXX ?= clang++ - -# Set coz and include path for coz -ifeq ($(USE_SYSTEM_COZ),1) -COZ := $(shell which coz) -else -COZ := $(ROOT)/coz -endif - -# Default flags -CFLAGS ?= -g -O2 -CXXFLAGS ?= $(CFLAGS) - -# Default source and object files -SRCS ?= $(wildcard *.cpp) $(wildcard *.c) -OBJS ?= $(addprefix obj/,$(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SRCS)))) - -# Prevent errors if files named all, clean, distclean, bench, or test exist -.PHONY: all clean distclean bench bench_small bench_large test - -# Targets to build recirsively into $(DIRS) -RECURSIVE_TARGETS ?= all clean bench bench_large bench_small test install check - -# Targets separated by type -SHARED_LIB_TARGETS := $(filter %.so, $(TARGETS)) -STATIC_LIB_TARGETS := $(filter %.a, $(TARGETS)) -OTHER_TARGETS := $(filter-out %.so, $(filter-out %.a, $(TARGETS))) - -# If not set, the build path is just the current directory name -MAKEPATH ?= $(shell basename $(shell pwd)) - -# Log the build path in gray, following by a log message in bold green -LOG_PREFIX := "$(shell tput setaf 7)[$(MAKEPATH)]$(shell tput sgr0)$(shell tput setaf 2)" -LOG_SUFFIX := "$(shell tput sgr0)" - -# Build in parallel -MAKEFLAGS += -j - -# Build all targets by default, unless this is a benchmark -all:: $(TARGETS) - -# Clean up after a build -clean:: - @for t in $(TARGETS); do \ - echo $(LOG_PREFIX) Cleaning $$t $(LOG_SUFFIX); \ - done - @rm -rf $(TARGETS) obj - -# Bring source back to pristine state -distclean:: clean - @$(MAKE) -C benchmarks clean - -# Compile a C++ source file (and generate its dependency rules) -obj/%.o: %.cpp $(PREREQS) - @echo $(LOG_PREFIX) Compiling $< $(LOG_SUFFIX) - @mkdir -p obj - @$(CXX) $(CXXFLAGS) -MMD -MP -o $@ -c $< - -# Compile a C source file (and generate its dependency rules) -obj/%.o: %.c $(PREREQS) - @echo $(LOG_PREFIX) Compiling $< $(LOG_SUFFIX) - @mkdir -p obj - @$(CC) $(CFLAGS) -MMD -MP -o $@ -c $< - -# Link a shared library -$(SHARED_LIB_TARGETS): $(OBJS) - @echo $(LOG_PREFIX) Linking $@ $(LOG_SUFFIX) - @$(CXX) -shared $(LDFLAGS) -o $@ $^ $(LIBS) - -$(STATIC_LIB_TARGETS): $(OBJS) - @echo $(LOG_PREFIX) Linking $@ $(LOG_SUFFIX) - @ar rs $@ $^ - -# Link binary targets -$(OTHER_TARGETS): $(OBJS) - @echo $(LOG_PREFIX) Linking $@ $(LOG_SUFFIX) - @$(CXX) $(LDFLAGS) -o $@ $^ $(LIBS) - -# Include dependency rules for all objects --include $(OBJS:.o=.d) - -# Build any recursive targets in subdirectories -$(RECURSIVE_TARGETS):: - @for dir in $(DIRS); do \ - $(MAKE) -C $$dir --no-print-directory $@ MAKEPATH="$(MAKEPATH)/$$dir" || exit 1; \ - done diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 0000000..5cbd241 --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,9 @@ +[requires] +libelfin/[>=0.3] + +[build_requires] +bzip2/[>=1.0.8] +sqlite3/[>=3.33.0] + +[generators] +cmake_find_package diff --git a/coz b/coz index db10b5b..3f8830e 100755 --- a/coz +++ b/coz @@ -59,7 +59,7 @@ def _coz_run(args): os.path.join(coz_prefix, '..', 'lib', 'coz-profiler', 'libcoz.so'), # Local library under development directory - os.path.join(coz_prefix, 'libcoz', 'libcoz.so') # Local library during development + os.path.join('libcoz', 'libcoz.so') # Local library during development ] # Find the first library location that exists diff --git a/coz-profilerConfig.cmake.in b/coz-profilerConfig.cmake.in index c8cc516..ae3ca59 100644 --- a/coz-profilerConfig.cmake.in +++ b/coz-profilerConfig.cmake.in @@ -1,11 +1,8 @@ -set(COZDIR destdir) - -set(COZ_BIN ${COZDIR}/bin/coz) -set(COZ_INCLUDE_DIR ${COZDIR}/include) -get_filename_component(LIBRARY_DIR ${CMAKE_CURRENT_LIST_FILE} DIRECTORY) -set(COZ_LIBRARY ${LIBRARY_DIR}/libcoz.so) +set(COZ_BIN @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/coz) +set(COZ_INCLUDE_DIR @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@) +set(COZ_LIBRARY @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libcoz.so) set(COZ_FOUND ON) diff --git a/libcoz/CMakeLists.txt b/libcoz/CMakeLists.txt new file mode 100644 index 0000000..a93422d --- /dev/null +++ b/libcoz/CMakeLists.txt @@ -0,0 +1,23 @@ +add_library(coz MODULE ${sources}) +set_target_properties(coz PROPERTIES PUBLIC_HEADER "${headers}") +if(CONAN_PACKAGE_VERSION) + set_target_properties(coz PROPERTIES VERSION ${CONAN_PACKAGE_VERSION}) +endif() +target_include_directories(coz + PUBLIC + $ + $) +target_link_libraries(coz PUBLIC dl rt Threads::Threads libelfin::libelfin) + +install(TARGETS coz + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/coz) + +add_library(coz-instrumentation INTERFACE) +target_include_directories(coz-instrumentation + INTERFACE + $ + $) +target_link_options(coz-instrumentation INTERFACE -Wl,--push-state,--no-as-needed -ldl -Wl,--pop-state) diff --git a/libcoz/Makefile b/libcoz/Makefile deleted file mode 100644 index 4647fd2..0000000 --- a/libcoz/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -ROOT := .. -TARGETS := libcoz.so -LIBS := -ldl -lrt -lpthread $(shell pkg-config --libs libelf++ libdwarf++) -CXXFLAGS := -gdwarf-3 --std=c++0x -g -O2 -fPIC -I$(ROOT)/include -I. \ - $(shell pkg-config --cflags libelf++ libdwarf++) - -include $(ROOT)/common.mk - -check:: libcoz.so - printf "int main(int argc, char *argv[])\n{\nreturn (0);\n}\n" > x.c - gcc -g -o x x.c || ( $(RM) x x.c ; exit 1) - ../coz run --- ./x - if grep -q time= profile.coz; then echo success: coz profiler ran as it should.; fi - $(RM) -f x.c x profile.coz diff --git a/viewer/Makefile b/viewer/Makefile deleted file mode 100644 index 57ee1a8..0000000 --- a/viewer/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -ROOT := .. - -include $(ROOT)/common.mk - -all:: js/ui.js - -js/ui.js: $(wildcard ts/*.ts) tsconfig.json - @echo $(LOG_PREFIX) Building profile viewer $(LOG_SUFFIX) - @npm install > /dev/null From 0659e3ab1d08eb892b1b30b119f8b2db688a756c Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Fri, 8 Jan 2021 09:59:15 -0800 Subject: [PATCH 02/20] Port old "check" target and update CI Use "make test" to run the old target. Only works for Debug and RelWithDebInfo, since coz requires debug symbols in the program under profile. --- .travis.yml | 15 ++++++++------- CMakeLists.txt | 5 +++++ benchmarks/check-output.sh | 11 +++++++++++ benchmarks/kmeans/CMakeLists.txt | 5 +++++ 4 files changed, 29 insertions(+), 7 deletions(-) create mode 100755 benchmarks/check-output.sh diff --git a/.travis.yml b/.travis.yml index a049d7a..b54ae2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,16 +17,17 @@ branches: # Install dependencies before_install: - sudo apt-get update - - sudo apt-get install -y --install-recommends docutils-common libelfin-dev nodejs npm + - sudo apt-get install -y --install-recommends build-essential cmake ninja-build docutils-common nodejs npm + - sudo pip install conan # Make and install install: - - make - - sudo make install - -# Run the make check target (add tests later) -script: - - make check USE_SYSTEM_COZ=1 + - mkdir build && cd build + - conan install .. + - cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_BENCHMARKS=ON -G Ninja + - ninja + - CTEST_OUTPUT_ON_FAILURE=1 ninja test + - sudo ninja install # Test the Rust support as well matrix: diff --git a/CMakeLists.txt b/CMakeLists.txt index 07f3cf3..afd32d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.1) project(coz C CXX) +enable_testing() + set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -20,6 +22,9 @@ add_subdirectory(libcoz) option(BUILD_BENCHMARKS "Build benchmarks" OFF) if(BUILD_BENCHMARKS) + if(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")) + message(FATAL_ERROR "Build benchmarks with debug information - use Debug or RelWithDebInfo") + endif() find_package(SQLite3 REQUIRED) find_package(BZip2 REQUIRED) add_subdirectory(benchmarks) diff --git a/benchmarks/check-output.sh b/benchmarks/check-output.sh new file mode 100755 index 0000000..9d50b40 --- /dev/null +++ b/benchmarks/check-output.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e +rm -f profile.coz + +$@ + +grep -q "time=" profile.coz || { echo failure: valid profile.coz not generated; exit 1; } +grep -q "throughput-point" profile.coz || { echo failure: throughput-point not found in profile; exit 1; } +grep -q -P "samples\tlocation=" profile.coz || { echo failure: samples not found in profile; exit 1; } +echo success: benchmark generated valid profile.coz diff --git a/benchmarks/kmeans/CMakeLists.txt b/benchmarks/kmeans/CMakeLists.txt index cf4e9eb..5ffce05 100644 --- a/benchmarks/kmeans/CMakeLists.txt +++ b/benchmarks/kmeans/CMakeLists.txt @@ -3,3 +3,8 @@ target_link_libraries(kmeans PRIVATE coz-instrumentation pthread) add_coz_run_target(run_kmeans_small COMMAND $ -d 3 -c 100 -p 10000 -s 100) add_coz_run_target(run_kmeans_large COMMAND $ -d 3 -c 100 -p 100000 -s 1000) + +add_test( + NAME test_run_kmeans + COMMAND ${PROJECT_SOURCE_DIR}/benchmarks/check-output.sh ${PROJECT_SOURCE_DIR}/coz run --- $ + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) From ffd1cd8ff255530aa8350b8b2037bae3c52b80ba Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Fri, 8 Jan 2021 11:10:13 -0800 Subject: [PATCH 03/20] Set required CMake version to 3.13 Required for `target_link_options`. --- .travis.yml | 2 ++ CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b54ae2c..ad895c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,8 @@ branches: # Install dependencies before_install: + - wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null + - sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' - sudo apt-get update - sudo apt-get install -y --install-recommends build-essential cmake ninja-build docutils-common nodejs npm - sudo pip install conan diff --git a/CMakeLists.txt b/CMakeLists.txt index afd32d4..7b45380 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.13) project(coz C CXX) enable_testing() From e5329ce9d5ca610ddd4b0c42a8335d087481078d Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Fri, 8 Jan 2021 15:19:25 -0800 Subject: [PATCH 04/20] Remove default cmake installation It seems the default is CMake 3.12 and we need at least CMake 3.13. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ad895c3..1b35646 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ branches: # Install dependencies before_install: + - sudo apt remove --purge --auto-remove cmake - wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null - sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' - sudo apt-get update From b929ee2ce7eb972df0dda84be775fd7bd20ffbee Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Fri, 8 Jan 2021 16:37:41 -0800 Subject: [PATCH 05/20] Reduce CMake requirement to v3.4 --- .travis.yml | 3 --- CMakeLists.txt | 2 +- libcoz/CMakeLists.txt | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1b35646..b54ae2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,9 +16,6 @@ branches: # Install dependencies before_install: - - sudo apt remove --purge --auto-remove cmake - - wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null - - sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' - sudo apt-get update - sudo apt-get install -y --install-recommends build-essential cmake ninja-build docutils-common nodejs npm - sudo pip install conan diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b45380..e714b76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.4) project(coz C CXX) enable_testing() diff --git a/libcoz/CMakeLists.txt b/libcoz/CMakeLists.txt index a93422d..2cff026 100644 --- a/libcoz/CMakeLists.txt +++ b/libcoz/CMakeLists.txt @@ -20,4 +20,4 @@ target_include_directories(coz-instrumentation INTERFACE $ $) -target_link_options(coz-instrumentation INTERFACE -Wl,--push-state,--no-as-needed -ldl -Wl,--pop-state) +target_link_libraries(coz-instrumentation INTERFACE -Wl,--push-state,--no-as-needed -ldl -Wl,--pop-state) From bd655df54f9183683d860f18842567d3081e0135 Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Fri, 8 Jan 2021 16:59:00 -0800 Subject: [PATCH 06/20] Fix C++11 ABI compatibility --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b54ae2c..ad23d81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,7 @@ before_install: # Make and install install: - mkdir build && cd build + - conan profile update settings.compiler.libcxx=libstdc++11 default - conan install .. - cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_BENCHMARKS=ON -G Ninja - ninja From 4b322891b0289eb68bfe0243a58047d821afa257 Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Fri, 8 Jan 2021 17:33:47 -0800 Subject: [PATCH 07/20] Fix CXX11 ABI compatibility part 2 --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ad23d81..5b64aed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,8 +23,7 @@ before_install: # Make and install install: - mkdir build && cd build - - conan profile update settings.compiler.libcxx=libstdc++11 default - - conan install .. + - conan install .. -s compiler.libcxx=libstdc++11 -s compiler.cppstd=11 - cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_BENCHMARKS=ON -G Ninja - ninja - CTEST_OUTPUT_ON_FAILURE=1 ninja test From aa29b4d88180b462cd877bb8b0b49b4c06c7b2c0 Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Fri, 8 Jan 2021 17:50:13 -0800 Subject: [PATCH 08/20] Build outdated Conan packages --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5b64aed..ab8b9eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ before_install: # Make and install install: - mkdir build && cd build - - conan install .. -s compiler.libcxx=libstdc++11 -s compiler.cppstd=11 + - conan install .. -s compiler.libcxx=libstdc++11 -s compiler.cppstd=11 --build=outdated - cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_BENCHMARKS=ON -G Ninja - ninja - CTEST_OUTPUT_ON_FAILURE=1 ninja test From d743743d00e1ae2694a3ec4f00fa6f7b55dd7025 Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Fri, 8 Jan 2021 18:23:23 -0800 Subject: [PATCH 09/20] Restore custom "script" to run tests --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ab8b9eb..0e1f031 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,9 +26,12 @@ install: - conan install .. -s compiler.libcxx=libstdc++11 -s compiler.cppstd=11 --build=outdated - cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_BENCHMARKS=ON -G Ninja - ninja - - CTEST_OUTPUT_ON_FAILURE=1 ninja test - sudo ninja install +# Run tests +script: + - CTEST_OUTPUT_ON_FAILURE=1 ninja test + # Test the Rust support as well matrix: include: From 9acba33cdb9f355e8a8d3f4e1f32cf56e844a8c4 Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Fri, 8 Jan 2021 18:34:50 -0800 Subject: [PATCH 10/20] Restore -Wno-format for some benchmarks --- benchmarks/matrix_multiply/CMakeLists.txt | 1 + benchmarks/pbzip2/CMakeLists.txt | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/benchmarks/matrix_multiply/CMakeLists.txt b/benchmarks/matrix_multiply/CMakeLists.txt index a20be63..c3f8184 100644 --- a/benchmarks/matrix_multiply/CMakeLists.txt +++ b/benchmarks/matrix_multiply/CMakeLists.txt @@ -1,5 +1,6 @@ add_executable(matrix_multiply matrix_multiply-pthread.c) target_link_libraries(matrix_multiply PRIVATE coz-instrumentation pthread) +target_compile_options(matrix_multiply PRIVATE -Wno-format) add_custom_command( COMMENT "Generating bench input" diff --git a/benchmarks/pbzip2/CMakeLists.txt b/benchmarks/pbzip2/CMakeLists.txt index ca30c89..b191307 100644 --- a/benchmarks/pbzip2/CMakeLists.txt +++ b/benchmarks/pbzip2/CMakeLists.txt @@ -1,5 +1,6 @@ -ADd_executable(pbzip2 BZ2StreamScanner.cpp ErrorContext.cpp pbzip2.cpp) +add_executable(pbzip2 BZ2StreamScanner.cpp ErrorContext.cpp pbzip2.cpp) target_link_libraries(pbzip2 PRIVATE BZip2::BZip2 coz-instrumentation pthread) +target_compile_options(pbzip2 PRIVATE -Wno-format) set(datafiles ${CMAKE_CURRENT_BINARY_DIR}/../linear_regression/linear_regression_datafiles) From 44edb3f3e22dd7dccf00b8ecb3afee5eb2890bf5 Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Thu, 21 Jan 2021 10:53:30 -0800 Subject: [PATCH 11/20] Add -gdwarf-3 compile option Restores original build flag. --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e714b76..b850c63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,8 @@ file(GLOB_RECURSE headers include/*.h) install(PROGRAMS coz DESTINATION bin) install(FILES LICENSE.md DESTINATION licenses) +add_compile_options(-gdwarf-3) + add_subdirectory(libcoz) option(BUILD_BENCHMARKS "Build benchmarks" OFF) From 43637b877a40ecb2e79ebb07bf4b8b7a64b7fe77 Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Thu, 21 Jan 2021 11:04:52 -0800 Subject: [PATCH 12/20] Make coz-profilerConfig.cmake to be relocatable --- CMakeLists.txt | 3 +-- coz-profilerConfig.cmake.in => coz-profilerConfig.cmake | 8 +++----- 2 files changed, 4 insertions(+), 7 deletions(-) rename coz-profilerConfig.cmake.in => coz-profilerConfig.cmake (71%) diff --git a/CMakeLists.txt b/CMakeLists.txt index b850c63..eea1beb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,5 +32,4 @@ if(BUILD_BENCHMARKS) add_subdirectory(benchmarks) endif() -configure_file(coz-profilerConfig.cmake.in coz-profilerConfig.cmake @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/coz-profilerConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) +install(FILES coz-profilerConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) diff --git a/coz-profilerConfig.cmake.in b/coz-profilerConfig.cmake similarity index 71% rename from coz-profilerConfig.cmake.in rename to coz-profilerConfig.cmake index ae3ca59..c3dac53 100644 --- a/coz-profilerConfig.cmake.in +++ b/coz-profilerConfig.cmake @@ -1,8 +1,6 @@ - - -set(COZ_BIN @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/coz) -set(COZ_INCLUDE_DIR @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@) -set(COZ_LIBRARY @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libcoz.so) +set(COZ_BIN ${CMAKE_CURRENT_LIST_DIR}/../../bin/coz) +set(COZ_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../include) +set(COZ_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/../libcoz.so) set(COZ_FOUND ON) From ee410664f897327421904158cb0a275ab4009a4b Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Thu, 21 Jan 2021 11:16:06 -0800 Subject: [PATCH 13/20] Avoid globbing sources Helps to automatically re-run cmake if new files added. --- CMakeLists.txt | 3 --- libcoz/CMakeLists.txt | 9 +++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eea1beb..f601486 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,9 +12,6 @@ include(GNUInstallDirs) find_package(Threads REQUIRED) find_package(libelfin REQUIRED) -file(GLOB_RECURSE sources libcoz/*.cpp) -file(GLOB_RECURSE headers include/*.h) - install(PROGRAMS coz DESTINATION bin) install(FILES LICENSE.md DESTINATION licenses) diff --git a/libcoz/CMakeLists.txt b/libcoz/CMakeLists.txt index 2cff026..09fa793 100644 --- a/libcoz/CMakeLists.txt +++ b/libcoz/CMakeLists.txt @@ -1,3 +1,12 @@ +set(sources + inspect.cpp + libcoz.cpp + perf.cpp + profiler.cpp + real.cpp) +set(headers + ${PROJECT_SOURCE_DIR}/include/coz.h) + add_library(coz MODULE ${sources}) set_target_properties(coz PROPERTIES PUBLIC_HEADER "${headers}") if(CONAN_PACKAGE_VERSION) From c3876783157eac4dfe220303da0095d6cdec65b1 Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Thu, 21 Jan 2021 11:23:42 -0800 Subject: [PATCH 14/20] Add an option to disable Coz install when embedding --- CMakeLists.txt | 12 +++++++----- libcoz/CMakeLists.txt | 14 ++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f601486..70254e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,13 +8,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) list(APPEND CMAKE_MODULE_PATH ${PROJECT_BINARY_DIR}) -include(GNUInstallDirs) find_package(Threads REQUIRED) find_package(libelfin REQUIRED) -install(PROGRAMS coz DESTINATION bin) -install(FILES LICENSE.md DESTINATION licenses) - add_compile_options(-gdwarf-3) add_subdirectory(libcoz) @@ -29,4 +25,10 @@ if(BUILD_BENCHMARKS) add_subdirectory(benchmarks) endif() -install(FILES coz-profilerConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) +option(INSTALL_COZ "Enable installation of coz. (Projects embedding coz may want to turn this OFF.)" ON) +if(INSTALL_COZ) + include(GNUInstallDirs) + install(PROGRAMS coz DESTINATION bin) + install(FILES LICENSE.md DESTINATION licenses) + install(FILES coz-profilerConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) +endif() diff --git a/libcoz/CMakeLists.txt b/libcoz/CMakeLists.txt index 09fa793..6cde506 100644 --- a/libcoz/CMakeLists.txt +++ b/libcoz/CMakeLists.txt @@ -18,15 +18,17 @@ target_include_directories(coz $) target_link_libraries(coz PUBLIC dl rt Threads::Threads libelfin::libelfin) -install(TARGETS coz - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/coz) - add_library(coz-instrumentation INTERFACE) target_include_directories(coz-instrumentation INTERFACE $ $) target_link_libraries(coz-instrumentation INTERFACE -Wl,--push-state,--no-as-needed -ldl -Wl,--pop-state) + +if(INSTALL_COZ) + install(TARGETS coz + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/coz) +endif() From ae1db280ea080f334b57772a131afa83b6870ed6 Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Thu, 21 Jan 2021 11:32:34 -0800 Subject: [PATCH 15/20] Include headers in the list of sources Some IDEs (like older versions of CLion) track project source from CMakeLists.txt file. --- libcoz/CMakeLists.txt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libcoz/CMakeLists.txt b/libcoz/CMakeLists.txt index 6cde506..cd23904 100644 --- a/libcoz/CMakeLists.txt +++ b/libcoz/CMakeLists.txt @@ -1,14 +1,22 @@ set(sources inspect.cpp + inspect.h libcoz.cpp perf.cpp + perf.h profiler.cpp - real.cpp) -set(headers + profiler.h + progress_point.h + real.cpp + real.h + thread_state.h + util.h + ) +set(public_headers ${PROJECT_SOURCE_DIR}/include/coz.h) -add_library(coz MODULE ${sources}) -set_target_properties(coz PROPERTIES PUBLIC_HEADER "${headers}") +add_library(coz MODULE ${sources} ${public_headers}) +set_target_properties(coz PROPERTIES PUBLIC_HEADER "${public_headers}") if(CONAN_PACKAGE_VERSION) set_target_properties(coz PROPERTIES VERSION ${CONAN_PACKAGE_VERSION}) endif() From 94954b865ebcba2c24d21aad8e2da4c5e01ffe33 Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Thu, 21 Jan 2021 11:38:00 -0800 Subject: [PATCH 16/20] Use CMAKE_DL_LIBS for dl dependency --- libcoz/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libcoz/CMakeLists.txt b/libcoz/CMakeLists.txt index cd23904..5d64f4c 100644 --- a/libcoz/CMakeLists.txt +++ b/libcoz/CMakeLists.txt @@ -24,14 +24,14 @@ target_include_directories(coz PUBLIC $ $) -target_link_libraries(coz PUBLIC dl rt Threads::Threads libelfin::libelfin) +target_link_libraries(coz PRIVATE ${CMAKE_DL_LIBS} rt Threads::Threads libelfin::libelfin) add_library(coz-instrumentation INTERFACE) target_include_directories(coz-instrumentation INTERFACE $ $) -target_link_libraries(coz-instrumentation INTERFACE -Wl,--push-state,--no-as-needed -ldl -Wl,--pop-state) +target_link_libraries(coz-instrumentation INTERFACE -Wl,--push-state,--no-as-needed ${CMAKE_DL_LIBS} -Wl,--pop-state) if(INSTALL_COZ) install(TARGETS coz From a15cfb4f9615c0faf22ebead0fad5fed80609744 Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Thu, 21 Jan 2021 12:07:52 -0800 Subject: [PATCH 17/20] Fallback to install include/coz.h instead of include/coz/coz.h --- libcoz/CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libcoz/CMakeLists.txt b/libcoz/CMakeLists.txt index 5d64f4c..2bdd81a 100644 --- a/libcoz/CMakeLists.txt +++ b/libcoz/CMakeLists.txt @@ -1,4 +1,5 @@ set(sources + ${PROJECT_SOURCE_DIR}/include/coz.h inspect.cpp inspect.h libcoz.cpp @@ -12,11 +13,8 @@ set(sources thread_state.h util.h ) -set(public_headers - ${PROJECT_SOURCE_DIR}/include/coz.h) add_library(coz MODULE ${sources} ${public_headers}) -set_target_properties(coz PROPERTIES PUBLIC_HEADER "${public_headers}") if(CONAN_PACKAGE_VERSION) set_target_properties(coz PROPERTIES VERSION ${CONAN_PACKAGE_VERSION}) endif() @@ -37,6 +35,6 @@ if(INSTALL_COZ) install(TARGETS coz ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/coz) + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/. TYPE INCLUDE) endif() From 33a2a5a93055f625e7525797b3706dfdea574c8a Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Thu, 21 Jan 2021 12:15:05 -0800 Subject: [PATCH 18/20] Relocate coz-profilerConfig.cmake to cmake subdir --- CMakeLists.txt | 2 +- coz-profilerConfig.cmake => cmake/coz-profilerConfig.cmake | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename coz-profilerConfig.cmake => cmake/coz-profilerConfig.cmake (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70254e6..a59ea99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,5 +30,5 @@ if(INSTALL_COZ) include(GNUInstallDirs) install(PROGRAMS coz DESTINATION bin) install(FILES LICENSE.md DESTINATION licenses) - install(FILES coz-profilerConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) + install(FILES cmake/coz-profilerConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) endif() diff --git a/coz-profilerConfig.cmake b/cmake/coz-profilerConfig.cmake similarity index 100% rename from coz-profilerConfig.cmake rename to cmake/coz-profilerConfig.cmake From f1a7978f82a3d7b1a20d015e3480685cc85ce7de Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Thu, 21 Jan 2021 13:17:26 -0800 Subject: [PATCH 19/20] Provide default Findlibelfin.cmake if not using Conan --- CMakeLists.txt | 3 ++- cmake/Findlibelfin.cmake | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 cmake/Findlibelfin.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a59ea99..7329632 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,9 @@ enable_testing() set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CONAN_CMAKE_SILENT_OUTPUT ON) -list(APPEND CMAKE_MODULE_PATH ${PROJECT_BINARY_DIR}) +list(APPEND CMAKE_MODULE_PATH ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake) find_package(Threads REQUIRED) find_package(libelfin REQUIRED) diff --git a/cmake/Findlibelfin.cmake b/cmake/Findlibelfin.cmake new file mode 100644 index 0000000..8acf35e --- /dev/null +++ b/cmake/Findlibelfin.cmake @@ -0,0 +1,29 @@ +include(FindPkgConfig) +pkg_check_modules(libelfxx REQUIRED libelf++>=0.3) +pkg_check_modules(libdwarfxx REQUIRED libdwarf++>=0.3) + +add_library(libelfin::libelf++ INTERFACE IMPORTED) +set_target_properties(libelfin::libelf++ PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${libelfxx_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${libelfxx_LDFLAGS}" + INTERFACE_COMPILE_OPTIONS "${libelfxx_CFLAGS};${libelfxx_CFLAGS_OTHER}") +add_library(libelfin::libdwarf++ INTERFACE IMPORTED) +set_target_properties(libelfin::libdwarf++ PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${libdwarfxx_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${libdwarfxx_LDFLAGS}" + INTERFACE_COMPILE_OPTIONS "${libdwarfxx_CFLAGS};${libdwarfxx_CFLAGS_OTHER}") + +if(libelfxx_FOUND AND libdwarfxx_FOUND) + set(libelfin_FOUND 1) + set(libelfin_VERSION ${libelfxx_VERSION}) + if(NOT TARGET libelfin::libelfin) + add_library(libelfin::libelfin INTERFACE IMPORTED) + endif() + set_target_properties(libelfin::libelfin PROPERTIES + INTERFACE_LINK_LIBRARIES "libelfin::libdwarf++;libelfin::libelf++") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(libelfin + REQUIRED_VARS libelfin_VERSION + VERSION_VAR libelfin_VERSION) From fafd230bbbc8b4ee8ecbd31efb3a1c71ea5dee11 Mon Sep 17 00:00:00 2001 From: Alexey Klimkin Date: Sun, 24 Jan 2021 20:56:30 -0800 Subject: [PATCH 20/20] Fix compatibility with CMake v3.4 --- libcoz/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcoz/CMakeLists.txt b/libcoz/CMakeLists.txt index 2bdd81a..faf06f6 100644 --- a/libcoz/CMakeLists.txt +++ b/libcoz/CMakeLists.txt @@ -36,5 +36,5 @@ if(INSTALL_COZ) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/. TYPE INCLUDE) + install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif()