* [PATCH] lib/crypto: ensure generated *.S files are removed on make clean
@ 2025-08-14 0:38 Tal Zussman
2025-08-14 0:47 ` Tal Zussman
0 siblings, 1 reply; 3+ messages in thread
From: Tal Zussman @ 2025-08-14 0:38 UTC (permalink / raw)
To: Eric Biggers, Jason A. Donenfeld, Ard Biesheuvel
Cc: linux-crypto, linux-kernel, Tal Zussman
make clean does not check the kernel config when removing files. As
such, additions to clean-files under CONFIG_ARM or CONFIG_ARM64 are not
evaluated. For example, when building on arm64, this means that
lib/crypto/arm64/sha{256,512}-core.S are left over after make clean.
Set clean-files unconditionally to ensure that make clean removes these
files.
Fixes: e96cb9507f2d ("lib/crypto: sha256: Consolidate into single module")
Fixes: 24c91b62ac50 ("lib/crypto: arm/sha512: Migrate optimized SHA-512 code to library")
Fixes: 60e3f1e9b7a5 ("lib/crypto: arm64/sha512: Migrate optimized SHA-512 code to library")
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
An alternative approach is to rename the generated files to *.s and
remove the clean-files lines, as make clean removes *.s files
automatically. However, this would require explicitly defining the
corresponding *.o rules.
---
lib/crypto/Makefile | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
index e4151be2ebd4..44f6a1fdc808 100644
--- a/lib/crypto/Makefile
+++ b/lib/crypto/Makefile
@@ -100,7 +100,6 @@ ifeq ($(CONFIG_ARM),y)
libsha256-y += arm/sha256-ce.o arm/sha256-core.o
$(obj)/arm/sha256-core.S: $(src)/arm/sha256-armv4.pl
$(call cmd,perlasm)
-clean-files += arm/sha256-core.S
AFLAGS_arm/sha256-core.o += $(aflags-thumb2-y)
endif
@@ -108,7 +107,6 @@ ifeq ($(CONFIG_ARM64),y)
libsha256-y += arm64/sha256-core.o
$(obj)/arm64/sha256-core.S: $(src)/arm64/sha2-armv8.pl
$(call cmd,perlasm_with_args)
-clean-files += arm64/sha256-core.S
libsha256-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha256-ce.o
endif
@@ -132,7 +130,6 @@ ifeq ($(CONFIG_ARM),y)
libsha512-y += arm/sha512-core.o
$(obj)/arm/sha512-core.S: $(src)/arm/sha512-armv4.pl
$(call cmd,perlasm)
-clean-files += arm/sha512-core.S
AFLAGS_arm/sha512-core.o += $(aflags-thumb2-y)
endif
@@ -140,7 +137,6 @@ ifeq ($(CONFIG_ARM64),y)
libsha512-y += arm64/sha512-core.o
$(obj)/arm64/sha512-core.S: $(src)/arm64/sha2-armv8.pl
$(call cmd,perlasm_with_args)
-clean-files += arm64/sha512-core.S
libsha512-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha512-ce-core.o
endif
@@ -167,3 +163,7 @@ obj-$(CONFIG_PPC) += powerpc/
obj-$(CONFIG_RISCV) += riscv/
obj-$(CONFIG_S390) += s390/
obj-$(CONFIG_X86) += x86/
+
+# clean-files must be defined unconditionally
+clean-files += arm/sha256-core.S arm/sha256-core.S
+clean-files += arm64/sha512-core.S arm64/sha512-core.S
---
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250813-crypto_clean-6b4d483e40fb
Best regards,
--
Tal Zussman <tz2294@columbia.edu>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lib/crypto: ensure generated *.S files are removed on make clean
2025-08-14 0:38 [PATCH] lib/crypto: ensure generated *.S files are removed on make clean Tal Zussman
@ 2025-08-14 0:47 ` Tal Zussman
2025-08-14 2:40 ` Eric Biggers
0 siblings, 1 reply; 3+ messages in thread
From: Tal Zussman @ 2025-08-14 0:47 UTC (permalink / raw)
To: Eric Biggers, Jason A. Donenfeld, Ard Biesheuvel
Cc: linux-crypto, linux-kernel
On Thu, Aug 14, 2025 at 3:39 AM Tal Zussman <tz2294@columbia.edu> wrote:
>
> make clean does not check the kernel config when removing files. As
> such, additions to clean-files under CONFIG_ARM or CONFIG_ARM64 are not
> evaluated. For example, when building on arm64, this means that
> lib/crypto/arm64/sha{256,512}-core.S are left over after make clean.
>
> Set clean-files unconditionally to ensure that make clean removes these
> files.
>
> Fixes: e96cb9507f2d ("lib/crypto: sha256: Consolidate into single module")
> Fixes: 24c91b62ac50 ("lib/crypto: arm/sha512: Migrate optimized SHA-512 code to library")
> Fixes: 60e3f1e9b7a5 ("lib/crypto: arm64/sha512: Migrate optimized SHA-512 code to library")
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
> ---
> An alternative approach is to rename the generated files to *.s and
> remove the clean-files lines, as make clean removes *.s files
> automatically. However, this would require explicitly defining the
> corresponding *.o rules.
> ---
> lib/crypto/Makefile | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
> index e4151be2ebd4..44f6a1fdc808 100644
> --- a/lib/crypto/Makefile
> +++ b/lib/crypto/Makefile
> @@ -100,7 +100,6 @@ ifeq ($(CONFIG_ARM),y)
> libsha256-y += arm/sha256-ce.o arm/sha256-core.o
> $(obj)/arm/sha256-core.S: $(src)/arm/sha256-armv4.pl
> $(call cmd,perlasm)
> -clean-files += arm/sha256-core.S
> AFLAGS_arm/sha256-core.o += $(aflags-thumb2-y)
> endif
>
> @@ -108,7 +107,6 @@ ifeq ($(CONFIG_ARM64),y)
> libsha256-y += arm64/sha256-core.o
> $(obj)/arm64/sha256-core.S: $(src)/arm64/sha2-armv8.pl
> $(call cmd,perlasm_with_args)
> -clean-files += arm64/sha256-core.S
> libsha256-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha256-ce.o
> endif
>
> @@ -132,7 +130,6 @@ ifeq ($(CONFIG_ARM),y)
> libsha512-y += arm/sha512-core.o
> $(obj)/arm/sha512-core.S: $(src)/arm/sha512-armv4.pl
> $(call cmd,perlasm)
> -clean-files += arm/sha512-core.S
> AFLAGS_arm/sha512-core.o += $(aflags-thumb2-y)
> endif
>
> @@ -140,7 +137,6 @@ ifeq ($(CONFIG_ARM64),y)
> libsha512-y += arm64/sha512-core.o
> $(obj)/arm64/sha512-core.S: $(src)/arm64/sha2-armv8.pl
> $(call cmd,perlasm_with_args)
> -clean-files += arm64/sha512-core.S
> libsha512-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha512-ce-core.o
> endif
>
> @@ -167,3 +163,7 @@ obj-$(CONFIG_PPC) += powerpc/
> obj-$(CONFIG_RISCV) += riscv/
> obj-$(CONFIG_S390) += s390/
> obj-$(CONFIG_X86) += x86/
> +
> +# clean-files must be defined unconditionally
> +clean-files += arm/sha256-core.S arm/sha256-core.S
> +clean-files += arm64/sha512-core.S arm64/sha512-core.S
Sorry this is broken, needs the following fix on top.
I'll fix in v2.
diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
index 44f6a1fdc808..539d5d59a50e 100644
--- a/lib/crypto/Makefile
+++ b/lib/crypto/Makefile
@@ -165,5 +165,5 @@ obj-$(CONFIG_S390) += s390/
obj-$(CONFIG_X86) += x86/
# clean-files must be defined unconditionally
-clean-files += arm/sha256-core.S arm/sha256-core.S
-clean-files += arm64/sha512-core.S arm64/sha512-core.S
+clean-files += arm/sha256-core.S arm/sha512-core.S
+clean-files += arm64/sha256-core.S arm64/sha512-core.S
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lib/crypto: ensure generated *.S files are removed on make clean
2025-08-14 0:47 ` Tal Zussman
@ 2025-08-14 2:40 ` Eric Biggers
0 siblings, 0 replies; 3+ messages in thread
From: Eric Biggers @ 2025-08-14 2:40 UTC (permalink / raw)
To: Tal Zussman
Cc: Jason A. Donenfeld, Ard Biesheuvel, linux-crypto, linux-kernel
On Thu, Aug 14, 2025 at 03:47:05AM +0300, Tal Zussman wrote:
> On Thu, Aug 14, 2025 at 3:39 AM Tal Zussman <tz2294@columbia.edu> wrote:
> >
> > make clean does not check the kernel config when removing files. As
> > such, additions to clean-files under CONFIG_ARM or CONFIG_ARM64 are not
> > evaluated. For example, when building on arm64, this means that
> > lib/crypto/arm64/sha{256,512}-core.S are left over after make clean.
> >
> > Set clean-files unconditionally to ensure that make clean removes these
> > files.
> >
> > Fixes: e96cb9507f2d ("lib/crypto: sha256: Consolidate into single module")
> > Fixes: 24c91b62ac50 ("lib/crypto: arm/sha512: Migrate optimized SHA-512 code to library")
> > Fixes: 60e3f1e9b7a5 ("lib/crypto: arm64/sha512: Migrate optimized SHA-512 code to library")
> > Signed-off-by: Tal Zussman <tz2294@columbia.edu>
> > ---
> > An alternative approach is to rename the generated files to *.s and
> > remove the clean-files lines, as make clean removes *.s files
> > automatically. However, this would require explicitly defining the
> > corresponding *.o rules.
> > ---
> > lib/crypto/Makefile | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
> > index e4151be2ebd4..44f6a1fdc808 100644
> > --- a/lib/crypto/Makefile
> > +++ b/lib/crypto/Makefile
> > @@ -100,7 +100,6 @@ ifeq ($(CONFIG_ARM),y)
> > libsha256-y += arm/sha256-ce.o arm/sha256-core.o
> > $(obj)/arm/sha256-core.S: $(src)/arm/sha256-armv4.pl
> > $(call cmd,perlasm)
> > -clean-files += arm/sha256-core.S
> > AFLAGS_arm/sha256-core.o += $(aflags-thumb2-y)
> > endif
> >
> > @@ -108,7 +107,6 @@ ifeq ($(CONFIG_ARM64),y)
> > libsha256-y += arm64/sha256-core.o
> > $(obj)/arm64/sha256-core.S: $(src)/arm64/sha2-armv8.pl
> > $(call cmd,perlasm_with_args)
> > -clean-files += arm64/sha256-core.S
> > libsha256-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha256-ce.o
> > endif
> >
> > @@ -132,7 +130,6 @@ ifeq ($(CONFIG_ARM),y)
> > libsha512-y += arm/sha512-core.o
> > $(obj)/arm/sha512-core.S: $(src)/arm/sha512-armv4.pl
> > $(call cmd,perlasm)
> > -clean-files += arm/sha512-core.S
> > AFLAGS_arm/sha512-core.o += $(aflags-thumb2-y)
> > endif
> >
> > @@ -140,7 +137,6 @@ ifeq ($(CONFIG_ARM64),y)
> > libsha512-y += arm64/sha512-core.o
> > $(obj)/arm64/sha512-core.S: $(src)/arm64/sha2-armv8.pl
> > $(call cmd,perlasm_with_args)
> > -clean-files += arm64/sha512-core.S
> > libsha512-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha512-ce-core.o
> > endif
> >
> > @@ -167,3 +163,7 @@ obj-$(CONFIG_PPC) += powerpc/
> > obj-$(CONFIG_RISCV) += riscv/
> > obj-$(CONFIG_S390) += s390/
> > obj-$(CONFIG_X86) += x86/
> > +
> > +# clean-files must be defined unconditionally
> > +clean-files += arm/sha256-core.S arm/sha256-core.S
> > +clean-files += arm64/sha512-core.S arm64/sha512-core.S
>
> Sorry this is broken, needs the following fix on top.
> I'll fix in v2.
>
> diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
> index 44f6a1fdc808..539d5d59a50e 100644
> --- a/lib/crypto/Makefile
> +++ b/lib/crypto/Makefile
> @@ -165,5 +165,5 @@ obj-$(CONFIG_S390) += s390/
> obj-$(CONFIG_X86) += x86/
>
> # clean-files must be defined unconditionally
> -clean-files += arm/sha256-core.S arm/sha256-core.S
> -clean-files += arm64/sha512-core.S arm64/sha512-core.S
> +clean-files += arm/sha256-core.S arm/sha512-core.S
> +clean-files += arm64/sha256-core.S arm64/sha512-core.S
Hmm, interesting. So 'make clean' works in kind of a unique way. It
looks at $(ARCH), but not .config. And though no CONFIG_* options are
set for it, it still processes all the subdirectories like
'obj-$(CONFIG_FOO) += subdir/'. But it doesn't process the contents of
'if' statements conditional on $(CONFIG_FOO). I guess it couldn't
really work in any other way, but it's a bit unique.
Yes, just defining the clean-files unconditionally looks like the best
option here. Please go ahead and send out v2 with the corrected
filenames. Thanks!
- Eric
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-14 2:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-14 0:38 [PATCH] lib/crypto: ensure generated *.S files are removed on make clean Tal Zussman
2025-08-14 0:47 ` Tal Zussman
2025-08-14 2:40 ` Eric Biggers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).