diff mbox series

[U-Boot,01/30] lib: Allow crc32 to be disabled.

Message ID 20191027155410.187957-1-sjg@chromium.org
State Changes Requested
Delegated to: Tom Rini
Headers show
Series [U-Boot,01/30] lib: Allow crc32 to be disabled. | expand

Commit Message

Simon Glass Oct. 27, 2019, 3:53 p.m. UTC
Unfortunately this table seems to appear in TPL with gcc 7.3 even if it
is not used. Fix it by creating a Kconfig that can be used to disable this
routine.

It is enabled by default, since most boards use it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 lib/Kconfig  | 29 +++++++++++++++++++++++++++++
 lib/Makefile |  2 +-
 2 files changed, 30 insertions(+), 1 deletion(-)

Comments

Heinrich Schuchardt Oct. 27, 2019, 4:48 p.m. UTC | #1
On 10/27/19 4:53 PM, Simon Glass wrote:
> Unfortunately this table seems to appear in TPL with gcc 7.3 even if it
> is not used. Fix it by creating a Kconfig that can be used to disable this
> routine.
>
> It is enabled by default, since most boards use it.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>   lib/Kconfig  | 29 +++++++++++++++++++++++++++++
>   lib/Makefile |  2 +-
>   2 files changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/lib/Kconfig b/lib/Kconfig
> index 135f0b372b..be5f9d343a 100644
> --- a/lib/Kconfig
> +++ b/lib/Kconfig
> @@ -353,6 +353,35 @@ config SHA_PROG_HW_ACCEL
>   config MD5
>   	bool
>
> +config CRC32
> +	bool "Enable crc32 routine"

env/common.c uses crc32(). I could not find how to disable building it.
So this configuration option seems to be superfluous. Otherwise please,
add all reverse dependencies like EFI_LOADER, CMD_UBIFS, ...

> +	default y
> +	help
> +	  This enables a 32-bit CRC (cyclic-redundancy check) routine. It is
> +	  typically used to check for changes in a group of bytes. Even a
> +	  small change typically produces a very different CRC value. This
> +	  algorithm is simple and quite fast.
> +
> +config SPL_CRC32
> +	bool "Enable crc32 routine in SPL"
> +	depends on SPL

Reverse dependencies are missing here, e.g.

selected by SPL_EFI_PARTITION

Best regards

Heinrich

> +	default y
> +	help
> +	  This enables a 32-bit CRC (cyclic-redundancy check) routine in SPL. It
> +	  is typically used to check for changes in a group of bytes. Even a
> +	  small change typically produces a very different CRC value. This
> +	  algorithm is simple and quite fast.
> +
> +config TPL_CRC32
> +	bool "Enable crc32 routine in SPL"
> +	depends on TPL
> +	default y
> +	help
> +	  This enables a 32-bit CRC (cyclic-redundancy check) routine in SPL. It
> +	  is typically used to check for changes in a group of bytes. Even a
> +	  small change typically produces a very different CRC value. This
> +	  algorithm is simple and quite fast.
> +
>   config CRC32C
>   	bool
>
> diff --git a/lib/Makefile b/lib/Makefile
> index d248d8626c..8adc08fd73 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -84,7 +84,7 @@ obj-y += errno.o
>   obj-y += display_options.o
>   CFLAGS_display_options.o := $(if $(BUILD_TAG),-DBUILD_TAG='"$(BUILD_TAG)"')
>   obj-$(CONFIG_BCH) += bch.o
> -obj-y += crc32.o
> +obj-$(CONFIG_$(SPL_TPL_)CRC32) += crc32.o
>   obj-$(CONFIG_CRC32C) += crc32c.o
>   obj-y += ctype.o
>   obj-y += div64.o
>
Tom Rini Nov. 8, 2019, 2:59 p.m. UTC | #2
On Sun, Oct 27, 2019 at 05:48:39PM +0100, Heinrich Schuchardt wrote:
> On 10/27/19 4:53 PM, Simon Glass wrote:
> > Unfortunately this table seems to appear in TPL with gcc 7.3 even if it
> > is not used. Fix it by creating a Kconfig that can be used to disable this
> > routine.
> > 
> > It is enabled by default, since most boards use it.
> > 
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> > 
> >   lib/Kconfig  | 29 +++++++++++++++++++++++++++++
> >   lib/Makefile |  2 +-
> >   2 files changed, 30 insertions(+), 1 deletion(-)
> > 
> > diff --git a/lib/Kconfig b/lib/Kconfig
> > index 135f0b372b..be5f9d343a 100644
> > --- a/lib/Kconfig
> > +++ b/lib/Kconfig
> > @@ -353,6 +353,35 @@ config SHA_PROG_HW_ACCEL
> >   config MD5
> >   	bool
> > 
> > +config CRC32
> > +	bool "Enable crc32 routine"
> 
> env/common.c uses crc32(). I could not find how to disable building it.
> So this configuration option seems to be superfluous. Otherwise please,
> add all reverse dependencies like EFI_LOADER, CMD_UBIFS, ...
> 
> > +	default y
> > +	help
> > +	  This enables a 32-bit CRC (cyclic-redundancy check) routine. It is
> > +	  typically used to check for changes in a group of bytes. Even a
> > +	  small change typically produces a very different CRC value. This
> > +	  algorithm is simple and quite fast.
> > +
> > +config SPL_CRC32
> > +	bool "Enable crc32 routine in SPL"
> > +	depends on SPL
> 
> Reverse dependencies are missing here, e.g.
> 
> selected by SPL_EFI_PARTITION

I think the problem is that for 'CRC32' itself, we need to not have it
be a visible symbol as it's non-optional in main U-Boot.  And then it
should be select'd as needed by SPL_xxx and TPL_xxx symbols.  Thanks!
diff mbox series

Patch

diff --git a/lib/Kconfig b/lib/Kconfig
index 135f0b372b..be5f9d343a 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -353,6 +353,35 @@  config SHA_PROG_HW_ACCEL
 config MD5
 	bool
 
+config CRC32
+	bool "Enable crc32 routine"
+	default y
+	help
+	  This enables a 32-bit CRC (cyclic-redundancy check) routine. It is
+	  typically used to check for changes in a group of bytes. Even a
+	  small change typically produces a very different CRC value. This
+	  algorithm is simple and quite fast.
+
+config SPL_CRC32
+	bool "Enable crc32 routine in SPL"
+	depends on SPL
+	default y
+	help
+	  This enables a 32-bit CRC (cyclic-redundancy check) routine in SPL. It
+	  is typically used to check for changes in a group of bytes. Even a
+	  small change typically produces a very different CRC value. This
+	  algorithm is simple and quite fast.
+
+config TPL_CRC32
+	bool "Enable crc32 routine in SPL"
+	depends on TPL
+	default y
+	help
+	  This enables a 32-bit CRC (cyclic-redundancy check) routine in SPL. It
+	  is typically used to check for changes in a group of bytes. Even a
+	  small change typically produces a very different CRC value. This
+	  algorithm is simple and quite fast.
+
 config CRC32C
 	bool
 
diff --git a/lib/Makefile b/lib/Makefile
index d248d8626c..8adc08fd73 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -84,7 +84,7 @@  obj-y += errno.o
 obj-y += display_options.o
 CFLAGS_display_options.o := $(if $(BUILD_TAG),-DBUILD_TAG='"$(BUILD_TAG)"')
 obj-$(CONFIG_BCH) += bch.o
-obj-y += crc32.o
+obj-$(CONFIG_$(SPL_TPL_)CRC32) += crc32.o
 obj-$(CONFIG_CRC32C) += crc32c.o
 obj-y += ctype.o
 obj-y += div64.o