From f4dc67879e965249191d4b6f9e43d5647c39921a Mon Sep 17 00:00:00 2001 From: Keith Rothman <537074+litghost@users.noreply.github.com> Date: Thu, 18 Mar 2021 13:47:06 -0700 Subject: [PATCH 1/3] Fixup GUI link dependencies on headers from libraries. Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com> --- CMakeLists.txt | 16 ++++++++++++---- fpga_interchange/family.cmake | 5 +++++ gui/CMakeLists.txt | 4 ++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ebc2e75..daddb258 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.5) project(nextpnr CXX C) +# Allow family.cmake add additional dependencies to gui_${family}. +cmake_policy(SET CMP0079 NEW) + option(BUILD_GUI "Build GUI" OFF) option(BUILD_PYTHON "Build Python Integration" ON) option(BUILD_TESTS "Build tests" OFF) @@ -223,6 +226,12 @@ else() set(BBASM_ENDIAN_FLAG "--le") endif() +set(EXTRA_LIB_DEPS) +if (USE_THREADS) + list(APPEND EXTRA_LIB_DEPS absl::flat_hash_map) + list(APPEND EXTRA_LIB_DEPS absl::flat_hash_set) +endif() + foreach (family ${ARCH}) message(STATUS "Configuring architecture: ${family}") string(TOUPPER ${family} ufamily) @@ -276,10 +285,9 @@ foreach (family ${ARCH}) # Include the family-specific CMakeFile include(${family}/family.cmake) foreach (target ${family_targets}) - if (USE_THREADS) - target_link_libraries(${target} PRIVATE absl::flat_hash_map) - target_link_libraries(${target} PRIVATE absl::flat_hash_set) - endif() + foreach(lib_dep ${EXTRA_LIB_DEPS}) + target_link_libraries(${target} PRIVATE ${lib_dep}) + endforeach() # Include family-specific source files to all family targets and set defines appropriately target_include_directories(${target} PRIVATE ${family}/ ${CMAKE_CURRENT_BINARY_DIR}/generated/) diff --git a/fpga_interchange/family.cmake b/fpga_interchange/family.cmake index bad439f8..16a38fa7 100644 --- a/fpga_interchange/family.cmake +++ b/fpga_interchange/family.cmake @@ -30,3 +30,8 @@ foreach (target ${family_targets}) target_link_libraries(${target} PRIVATE fpga_interchange_capnp) target_link_libraries(${target} PRIVATE z) endforeach() + +if(BUILD_GUI) + target_link_libraries(gui_${family} fpga_interchange_capnp) + target_link_libraries(gui_${family} z) +endif() diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index a818640f..e692eee9 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -40,3 +40,7 @@ endif() target_compile_definitions(gui_${family} PRIVATE NEXTPNR_NAMESPACE=nextpnr_${family} ARCH_${ufamily} ARCHNAME=${family} QT_NO_KEYWORDS) target_link_libraries(gui_${family} Qt5::Widgets) + +foreach(lib_dep ${EXTRA_LIB_DEPS}) + target_link_libraries(gui_${family} ${lib_dep}) +endforeach() From d5021e7ed5aa3f30e25125e2569a6a94bbe502c4 Mon Sep 17 00:00:00 2001 From: Keith Rothman <537074+litghost@users.noreply.github.com> Date: Thu, 18 Mar 2021 14:01:40 -0700 Subject: [PATCH 2/3] Add IPO support for nextpnr, and have it enabled by default. Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com> --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index daddb258..704815e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,11 @@ project(nextpnr CXX C) # Allow family.cmake add additional dependencies to gui_${family}. cmake_policy(SET CMP0079 NEW) +# Enable IPO support. +cmake_policy(SET CMP0069 NEW) +include(CheckIPOSupported) +check_ipo_supported() + option(BUILD_GUI "Build GUI" OFF) option(BUILD_PYTHON "Build Python Integration" ON) option(BUILD_TESTS "Build tests" OFF) @@ -14,6 +19,8 @@ option(STATIC_BUILD "Create static build" OFF) option(EXTERNAL_CHIPDB "Create build with pre-built chipdb binaries" OFF) option(WERROR "pass -Werror to compiler (used for CI)" OFF) +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + if(WIN32 OR EXTERNAL_CHIPDB) set(BBASM_MODE "binary") else() From 76c6e1248c3550bf5dfc6191421225507dabe404 Mon Sep 17 00:00:00 2001 From: Keith Rothman <537074+litghost@users.noreply.github.com> Date: Thu, 18 Mar 2021 14:02:07 -0700 Subject: [PATCH 3/3] Add option to link against "libprofiler". Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com> --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 704815e3..e3c4472c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ option(COVERAGE "Add code coverage info" OFF) option(STATIC_BUILD "Create static build" OFF) option(EXTERNAL_CHIPDB "Create build with pre-built chipdb binaries" OFF) option(WERROR "pass -Werror to compiler (used for CI)" OFF) +option(PROFILER "Link against libprofiler" OFF) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) @@ -238,6 +239,9 @@ if (USE_THREADS) list(APPEND EXTRA_LIB_DEPS absl::flat_hash_map) list(APPEND EXTRA_LIB_DEPS absl::flat_hash_set) endif() +if(PROFILER) + list(APPEND EXTRA_LIB_DEPS profiler) +endif() foreach (family ${ARCH}) message(STATUS "Configuring architecture: ${family}")