[PATCH v2 00/10] kbuild: userprogs: introduce architecture-specific CC_CAN_LINK and userprog flags

Thomas Weißschuh posted 10 patches 2 months ago
There is a newer version of this series
Makefile                |  8 ++++++--
arch/mips/Kconfig       | 15 +++++++++++++++
arch/powerpc/Kconfig    | 15 +++++++++++++++
arch/riscv/Kconfig      | 11 +++++++++++
arch/s390/Kconfig       | 11 +++++++++++
arch/sparc/Kconfig      | 11 +++++++++++
arch/x86/Kconfig        | 11 +++++++++++
init/Kconfig            |  7 +++++--
scripts/Kconfig.include |  3 +++
scripts/cc-can-link.sh  |  2 +-
10 files changed, 89 insertions(+), 5 deletions(-)
[PATCH v2 00/10] kbuild: userprogs: introduce architecture-specific CC_CAN_LINK and userprog flags
Posted by Thomas Weißschuh 2 months ago
The current logic to inherit -m32/-m64 from the kernel build only works
for a few architectures. It does not handle byte order differences,
architectures using different compiler flags or different kinds of ABIs.

Introduce a per-architecture override mechanism to set CC_CAN_LINK and
the flags used for userprogs.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
Changes in v2:
- Rebase and drop already applied patch
- Disable CC_CAN_LINK if the test program generates warnings
- Move to architecture-specific logic
- Link to v1: https://lore.kernel.org/r/20250813-kbuild-userprogs-bits-v1-0-2d9f7f411083@linutronix.de

---
Thomas Weißschuh (10):
      kbuild: don't enable CC_CAN_LINK if the dummy program generates warnings
      init: deduplicate cc-can-link.sh invocations
      kbuild: allow architectures to override CC_CAN_LINK
      riscv: Implement custom CC_CAN_LINK
      s390: Implement custom CC_CAN_LINK
      powerpc: Implement custom CC_CAN_LINK
      MIPS: Implement custom CC_CAN_LINK
      x86/Kconfig: Implement custom CC_CAN_LINK
      sparc: Implement custom CC_CAN_LINK
      kbuild: simplify CC_CAN_LINK

 Makefile                |  8 ++++++--
 arch/mips/Kconfig       | 15 +++++++++++++++
 arch/powerpc/Kconfig    | 15 +++++++++++++++
 arch/riscv/Kconfig      | 11 +++++++++++
 arch/s390/Kconfig       | 11 +++++++++++
 arch/sparc/Kconfig      | 11 +++++++++++
 arch/x86/Kconfig        | 11 +++++++++++
 init/Kconfig            |  7 +++++--
 scripts/Kconfig.include |  3 +++
 scripts/cc-can-link.sh  |  2 +-
 10 files changed, 89 insertions(+), 5 deletions(-)
---
base-commit: 10f8210c7a7098897fcee5ca70236167b39eb797
change-id: 20250813-kbuild-userprogs-bits-03c117da4d50

Best regards,
-- 
Thomas Weißschuh <thomas.weissschuh@linutronix.de>

Re: [PATCH v2 00/10] kbuild: userprogs: introduce architecture-specific CC_CAN_LINK and userprog flags
Posted by Nicolas Schier 1 month ago
On Tue, Oct 14, 2025 at 03:05:15PM +0200, Thomas Weißschuh wrote:
> The current logic to inherit -m32/-m64 from the kernel build only works
> for a few architectures. It does not handle byte order differences,
> architectures using different compiler flags or different kinds of ABIs.
> 
> Introduce a per-architecture override mechanism to set CC_CAN_LINK and
> the flags used for userprogs.
> 
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> ---
> Changes in v2:
> - Rebase and drop already applied patch
> - Disable CC_CAN_LINK if the test program generates warnings
> - Move to architecture-specific logic
> - Link to v1: https://lore.kernel.org/r/20250813-kbuild-userprogs-bits-v1-0-2d9f7f411083@linutronix.de
> 
> ---
> Thomas Weißschuh (10):
>       kbuild: don't enable CC_CAN_LINK if the dummy program generates warnings
>       init: deduplicate cc-can-link.sh invocations
>       kbuild: allow architectures to override CC_CAN_LINK
>       riscv: Implement custom CC_CAN_LINK
>       s390: Implement custom CC_CAN_LINK
>       powerpc: Implement custom CC_CAN_LINK
>       MIPS: Implement custom CC_CAN_LINK
>       x86/Kconfig: Implement custom CC_CAN_LINK
>       sparc: Implement custom CC_CAN_LINK
>       kbuild: simplify CC_CAN_LINK
> 
>  Makefile                |  8 ++++++--
>  arch/mips/Kconfig       | 15 +++++++++++++++
>  arch/powerpc/Kconfig    | 15 +++++++++++++++
>  arch/riscv/Kconfig      | 11 +++++++++++
>  arch/s390/Kconfig       | 11 +++++++++++
>  arch/sparc/Kconfig      | 11 +++++++++++
>  arch/x86/Kconfig        | 11 +++++++++++
>  init/Kconfig            |  7 +++++--
>  scripts/Kconfig.include |  3 +++
>  scripts/cc-can-link.sh  |  2 +-
>  10 files changed, 89 insertions(+), 5 deletions(-)
> ---
> base-commit: 10f8210c7a7098897fcee5ca70236167b39eb797
> change-id: 20250813-kbuild-userprogs-bits-03c117da4d50
> 
> Best regards,
> -- 
> Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> 

Thanks for the patch set and all the work behind!  I found only one
issue in patch 3, the rest looks good to me as they are.

I haven't reviewed the compiler flags for the archs, but from the formal
point of view they look good to me, too.

How shall we proceed with here?  I think, easiest would be if we get
appropriate acks from the architecture maintainers, so we could take
this via kbuild.

Other opinions?

Kind regards,
Nicolas
Re: [PATCH v2 00/10] kbuild: userprogs: introduce architecture-specific CC_CAN_LINK and userprog flags
Posted by Thomas Weißschuh 1 month ago
On Wed, Nov 12, 2025 at 09:03:23PM +0100, Nicolas Schier wrote:
> On Tue, Oct 14, 2025 at 03:05:15PM +0200, Thomas Weißschuh wrote:
> > The current logic to inherit -m32/-m64 from the kernel build only works
> > for a few architectures. It does not handle byte order differences,
> > architectures using different compiler flags or different kinds of ABIs.
> > 
> > Introduce a per-architecture override mechanism to set CC_CAN_LINK and
> > the flags used for userprogs.
> > 
> > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> > ---
> > Changes in v2:
> > - Rebase and drop already applied patch
> > - Disable CC_CAN_LINK if the test program generates warnings
> > - Move to architecture-specific logic
> > - Link to v1: https://lore.kernel.org/r/20250813-kbuild-userprogs-bits-v1-0-2d9f7f411083@linutronix.de
> > 
> > ---
> > Thomas Weißschuh (10):
> >       kbuild: don't enable CC_CAN_LINK if the dummy program generates warnings
> >       init: deduplicate cc-can-link.sh invocations
> >       kbuild: allow architectures to override CC_CAN_LINK
> >       riscv: Implement custom CC_CAN_LINK
> >       s390: Implement custom CC_CAN_LINK
> >       powerpc: Implement custom CC_CAN_LINK
> >       MIPS: Implement custom CC_CAN_LINK
> >       x86/Kconfig: Implement custom CC_CAN_LINK
> >       sparc: Implement custom CC_CAN_LINK
> >       kbuild: simplify CC_CAN_LINK
> > 
> >  Makefile                |  8 ++++++--
> >  arch/mips/Kconfig       | 15 +++++++++++++++
> >  arch/powerpc/Kconfig    | 15 +++++++++++++++
> >  arch/riscv/Kconfig      | 11 +++++++++++
> >  arch/s390/Kconfig       | 11 +++++++++++
> >  arch/sparc/Kconfig      | 11 +++++++++++
> >  arch/x86/Kconfig        | 11 +++++++++++
> >  init/Kconfig            |  7 +++++--
> >  scripts/Kconfig.include |  3 +++
> >  scripts/cc-can-link.sh  |  2 +-
> >  10 files changed, 89 insertions(+), 5 deletions(-)
> > ---
> > base-commit: 10f8210c7a7098897fcee5ca70236167b39eb797
> > change-id: 20250813-kbuild-userprogs-bits-03c117da4d50
> > 
> > Best regards,
> > -- 
> > Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> > 
> 
> Thanks for the patch set and all the work behind!  I found only one
> issue in patch 3, the rest looks good to me as they are.
> 
> I haven't reviewed the compiler flags for the archs, but from the formal
> point of view they look good to me, too.
> 
> How shall we proceed with here?  I think, easiest would be if we get
> appropriate acks from the architecture maintainers, so we could take
> this via kbuild.

That would surely be the best option. Unfortunately quite frequently it is hard
to get architecture maintainer's feedback on a cross-architecture series.

> Other opinions?

It would also work to only take the first three patches through the kbuild tree
and push the other ones through the architecture trees.

I don't really have a clear preference.


Thomas
Re: [PATCH v2 00/10] kbuild: userprogs: introduce architecture-specific CC_CAN_LINK and userprog flags
Posted by Nathan Chancellor 1 month ago
On Thu, Nov 13, 2025 at 10:31:10AM +0100, Thomas Weißschuh wrote:
> On Wed, Nov 12, 2025 at 09:03:23PM +0100, Nicolas Schier wrote:
> > Thanks for the patch set and all the work behind!  I found only one
> > issue in patch 3, the rest looks good to me as they are.
> > 
> > I haven't reviewed the compiler flags for the archs, but from the formal
> > point of view they look good to me, too.
> > 
> > How shall we proceed with here?  I think, easiest would be if we get
> > appropriate acks from the architecture maintainers, so we could take
> > this via kbuild.
> 
> That would surely be the best option. Unfortunately quite frequently it is hard
> to get architecture maintainer's feedback on a cross-architecture series.
> 
> > Other opinions?
> 
> It would also work to only take the first three patches through the kbuild tree
> and push the other ones through the architecture trees.
> 
> I don't really have a clear preference.

If you do not have a preference, I think it would be easier if Nicolas
picks up the first three patches (which I will go review formally
shortly, sorry again for the delay on that) to make sure they make
6.19-rc1 then you can send out the architecture changes individually
with plans to pick up any ones that have been left behind after a
development cycle? That should give architecture maintainers enough time
to properly react and review the series (since they will know if those
flags are appropriate). We could probably send the last patch as a fix
if those changes do not land until 6.20-rc1.

Cheers,
Nathan