From 820b5ea5bf4b543b3a2eb1b4b19b2bb93ddc5b5c Mon Sep 17 00:00:00 2001 From: tangxifan Date: Mon, 26 Sep 2022 15:46:12 -0700 Subject: [PATCH 1/6] [script] add options to cmake: users can skip the build of Yosys, yosys-plugin, and testing; Force to turn off building abc, odin and yosys in vtr --- CMakeLists.txt | 70 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43a07188f..95d5b73c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,24 @@ add_definitions("-DVTR_ASSERT_LEVEL=${VTR_ASSERT_LEVEL}") # compiler flag configuration checks include(CheckCXXCompilerFlag) +# Options +## General options +option(OPENFPGA_WITH_YOSYS "Enable building Yosys" ON) +option(OPENFPGA_WITH_YOSYS_PLUGIN "Enable building Yosys plugin" ON) +option(OPENFPGA_WITH_TEST "Enable testing build for codebase. Once enabled, make test can be run" ON) + +# Options pass on to VTR +set(WITH_ABC OFF CACHE BOOL "Enable building ABC in Verilog-to-Routing") +set(WITH_ODIN OFF CACHE BOOL "Enable building Odin in Verilog-to-Routing") +set(ODIN_DEBUG OFF CACHE BOOL "Enable building odin with debug flags in Verilog-to-Routing") +set(ODIN_WARN OFF CACHE BOOL "Enable building odin with extra warning flags in Verilog-to-Routing") +set(ODIN_COVERAGE OFF CACHE BOOL "Enable building odin with coverage flags in Verilog-to-Routing") +set(ODIN_TIDY OFF CACHE BOOL "Enable building odin with clang tidy in Verilog-to-Routing") +set(ODIN_SANITIZE OFF CACHE BOOL "Enable building odin with sanitize flags in Verilog-to-Routing") +set(WITH_YOSYS OFF CACHE BOOL "Enable building Yosys in Verilog-to-Routing") +set(ODIN_YOSYS OFF CACHE BOOL "Enable building odin with yosys in Verilog-to-Routing") +set(YOSYS_SV_UHDM_PLUGIN OFF CACHE BOOL "Enable building and installing Yosys SystemVerilog and UHDM plugins in Verilog-to-Routing") + # # We require c++14 support # @@ -204,7 +222,9 @@ message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") # Unit Testing # -enable_testing() +if (OPENFPGA_WITH_TEST) + enable_testing() +endif() # # Sub-projects @@ -251,30 +271,32 @@ include(CheckCXXCompilerFlag) # # we will check if yosys already exist. if not then build it -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/yosys/install/bin/yosys) - message(STATUS "Yosys pre-build exist so skipping it") -else () -# run makefile provided, we pass-on the options to the local make file -add_custom_target( - yosys ALL - COMMAND $(MAKE) config-gcc - COMMAND $(MAKE) install PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/yosys/install - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/yosys - COMMENT "Compile Yosys with given Makefile" -) +if (OPENFPGA_WITH_YOSYS) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/yosys/install/bin/yosys) + message(STATUS "Yosys pre-build exist so skipping it") + else () + # run makefile provided, we pass-on the options to the local make file + add_custom_target( + yosys ALL + COMMAND $(MAKE) config-gcc + COMMAND $(MAKE) install PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/yosys/install + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/yosys + COMMENT "Compile Yosys with given Makefile" + ) + # yosys compilation ends -# yosys compilation ends - -# yosys-plugins compilation starts -add_custom_target( - yosys-plugins ALL - COMMAND $(MAKE) install_ql-qlf YOSYS_PATH=${CMAKE_CURRENT_SOURCE_DIR}/yosys/install EXTRA_FLAGS="-DPASS_NAME=synth_ql" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/yosys-plugins - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/yosys/install/bin/yosys - COMMENT "Compile Yosys-plugins with given Makefile" -) - -add_dependencies(yosys-plugins yosys) + # yosys-plugins compilation starts + if (OPENFPGA_WITH_YOSYS_PLUGIN) + add_custom_target( + yosys-plugins ALL + COMMAND $(MAKE) install_ql-qlf YOSYS_PATH=${CMAKE_CURRENT_SOURCE_DIR}/yosys/install EXTRA_FLAGS="-DPASS_NAME=synth_ql" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/yosys-plugins + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/yosys/install/bin/yosys + COMMENT "Compile Yosys-plugins with given Makefile" + ) + add_dependencies(yosys-plugins yosys) + endif() + endif() endif() # run make to extract compiler options, linker options and list of source files From c1665bb26c352a29c261601b30c608ea46da5900 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Mon, 26 Sep 2022 15:58:10 -0700 Subject: [PATCH 2/6] [ci] deploy new build tests to ci --- .github/workflows/build.yml | 57 +++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aca7d66e0..d6d1a1a11 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -154,6 +154,63 @@ jobs: yosys/install/bin openfpga_flow openfpga.sh + + linux_build_opt: + needs: change_detect + if: ${{ fromJSON(needs.change_detect.outputs.source_modified) }} + name: ${{ matrix.config.name }} + runs-on: ubuntu-20.04 + # Note: dependencies are installed in the container. See details about dependency list in docker/Dockerfile.master + # Comment the line out when base image is built again + #container: ghcr.io/${{ needs.change_detect.outputs.docker_repo }}/openfpga-build-${{ matrix.config.cc}} + # Branch on different OS and settings + strategy: + fail-fast: false + matrix: + config: + - name: "Build w/o Yosys (Ubuntu 20.04)" + cc: gcc-9 + cxx: g++-9 + cmake_flags: "-DOPENFPGA_WITH_YOSYS OFF" + - name: "Build w/o Yosys plugin (Ubuntu 20.04)" + cc: gcc-9 + cxx: g++-9 + cmake_flags: "-DOPENFPGA_WITH_YOSYS_PLUGIN OFF" + - name: "Build w/o test (Ubuntu 20.04)" + cc: gcc-9 + cxx: g++-9 + cmake_flags: "-DOPENFPGA_WITH_TEST OFF" + # Define the steps to run the build job + env: + CC: ${{ matrix.config.cc }} + CXX: ${{ matrix.config.cxx }} + steps: + - name: Cancel previous + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + + - name: Checkout OpenFPGA repo + uses: actions/checkout@v2 + with: + submodules: true + + - name: Install dependencies + run: ./.github/workflows/install_dependencies_build.sh + + - name: Dump tool versions + run: | + cmake --version + ${CC} --version + ${CXX} --version + + - uses: hendrikmuhs/ccache-action@v1 + + - name: Build + shell: bash + run: | + make all BUILD_TYPE=$BUILD_TYPE CMAKE_FLAGS=${{ matrix.config.cmake_flags }} + docker_distribution: name: Build docker image for distribution runs-on: ubuntu-latest From 76404d6b81b9c4064c91cc6205c103ea62cb225d Mon Sep 17 00:00:00 2001 From: tangxifan Date: Mon, 26 Sep 2022 16:03:32 -0700 Subject: [PATCH 3/6] [ci] add missing quotes --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d6d1a1a11..b505b5e1e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -209,7 +209,7 @@ jobs: - name: Build shell: bash run: | - make all BUILD_TYPE=$BUILD_TYPE CMAKE_FLAGS=${{ matrix.config.cmake_flags }} + make all BUILD_TYPE=$BUILD_TYPE CMAKE_FLAGS="${{ matrix.config.cmake_flags }}" docker_distribution: name: Build docker image for distribution From 445a24535a135073193e0e69db726f8c2c2742e8 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Mon, 26 Sep 2022 16:13:00 -0700 Subject: [PATCH 4/6] [ci] typo --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b505b5e1e..c6cfb7c3a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -171,15 +171,15 @@ jobs: - name: "Build w/o Yosys (Ubuntu 20.04)" cc: gcc-9 cxx: g++-9 - cmake_flags: "-DOPENFPGA_WITH_YOSYS OFF" + cmake_flags: "-DOPENFPGA_WITH_YOSYS=OFF" - name: "Build w/o Yosys plugin (Ubuntu 20.04)" cc: gcc-9 cxx: g++-9 - cmake_flags: "-DOPENFPGA_WITH_YOSYS_PLUGIN OFF" + cmake_flags: "-DOPENFPGA_WITH_YOSYS_PLUGIN=OFF" - name: "Build w/o test (Ubuntu 20.04)" cc: gcc-9 cxx: g++-9 - cmake_flags: "-DOPENFPGA_WITH_TEST OFF" + cmake_flags: "-DOPENFPGA_WITH_TEST=OFF" # Define the steps to run the build job env: CC: ${{ matrix.config.cc }} From 9b65472ffb99a5d28977e246512b9449e60b0d07 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Mon, 26 Sep 2022 16:22:40 -0700 Subject: [PATCH 5/6] [doc] update compilation guidelines --- .../tutorials/getting_started/compile.rst | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/source/tutorials/getting_started/compile.rst b/docs/source/tutorials/getting_started/compile.rst index 05ccda637..a4f5a19ff 100644 --- a/docs/source/tutorials/getting_started/compile.rst +++ b/docs/source/tutorials/getting_started/compile.rst @@ -38,6 +38,33 @@ To quickly verify the tool is well compiled, users can run the following command python3 openfpga_flow/scripts/run_fpga_task.py compilation_verification --debug --show_thread_logs +.. _tutorial_compile_build_options: + +Build Options +~~~~~~~~~~~~~ + +General build targets are available in the top-level makefile. Call help desk to see details + +.. code-block:: shell + + make help + +The following options are available for a custom build + +.. option:: BUILD_TYPE= + + Specify the type of build. Can be either ``release`` or ``debug``. By default, release mode is selected (full optimization on runtime) + +.. option:: CMAKE_FLAGS= + + Force build flags to CMake. The following flags are available + + - ``DOPENFPGA_WITH_TEST=[ON|OFF]``: Enable/Disable the test build + - ``DOPENFPGA_WITH_YOSYS=[ON|OFF]``: Enable/Disable the build of yosys. Note that when disabled, the build of yosys-plugin is also disabled + - ``DOPENFPGA_WITH_YOSYS_PLUGIN=[ON|OFF]``: Enable/Disable the build of yosys-plugin. + +.. warning:: By default, only required modules in *Verilog-to-Routing* (VTR) is enabled. On other words, ``abc``, ``odin``, ``yosys`` and other add-ons inside VTR are not built. If you want to enable them, please look into the dedicated options of CMake scripts. + .. _tutorial_compile_dependencies: Dependencies From 7fcaecd0f514074859307e758f31ecb26b7f4137 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Mon, 26 Sep 2022 21:06:51 -0700 Subject: [PATCH 6/6] [script] enable abc build in vtr because we need ace2 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95d5b73c5..73b0eccb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ option(OPENFPGA_WITH_YOSYS_PLUGIN "Enable building Yosys plugin" ON) option(OPENFPGA_WITH_TEST "Enable testing build for codebase. Once enabled, make test can be run" ON) # Options pass on to VTR -set(WITH_ABC OFF CACHE BOOL "Enable building ABC in Verilog-to-Routing") +set(WITH_ABC ON CACHE BOOL "Enable building ABC in Verilog-to-Routing") set(WITH_ODIN OFF CACHE BOOL "Enable building Odin in Verilog-to-Routing") set(ODIN_DEBUG OFF CACHE BOOL "Enable building odin with debug flags in Verilog-to-Routing") set(ODIN_WARN OFF CACHE BOOL "Enable building odin with extra warning flags in Verilog-to-Routing")