Skip to content

Commit

Permalink
Merge pull request #89 from sifferman/master
Browse files Browse the repository at this point in the history
Added verilator hotfix
  • Loading branch information
mmicko authored Dec 2, 2023
2 parents f41b9ae + 29e8515 commit b31eaff
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 278 deletions.
274 changes: 0 additions & 274 deletions default/patches/verilated.mk.in

This file was deleted.

62 changes: 62 additions & 0 deletions default/patches/verilator_patches.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3

# Patch to force the addition of -fcoroutines
# Should be removed once YosysHQ/oss-cad-suite-build#84 is properly fixed
def patch_configure_ac():
file_path="configure.ac"

with open(file_path, 'r') as file:
new_content = file.read()

search_string = """
_MY_CXX_CHECK_SET(CFG_CXXFLAGS_COROUTINES,-fcoroutines-ts)
_MY_CXX_CHECK_SET(CFG_CXXFLAGS_COROUTINES,-fcoroutines)
_MY_CXX_CHECK_SET(CFG_CXXFLAGS_COROUTINES,-fcoroutines-ts -Wno-deprecated-experimental-coroutine)
AC_SUBST(CFG_CXXFLAGS_COROUTINES)
"""

replace_string = """
CFG_CXXFLAGS_COROUTINES="-fcoroutines"
AC_SUBST(CFG_CXXFLAGS_COROUTINES)
"""

if search_string in new_content:
new_content = new_content.replace(search_string, replace_string)

search_string = """
AC_MSG_CHECKING([whether coroutines are supported by $CXX])
ACO_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $CFG_CXXFLAGS_COROUTINES"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([
#ifdef __clang__
#define __cpp_impl_coroutine 1
#endif
#include <coroutine>
],[[]])],
[_my_result=yes
AC_DEFINE([HAVE_COROUTINES],[1],[Defined if coroutines are supported by $CXX])],
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <experimental/coroutine>],[[]])],
[_my_result=yes
AC_DEFINE([HAVE_COROUTINES],[1],[Defined if coroutines are supported by $CXX])],
[_my_result=no])])
AC_MSG_RESULT($_my_result)
CXXFLAGS="$ACO_SAVE_CXXFLAGS"
AC_SUBST(HAVE_COROUTINES)
"""

replace_string = """
AC_DEFINE([HAVE_COROUTINES],[1],[Defined for OSS CAD Suite Release])
AC_SUBST(HAVE_COROUTINES)
"""

if search_string in new_content:
new_content = new_content.replace(search_string, replace_string)

with open(file_path, 'w') as file:
file.write(new_content)

# Run patches
if __name__ == "__main__":
patch_configure_ac()
2 changes: 1 addition & 1 deletion default/rules/verilator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
Target(
name = 'verilator',
sources = [ 'verilator' ],
patches = [ 'verilated.mk.in' ],
patches = [ 'verilator_patches.py' ],
package = 'verilator',
)
4 changes: 1 addition & 3 deletions default/scripts/verilator.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
cd verilator
if [ ${ARCH_BASE} == 'darwin' ]; then
cp ${PATCHES_DIR}/verilated.mk.in include/.
fi
python3 ${PATCHES_DIR}/verilator_patches.py
autoconf
./configure --prefix=${INSTALL_PREFIX} --host=${CROSS_NAME}
if [ ${ARCH_BASE} == 'darwin' ]; then
Expand Down

0 comments on commit b31eaff

Please sign in to comment.