Skip to content

Commit 6921a93

Browse files
authored
Merge pull request #2508 from verilog-to-routing/gcc8_support_issue
Link stdc++fs for older gcc versions
2 parents 16cba21 + 92caa13 commit 6921a93

File tree

12 files changed

+67
-27
lines changed

12 files changed

+67
-27
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ set(VTR_IPO_BUILD "auto" CACHE STRING "Should VTR be compiled with interprocedur
2323
set_property(CACHE VTR_IPO_BUILD PROPERTY STRINGS auto on off)
2424

2525
#Allow the user to configure how much assertion checking should occur
26-
set(VTR_ASSERT_LEVEL "2" CACHE STRING "VTR assertion checking level. 0: no assertions, 1: fast assertions, 2: regular assertions, 3: additional assertions with noticable run-time overhead, 4: all assertions (including those with significant run-time cost)")
26+
set(VTR_ASSERT_LEVEL "2" CACHE STRING "VTR assertion checking level. 0: no assertions, 1: fast assertions, 2: regular assertions, 3: additional assertions with noticeable run-time overhead, 4: all assertions (including those with significant run-time cost)")
2727
set_property(CACHE VTR_ASSERT_LEVEL PROPERTY STRINGS 0 1 2 3 4)
2828

2929
option(VTR_ENABLE_STRICT_COMPILE "Specifies whether compiler warnings should be treated as errors (e.g. -Werror)" OFF)

libs/EXTERNAL/libargparse/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ libargparse
22
===========
33
This is (yet another) simple command-line parser for C++ applications, inspired by Python's agparse module.
44

5-
It requires only a C++11 compiler, and has no external dependancies.
5+
It requires only a C++11 compiler, and has no external dependencies.
66

77
One of the advantages of libargparse is that all conversions from command-line strings to program types (bool, int etc.) are performed when the command line is parsed (and not when the options are accessed).
88
This avoids command-line related errors from showing up deep in the program execution, which can be problematic for long-running programs.

libs/libarchfpga/CMakeLists.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,34 @@ target_include_directories(libarchfpga PUBLIC ${LIB_INCLUDE_DIRS})
1717

1818
set_target_properties(libarchfpga PROPERTIES PREFIX "") #Avoid extra 'lib' prefix
1919

20-
#Specify link-time dependancies
20+
#Specify link-time dependencies
2121
target_link_libraries(libarchfpga
2222
libvtrutil
2323
libpugixml
2424
libpugiutil
2525
libvtrcapnproto
2626
)
2727

28+
# Using filesystem library requires additional compiler/linker options for GNU implementation prior to 9.1
29+
# and LLVM implementation prior to LLVM 9.0;
30+
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
31+
# Get the compiler version string
32+
execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE _gcc_output)
33+
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" _gcc_version ${_gcc_output})
34+
35+
if(_gcc_version VERSION_LESS "9.1")
36+
target_link_libraries(libarchfpga stdc++fs)
37+
endif()
38+
elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
39+
# Get the compiler version string
40+
execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE _clang_output)
41+
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" _clang_version ${_clang_output})
42+
43+
if(_clang_version VERSION_LESS "9.0")
44+
target_link_libraries(libarchfpga c++fs)
45+
endif()
46+
endif()
47+
2848
target_compile_definitions(libarchfpga PUBLIC ${INTERCHANGE_SCHEMA_HEADERS})
2949

3050
#Create the test executable

libs/librrgraph/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ target_include_directories(librrgraph PUBLIC ${LIB_INCLUDE_DIRS})
2121

2222
set_target_properties(librrgraph PROPERTIES PREFIX "") #Avoid extra 'lib' prefix
2323

24-
#Specify link-time dependancies
24+
#Specify link-time dependencies
2525
target_link_libraries(librrgraph
2626
libvtrutil
2727
libarchfpga

libs/libvtrutil/CMakeLists.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,30 @@ set_target_properties(libvtrutil PROPERTIES PREFIX "") #Avoid extra 'lib' prefix
100100
#Ensure version is always up to date by requiring version to be run first
101101
add_dependencies(libvtrutil version)
102102

103-
#Specify link-time dependancies
103+
#Specify link-time dependencies
104104
target_link_libraries(libvtrutil
105105
liblog)
106106

107+
# Using filesystem library requires additional compiler/linker options for GNU implementation prior to 9.1
108+
# and LLVM implementation prior to LLVM 9.0;
109+
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
110+
# Get the compiler version string
111+
execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE _gcc_output)
112+
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" _gcc_version ${_gcc_output})
113+
114+
if(_gcc_version VERSION_LESS "9.1")
115+
target_link_libraries(libvtrutil stdc++fs)
116+
endif()
117+
elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
118+
# Get the compiler version string
119+
execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE _clang_output)
120+
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" _clang_version ${_clang_output})
121+
122+
if(_clang_version VERSION_LESS "9.0")
123+
target_link_libraries(libvtrutil c++fs)
124+
endif()
125+
endif()
126+
107127
install(TARGETS libvtrutil DESTINATION bin)
108128
install(FILES ${LIB_HEADERS} DESTINATION include/libvtrutil)
109129

libs/libvtrutil/src/vtr_util.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ static int cont; /* line continued? (used by strtok)*/
2626
*
2727
* The split strings (excluding the delimiters) are returned
2828
*/
29-
std::vector<std::string> split(const char* text, const std::string delims) {
29+
std::vector<std::string> split(const char* text, const std::string& delims) {
3030
if (text) {
3131
std::string text_str(text);
3232
return split(text_str, delims);
3333
}
34-
return std::vector<std::string>();
34+
return {};
3535
}
3636

3737
/**
3838
* @brief Splits the string 'text' along the specified delimiter characters in 'delims'
3939
*
4040
* The split strings (excluding the delimiters) are returned
4141
*/
42-
std::vector<std::string> split(const std::string& text, const std::string delims) {
42+
std::vector<std::string> split(const std::string& text, const std::string& delims) {
4343
std::vector<std::string> tokens;
4444

4545
std::string curr_tok;
@@ -102,7 +102,7 @@ std::string replace_all(const std::string& input, const std::string& search, con
102102
}
103103

104104
///@brief Retruns true if str starts with prefix
105-
bool starts_with(std::string str, std::string prefix) {
105+
bool starts_with(const std::string& str, const std::string& prefix) {
106106
return str.find(prefix) == 0;
107107
}
108108

@@ -461,8 +461,8 @@ bool file_exists(const char* filename) {
461461
*
462462
* Returns true if the extension is correct, and false otherwise.
463463
*/
464-
bool check_file_name_extension(std::string file_name,
465-
std::string file_extension) {
464+
bool check_file_name_extension(const std::string& file_name,
465+
const std::string& file_extension) {
466466
auto ext = std::filesystem::path(file_name).extension();
467467
return ext == file_extension;
468468
}

libs/libvtrutil/src/vtr_util.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ namespace vtr {
1414
*
1515
* The split strings (excluding the delimiters) are returned
1616
*/
17-
std::vector<std::string> split(const char* text, const std::string delims = " \t\n");
18-
std::vector<std::string> split(const std::string& text, const std::string delims = " \t\n");
17+
std::vector<std::string> split(const char* text, const std::string& delims = " \t\n");
18+
std::vector<std::string> split(const std::string& text, const std::string& delims = " \t\n");
1919

2020
///@brief Returns 'input' with the first instance of 'search' replaced with 'replace'
2121
std::string replace_first(const std::string& input, const std::string& search, const std::string& replace);
@@ -24,7 +24,7 @@ std::string replace_first(const std::string& input, const std::string& search, c
2424
std::string replace_all(const std::string& input, const std::string& search, const std::string& replace);
2525

2626
///@brief Retruns true if str starts with prefix
27-
bool starts_with(std::string str, std::string prefix);
27+
bool starts_with(const std::string& str, const std::string& prefix);
2828

2929
///@brief Returns a std::string formatted using a printf-style format string
3030
std::string string_fmt(const char* fmt, ...);
@@ -69,7 +69,7 @@ double atod(const std::string& value);
6969
*/
7070
int get_file_line_number_of_last_opened_file();
7171
bool file_exists(const char* filename);
72-
bool check_file_name_extension(std::string file_name, std::string file_extension);
72+
bool check_file_name_extension(const std::string& file_name, const std::string& file_extension);
7373

7474
extern std::string out_file_prefix;
7575

utils/fasm/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if (GENFASM_USES_IPO)
3333
set_property(TARGET genfasm APPEND PROPERTY LINK_FLAGS ${IPO_LINK_WARN_SUPRESS_FLAGS})
3434
endif()
3535

36-
#Specify link-time dependancies
36+
#Specify link-time dependencies
3737
install(TARGETS genfasm DESTINATION bin)
3838

3939
#
@@ -49,7 +49,7 @@ set(TEST_SOURCES
4949
add_executable(test_fasm ${TEST_SOURCES})
5050
target_link_libraries(test_fasm fasm Catch2::Catch2WithMain)
5151

52-
#Supress IPO link warnings if IPO is enabled
52+
#Suppress IPO link warnings if IPO is enabled
5353
get_target_property(TEST_FASM_USES_IPO test_fasm INTERPROCEDURAL_OPTIMIZATION)
5454
if (TEST_FASM_USES_IPO)
5555
set_property(TARGET test_fasm APPEND PROPERTY LINK_FLAGS ${IPO_LINK_WARN_SUPRESS_FLAGS})

utils/vqm2blif/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ add_library(libvqm2blif STATIC
1515
target_include_directories(libvqm2blif PUBLIC ${LIB_INCLUDE_DIRS})
1616
set_target_properties(libvqm2blif PROPERTIES PREFIX "") #Avoid extra 'lib' prefix
1717

18-
#Specify link-time dependancies
18+
#Specify link-time dependencies
1919
target_link_libraries(libvqm2blif
2020
libarchfpga
2121
libvqm)

vpr/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ add_library(libvpr STATIC
6161

6262
target_include_directories(libvpr PUBLIC ${LIB_INCLUDE_DIRS})
6363

64-
#VPR_ANALYTIC_PLACE is inisitalized in the root CMakeLists
64+
#VPR_ANALYTIC_PLACE is initialized in the root CMakeLists
6565
#Check Eigen dependency
6666
if(${VPR_ANALYTIC_PLACE})
6767
message(STATUS "VPR Analytic Placement: Requested")
@@ -79,7 +79,7 @@ endif()
7979

8080
set_target_properties(libvpr PROPERTIES PREFIX "") #Avoid extra 'lib' prefix
8181

82-
#Specify link-time dependancies
82+
#Specify link-time dependencies
8383
target_link_libraries(libvpr
8484
libvtrutil
8585
libarchfpga
@@ -249,7 +249,7 @@ endif()
249249
# Signal handler configuration
250250
#
251251
if (VPR_USE_SIGNAL_HANDLER)
252-
#Check wheter VPR can use sigaction to handle signals (only supported by POSIX)
252+
#Check whether VPR can use sigaction to handle signals (only supported by POSIX)
253253
CHECK_CXX_SYMBOL_EXISTS(sigaction csignal HAVE_SIGACTION)
254254
if(HAVE_SIGACTION)
255255
target_compile_definitions(libvpr PRIVATE VPR_USE_SIGACTION)

0 commit comments

Comments
 (0)