diff --git a/Changes b/Changes index 160b90632..1ebbc3f19 100644 --- a/Changes +++ b/Changes @@ -21,6 +21,7 @@ Verilator 5.011 devel * Support get_randstate/set_randstate class method function. * Add creating __inputs.vpp file with --debug (#4177). [Tudor Timi] * Optimize VPI callValueCbs (#4155). [Hennadii Chernyshchyk] +* Configure for faster C++ linking using 'mold', if it is installed. * Fix crash on duplicate imported modules (#3231). [Robert Balas] * Fix false WIDTHEXPAND on array declarations (#3959). [JOTEGO] * Fix marking overridden methods as coroutines (#4120) (#4169). [Krzysztof Bieganski, Antmicro Ltd] diff --git a/ci/ci-install.bash b/ci/ci-install.bash index d3372a798..648620c81 100755 --- a/ci/ci-install.bash +++ b/ci/ci-install.bash @@ -63,8 +63,8 @@ if [ "$CI_BUILD_STAGE_NAME" = "build" ]; then sudo apt-get install ccache help2man libfl-dev if [ "$CI_RUNS_ON" != "ubuntu-22.04" ]; then # Some conflict of libunwind verison on 22.04, can live without it for now - sudo apt-get install libgoogle-perftools-dev || - sudo apt-get install libgoogle-perftools-dev + sudo apt-get install libgoogle-perftools-dev mold || + sudo apt-get install libgoogle-perftools-dev mold fi if [ "$CI_RUNS_ON" = "ubuntu-20.04" ] || [ "$CI_RUNS_ON" = "ubuntu-22.04" ]; then sudo apt-get install libsystemc libsystemc-dev || diff --git a/configure.ac b/configure.ac index 43bd263f1..3b8977d34 100644 --- a/configure.ac +++ b/configure.ac @@ -470,6 +470,10 @@ m4_foreach([ldflag], [ AC_SUBST(CFG_LDLIBS_THREADS) AC_SUBST(CFG_LDFLAGS_THREADS_CMAKE) +# If 'mold' is installed, use it to link for faster buildtimes +_MY_LDLIBS_CHECK_OPT(CFG_LDFLAGS_SRC, -fuse-ld=mold) +_MY_LDLIBS_CHECK_OPT(CFG_LDFLAGS_VERILATED, -fuse-ld=mold) + # When linking partially statically if test "$CFG_ENABLE_PARTIAL_STATIC" = "yes"; then _MY_LDLIBS_CHECK_OPT(CFG_LDFLAGS_SRC, -static-libgcc) @@ -480,6 +484,7 @@ else LTCMALLOC=-ltcmalloc_minimal fi AC_SUBST(CFG_LDFLAGS_SRC) +AC_SUBST(CFG_LDFLAGS_VERILATED) # The pthread library is required by tcmalloc, so add it if it exists. If it # does not, the tcmalloc check below will fail anyway, and linking against diff --git a/docs/guide/install.rst b/docs/guide/install.rst index 594773ae6..a862b4abb 100644 --- a/docs/guide/install.rst +++ b/docs/guide/install.rst @@ -104,6 +104,7 @@ for good performance: :: sudo apt-get install ccache # If present at build, needed for run + sudo apt-get install mold # If present at build, needed for run sudo apt-get install libgoogle-perftools-dev numactl The following is optional but is recommended for nicely rendered command line @@ -124,7 +125,7 @@ Those developing Verilator itself may also want these (see internals.rst): :: - sudo apt-get install gdb graphviz cmake clang clang-format-14 gprof lcov + sudo apt-get install clang clang-format-14 cmake gdb gprof graphviz lcov sudo apt-get install libclang-dev yapf3 sudo pip3 install clang sphinx sphinx_rtd_theme sphinxcontrib-spelling breathe ruff cpan install Pod::Perldoc diff --git a/include/verilated.mk.in b/include/verilated.mk.in index 7a2d51ff6..4f138288b 100644 --- a/include/verilated.mk.in +++ b/include/verilated.mk.in @@ -31,6 +31,8 @@ CFG_CXXFLAGS_NO_UNUSED = @CFG_CXXFLAGS_NO_UNUSED@ CFG_CXXFLAGS_WEXTRA = @CFG_CXXFLAGS_WEXTRA@ # Compiler flags that enable coroutine support CFG_CXXFLAGS_COROUTINES = @CFG_CXXFLAGS_COROUTINES@ +# Linker flags +CFG_LDFLAGS_VERILATED = @CFG_LDFLAGS_VERILATED@ # Linker libraries for multithreading CFG_LDLIBS_THREADS = @CFG_LDLIBS_THREADS@ @@ -77,6 +79,8 @@ VPATH += .. VPATH += $(VERILATOR_ROOT)/include VPATH += $(VERILATOR_ROOT)/include/vltstd +LDFLAGS += $(CFG_LDFLAGS_VERILATED) + #OPT = -ggdb -DPRINTINITSTR -DDETECTCHANGE #OPT = -ggdb -DPRINTINITSTR CPPFLAGS += $(OPT)