All of lore.kernel.org
 help / color / mirror / Atom feed
* x86 - weird cross-compile build problem with try-run next-20210602
@ 2021-06-04 20:33 Valdis Klētnieks
  2021-06-05  8:19 ` Masahiro Yamada
  0 siblings, 1 reply; 3+ messages in thread
From: Valdis Klētnieks @ 2021-06-04 20:33 UTC (permalink / raw)
  To: Masahiro Yamada, Thomas Gleixner, Ingo Molnar; +Cc: linux-kernel, x86

I built a gcc 11.1 cross-compiler targeting x86_64, and builds
were throwing an error message:

Makefile:149: CONFIG_X86_X32 enabled but no binutils support

so I added some debugging to arch/x86/Makefile:

ifdef CONFIG_X86_X32
        x32_ld_ok := $(call try-run,\
                        /bin/echo -e '1: .quad 1b' | \ 
                        $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" - && \
                        $(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMP.o" && \
                        $(LD) -m elf32_x86_64 "$$TMP.o" -o "$$TMP",y,n)
 $(warning x32_ld_ok is +$(x32_ld_ok)+ with CC=$(CC) $(KBUILD_AFLAGS) OBJ=$(OBJCOPY) LD=$(LD) )
        ifeq ($(x32_ld_ok),y)
                CONFIG_X86_X32_ABI := y

and that throws:

arch/x86/Makefile:143: x32_ld_ok is ++ with CC=x86_64-unknown-linux-gnu-gcc -D__ASSEMBLY__ -fno-PIE -m64 OBJ=x86_64-unknown-linux-gnu-objcopy LD=x86_64-unknown-linux-gnu-ld 

Anybody have a clue why $(x32_ld_ok)  is null rather than 'y' or 'n'?

(It's totally possible that my cross-compiler is broken, but I still don't see how
try-run would return null rather than 'n' in that case...  I built a shell script that did the
test and that ended with $? == 0, but had a warning msg:

+ /bin/echo -e '1: .quad 1b'
+ x86_64-unknown-linux-gnu-gcc -D__ASSEMBLY__ -fno-PIE -m64 -c -x assembler -o /tmp/z97 -
+ x86_64-unknown-linux-gnu-objcopy -O elf32-x86-64 /tmp/z97 /tmp/z99.o
+ x86_64-unknown-linux-gnu-ld -m elf32_x86_64 /tmp/z99.o -o /tmp/z98
x86_64-unknown-linux-gnu-ld: warning: cannot find entry symbol _start; defaulting to 0000000000401000
echo $?
+ echo 0
0




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

* Re: x86 - weird cross-compile build problem with try-run next-20210602
  2021-06-04 20:33 x86 - weird cross-compile build problem with try-run next-20210602 Valdis Klētnieks
@ 2021-06-05  8:19 ` Masahiro Yamada
  2021-06-05 10:50   ` Valdis Klētnieks
  0 siblings, 1 reply; 3+ messages in thread
From: Masahiro Yamada @ 2021-06-05  8:19 UTC (permalink / raw)
  To: Valdis Klētnieks
  Cc: Thomas Gleixner, Ingo Molnar, Linux Kernel Mailing List, X86 ML

On Sat, Jun 5, 2021 at 5:33 AM Valdis Klētnieks <valdis.kletnieks@vt.edu> wrote:
>
> I built a gcc 11.1 cross-compiler targeting x86_64, and builds
> were throwing an error message:
>
> Makefile:149: CONFIG_X86_X32 enabled but no binutils support
>
> so I added some debugging to arch/x86/Makefile:
>
> ifdef CONFIG_X86_X32
>         x32_ld_ok := $(call try-run,\
>                         /bin/echo -e '1: .quad 1b' | \
>                         $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" - && \
>                         $(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMP.o" && \
>                         $(LD) -m elf32_x86_64 "$$TMP.o" -o "$$TMP",y,n)
>  $(warning x32_ld_ok is +$(x32_ld_ok)+ with CC=$(CC) $(KBUILD_AFLAGS) OBJ=$(OBJCOPY) LD=$(LD) )
>         ifeq ($(x32_ld_ok),y)
>                 CONFIG_X86_X32_ABI := y
>
> and that throws:
>
> arch/x86/Makefile:143: x32_ld_ok is ++ with CC=x86_64-unknown-linux-gnu-gcc -D__ASSEMBLY__ -fno-PIE -m64 OBJ=x86_64-unknown-linux-gnu-objcopy LD=x86_64-unknown-linux-gnu-ld
>
> Anybody have a clue why $(x32_ld_ok)  is null rather than 'y' or 'n'?


What command did you run?

I see this warning message for 'make install' for example.

$ make install
arch/x86/Makefile:148: CONFIG_X86_X32 enabled but no binutils support



Please add one more debug line:
  $(warning need-compiler is +$(need-compiler)+)
and what will you get?



One quick fix is to change

    ifeq ($(x32_ld_ok),y)

to

   ifneq ($(x32_ld_ok),n)

But, I think moving this check to Kconfig
is a more proper fix.







> (It's totally possible that my cross-compiler is broken, but I still don't see how
> try-run would return null rather than 'n' in that case...  I built a shell script that did the
> test and that ended with $? == 0, but had a warning msg:
>
> + /bin/echo -e '1: .quad 1b'
> + x86_64-unknown-linux-gnu-gcc -D__ASSEMBLY__ -fno-PIE -m64 -c -x assembler -o /tmp/z97 -
> + x86_64-unknown-linux-gnu-objcopy -O elf32-x86-64 /tmp/z97 /tmp/z99.o
> + x86_64-unknown-linux-gnu-ld -m elf32_x86_64 /tmp/z99.o -o /tmp/z98
> x86_64-unknown-linux-gnu-ld: warning: cannot find entry symbol _start; defaulting to 0000000000401000
> echo $?
> + echo 0
> 0
>
>
>


-- 
Best Regards
Masahiro Yamada

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

* Re: x86 - weird cross-compile build problem with try-run next-20210602
  2021-06-05  8:19 ` Masahiro Yamada
@ 2021-06-05 10:50   ` Valdis Klētnieks
  0 siblings, 0 replies; 3+ messages in thread
From: Valdis Klētnieks @ 2021-06-05 10:50 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Thomas Gleixner, Ingo Molnar, Linux Kernel Mailing List, X86 ML

On Sat, 05 Jun 2021 17:19:30 +0900, Masahiro Yamada said:

> > Anybody have a clue why $(x32_ld_ok)  is null rather than 'y' or 'n'?
>
>
> What command did you run?
>
> I see this warning message for 'make install' for example.
>
> $ make install
> arch/x86/Makefile:148: CONFIG_X86_X32 enabled but no binutils support

> Please add one more debug line:
>   $(warning need-compiler is +$(need-compiler)+)
> and what will you get?
>
Bingo.

arch/x86/Makefile:143: need-compiler is ++ x32_ld_ok is ++ with CC=(.... same as before)

And it was hitting on a 'make kernelrelease'

805b2e1d427aa (Masahiro Yamada          2021-02-28 15:10:28 +0900  275) # is an exception where build artifacts may be updated. This must be fixed.
805b2e1d427aa (Masahiro Yamada          2021-02-28 15:10:28 +0900  276) no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
805b2e1d427aa (Masahiro Yamada          2021-02-28 15:10:28 +0900  277)                         headers_install modules_install kernelrelease image_name
993bdde945478 (Masahiro Yamada          2021-02-28 15:10:25 +0900  278) no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \

I suspect it's this:

 # Include this also for config targets because some architectures need
 # cc-cross-prefix to determine CROSS_COMPILE.
+ifdef need-compiler
 include $(srctree)/scripts/Makefile.compiler
+endif

and as a result, try-run isn't defined when we get into the ifdef CONFIG_X86_32
chunk in arch/x86/Makefile, which silently fails and returns a null.   I added
more debugging to double-check...

ifdef CONFIG_X86_X32
        x32_ld_ok := $(call try-run,\
                        /bin/echo -e '1: .quad 1b' | \ 
                        $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" - && \
                        $(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMP.o" && \
                        $(LD) -m elf32_x86_64 "$$TMP.o" -o "$$TMP",y,n)
 $(warning need-compiler is +$(need-compiler)+ x32_ld_ok is +$(x32_ld_ok)+ with CC=$(CC) $(KBUILD_AFLAGS) OBJ=$(OBJCOPY) LD=$(LD) )
 foo := $(call wombats-r-us )
 $(warning foo is +$(foo)+ )
        ifeq ($(x32_ld_ok),y)

and that gets:

/usr/src/linux-next/arch/x86/Makefile:143: need-compiler is ++ x32_ld_ok is ++ with CC=x86_64-unknown-linux-gnu-gcc -D__ASSEMBLY__ -fno-PIE -m64 OBJ=x86_64-unknown-linux-gnu-objcopy LD=x86_64-unknown-linux-gnu-ld 
/usr/src/linux-next/arch/x86/Makefile:145: foo is ++ 
/usr/src/linux-next/arch/x86/Makefile:151: CONFIG_X86_X32 enabled but no binutils support

So the call to the undefined 'wombats-r-us' fails silently and returns a null..
and try-run is also failing silently the same way because it's not defined either.

There's only a few uses of try-run outside Makefile.compiler, and it looks like
x32_ld_ok is the only place where Makefile logic changes based on what try-run
returns (the rest just change compiler flags).

Havings said that, I'm not sure what the proper fix is. Move try-run out of Makefile.compiler?

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

end of thread, other threads:[~2021-06-05 10:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-04 20:33 x86 - weird cross-compile build problem with try-run next-20210602 Valdis Klētnieks
2021-06-05  8:19 ` Masahiro Yamada
2021-06-05 10:50   ` Valdis Klētnieks

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.