All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kbuild: Fix running modpost with musl libc
@ 2022-12-27 21:48 Samuel Holland
  2022-12-28 16:34 ` Nathan Chancellor
  2022-12-29  2:14 ` Masahiro Yamada
  0 siblings, 2 replies; 4+ messages in thread
From: Samuel Holland @ 2022-12-27 21:48 UTC (permalink / raw)
  To: Masahiro Yamada, linux-kbuild
  Cc: Samuel Holland, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, linux-kernel

commit 3d57e1b7b1d4 ("kbuild: refactor the prerequisites of the modpost
rule") moved 'vmlinux.o' inside modpost-args, possibly before some of
the other options. However, getopt() in musl libc follows POSIX and
stops looking for options upon reaching the first non-option argument.
As a result, the '-T' option is misinterpreted as a positional argument,
and the build fails:

  make -f ./scripts/Makefile.modpost
     scripts/mod/modpost   -E   -o Module.symvers vmlinux.o -T modules.order
  -T: No such file or directory
  make[1]: *** [scripts/Makefile.modpost:137: Module.symvers] Error 1
  make: *** [Makefile:1960: modpost] Error 2

The fix is to move all options before 'vmlinux.o' in modpost-args.

Fixes: 3d57e1b7b1d4 ("kbuild: refactor the prerequisites of the modpost rule")
Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 scripts/Makefile.modpost | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 5eb5e8280379..0ee296cf520c 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -55,6 +55,17 @@ ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),)
 modpost-args += -n
 endif
 
+ifneq ($(KBUILD_MODPOST_WARN)$(missing-input),)
+modpost-args += -w
+endif
+
+# Read out modules.order to pass in modpost.
+# Otherwise, allmodconfig would fail with "Argument list too long".
+ifdef KBUILD_MODULES
+modpost-args += -T $(MODORDER)
+modpost-deps += $(MODORDER)
+endif
+
 ifeq ($(KBUILD_EXTMOD),)
 
 # Generate the list of in-tree objects in vmlinux
@@ -113,17 +124,6 @@ modpost-args += -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS))
 
 endif # ($(KBUILD_EXTMOD),)
 
-ifneq ($(KBUILD_MODPOST_WARN)$(missing-input),)
-modpost-args += -w
-endif
-
-ifdef KBUILD_MODULES
-modpost-args += -T $(MODORDER)
-modpost-deps += $(MODORDER)
-endif
-
-# Read out modules.order to pass in modpost.
-# Otherwise, allmodconfig would fail with "Argument list too long".
 quiet_cmd_modpost = MODPOST $@
       cmd_modpost = \
 	$(if $(missing-input), \
-- 
2.37.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: Fix running modpost with musl libc
  2022-12-27 21:48 [PATCH] kbuild: Fix running modpost with musl libc Samuel Holland
@ 2022-12-28 16:34 ` Nathan Chancellor
  2022-12-29  2:14 ` Masahiro Yamada
  1 sibling, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2022-12-28 16:34 UTC (permalink / raw)
  To: Samuel Holland
  Cc: Masahiro Yamada, linux-kbuild, Nick Desaulniers, Nicolas Schier,
	linux-kernel

On Tue, Dec 27, 2022 at 03:48:21PM -0600, Samuel Holland wrote:
> commit 3d57e1b7b1d4 ("kbuild: refactor the prerequisites of the modpost
> rule") moved 'vmlinux.o' inside modpost-args, possibly before some of
> the other options. However, getopt() in musl libc follows POSIX and
> stops looking for options upon reaching the first non-option argument.
> As a result, the '-T' option is misinterpreted as a positional argument,
> and the build fails:
> 
>   make -f ./scripts/Makefile.modpost
>      scripts/mod/modpost   -E   -o Module.symvers vmlinux.o -T modules.order
>   -T: No such file or directory
>   make[1]: *** [scripts/Makefile.modpost:137: Module.symvers] Error 1
>   make: *** [Makefile:1960: modpost] Error 2
> 
> The fix is to move all options before 'vmlinux.o' in modpost-args.
> 
> Fixes: 3d57e1b7b1d4 ("kbuild: refactor the prerequisites of the modpost rule")
> Signed-off-by: Samuel Holland <samuel@sholland.org>

Seems reasonable to me.

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> 
>  scripts/Makefile.modpost | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
> index 5eb5e8280379..0ee296cf520c 100644
> --- a/scripts/Makefile.modpost
> +++ b/scripts/Makefile.modpost
> @@ -55,6 +55,17 @@ ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),)
>  modpost-args += -n
>  endif
>  
> +ifneq ($(KBUILD_MODPOST_WARN)$(missing-input),)
> +modpost-args += -w
> +endif
> +
> +# Read out modules.order to pass in modpost.
> +# Otherwise, allmodconfig would fail with "Argument list too long".
> +ifdef KBUILD_MODULES
> +modpost-args += -T $(MODORDER)
> +modpost-deps += $(MODORDER)
> +endif
> +
>  ifeq ($(KBUILD_EXTMOD),)
>  
>  # Generate the list of in-tree objects in vmlinux
> @@ -113,17 +124,6 @@ modpost-args += -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS))
>  
>  endif # ($(KBUILD_EXTMOD),)
>  
> -ifneq ($(KBUILD_MODPOST_WARN)$(missing-input),)
> -modpost-args += -w
> -endif
> -
> -ifdef KBUILD_MODULES
> -modpost-args += -T $(MODORDER)
> -modpost-deps += $(MODORDER)
> -endif
> -
> -# Read out modules.order to pass in modpost.
> -# Otherwise, allmodconfig would fail with "Argument list too long".
>  quiet_cmd_modpost = MODPOST $@
>        cmd_modpost = \
>  	$(if $(missing-input), \
> -- 
> 2.37.4
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: Fix running modpost with musl libc
  2022-12-27 21:48 [PATCH] kbuild: Fix running modpost with musl libc Samuel Holland
  2022-12-28 16:34 ` Nathan Chancellor
@ 2022-12-29  2:14 ` Masahiro Yamada
  2023-01-04  8:12   ` Christopher Schramm
  1 sibling, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2022-12-29  2:14 UTC (permalink / raw)
  To: Samuel Holland
  Cc: linux-kbuild, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, linux-kernel

On Wed, Dec 28, 2022 at 6:48 AM Samuel Holland <samuel@sholland.org> wrote:
>
> commit 3d57e1b7b1d4 ("kbuild: refactor the prerequisites of the modpost
> rule") moved 'vmlinux.o' inside modpost-args, possibly before some of
> the other options. However, getopt() in musl libc follows POSIX and
> stops looking for options upon reaching the first non-option argument.
> As a result, the '-T' option is misinterpreted as a positional argument,
> and the build fails:
>
>   make -f ./scripts/Makefile.modpost
>      scripts/mod/modpost   -E   -o Module.symvers vmlinux.o -T modules.order
>   -T: No such file or directory
>   make[1]: *** [scripts/Makefile.modpost:137: Module.symvers] Error 1
>   make: *** [Makefile:1960: modpost] Error 2
>
> The fix is to move all options before 'vmlinux.o' in modpost-args.
>
> Fixes: 3d57e1b7b1d4 ("kbuild: refactor the prerequisites of the modpost rule")
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
>



Applied to linux-kbuild/fixes. Thanks.


>  scripts/Makefile.modpost | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
> index 5eb5e8280379..0ee296cf520c 100644
> --- a/scripts/Makefile.modpost
> +++ b/scripts/Makefile.modpost
> @@ -55,6 +55,17 @@ ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),)
>  modpost-args += -n
>  endif
>
> +ifneq ($(KBUILD_MODPOST_WARN)$(missing-input),)
> +modpost-args += -w
> +endif
> +
> +# Read out modules.order to pass in modpost.
> +# Otherwise, allmodconfig would fail with "Argument list too long".
> +ifdef KBUILD_MODULES
> +modpost-args += -T $(MODORDER)
> +modpost-deps += $(MODORDER)
> +endif
> +
>  ifeq ($(KBUILD_EXTMOD),)
>
>  # Generate the list of in-tree objects in vmlinux
> @@ -113,17 +124,6 @@ modpost-args += -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS))
>
>  endif # ($(KBUILD_EXTMOD),)
>
> -ifneq ($(KBUILD_MODPOST_WARN)$(missing-input),)
> -modpost-args += -w
> -endif
> -
> -ifdef KBUILD_MODULES
> -modpost-args += -T $(MODORDER)
> -modpost-deps += $(MODORDER)
> -endif
> -
> -# Read out modules.order to pass in modpost.
> -# Otherwise, allmodconfig would fail with "Argument list too long".
>  quiet_cmd_modpost = MODPOST $@
>        cmd_modpost = \
>         $(if $(missing-input), \
> --
> 2.37.4
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: Fix running modpost with musl libc
  2022-12-29  2:14 ` Masahiro Yamada
@ 2023-01-04  8:12   ` Christopher Schramm
  0 siblings, 0 replies; 4+ messages in thread
From: Christopher Schramm @ 2023-01-04  8:12 UTC (permalink / raw)
  To: masahiroy, samuel, nathan
  Cc: linux-kbuild, linux-kernel, ndesaulniers, nicolas

This change seems to break expected symbol warnings when building an 
external module against a kernel prepared with modules_prepare.

The build used to show

     WARNING: Module.symvers is missing.
              Modules may not have dependencies or modversions.
              You may get many unresolved symbol warnings.

followed by those many unresolved symbol warnings.

6.2-rc2 still shows that warning but the unresolved symbol messages are 
now errors and the build fails (at scripts/Makefile.modpost:137). This 
seems to happen due to -T getting added.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-04  8:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-27 21:48 [PATCH] kbuild: Fix running modpost with musl libc Samuel Holland
2022-12-28 16:34 ` Nathan Chancellor
2022-12-29  2:14 ` Masahiro Yamada
2023-01-04  8:12   ` Christopher Schramm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.