Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Architectures & Platforms Gentoo on ARM
  • Search

How to compile GCC 32bit app on 64bit ARM device?

Gentoo on all things ARM. Both 32 bit and 64 bit.
Tell about your hardware and CHOST.
Problems with crossdev targeting ARM hardware go here too.
Post Reply
  • Print view
Advanced search
11 posts • Page 1 of 1
Author
Message
Gistapo
n00b
n00b
User avatar
Posts: 4
Joined: Mon Nov 05, 2018 9:27 am

How to compile GCC 32bit app on 64bit ARM device?

  • Quote

Post by Gistapo » Mon Nov 05, 2018 9:37 am

Hello,

I have Raspberry Pi 3 Model B with https://github.com/sakaki-/gentoo-on-rpi3-64bit image installed on it.

By default there is gcc-8.2.0-r3 pre-installed already, but I have installed gcc-5.4.0-r4 and selected it as default beacause of my C++ app that I need to compile.

Code: Select all

 gcc-config --list-profiles
 [1] aarch64-unknown-linux-gnu-5.4.0 *
 [2] aarch64-unknown-linux-gnu-8.2.0
The questions is, how to download multilib to be able to compile 32bit app on my 64bit OS ARM device?

Thanks in advance to everyone for suggestions.
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56106
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Mon Nov 05, 2018 4:26 pm

Moved from Portage & Programming to Gentoo on ARM.

First of all, if your program is C++, it might just build on 64 bit. Try it.

Gentoo does not currently support multilib on arm64.
Arm64 multilib is a bit odd.
On arm64, the 32 bit instruction set is optional. Some CPUs support it, some don't. The Pi does.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
Gistapo
n00b
n00b
User avatar
Posts: 4
Joined: Mon Nov 05, 2018 9:27 am

  • Quote

Post by Gistapo » Mon Nov 05, 2018 5:14 pm

NeddySeagoon wrote:Moved from Portage & Programming to Gentoo on ARM.

First of all, if your program is C++, it might just build on 64 bit. Try it.

Gentoo does not currently support multilib on arm64.
Arm64 multilib is a bit odd.
On arm64, the 32 bit instruction set is optional. Some CPUs support it, some don't. The Pi does.
Thank you for your answer, now everything is clear.
I did compile 32bit app on 64bit Ubuntu on x86_64 PC device, so I thouth it is also possible to do the same on ARM devices using by downloading gcc-multilib and using gcc -m32 parameter to compile. I did spent a few days trying this, but here is a simple answer it is not available.

Topic can be closed now.
Top
Hu
Administrator
Administrator
Posts: 24403
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Tue Nov 06, 2018 3:10 am

What happens when you compile your program as 64-bit on arm64?
Top
Gistapo
n00b
n00b
User avatar
Posts: 4
Joined: Mon Nov 05, 2018 9:27 am

  • Quote

Post by Gistapo » Tue Nov 06, 2018 6:53 am

Hu wrote:What happens when you compile your program as 64-bit on arm64?
It is compiled without any problems as 64-bit on arm64, but I was looking for way to compile 32-bit app, but it is not supported as it is stated above.
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56106
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Tue Nov 06, 2018 9:23 am

Gistapo,

There is the 32 bit chroot approach. You need enough in the chroot to support the toolchain and libraries your code links against.

Provided you have kernel support, arm64 CPUs that support 32 bit mode too, switch modes transparently.
As its a Pi, you could have a 32 bit install on another SDCard,

-- Edit --

If you are feeling really adventuerous you have the 32 bit KVM option too. Sakakis image supports KVM.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
Sakaki
Guru
Guru
User avatar
Posts: 409
Joined: Wed May 21, 2014 8:15 pm

  • Quote

Post by Sakaki » Tue Nov 06, 2018 12:20 pm

NeddySeagoon wrote:Gistapo,

There is the 32 bit chroot approach. You need enough in the chroot to support the toolchain and libraries your code links against.

Provided you have kernel support, arm64 CPUs that support 32 bit mode too, switch modes transparently.
As its a Pi, you could have a 32 bit install on another SDCard,
There are instructions for doing this on the gentoo-on-rpi3-64bit project's open wiki, here (for 32-bit Raspbian as the chroot guest, but you could easily adapt to run 32-bit Gentoo as the guest instead).
NeddySeagoon wrote:If you are feeling really adventuerous you have the 32 bit KVM option too. Sakakis image supports KVM.
Instructions for this are on the same wiki here and here (this is for 64-bit Ubuntu 18.04 server as the kvm guest, but you can run 32-bit KVM guests with a 64-bit kernel system also).
Regards,

sakaki
Top
Gistapo
n00b
n00b
User avatar
Posts: 4
Joined: Mon Nov 05, 2018 9:27 am

  • Quote

Post by Gistapo » Tue Nov 06, 2018 2:55 pm

Sakaki,

Thanks for provided info, but it doesn't looks that simple as just installing gcc-multilib and run gcc -m32 on Ubuntu Linux x86_64 architecture machine, so I don't want to waist my time on it anymore.
Top
Crocodillian
n00b
n00b
Posts: 3
Joined: Tue Oct 16, 2018 9:23 am
Location: San Francisco, CA, United States
Contact:
Contact Crocodillian
Website

works fine these days

  • Quote

Post by Crocodillian » Fri Feb 22, 2019 5:03 pm

For anyone coming across this thread, gcc -m32 works just fine in current gentoo.

You just need to add the abi_x86_32 USE flag to any libraries you will link and make sure you are using a multilib profile.
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56106
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Fri Feb 22, 2019 5:27 pm

Crocodillian,

You need a hardware platform that supports the optional, on arm64, 32 bit instruction set too.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
antonlacon
Apprentice
Apprentice
Posts: 257
Joined: Sun Jun 27, 2004 1:36 am

Re: works fine these days

  • Quote

Post by antonlacon » Fri Feb 22, 2019 9:25 pm

Crocodillian wrote:For anyone coming across this thread, gcc -m32 works just fine in current gentoo.

You just need to add the abi_x86_32 USE flag to any libraries you will link and make sure you are using a multilib profile.
Your instructions are fine for x86-64, but this is arm. You need a 32-bit arm toolchain to build for arm. -m32 is not a valid flag for aarch64's gcc: http://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html
Top
Post Reply
  • Print view

11 posts • Page 1 of 1

Return to “Gentoo on ARM”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic