diff mbox

luajit package fails to build on x86_64 for x86

Message ID CAHkwnC8GuQJaRaqw_0A1KNNaFyz4scJBzsALRGx0ounsg7Y5mQ@mail.gmail.com
State Superseded
Headers show

Commit Message

Fabio Porcedda March 7, 2014, 8:37 p.m. UTC
On Fri, Mar 7, 2014 at 8:40 PM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Dear Yann E. MORIN,
>
> On Fri, 7 Mar 2014 18:49:03 +0100, Yann E. MORIN wrote:
>
>> Doing the check in dependencies is not much better than doing it as a
>> pre-configure hook: it can be delayed quite late in the build process.
>>
>> > Right now i don't know how to check about the presence of the 32bit
>> > support on the 64 bit host toolchain.
>>
>> What about something like this:
>>
>>     ifeq ($(BR2_PACKAGE_LUAJIT),y)
>>     ifeq ($(TARGET_32BIT)$(HOST_64BIT),yy)
>>     ifneq ($(shell echo 'int main() { return 0; }' |gcc -m32 -o foo -x c - >/dev/null 2>&1 && echo y; rm -f foo),y)
>>     $(error Can't build luajit for 32-bit target on this machine (mising 32-bit development packages))
>>     endif
>>     endif
>>     endif
>>
>> Not really trivial, but should work with some tweaking...
>
> Why do you invent something crazy here? We already have
> BR2_HOSTARCH_NEEDS_IA32_COMPILER which tests exactly what your new test

That's great so we need to add just:

          by Lua 5.1. The virtual machine (VM) is API- and

> intends to do. However, I'm not sure this test is actually completely
> correct: -m32 is a x86 compiler option. And my understanding is that
> Luajit needs to be built with a host that has the same bitness, so for
> example building a x86-64 target on a x86 system would not work, and
> your test would not catch such a situation.

For such a case there is already a check:

config BR2_PACKAGE_LUAJIT
depends on BR2_i386 || (BR2_x86_64 && BR2_HOSTARCH='x86_64') ||
BR2_powerpc || BR2_arm || BR2_armeb

Regards

Comments

Thomas Petazzoni March 7, 2014, 8:46 p.m. UTC | #1
Dear Fabio Porcedda,

On Fri, 7 Mar 2014 21:37:14 +0100, Fabio Porcedda wrote:

> diff --git a/package/luajit/Config.in b/package/luajit/Config.in
> index 9c4ecc3..d0c1512 100644
> --- a/package/luajit/Config.in
> +++ b/package/luajit/Config.in
> @@ -4,6 +4,7 @@ config BR2_PACKAGE_LUAJIT
>         # Luajit is only available for some target architectures, and
>         # has some complexity wrt 32/64. See luajit.mk for details.
>         depends on BR2_i386 || (BR2_x86_64 && BR2_HOSTARCH='x86_64')
> || BR2_powerpc || BR2_arm || BR2_armeb
> +       select BR2_HOSTARCH_NEEDS_IA32_COMPILER if !BR2_x86_64

This will prevent building Luajit for ARM, while running Buildroot on
an ARM platform. It's fairly unlikely, but still. "gcc -m32" will only
work on x86, or x86-64 with the 32 bits development files installed.
While in fact Luajit can build in situation where the bitness of the
target and the bitness of the arch match.

For example, Peter has one PowerPC build server: a "gcc -m32" test
would fail on it, even though it would be perfectly capable of building
the ARM 32 bits, PowerPC or x86 Luajit.

Thomas
Fabio Porcedda March 7, 2014, 8:51 p.m. UTC | #2
On Fri, Mar 7, 2014 at 9:46 PM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Dear Fabio Porcedda,
>
> On Fri, 7 Mar 2014 21:37:14 +0100, Fabio Porcedda wrote:
>
>> diff --git a/package/luajit/Config.in b/package/luajit/Config.in
>> index 9c4ecc3..d0c1512 100644
>> --- a/package/luajit/Config.in
>> +++ b/package/luajit/Config.in
>> @@ -4,6 +4,7 @@ config BR2_PACKAGE_LUAJIT
>>         # Luajit is only available for some target architectures, and
>>         # has some complexity wrt 32/64. See luajit.mk for details.
>>         depends on BR2_i386 || (BR2_x86_64 && BR2_HOSTARCH='x86_64')
>> || BR2_powerpc || BR2_arm || BR2_armeb
>> +       select BR2_HOSTARCH_NEEDS_IA32_COMPILER if !BR2_x86_64
>
> This will prevent building Luajit for ARM, while running Buildroot on
> an ARM platform. It's fairly unlikely, but still. "gcc -m32" will only
> work on x86, or x86-64 with the 32 bits development files installed.
> While in fact Luajit can build in situation where the bitness of the
> target and the bitness of the arch match.
>
> For example, Peter has one PowerPC build server: a "gcc -m32" test
> would fail on it, even though it would be perfectly capable of building
> the ARM 32 bits, PowerPC or x86 Luajit.

Reading the gcc documentation the option -m32 work even on PowerPC:
http://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/RS_002f6000-and-PowerPC-Options.html

 RS/6000 and PowerPC Options -mcpu=cpu-type -mtune=cpu-type
-mcmodel=code-model -mpowerpc64 -maltivec  -mno-altivec
           -mpowerpc-gpopt  -mno-powerpc-gpopt -mpowerpc-gfxopt
-mno-powerpc-gfxopt -mmfcrf  -mno-mfcrf  -mpopcntb  -mno-popcntb
           -mpopcntd -mno-popcntd -mfprnd  -mno-fprnd -mcmpb -mno-cmpb
-mmfpgpr -mno-mfpgpr -mhard-dfp -mno-hard-dfp -mfull-toc
           -mminimal-toc  -mno-fp-in-toc  -mno-sum-in-toc -m64  -m32

So maybe we need to change the name of the option
BR2_HOSTARCH_NEEDS_IA32_COMPILER

Regards
Thomas Petazzoni March 7, 2014, 8:58 p.m. UTC | #3
Dear Fabio Porcedda,

On Fri, 7 Mar 2014 21:51:57 +0100, Fabio Porcedda wrote:

> Reading the gcc documentation the option -m32 work even on PowerPC:
> http://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/RS_002f6000-and-PowerPC-Options.html

Ok, but not on ARM or MIPS, and probably not on many other 32 bits
architectures supported by Buildroot. Bottom line: testing 'gcc -m32'
is not a good way of testing whether the architecture is 32 bits or is
a 64 bits architecture capable of building and running 32 bits binaries.

Best regards,

Thomas
Fabio Porcedda March 7, 2014, 9:11 p.m. UTC | #4
On Fri, Mar 7, 2014 at 9:58 PM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Dear Fabio Porcedda,
>
> On Fri, 7 Mar 2014 21:51:57 +0100, Fabio Porcedda wrote:
>
>> Reading the gcc documentation the option -m32 work even on PowerPC:
>> http://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/RS_002f6000-and-PowerPC-Options.html
>
> Ok, but not on ARM or MIPS, and probably not on many other 32 bits
> architectures supported by Buildroot. Bottom line: testing 'gcc -m32'
> is not a good way of testing whether the architecture is 32 bits or is
> a 64 bits architecture capable of building and running 32 bits binaries.

We need to test if 32bit binaries are built only for 64bit host architectures.
Which are the 64bit host architectures that Buildroot supports?
Thomas Petazzoni March 7, 2014, 9:30 p.m. UTC | #5
Dear Fabio Porcedda,

On Fri, 7 Mar 2014 22:11:33 +0100, Fabio Porcedda wrote:

> > Ok, but not on ARM or MIPS, and probably not on many other 32 bits
> > architectures supported by Buildroot. Bottom line: testing 'gcc -m32'
> > is not a good way of testing whether the architecture is 32 bits or is
> > a 64 bits architecture capable of building and running 32 bits binaries.
> 
> We need to test if 32bit binaries are built only for 64bit host architectures.
> Which are the 64bit host architectures that Buildroot supports?

Potentially any 64 bits architecture, we don't have particular
dependencies on the host architecture.

Thomas
Fabio Porcedda March 7, 2014, 9:58 p.m. UTC | #6
On Fri, Mar 7, 2014 at 10:30 PM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Dear Fabio Porcedda,
>
> On Fri, 7 Mar 2014 22:11:33 +0100, Fabio Porcedda wrote:
>
>> > Ok, but not on ARM or MIPS, and probably not on many other 32 bits
>> > architectures supported by Buildroot. Bottom line: testing 'gcc -m32'
>> > is not a good way of testing whether the architecture is 32 bits or is
>> > a 64 bits architecture capable of building and running 32 bits binaries.
>>
>> We need to test if 32bit binaries are built only for 64bit host architectures.
>> Which are the 64bit host architectures that Buildroot supports?
>
> Potentially any 64 bits architecture, we don't have particular
> dependencies on the host architecture.

Ok i undertand the general problem but right now the luajit package
support building 32 binaries on a 64 host architecture only if the
host compiler support the -m32 option so right now it's fine to test
only if the -m32 option is used.

So i think adding the line
select BR2_HOSTARCH_NEEDS_IA32_COMPILER if BR2_ARCH_IS_64
it's the right solution for checking the configurations supported by
the luajit package.
diff mbox

Patch

diff --git a/package/luajit/Config.in b/package/luajit/Config.in
index 9c4ecc3..d0c1512 100644
--- a/package/luajit/Config.in
+++ b/package/luajit/Config.in
@@ -4,6 +4,7 @@  config BR2_PACKAGE_LUAJIT
        # Luajit is only available for some target architectures, and
        # has some complexity wrt 32/64. See luajit.mk for details.
        depends on BR2_i386 || (BR2_x86_64 && BR2_HOSTARCH='x86_64')
|| BR2_powerpc || BR2_arm || BR2_armeb
+       select BR2_HOSTARCH_NEEDS_IA32_COMPILER if !BR2_x86_64
        help
          LuaJIT implements the full set of language features defined