Skip to content

Commit 73645c3

Browse files
[CAPNPROTO][CMake] Fixed Build When CAPNPROTO is Disabled
There were many build errors that arose when CAPNPROTO was disabled. It looks like there was a dependency in libarchfpga on libvtrcapnproto even though the library is disabled if the user passes a flag to disable it. Removed this dependency when the flag is disabled. VPR also had a similar issue. This appears to have been handled in the past, but has since regressed. We should consider adding this build to CI to prevent further regressions (if this feature is needed).
1 parent d9644e8 commit 73645c3

File tree

6 files changed

+52
-14
lines changed

6 files changed

+52
-14
lines changed

libs/libarchfpga/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ target_link_libraries(libarchfpga
2222
libvtrutil
2323
libpugixml
2424
libpugiutil
25-
libvtrcapnproto
2625
)
2726

27+
if(${VTR_ENABLE_CAPNPROTO})
28+
target_link_libraries(libarchfpga libvtrcapnproto)
29+
target_compile_definitions(libarchfpga PRIVATE VTR_ENABLE_CAPNPROTO)
30+
endif()
31+
2832
# Using filesystem library requires additional compiler/linker options for GNU implementation prior to 9.1
2933
# and LLVM implementation prior to LLVM 9.0;
3034
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")

libs/libarchfpga/src/read_fpga_interchange_arch.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2+
3+
#include "read_fpga_interchange_arch.h"
4+
#include "vtr_error.h"
5+
6+
#ifdef VTR_ENABLE_CAPNPROTO
7+
18
#include <algorithm>
29
#include <kj/std/iostream.h>
310
#include <limits>
@@ -21,7 +28,6 @@
2128
#include "arch_util.h"
2229
#include "arch_types.h"
2330

24-
#include "read_fpga_interchange_arch.h"
2531

2632
/*
2733
* FPGA Interchange Device frontend
@@ -2497,11 +2503,14 @@ struct ArchReader {
24972503
}
24982504
};
24992505

2506+
#endif // VTR_ENABLE_CAPNPROTO
2507+
25002508
void FPGAInterchangeReadArch(const char* FPGAInterchangeDeviceFile,
25012509
const bool /*timing_enabled*/,
25022510
t_arch* arch,
25032511
std::vector<t_physical_tile_type>& PhysicalTileTypes,
25042512
std::vector<t_logical_block_type>& LogicalBlockTypes) {
2513+
#ifdef VTR_ENABLE_CAPNPROTO
25052514
// Decompress GZipped capnproto device file
25062515
gzFile file = gzopen(FPGAInterchangeDeviceFile, "r");
25072516
VTR_ASSERT(file != Z_NULL);
@@ -2542,4 +2551,12 @@ void FPGAInterchangeReadArch(const char* FPGAInterchangeDeviceFile,
25422551

25432552
ArchReader reader(arch, device_reader, FPGAInterchangeDeviceFile, PhysicalTileTypes, LogicalBlockTypes);
25442553
reader.read_arch();
2554+
#else // VTR_ENABLE_CAPNPROTO
2555+
// If CAPNPROTO is disabled, throw an error.
2556+
(void)FPGAInterchangeDeviceFile;
2557+
(void)arch;
2558+
(void)PhysicalTileTypes;
2559+
(void)LogicalBlockTypes;
2560+
throw vtr::VtrError("Unable to read FPGA interchange if CAPNPROTO is not enabled", __FILE__, __LINE__);
2561+
#endif // VTR_ENABLE_CAPNPROTO
25452562
}

libs/libarchfpga/src/read_fpga_interchange_arch.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33

44
#include "arch_types.h"
55

6+
#ifdef VTR_ENABLE_CAPNPROTO
7+
68
#include "DeviceResources.capnp.h"
79
#include "LogicalNetlist.capnp.h"
810
#include "capnp/serialize.h"
911
#include "capnp/serialize-packed.h"
1012
#include <fcntl.h>
1113
#include <unistd.h>
1214

15+
#endif // VTR_ENABLE_CAPNPROTO
16+
1317
#ifdef __cplusplus
1418
extern "C" {
1519
#endif

vpr/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ file(GLOB_RECURSE LIB_SOURCES src/*/*.cpp)
4343
file(GLOB_RECURSE LIB_HEADERS src/*/*.h)
4444
files_to_dirs(LIB_HEADERS LIB_INCLUDE_DIRS)
4545

46-
if(${VTR_ENABLE_CAPNPROTO})
47-
add_definitions("-DVTR_ENABLE_CAPNPROTO")
48-
endif()
49-
5046
if(${VPR_DEBUG_PARTITION_TREE})
5147
message(STATUS "VPR: Partition tree debug logs: enabled")
5248
add_definitions("-DVPR_DEBUG_PARTITION_TREE")
@@ -131,6 +127,7 @@ target_compile_definitions(libvpr PUBLIC ${GRAPHICS_DEFINES})
131127

132128
if(${VTR_ENABLE_CAPNPROTO})
133129
target_link_libraries(libvpr libvtrcapnproto)
130+
target_compile_definitions(libvpr PRIVATE VTR_ENABLE_CAPNPROTO)
134131
endif()
135132

136133
add_executable(vpr ${EXEC_SOURCES})

vpr/src/base/read_interchange_netlist.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
* hierarchical) netlist in FPGA Interchange Format file, and
77
* builds a netlist data structure (AtomNetlist) from it.
88
*/
9+
10+
#include "read_interchange_netlist.h"
11+
#include "atom_netlist.h"
12+
#include "vtr_error.h"
13+
14+
#ifdef VTR_ENABLE_CAPNPROTO
15+
916
#include <cmath>
1017
#include <limits>
1118
#include <kj/std/iostream.h>
@@ -21,8 +28,6 @@
2128
#include "capnp/serialize.h"
2229
#include "capnp/serialize-packed.h"
2330

24-
#include "atom_netlist.h"
25-
2631
#include "vtr_assert.h"
2732
#include "vtr_hash.h"
2833
#include "vtr_util.h"
@@ -34,7 +39,6 @@
3439
#include "vpr_types.h"
3540
#include "vpr_error.h"
3641
#include "globals.h"
37-
#include "read_interchange_netlist.h"
3842
#include "arch_types.h"
3943

4044
struct NetlistReader {
@@ -520,8 +524,11 @@ struct NetlistReader {
520524
}
521525
};
522526

527+
#endif // VTR_ENABLE_CAPNPROTO
528+
523529
AtomNetlist read_interchange_netlist(const char* ic_netlist_file,
524530
t_arch& arch) {
531+
#ifdef VTR_ENABLE_CAPNPROTO
525532
AtomNetlist netlist;
526533
std::string netlist_id = vtr::secure_digest_file(ic_netlist_file);
527534

@@ -564,4 +571,13 @@ AtomNetlist read_interchange_netlist(const char* ic_netlist_file,
564571
NetlistReader reader(netlist, netlist_reader, netlist_id, ic_netlist_file, arch);
565572

566573
return netlist;
574+
575+
#else // VTR_ENABLE_CAPNPROTO
576+
577+
// If CAPNPROTO is not enabled, throw an error
578+
(void)ic_netlist_file;
579+
(void)arch;
580+
throw vtr::VtrError("Unable to read interchange netlist with CAPNPROTO disabled", __FILE__, __LINE__);
581+
582+
#endif // VTR_ENABLE_CAPNPROTO
567583
}

vpr/src/route/router_lookahead_map.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -897,20 +897,20 @@ static void min_opin_distance_cost_map(const util::t_src_opin_delays& src_opin_d
897897
"Re-compile with CMake option VTR_ENABLE_CAPNPROTO=ON to enable."
898898

899899
void read_router_lookahead(const std::string& /*file*/) {
900-
VPR_THROW(VPR_ERROR_PLACE, "MapLookahead::read " DISABLE_ERROR);
900+
VPR_THROW(VPR_ERROR_PLACE, "MapLookahead::read_router_lookahead " DISABLE_ERROR);
901901
}
902902

903-
void write_router_lookahead(const std::string& file) {
904-
VPR_THROW(VPR_ERROR_PLACE, "MapLookahead::write " DISABLE_ERROR);
903+
void write_router_lookahead(const std::string& /*file*/) {
904+
VPR_THROW(VPR_ERROR_PLACE, "MapLookahead::write_router_lookahead " DISABLE_ERROR);
905905
}
906906

907-
static void read_intra_cluster_router_lookahead(std::unordered_map<t_physical_tile_type_ptr, util::t_ipin_primitive_sink_delays>& /*intra_tile_pin_primitive_pin_delay*/,
907+
static void read_intra_cluster_router_lookahead(std::unordered_map<int, util::t_ipin_primitive_sink_delays>& /*intra_tile_pin_primitive_pin_delay*/,
908908
const std::string& /*file*/) {
909909
VPR_THROW(VPR_ERROR_PLACE, "MapLookahead::read_intra_cluster_router_lookahead " DISABLE_ERROR);
910910
}
911911

912912
static void write_intra_cluster_router_lookahead(const std::string& /*file*/,
913-
const std::unordered_map<t_physical_tile_type_ptr, util::t_ipin_primitive_sink_delays>& /*intra_tile_pin_primitive_pin_delay*/) {
913+
const std::unordered_map<int, util::t_ipin_primitive_sink_delays>& /*intra_tile_pin_primitive_pin_delay*/) {
914914
VPR_THROW(VPR_ERROR_PLACE, "MapLookahead::write_intra_cluster_router_lookahead " DISABLE_ERROR);
915915
}
916916

0 commit comments

Comments
 (0)