Re: linux-parisc compile failure in current git

From: Masahiro Yamada
Date: Fri Aug 19 2022 - 13:25:12 EST


On Fri, Aug 19, 2022 at 10:56 PM Helge Deller <deller@xxxxxx> wrote:
>
> On 8/19/22 14:45, Masahiro Yamada wrote:
> > On Thu, Aug 18, 2022 at 5:59 AM Randy Dunlap <rdunlap@xxxxxxxxxxxxx> wrote:
> >>
> >> Hi--
> >>
> >> On 6/23/21 13:33, Helge Deller wrote:
> >>> * Masahiro Yamada <masahiroy@xxxxxxxxxx>:
> >>>> On Thu, Jun 10, 2021 at 4:04 PM Helge Deller <deller@xxxxxx> wrote:
> >>>>>
> >>>>> Hi Masahiro,
> >>>>>
> >>>>> On 6/10/21 4:03 AM, Masahiro Yamada wrote:
> >>>>>> On Thu, Jun 10, 2021 at 7:50 AM Helge Deller <deller@xxxxxx> wrote:
> >>
> >> [snip]
> >>
> >>>>>> But, please keep in mind that there is an issue remaining.
> >>>>>>
> >>>>>> Please see this code:
> >>>>>>
> >>>>>> ifdef CONFIG_64BIT
> >>>>>> UTS_MACHINE := parisc64
> >>>>>> CHECKFLAGS += -D__LP64__=1
> >>>>>> CC_ARCHES = hppa64
> >>>>>> LD_BFD := elf64-hppa-linux
> >>>>>> else # 32-bit
> >>>>>> CC_ARCHES = hppa hppa2.0 hppa1.1
> >>>>>> LD_BFD := elf32-hppa-linux
> >>>>>> endif
> >>>>>>
> >>>>>>
> >>>>>> UTS_MACHINE is determined by CONFIG_64BIT.
> >>>>>>
> >>>>>> CONFIG_64BIT is defined only after Kconfig is finished.
> >>>>>> When you are trying to configure the .config,
> >>>>>> CONFIG_64BIT is not defined yet.
> >>>>>> So UTS_MACHINE is always 'parisc'.
> >>>>>
> >>>>> Yes.
> >>>>> See above, but it worked when I had SUBARCH=x86 (when running my laptop).
> >>>>>
> >>>>>
> >>>>>> As you know, Kconfig files now have a bunch of 'cc-option' syntax
> >>>>>> to check the compiler capability in Kconfig time.
> >>>>>> Hence, you need to provide a proper compiler in Kconfig time too.
> >>>>>>
> >>>>>> When you build a 64-bit parisc kernel on a 32-bit parisc machine,
> >>>>>
> >>>>> Please note, that we don't have a 64-bit parisc userspace yet (just kernel).
> >>>>> This means, that all builds on parisc machines are 32bit and do a
> >>>>> cross-compilation to a parisc64 kernel if requested in the .config.
> >>>>>
> >>>>>> Kconfig is passed with CC=gcc since SUBARCH==UTS_MACHINE==parisc.
> >>>>>> After Kconfig, CROSS_COMPILE=hppa64-* is set,
> >>>>>> and the kernel is built by CC=hppa64-*-gcc.
> >>>>>
> >>>>> Right. That is the old behaviour. Based on the CONFIG_64BIT option
> >>>>> the hppa64 compiler is choosen for CROSS_COMPILE.
> >>>>>
> >>>>>> So, Kconfig evaluated a compiletely different compiler. This is pointless.
> >>>>>
> >>>>> Yes, probably.
> >>>>>
> >>>>>
> >>>>>> There are some options
> >>>>>>
> >>>>>> [option 1]
> >>>>>> revert the parisc bit of 23243c1ace9fb4eae2f75e0fe0ece8e3219fb4f3
> >>>>>> This will restore the functionality you may want, but
> >>>>>> as I said above, Kconfig is doing pointless things.
> >>>>>
> >>>>> as mentioned above: Doesn't solve the issue.
> >>>>>
> >>>>>> [option 2]
> >>>>>> Stop using cc-cross-prefix, and pass CROSS_COMPILE explicitly.
> >>>>>> This is what many architectures including arm, arm64 do.
> >>>>>> You need to explicitly pass CROSS_COMPILE=aarch64-linux-gnu- etc.
> >>>>>> if you are cross-compiling arm64.
> >>>>>
> >>>>> Might be an option, but it's not as handy as simply choosing CONFIG_64BIT
> >>>>> and then things are done automatically.
> >>>>>
> >>>>>> [option 3]
> >>>>>> Introduce ARCH=parisc64.
> >>>>>>
> >>>>>> When you are building 64-bit kernel, you can pass ARCH=parisc64
> >>>>>> A patch attached. (but not tested much)
> >>>>>
> >>>>> Tried it, but doesn't work.
> >>>>> asm-offsets.c is still preprocessed with 32bit compiler (gcc, not hppa20-gcc).
> >>>>>
> >>>>> Thanks for your help so far!
> >>>>> If you like I'm happy to give you an account on a hppa64 machine to reproduce yourself.
> >>>>> I'll now try to bisect where it goes wrong. There must be something else before commit 23243c1ace9fb4eae2f75e0fe0ece8e3219fb4f3.
> >>>>>
> >>>>> Helge
> >>>>
> >>>>
> >>>> Sorry for my late reply.
> >>>
> >>> Me too.... :-(
> >>
> >> Sorry to jump in even later, but:
> >>
> >> I see that
> >> $ make ARCH=parisc64 defconfig
> >> does set CONFIG_64BIT.
> >
> > Strange. It does for me.
> > masahiro@grover:~/ref/linux-next$ make ARCH=parisc64 defconfig
> > *** Default configuration is based on 'generic-64bit_defconfig'
> > #
> > # configuration written to .config
> > #
> > masahiro@grover:~/ref/linux-next$ grep CONFIG_64BIT .config
> > CONFIG_64BIT=y
>
> Yes, as Randy said, this works.
>
> >> Is there a way to do
> >> $ make ARCH=parisc64 allmodconfig
> >> ?
> >> That does not set CONFIG_64BIT in my testing.
> >> (testing on linux-next-20220817)
> >
> > Right.
> > allmodconfig does not set CONFIG_64BIT.
> >
> > I think it is the same as before.
>
> Yep.
>
> > Is this thread related?
>
> What thread?


This thread ("linux-parisc compile failure in current git")
was posted more than a year ago.

If you start a new discussion,
let's open a new thread with a proper mail subject.




>
> > The reason is 64BIT depends on PA8X00.
> >
> > allmodconfig chooses PA7000 instead of PA8X00
> > in the "Processor type" choice since
> > PA7000 is the default.
> >
> >
> > If you apply this patch,
> >
> >
> >
> > diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
> > index 7f059cd1196a..458b8e22e240 100644
> > --- a/arch/parisc/Kconfig
> > +++ b/arch/parisc/Kconfig
> > @@ -146,7 +146,7 @@ menu "Processor type and features"
> >
> > choice
> > prompt "Processor type"
> > - default PA7000
> > + default PA8X00
> >
> > config PA7000
> > bool "PA7000/PA7100"
> >
> > allmodconfig will start enabling CONFIG_64BIT,
> > but it is up to Helge.
>
> That patch "partly" works, in the sense that with:
> make ARCH=parisc64 randconfig
>
> you randomly end up with a 32- or 64-bit kernel.
> Since "ARCH=parisc64" was given, one probably would expect a 64-bit-enabled kernel randconfig,
> and with "ARCH=parisc" a 32-bit randconfig.
> But, I'm not sure if this intended or not and works that way on other arches as well.


Ah, OK.

Then, you can mimic sparc code.





In the top Makefile:


ifeq ($(ARCH),sparc32)
SRCARCH := sparc
endif
ifeq ($(ARCH),sparc64)
SRCARCH := sparc
endif




In arch/sparc/Kconfig:


config 64BIT
bool "64-bit kernel" if "$(ARCH)" = "sparc"
default "$(ARCH)" = "sparc64"





"make ARCH=sparc32 randconfig" always disables
CONFIG_64BIT, and randomizes the rest of options.


"make ARCH=sparc64 randconfig" always enables
CONFIG_64BIT, and randomizes the rest of options.


"make ARCH=sparc randconfig" randomizes all options,
including CONFIG_64BIT.





I suggest to introduce ARCH=parisc32





>
> As written in the other mail, I added this patch in for-next:
> https://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux.git/commit/?h=for-next&id=34793a5d09d9122f90acfa7e8f705436d5090d4d
> The downside is, you need to give a special make target: parisc_randconfig / parisc64_randconfig
>
> Helge



--
Best Regards
Masahiro Yamada