Remove gperf usage from toolchain
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 19 Aug 2017 17:17:02 +0000 (10:17 -0700)
committerChristian Lamparter <chunkeey@gmail.com>
Sun, 5 Nov 2017 17:35:38 +0000 (18:35 +0100)
It turns out that gperf-3.1 changed types in the generated code in ways
that aren't even trivially detectable without having to generate a test-file.

It's just not worth using tools and libraries from clowns that don't
understand or care about compatibility.  So get rid of gperf.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com> [removed gperf related stuff]
README.md
config/CMakeLists.txt
config/kconf_id.c [new file with mode: 0644]
config/lkc.h
config/zconf.gperf [deleted file]
config/zconf.y
extra/FindGPERF.cmake [deleted file]

index 386e2076a696b769dba0186a893331db6cc6fcfc..65a3aa774298a0d3ec465e8cc1868bf43c72ce40 100644 (file)
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ tools and libraries:
 
  * gcc 6.0+ (including library and header dependencies)
 
- * gperf, bison/flex
+ * bison/flex
 
  * cmake 3.8+
 
index ac3f0a786e7fabc187f7f03e7e8b3c56408ee45d..0a96a82a1166e55d93d9daad285797736321a9c9 100644 (file)
@@ -11,14 +11,10 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 
 file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../include/generated")
 
-LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../extra")
-FIND_PACKAGE(GPERF REQUIRED)
-
 BISON_TARGET(zconf zconf.y zconf.tab.c COMPILE_FLAGS "-l -b zconf -p zconf -t")
 FLEX_TARGET(zconfscan zconf.l zconf.lex.c COMPILE_FLAGS "-Pzconf -L")
-GPERF_TARGET(zconfhash zconf.gperf zconf.hash.c)
 
-SET(zconf_deps ${FLEX_zconfscan_OUTPUTS} ${GPERF_zconfhash_OUTPUTS})
+SET(zconf_deps ${FLEX_zconfscan_OUTPUTS})
 SET_SOURCE_FILES_PROPERTIES(${BISON_zconf_OUTPUTS}
       PROPERTIES OBJECT_DEPENDS "${zconf_deps}")
 
diff --git a/config/kconf_id.c b/config/kconf_id.c
new file mode 100644 (file)
index 0000000..5abbc72
--- /dev/null
@@ -0,0 +1,54 @@
+
+static struct kconf_id kconf_id_array[] = {
+       { "mainmenu",           T_MAINMENU,             TF_COMMAND },
+       { "menu",               T_MENU,                 TF_COMMAND },
+       { "endmenu",            T_ENDMENU,              TF_COMMAND },
+       { "source",             T_SOURCE,               TF_COMMAND },
+       { "choice",             T_CHOICE,               TF_COMMAND },
+       { "endchoice",          T_ENDCHOICE,            TF_COMMAND },
+       { "comment",            T_COMMENT,              TF_COMMAND },
+       { "config",             T_CONFIG,               TF_COMMAND },
+       { "menuconfig",         T_MENUCONFIG,           TF_COMMAND },
+       { "help",               T_HELP,                 TF_COMMAND },
+       { "---help---",         T_HELP,                 TF_COMMAND },
+       { "if",                 T_IF,                   TF_COMMAND|TF_PARAM },
+       { "endif",              T_ENDIF,                TF_COMMAND },
+       { "depends",            T_DEPENDS,              TF_COMMAND },
+       { "optional",           T_OPTIONAL,             TF_COMMAND },
+       { "default",            T_DEFAULT,              TF_COMMAND, S_UNKNOWN },
+       { "prompt",             T_PROMPT,               TF_COMMAND },
+       { "tristate",           T_TYPE,                 TF_COMMAND, S_TRISTATE },
+       { "def_tristate",       T_DEFAULT,              TF_COMMAND, S_TRISTATE },
+       { "bool",               T_TYPE,                 TF_COMMAND, S_BOOLEAN },
+       { "boolean",            T_TYPE,                 TF_COMMAND, S_BOOLEAN },
+       { "def_bool",           T_DEFAULT,              TF_COMMAND, S_BOOLEAN },
+       { "int",                T_TYPE,                 TF_COMMAND, S_INT },
+       { "hex",                T_TYPE,                 TF_COMMAND, S_HEX },
+       { "string",             T_TYPE,                 TF_COMMAND, S_STRING },
+       { "select",             T_SELECT,               TF_COMMAND },
+       { "imply",              T_IMPLY,                TF_COMMAND },
+       { "range",              T_RANGE,                TF_COMMAND },
+       { "visible",            T_VISIBLE,              TF_COMMAND },
+       { "option",             T_OPTION,               TF_COMMAND },
+       { "on",                 T_ON,                   TF_PARAM },
+       { "modules",            T_OPT_MODULES,          TF_OPTION },
+       { "defconfig_list",     T_OPT_DEFCONFIG_LIST,   TF_OPTION },
+       { "env",                T_OPT_ENV,              TF_OPTION },
+       { "allnoconfig_y",      T_OPT_ALLNOCONFIG_Y,    TF_OPTION },
+};
+
+#define KCONF_ID_ARRAY_SIZE (sizeof(kconf_id_array)/sizeof(struct kconf_id))
+
+static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len)
+{
+       int i;
+
+       for (i = 0; i < KCONF_ID_ARRAY_SIZE; i++) {
+               struct kconf_id *id = kconf_id_array+i;
+               int l = strlen(id->name);
+
+               if (len == l && !memcmp(str, id->name, len))
+                       return id;
+       }
+       return NULL;
+}
index 91ca126ea0802e40278bbbf09b3413ce59c1bc15..cdcbe43e87b368f357f8aedb44d5dac39d796e49 100644 (file)
@@ -62,7 +62,7 @@ enum conf_def_mode {
 #define T_OPT_ALLNOCONFIG_Y    4
 
 struct kconf_id {
-       int name;
+       const char *name;
        int token;
        unsigned int flags;
        enum symbol_type stype;
diff --git a/config/zconf.gperf b/config/zconf.gperf
deleted file mode 100644 (file)
index 574f7b3..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-%language=ANSI-C
-%define hash-function-name kconf_id_hash
-%define lookup-function-name kconf_id_lookup
-%define string-pool-name kconf_id_strings
-%compare-strncmp
-%enum
-%pic
-%struct-type
-
-struct kconf_id;
-
-struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
-
-%%
-mainmenu,      T_MAINMENU,     TF_COMMAND
-menu,          T_MENU,         TF_COMMAND
-endmenu,       T_ENDMENU,      TF_COMMAND
-source,                T_SOURCE,       TF_COMMAND
-choice,                T_CHOICE,       TF_COMMAND
-endchoice,     T_ENDCHOICE,    TF_COMMAND
-comment,       T_COMMENT,      TF_COMMAND
-config,                T_CONFIG,       TF_COMMAND
-menuconfig,    T_MENUCONFIG,   TF_COMMAND
-help,          T_HELP,         TF_COMMAND
----help---,    T_HELP,         TF_COMMAND
-if,            T_IF,           TF_COMMAND|TF_PARAM
-endif,         T_ENDIF,        TF_COMMAND
-depends,       T_DEPENDS,      TF_COMMAND
-optional,      T_OPTIONAL,     TF_COMMAND
-default,       T_DEFAULT,      TF_COMMAND, S_UNKNOWN
-prompt,                T_PROMPT,       TF_COMMAND
-tristate,      T_TYPE,         TF_COMMAND, S_TRISTATE
-def_tristate,  T_DEFAULT,      TF_COMMAND, S_TRISTATE
-bool,          T_TYPE,         TF_COMMAND, S_BOOLEAN
-boolean,       T_TYPE,         TF_COMMAND, S_BOOLEAN
-def_bool,      T_DEFAULT,      TF_COMMAND, S_BOOLEAN
-int,           T_TYPE,         TF_COMMAND, S_INT
-hex,           T_TYPE,         TF_COMMAND, S_HEX
-string,                T_TYPE,         TF_COMMAND, S_STRING
-select,                T_SELECT,       TF_COMMAND
-imply,         T_IMPLY,        TF_COMMAND
-range,         T_RANGE,        TF_COMMAND
-visible,       T_VISIBLE,      TF_COMMAND
-option,                T_OPTION,       TF_COMMAND
-on,            T_ON,           TF_PARAM
-modules,       T_OPT_MODULES,  TF_OPTION
-defconfig_list,        T_OPT_DEFCONFIG_LIST,TF_OPTION
-env,           T_OPT_ENV,      TF_OPTION
-allnoconfig_y, T_OPT_ALLNOCONFIG_Y,TF_OPTION
-%%
index dfd602124b1037ea011653a30d16994bd00797d4..79c4f04f72fa819bfdb7548a736f1c16fcf37ec8 100644 (file)
@@ -101,8 +101,8 @@ static struct menu *current_menu, *current_entry;
 } if_entry menu_entry choice_entry
 
 %{
-/* Include zconf.hash.c here so it can see the token constants. */
-#include "zconf.hash.c"
+/* Include zconf_id.c here so it can see the token constants. */
+#include "kconf_id.c"
 %}
 
 %%
@@ -119,7 +119,7 @@ stmt_list:
        | stmt_list T_WORD error T_EOL  { zconf_error("unknown statement \"%s\"", $2); }
        | stmt_list option_name error T_EOL
 {
-       zconf_error("unexpected option \"%s\"", kconf_id_strings + $2->name);
+       zconf_error("unexpected option \"%s\"", $2->name);
 }
        | stmt_list error T_EOL         { zconf_error("invalid statement"); }
 ;
@@ -551,13 +551,13 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok
 {
        if (id->token != endtoken) {
                zconf_error("unexpected '%s' within %s block",
-                       kconf_id_strings + id->name, zconf_tokenname(starttoken));
+                       id->name, zconf_tokenname(starttoken));
                zconfnerrs++;
                return false;
        }
        if (current_menu->file != current_file) {
                zconf_error("'%s' in different file than '%s'",
-                       kconf_id_strings + id->name, zconf_tokenname(starttoken));
+                       id->name, zconf_tokenname(starttoken));
                fprintf(stderr, "%s:%d: location of the '%s'\n",
                        current_menu->file->name, current_menu->lineno,
                        zconf_tokenname(starttoken));
diff --git a/extra/FindGPERF.cmake b/extra/FindGPERF.cmake
deleted file mode 100644 (file)
index baf8749..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-# - Find gperf executable and provides a macro to generate custom build rules
-#
-# The module defines the following variables:
-#  GPERF_FOUND - true is gperf executable is found
-#  GPERF_EXECUTABLE - the path to the gperf executable
-#  GPERF_VERSION - the version of gperf
-#  GPERF_LIBRARIES - The gperf libraries
-#
-# The minimum required version of gperf can be specified using the
-# standard syntax, e.g. FIND_PACKAGE(GPERF 2.5.13)
-#
-#
-# If gperf is found on the system, the module provides the macro:
-#  GPERF_TARGET(Name GperfInput GperfOutput [COMPILE_FLAGS <string>])
-# which creates a custom command  to generate the <GperfOutput> file from
-# the <GperfInput> file.  If  COMPILE_FLAGS option is specified, the next
-# parameter is added to the gperf  command line. Name is an alias used to
-# get  details of  this custom  command.  Indeed the  macro defines  the
-# following variables:
-#  GPERF_${Name}_DEFINED - true is the macro ran successfully
-#  GPERF_${Name}_OUTPUTS - the source file generated by the custom rule, an
-#  alias for GperfOutput
-#  GPERF_${Name}_INPUT - the gperf source file, an alias for ${GperfInput}
-#
-# Gperf scanners oftenly use tokens  defined by Bison: the code generated
-# by Gperf  depends of the header  generated by Bison.   This module also
-# defines a macro:
-#  ADD_GPERF_BISON_DEPENDENCY(GperfTarget BisonTarget)
-# which  adds the  required dependency  between a  scanner and  a parser
-# where  <GperfTarget>  and <BisonTarget>  are  the  first parameters  of
-# respectively GPERF_TARGET and BISON_TARGET macros.
-#
-#  ====================================================================
-#  Example:
-#
-#   find_package(GPERF)
-#
-#   GPERF_TARGET(MyHash hash.gperf  ${CMAKE_CURRENT_BINARY_DIR}/hash.c)
-#
-#  ====================================================================
-
-#=============================================================================
-# Copyright 2009 Kitware, Inc.
-# Copyright 2006 Tristan Carel
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# * Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-#
-# * Neither the names of Kitware, Inc., the Insight Software Consortium,
-#   nor the names of their contributors may be used to endorse or promote
-#   products derived from this software without specific prior written
-#   permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-cmake_minimum_required(VERSION 2.8.4)
-
-FIND_PROGRAM(GPERF_EXECUTABLE gperf DOC "path to the gperf executable")
-MARK_AS_ADVANCED(GPERF_EXECUTABLE)
-
-FIND_LIBRARY(FL_LIBRARY NAMES fl
-  DOC "path to the fl library")
-MARK_AS_ADVANCED(FL_LIBRARY)
-SET(GPERF_LIBRARIES ${FL_LIBRARY})
-
-IF(GPERF_EXECUTABLE)
-
-  EXECUTE_PROCESS(COMMAND ${GPERF_EXECUTABLE} --version
-    OUTPUT_VARIABLE GPERF_version_output
-    ERROR_VARIABLE GPERF_version_error
-    RESULT_VARIABLE GPERF_version_result
-    OUTPUT_STRIP_TRAILING_WHITESPACE)
-
-  SET(ENV{LC_ALL} ${_Bison_SAVED_LC_ALL})
-
-  IF(NOT ${GPERF_version_result} EQUAL 0)
-    MESSAGE(SEND_ERROR "Command \"${GPERF_EXECUTABLE} --version\" failed with output:\n${GPERF_version_error}")
-  ELSE() 
-    STRING(REGEX REPLACE "^GNU gperf ([^\n]+)\n.*" "\\1"
-      GPERF_VERSION "${GPERF_version_output}")
-  ENDIF()
-
-  #============================================================
-  # GPERF_TARGET (public macro)
-  #============================================================
-  #
-  MACRO(GPERF_TARGET Name Input Output)
-    SET(GPERF_TARGET_usage "GPERF_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>]")
-    IF(${ARGC} GREATER 3)
-      IF(${ARGC} EQUAL 5)
-        IF("${ARGV3}" STREQUAL "COMPILE_FLAGS")
-          SET(GPERF_EXECUTABLE_opts  "${ARGV4}")
-          SEPARATE_ARGUMENTS(GPERF_EXECUTABLE_opts)
-        ELSE()
-          MESSAGE(SEND_ERROR ${GPERF_TARGET_usage})
-        ENDIF()
-      ELSE()
-        MESSAGE(SEND_ERROR ${GPERF_TARGET_usage})
-      ENDIF()
-    ENDIF()
-
-    ADD_CUSTOM_COMMAND(OUTPUT ${Output}
-      COMMAND ${GPERF_EXECUTABLE}
-      ARGS ${GPERF_EXECUTABLE_opts} < ${Input} > ${Output}
-      DEPENDS ${Input}
-      COMMENT "[GPERF][${Name}] Building hash with gperf ${GPERF_VERSION}"
-      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-
-    SET(GPERF_${Name}_DEFINED TRUE)
-    SET(GPERF_${Name}_OUTPUTS ${Output})
-    SET(GPERF_${Name}_INPUT ${Input})
-    SET(GPERF_${Name}_COMPILE_FLAGS ${GPERF_EXECUTABLE_opts})
-  ENDMACRO(GPERF_TARGET)
-  #============================================================
-
-
-  #============================================================
-  # ADD_GPERF_BISON_DEPENDENCY (public macro)
-  #============================================================
-  #
-  MACRO(ADD_GPERF_BISON_DEPENDENCY GperfTarget BisonTarget)
-
-    IF(NOT GPERF_${GperfTarget}_OUTPUTS)
-      MESSAGE(SEND_ERROR "Gperf target `${GperfTarget}' does not exists.")
-    ENDIF()
-
-    IF(NOT BISON_${BisonTarget}_OUTPUT_HEADER)
-      MESSAGE(SEND_ERROR "Bison target `${BisonTarget}' does not exists.")
-    ENDIF()
-
-    SET_SOURCE_FILES_PROPERTIES(${GPERF_${GperfTarget}_OUTPUTS}
-      PROPERTIES OBJECT_DEPENDS ${BISON_${BisonTarget}_OUTPUT_HEADER})
-  ENDMACRO(ADD_GPERF_BISON_DEPENDENCY)
-  #============================================================
-
-ENDIF(GPERF_EXECUTABLE)
-
-INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(GPERF REQUIRED_VARS GPERF_EXECUTABLE
-                                       VERSION_VAR GPERF_VERSION)
-
-# FindGPERF.cmake ends here