From 106a9fe67fc287fb8bb4c3f3d9efc9c9238fee6b Mon Sep 17 00:00:00 2001 From: Andrew Miloradovsky Date: Thu, 27 Jul 2023 09:42:35 +0000 Subject: [PATCH] Fix config_build.h issues (#4380) (#4381) --- Makefile.in | 4 +-- configure.ac | 2 +- docs/CONTRIBUTORS | 1 + docs/guide/verilating.rst | 2 +- src/.gitignore | 2 +- src/CMakeLists.txt | 2 +- src/Makefile.in | 2 +- src/V3Global.h | 4 +-- src/V3Options.cpp | 2 +- src/VlcMain.cpp | 6 ++-- src/{config_build.h.in => config_build.h} | 22 +------------ src/config_package.h.in | 38 +++++++++++++++++++++++ 12 files changed, 53 insertions(+), 34 deletions(-) rename src/{config_build.h.in => config_build.h} (74%) create mode 100644 src/config_package.h.in diff --git a/Makefile.in b/Makefile.in index c74aadd73..358823411 100644 --- a/Makefile.in +++ b/Makefile.in @@ -449,8 +449,8 @@ install-msg: IN_WILD := ${srcdir}/*.in ${srcdir}/*/*.in -# autoheader might not change config_build.h.in, so touch it -${srcdir}/config_build.h: ${srcdir}/config_build.h.in configure +# autoheader might not change config_package.h.in, so touch it +${srcdir}/config_package.h: ${srcdir}/config_package.h.in configure cd ${srcdir} && autoheader touch $@ Makefile: Makefile.in config.status $(IN_WILD) diff --git a/configure.ac b/configure.ac index 23ecbb20e..71a06aa55 100644 --- a/configure.ac +++ b/configure.ac @@ -14,7 +14,7 @@ AC_INIT([Verilator],[5.013 devel], [https://verilator.org], [verilator],[https://verilator.org]) -AC_CONFIG_HEADERS(src/config_build.h) +AC_CONFIG_HEADERS(src/config_package.h) AC_CONFIG_FILES(Makefile src/Makefile src/Makefile_obj include/verilated.mk include/verilated_config.h verilator.pc verilator-config.cmake verilator-config-version.cmake) # Version diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS index a991287ae..b9b184379 100644 --- a/docs/CONTRIBUTORS +++ b/docs/CONTRIBUTORS @@ -13,6 +13,7 @@ Aliaksei Chapyzhenka Ameya Vikram Singh Andreas Kuster Andrei Kostovski +Andrew Miloradovsky Andrew Nolte Anthony Donlon Arkadiusz Kozdra diff --git a/docs/guide/verilating.rst b/docs/guide/verilating.rst index e1b031c5a..7c1aa361b 100644 --- a/docs/guide/verilating.rst +++ b/docs/guide/verilating.rst @@ -165,7 +165,7 @@ compiled on the different target system. To support this, none of the files that Verilator produces will reference any configure-generated build-system-specific files, such as -:file:`config.h` (which is renamed in Verilator to :file:`config_build.h` +:file:`config.h` (which is renamed in Verilator to :file:`config_package.h` to reduce confusion.) The disadvantage of this approach is that :file:`include/verilatedos.h` must self-detect the requirements of the target system, rather than using configure. diff --git a/src/.gitignore b/src/.gitignore index 69a397007..0cfb6eb36 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,6 +1,6 @@ *~ *.old -config_build.h +config_package.h Makefile Makefile_obj .objcache* diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4f48e3927..ba230d891 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -324,7 +324,7 @@ file(TO_NATIVE_PATH ${srcdir}/../bin/verilator_includer VERILATOR_INCLUDER) file(TO_NATIVE_PATH ${srcdir}/vlcovgen VLCOVGEN) file(TO_NATIVE_PATH ${srcdir}/config_rev CONFIG_REV) -configure_file(config_build.h.in config_build.h @ONLY) +configure_file(config_package.h.in config_package.h @ONLY) add_custom_command( OUTPUT V3Ast__gen_forward_class_decls.h V3Dfg__gen_forward_class_decls.h diff --git a/src/Makefile.in b/src/Makefile.in index c8e94fe50..a1af5cf21 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -95,7 +95,7 @@ clean mostlyclean distclean maintainer-clean:: -rm -f .objcache* distclean maintainer-clean:: - -rm -f Makefile Makefile_obj config_build.h + -rm -f Makefile Makefile_obj config_package.h maintainer-clean:: -rm -f config_rev.h diff --git a/src/V3Global.h b/src/V3Global.h index fcb4b7e20..f9ee59dd0 100644 --- a/src/V3Global.h +++ b/src/V3Global.h @@ -19,8 +19,8 @@ // clang-format off #include "config_build.h" -#ifndef HAVE_CONFIG_BUILD -# error "Something failed during ./configure as config_build.h is incomplete. Perhaps you used autoreconf, don't." +#ifndef HAVE_CONFIG_PACKAGE +# error "Something failed during ./configure as config_package.h is incomplete. Perhaps you used autoreconf, don't." #endif // clang-format on diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 46daafcc8..8d0d3e26f 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -896,7 +896,7 @@ void V3Options::notify() { // V3 Options accessors string V3Options::version() VL_PURE { - string ver = DTVERSION; + string ver = PACKAGE_STRING; ver += " rev " + cvtToStr(DTVERSION_rev); return ver; } diff --git a/src/VlcMain.cpp b/src/VlcMain.cpp index e3b13fdee..b26753c62 100644 --- a/src/VlcMain.cpp +++ b/src/VlcMain.cpp @@ -16,8 +16,8 @@ // clang-format off #include "config_build.h" -#ifndef HAVE_CONFIG_BUILD -# error "Something failed during ./configure as config_build.h is incomplete. Perhaps you used autoreconf, don't." +#ifndef HAVE_CONFIG_PACKAGE +# error "Something failed during ./configure as config_package.h is incomplete. Perhaps you used autoreconf, don't." #endif // clang-format on @@ -48,7 +48,7 @@ static int debug() { return V3Error::debugDefault(); } void VlcOptions::addReadFile(const string& filename) { m_readFiles.insert(filename); } string VlcOptions::version() { - string ver = DTVERSION; + string ver = PACKAGE_STRING; ver += " rev " + cvtToStr(DTVERSION_rev); return ver; } diff --git a/src/config_build.h.in b/src/config_build.h similarity index 74% rename from src/config_build.h.in rename to src/config_build.h index 34cb81c45..afafb86f4 100644 --- a/src/config_build.h.in +++ b/src/config_build.h @@ -19,12 +19,7 @@ //********************************************************************** //**** Version and host name -// Autoconf substitutes this with the strings from AC_INIT. -#define PACKAGE_STRING "" - -#define PACKAGE_VERSION_NUMBER_STRING "0.000" - -#define DTVERSION PACKAGE_STRING +#include "config_package.h" //********************************************************************** //**** Functions @@ -73,22 +68,7 @@ using string = std::string; using std::cout; using std::endl; -//********************************************************************** -//**** Configure-discovered library options - -// Define if struct stat has st_mtim.tv_nsec (from configure) -#undef HAVE_STAT_NSEC -// Define if SystemC found -// - If defined, the default search path has it, so support is always enabled. -// - If undef, not system-wide, user can set SYSTEMC_INCLUDE. -#undef HAVE_SYSTEMC -#undef HAVE_COROUTINES - //********************************************************************** //**** OS and compiler specifics #include "verilatedos.h" - -//********************************************************************** -//**** This file sometimes gets truncated, so check in consumers -#define HAVE_CONFIG_BUILD diff --git a/src/config_package.h.in b/src/config_package.h.in new file mode 100644 index 000000000..25ccf8816 --- /dev/null +++ b/src/config_package.h.in @@ -0,0 +1,38 @@ +// -*- mode: C++; c-file-style: "cc-mode" -*- + +// DESCRIPTION: Verilator: Configure source; system configuration +// +// This file is part of Verilator. +// +// Code available from: https://verilator.org +// +// Copyright 2003-2023 by Wilson Snyder. This program is free software; +// you can redistribute it and/or modify it under the terms of either +// the GNU Lesser General Public License Version 3 or +// the Perl Artistic License Version 2.0. +// +// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + + +// Autoconf substitutes this with the strings from AC_INIT. +#define PACKAGE_STRING "" +#define PACKAGE_VERSION_NUMBER_STRING "0.000" +// Otherwise Autoheader generates it (with all the same macros and more) + +//********************************************************************** +//**** Configure-discovered library options + +// Define if struct stat has st_mtim.tv_nsec (from configure) +#undef HAVE_STAT_NSEC + +// Define if SystemC found +// - If defined, the default search path has it, so support is always enabled. +// - If undef, not system-wide, user can set SYSTEMC_INCLUDE. +#undef HAVE_SYSTEMC + +// Define if coroutines are supported on this platform +#undef HAVE_COROUTINES + +//********************************************************************** +//**** This file sometimes gets truncated, so check in consumers +#define HAVE_CONFIG_PACKAGE