Skip to contentSkip to conversation

Building LTP in a 64-bit machine for 32-bit target

LTP Pedro Fonseca 3 participants 4 messages Feb 19, 2013 – Mar 8, 2013

lore
Share & tools
lore
#0 lore raw

Hi,

I've been trying to cross compile LTP on a 64-bit x86 machine to produce tests for a 32-bit x86 machines. Unfortunately, so far I haven't found a clean way of achieving this.

I've tried configuring with "./configure --host=i386" but this still produces x86-64 binaries.

I've also tried configuring with "CFLAGS=-m32 ./configure CFLAGS=-m32" but it gives compilation errors on some tests (e.g. testcases/kernel/syscalls/chown01_16). I can get past some of the errors by disabling the "/../utils/compat_16.mk" lines in the individual test Makefiles. But is there a better way to compile LTP for 32-bit on a 64-bit?

Thanks,
Pedro

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#1 lore raw
Quoted 16 lines · Pedro Fonseca

Hi,

I've been trying to cross compile LTP on a 64-bit x86 machine to produce tests for a 32-bit x86 machines. Unfortunately, so far I haven't found a clean way of achieving this.

I've tried configuring with "./configure --host=i386" but this still produces x86-64 binaries.

I've also tried configuring with "CFLAGS=-m32 ./configure CFLAGS=-m32" but it gives compilation errors on some tests (e.g. testcases/kernel/syscalls/chown01_16). I can get past some of the errors by disabling the "/../utils/compat_16.mk" lines in the individual test Makefiles. But is there a better way to compile LTP for 32-bit on a 64-bit?

Quoted 9 lines

Thanks,
Pedro

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb

Hello Pedra Fonseca,

./configure --build=i686-pc-linux-gnu --target=i686-pc-linux-gnu "CFLAGS=-m32" "CPPFLAGS=-m32" "LDFLAGS=-m32"

I use the above command to build ltp for 32-bit architecture on 64-bit machine. Once you do run this, you can check the CFLAGS, CPPFLAGS, LDFALGS being set in config.status file. --target flag is to set target environment if it is different from build environment.
http://stackoverflow.com/questions/5139403/whats-the-difference-of-configure-option-build-host-and-target

In fedora-64 bit, to build a 32-bit binary you need following packages sudo yum install glibc-devel.i686 libgcc.i686

May be in Ubuntu, you may need these packages or similar kind. If not installed gcc will throw some error. Let me know if you still find problem.

Regards,
ShashiKiran

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw
Quoted 39 lines · Shashi
Quoted 16 lines · Pedro Fonseca

Hi,

I've been trying to cross compile LTP on a 64-bit x86 machine to produce tests for a 32-bit x86 machines. Unfortunately, so far I haven't found a clean way of achieving this.

I've tried configuring with "./configure --host=i386" but this still produces x86-64 binaries.

I've also tried configuring with "CFLAGS=-m32 ./configure CFLAGS=-m32" but it gives compilation errors on some tests (e.g. testcases/kernel/syscalls/chown01_16). I can get past some of the errors by disabling the "/../utils/compat_16.mk" lines in the individual test Makefiles. But is there a better way to compile LTP for 32-bit on a 64-bit?

Quoted 9 lines

Thanks,
Pedro

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb

Hello Pedra Fonseca,

./configure --build=i686-pc-linux-gnu --target=i686-pc-linux-gnu "CFLAGS=-m32" "CPPFLAGS=-m32" "LDFLAGS=-m32"

I use the above command to build ltp for 32-bit architecture on 64-bit machine. Once you do run this, you can check the CFLAGS, CPPFLAGS, LDFALGS being set in config.status file. --target flag is to set target environment if it is different from build environment.
http://stackoverflow.com/questions/5139403/whats-the-difference-of-configure-option-build-host-and-target

Quoted 9 lines

In fedora-64 bit, to build a 32-bit binary you need following packages sudo yum install glibc-devel.i686 libgcc.i686

May be in Ubuntu, you may need these packages or similar kind. If not installed gcc will throw some error. Let me know if you still find problem.

Regards,
ShashiKiran

[ CC Pedro ]

AFAICS "-m32" is available on gcc, dunno if for example clang supports that, too.

Can't say if "-m32" as LDFLAGS makes any sense or to say IOW "-m32" for CC is sufficient.
Maybe you can explain that, Shashi?

To support "-m32" CFLAGS for gcc on Debian/Ubuntu you need to install 'gcc-multilib' (gcc with biarch-support) package.
This installs 'libc6-i386' and 'libc6-i386-dev' packages automatically.

     $ sudo apt-get update
     $ sudo apt-get install gcc-multilib

Another way could be to install multiarch-support if not available (binutils-mutiarch and multiarch-support packages).
But I should check Debian's/Ubuntu's wiki pages, again... how to build on amd64 for i386...

Hope this helps people reading this ML.

Regards,
- Sedat -

Quoted 13 lines

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#3 lore raw
Quoted 72 lines · Sedat Dilek
Quoted 39 lines · Shashi
Quoted 16 lines · Pedro Fonseca

Hi,

I've been trying to cross compile LTP on a 64-bit x86 machine to produce tests for a 32-bit x86 machines. Unfortunately, so far I haven't found a clean way of achieving this.

I've tried configuring with "./configure --host=i386" but this still produces x86-64 binaries.

I've also tried configuring with "CFLAGS=-m32 ./configure CFLAGS=-m32" but it gives compilation errors on some tests (e.g. testcases/kernel/syscalls/chown01_16). I can get past some of the errors by disabling the "/../utils/compat_16.mk" lines in the individual test Makefiles. But is there a better way to compile LTP for 32-bit on a 64-bit?

Quoted 9 lines

Thanks,
Pedro

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb

Hello Pedra Fonseca,

./configure --build=i686-pc-linux-gnu --target=i686-pc-linux-gnu "CFLAGS=-m32" "CPPFLAGS=-m32" "LDFLAGS=-m32"

I use the above command to build ltp for 32-bit architecture on 64-bit machine. Once you do run this, you can check the CFLAGS, CPPFLAGS, LDFALGS being set in config.status file. --target flag is to set target environment if it is different from build environment.
http://stackoverflow.com/questions/5139403/whats-the-difference-of-configure-option-build-host-and-target

Quoted 9 lines

In fedora-64 bit, to build a 32-bit binary you need following packages sudo yum install glibc-devel.i686 libgcc.i686

May be in Ubuntu, you may need these packages or similar kind. If not installed gcc will throw some error. Let me know if you still find problem.

Regards,
ShashiKiran

[ CC Pedro ]

AFAICS "-m32" is available on gcc, dunno if for example clang supports that, too.

Can't say if "-m32" as LDFLAGS makes any sense or to say IOW "-m32" for CC is sufficient.
Maybe you can explain that, Shashi?

To support "-m32" CFLAGS for gcc on Debian/Ubuntu you need to install 'gcc-multilib' (gcc with biarch-support) package.
This installs 'libc6-i386' and 'libc6-i386-dev' packages automatically.

     $ sudo apt-get update
     $ sudo apt-get install gcc-multilib

Another way could be to install multiarch-support if not available (binutils-mutiarch and multiarch-support packages).
But I should check Debian's/Ubuntu's wiki pages, again... how to build on amd64 for i386...

Quoted 18 lines

Hope this helps people reading this ML.

Regards,
- Sedat -

Quoted 13 lines

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Hi ,

If "LDFLAGS=-m32" is not set, then following errors is observed while building ltp-pan,

gcc -m32 -g -O2 -fno-strict-aliasing -pipe -Wall -m32 -Wno-error
-I/home/user/ltp/ltp-full-20120903/pan -I../include -I../include -c -o ltp-bump.o ltp-bump.c
gcc -m32 -g -O2 -fno-strict-aliasing -pipe -Wall -m32 -Wno-error
-I/home/user/ltp/ltp-full-20120903/pan -I../include -I../include -c -o zoolib.o zoolib.c
gcc -L../lib ltp-bump.o zoolib.o -lm -o ltp-bump

/usr/bin/ld: i386 architecture of input file `ltp-bump.o' is
incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `zoolib.o' is
incompatible with i386:x86-64 output
collect2: ld returned 1 exit status
make: *** [ltp-bump] Error 1

As per rules set by makefile, gcc trying to build 64bit binary using 32bit objects. So When LDFLAGS is set to "-m32", gcc will create create 32bit binary by linking to 32bit object files.

gcc -m32 -L../lib ltp-bump.o zoolib.o -lm -o ltp-bump
gcc -m32 -g -O2 -fno-strict-aliasing -pipe -Wall -m32 -Wno-error
-I/home/user/ltp/ltp-full-20120903/pan -I../include -I../include -c -o ltp-pan.o ltp-pan.c
gcc -m32 -g -O2 -fno-strict-aliasing -pipe -Wall -m32 -Wno-error
-I/home/user/ltp/ltp-full-20120903/pan -I../include -I../include -c -o splitstr.o splitstr.c
gcc -m32 -L../lib ltp-pan.o zoolib.o splitstr.o -lm -o ltp-pan

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list