Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I wonder if WSL will support the i386 (32 bit) program running later? #2468

Closed
erikaemma opened this issue Sep 2, 2017 · 79 comments
Closed

Comments

@erikaemma
Copy link

erikaemma commented Sep 2, 2017

I just want to run arm-linux-gcc 4.4.3 :}

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get dist-upgrade

sudo apt-get install g++-multilib
sudo apt-get install libncurses5:i386
sudo apt-get install libc6:i386 libgcc1:i386 gcc-4.8-base:i386 libstdc++5:i386 libstdc++6:i386
sudo apt-get install lib32z1 lib32ncurses5 lib32ncursesw5 lib32ncursesw5-dev 
@therealkenc
Copy link
Collaborator

therealkenc commented Sep 3, 2017

The User Voice was opened back up. If the embedded people were as organised as university students taking Machine Learning courses it would have a better chance.

@poizan42
Copy link

poizan42 commented Sep 4, 2017

@plgkm6 That is quite an old gcc, do you need it for binary compatibility? Can't you just use 4.4.7? It is my understanding that gcc never breaks binary compatibility in minor releases. I believe you can just install the amd64 versions of the cross compiler from an older ubuntu version - you can find the softfloat version here and hardfloat version here. Select the amd64 built, you'll need the gcc-..._base_..., cpp-... and gcc-... packages at least.

For c++ support you will also need the g++-... and libstdc++6-4.4-dev-... packages.

If you really need gcc 4.4.3 then you could build a version for a 64-bit host yourself, there are plenty of guides on how to build gcc cross compilers.

@therealkenc
Copy link
Collaborator

therealkenc commented Sep 4, 2017

I was going to mention using the amd64 cross; but didn't because it isn't the root of (some of) the embedded guys' difficulty. The problem is many of their platform's supported build toolchains are stuck on 32-bit. Most notably Android, but also other embedded scenarios. Ref #1687, #1771, et al

@MikeGitb
Copy link

MikeGitb commented Sep 6, 2017

Disclaimer: I'm a x64 zealot and I'm programming embedded systems down to 8bit microcontroller, but have almost no experience with Android development.

My hope would be that without 32 support, the tool vendors get more pressure to update their toolchains and I'd much rather see some progress on their side than resources being wasted on backwards compatibility on the WSL side.

@therealkenc
Copy link
Collaborator

therealkenc commented Sep 6, 2017

I'm a x64 zealot

Yeah, me too a little. That said, you'd think Microsoft would be more sympathetic. My Visual Studio 2017 (August preview) is 32-bit, almost 15 years after Opteron was released. If the implication here is that Microsoft should encourage tool vendors like say Google to update, an obvious retort would be: "Whatever dude. You first."

Funny story if you are a 64-bit zealot.... The new ARM-powered Windows 10 laptops that are supposedly coming this Christmas have a 32-bit x86 emulator only. The laptops won't run amd64 apps. On a 64-bit Snapdragon. [I understand the reason; I just think it is funny.]

No word yet on whether they'll support WSL. 😉

@fpqc
Copy link

fpqc commented Sep 6, 2017

@therealkenc I sorta wonder if they could actually leverage what they already have with WSL to ARM64. If I remember correctly, ADSS was originally designed to emulate Android on Windows phone (running on an ARM). Ubuntu has an ARM port, and that kind of userspace would be a natural thing to use in a WSL for ARM64. I guess I'm saying that it's interesting since part of the work seems like it's already done!

@therealkenc
Copy link
Collaborator

therealkenc commented Sep 6, 2017

@fpqc - [Squarely in discussion tag territory] Yeah I yanked Ben's chain on that in #1769 (message). It would be fun to see for the amusement value, but my (sometimes flawed) powers of deductive reasoning say "nah". Ubuntu userland isn't the problem. The kernel is technically feasible. The problem is the target platform is the cheapest of cheap laptops. Not exactly a 'development use case scenario'. There's only 7-8 people on the team, and they need another target platform to support like they need a bullet in the head. Maybe I am jaded by the fact that I have seen this show before, and the ending is always the same. No not Windows 10 RT. I am old enough to have seen Windows NT 3.1 on MIPS. "This too will pass". Or, maybe I'm wrong. Maybe someone upstairs will tell the team different. Carry the OneCore torch and all that. Or maybe they'll do it for the amusement value. Or... maybe developers will run out in droves to buy Snapdraggon powered laptops this Christmas.

@poizan42
Copy link

poizan42 commented Sep 6, 2017

32-bit support could be fixed for probably 99% of programs by making a custom glibc, which anyone who feels up for it could do:

You can in fact run 32-bit code in WSL land. If you do a far jump to segment 0x23 then you are executing code in compatibility mode (i.e. 32-bit mode) - do a far jump to 0x33 to get back in 64-bit land. The problem is that WSL only supports 64-bit syscalls, so 32-bit code attempting to make syscalls won't work (and you can't trap them either, see #1655). I have a small demonstration that this is possible here: https://gist.github.com/poizan42/8ff01d3df80b1663afef775ca812b699

So if someone feel up for it then it should be possible to port glibc to "lol64" (Linux on Linux 64) that jumps to 64-bit mode to perform all the syscalls, and it should work for everything except fully static binaries and the rare stuff that makes syscalls without going through glibc (some emulation software possibly)

@therealkenc
Copy link
Collaborator

therealkenc commented Sep 7, 2017

rare stuff that makes syscalls without going through glibc (some emulation software possibly)

Rare stuff, like gdb. Very cool hack though. #1655 was a good bug report by the way. I hope it gets addressed on the merits, nevermind the use case. Maybe ping a name-drop over there at some point. Good issue posts get lost/forgotten sometimes in all the noise.

@MikeGitb
Copy link

MikeGitb commented Sep 7, 2017

[I understand the reason;

Actually I don't - That is, I can speculate, but if you have any actual information on this I would be thankful if you could share

@therealkenc
Copy link
Collaborator

therealkenc commented Sep 7, 2017

Well since you qualified the question, nope. I do not work at Microsoft, and even if I did, I couldn't share actual information like that. But I understand the reason.

@MikeGitb
Copy link

MikeGitb commented Sep 8, 2017

@therealkenc: Just to be clear, with "actual" information I didn't mean "official" information, but more like "knowledge / reasonable assumptions I gathered from other posts or experience".

As I said, I myself can only speculate that it has to do with performance or reuse of code, but that is not even an educated guess, because I have no knowledge about where the pain points are when trying to run x86 or x64 code on an arm system or how Microsoft does it.

@therealkenc
Copy link
Collaborator

therealkenc commented Sep 8, 2017

There is never a single reason a company makes a decision. But my guess, for the price you've paid for it, is that it has at least partially to do with not running amok of instruction set patents with their emulator. 32-bit x86 is a smaller surface for Intel’s lawyers to attack, because most if not all of the juicy 32-bit x86 patents have expired. This makes the MSFT lawyer's jobs easier, and since these are low end battery optimised 4GB notebooks anyway, there is not a strong reason to make their lawyer’s jobs harder. It doesn't matter whether Intel has a legal leg to stand on, or not, of course. It would cost more for the in-house legal analysis, let alone risk a fight, than the entire engineering effort of the port.

My basis for this hypothesis is that Microsoft, Qualcomm, Lenovo, and the rest don't want to have to advertise the 32-bit limitation any more than you want to hear it. Whatever the technical challenges of doing an amd64 emulator, which I suspect are marginal in the scheme, they are not high enough to justify having to explain to customers and all the Arstechnicas and Engadgets of the world that the machines don't run x64/amd64 binaries. Thus, I think the reasons are at least in part non-technical.

I could be wrong, IANAL, and all that.....

@Froosh
Copy link

Froosh commented Mar 21, 2018

Based on some tinkering I was doing with qemu for some ARM dev, I think I may have found a technique to allow general 32-bit support in WSL. Hat-tip to @therealkenc for the concept 😁

Edit: requires "Fall Creators Update", 1709, build 16299 or newer (I think)

Presuming a fresh Ubuntu WSL instance, you'll need to install the qemu-user-static package, add the i386 binfmt, enable the i386 architecture, update your package lists, and install some i386 packages:

Install qemu and binfmt

sudo apt update
sudo apt install qemu-user-static
sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'

[Edit: whoops, need to update package lists, added sudo apt update]

This will activate i386 support by causing them to be executed through qemu-i386-static, and drop a config file into /var/lib/binfmts/ for future reactivation.

You will need to reactivate this every time you restart WSL and want i386 support:

sudo service binfmt-support start

Enable i386 architecture and packages

sudo dpkg --add-architecture i386
sudo apt update
sudo apt install gcc:i386

Try it out

$ file /usr/bin/gcc-5
/usr/bin/gcc-5: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=2637bb7cb85f8f12b40f03cd015d404930c3c790, stripped

$ /usr/bin/gcc-5 --version
gcc-5 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc helloworld.c -o helloworld

$ ./helloworld
Hello, world!

$ file helloworld
helloworld: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=3a0c7be5c6a8d45613e4ef2b7b3474df6224a5da, not stripped

Proof

And to prove it really was working, disable i386 support and try again:

$ sudo service binfmt-support stop
 * Disabling additional executable binary formats binfmt-support [ OK ]

$ ./helloworld
-bash: ./helloworld: cannot execute binary file: Exec format error

@therealkenc
Copy link
Collaborator

therealkenc commented Mar 21, 2018

What does the binfmt_misc flags look like? I noticed your service binfmt-support start worked unimpeded in this instance. Still trying to figure out what is going on there. [edit] nvm I missed that you added it manually per #2620 in the quick skim. Not sure what the implications for multilib are going to be, but this is definitely cool. Still a little surprised no one did this sooner. I had left #2620 in a "whatever people, need-repro" since October. It was only after you posted that I even looked.

@therealkenc
Copy link
Collaborator

therealkenc commented Mar 21, 2018

I had to chase some generic apt borkage. After the dpkg --add-architecture and apt update, the apt install gcc:i386 gave me:

The following packages have unmet dependencies:
 gcc:i386 : Depends: cpp:i386 (>= 4:5.3.1-1ubuntu1) but it is not going to be installed
            Depends: gcc-5:i386 (>= 5.3.1-3~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Installing cpp-5:i386 and binutils:i386 harder eventually got me there. Pretty "normal" disarray for apt though. Could be just me.

Performance seems great so far in cursory tests. Which, of course it is; why wouldn't it be. The i386 code is being JIT compiled into x86-64. [One could even imagine hypothetical scenarios where it was faster on long long heavy code with lots of register pressure, though that's probably mostly wishful thinking.]

Nicely played Froosh. Adding the coveted workaround-available tag.

@fcying
Copy link

fcying commented Mar 23, 2018

@Froosh sudo apt install gcc:i386 have some problem:

 gcc:i386 : Depends: cpp:i386 (>= 4:5.3.1-1ubuntu1) but it is not going to be installed
            Depends: gcc-5:i386 (>= 5.3.1-3~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I use sudo apt install -y libc6:i386 libncurses5:i386 libstdc++6:i386 zlib1g:i386 zlib1g-dev:i386 instead of it.
Now it can run 32bit program , thanks very mush~~~~

@therealkenc
Copy link
Collaborator

therealkenc commented Mar 23, 2018

E: Unable to correct problems, you have held broken packages.

If anyone feels competent enough at dpkg and apt to make a definitive statement (that's not me) about how to add an i386 target to a pure amd64 Debian derived system after the fact it would be worth having on the books. Seems to me dpkg --add-architecture i386 ought to be enough, but that doesn't seem to be the case in practice. I only had to add cpp-5:i386 and binutils:i386, which managed to drag in the rest of the dependencies automatically (the most notable of which is of course libc6:i386). The "held broken packages" error is incorrect and/or spurious; there aren't any held packages, broken or otherwise. Maybe someone motivated could ask what's going on there in the Ubuntu forums. I suspect there is some baseline that is expected to exist for a MultiArch install, but really I just don't know.

@vsxd
Copy link

vsxd commented Apr 19, 2018

Thank you very much, Froosh. I had run a 32bit binary file in Ubuntu WSL. But, if I want to use gdb to debug the binary file, some error info displayed:

dong@Yoga-900:/mnt/d/bomblab$ gdb ./bomb
qemu: Unsupported syscall: 355
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
...

And, if I want to continue:

...
(gdb) start
Temporary breakpoint 1 at 0x804894b: file bomb.c, line 37.
Starting program: /mnt/d/bomblab/bomb
qemu: Unsupported syscall: 26
Welcome to my fiendish little bomb. You have 6 phases with
which to blow yourself up. Have a nice day!

I am a new Linux user, and this is my first time using gdb, I hope I didn't ask a wrong question

@lygstate
Copy link

lygstate commented May 22, 2018

Thanks a lot, works for me.

@therealkenc
Copy link
Collaborator

therealkenc commented May 22, 2018

qemu: Unsupported syscall: 355

this

qemu: Unsupported syscall: 26

and this

@jerrodrs
Copy link

jerrodrs commented Aug 19, 2019

Using WSL2 and Ubuntu 18.04 I still get "cannot execute binary file: Exec format error".

Are 32 bit binaries supported in WSL2?

@PeterFeicht
Copy link

PeterFeicht commented Aug 19, 2019

@jerrodrs did you enable the architecture like @drolevar said?

sudo dpkg --add-architecture i386
sudo apt-get update

@jerrodrs
Copy link

jerrodrs commented Aug 19, 2019

@jerrodrs did you enable the architecture like @drolevar said?

sudo dpkg --add-architecture i386
sudo apt-get update

My mistake, hadn't realized the version failed to set to 2 on my old distro. Now diagnosing that issue. #4103

@PaleNeutron
Copy link

PaleNeutron commented Apr 19, 2020

WSL2, debian 10 distro, still can not run 32 bit.
QQ截图20200419103227

PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

@onomatopellan
Copy link

onomatopellan commented Apr 19, 2020

@PaleNeutron What does uname -a show?

@PaleNeutron
Copy link

PaleNeutron commented Apr 19, 2020

@PaleNeutron What does uname -a show?

@onomatopellan

john@pn-i7z97:~$ uname -a
Linux pn-i7z97 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 GNU/Linux

@onomatopellan
Copy link

onomatopellan commented Apr 19, 2020

@PaleNeutron That's not a WSL2 distro. You are on build 18362 and for WSL2 you need at least build 19041.

@PaleNeutron
Copy link

PaleNeutron commented Apr 19, 2020

@onomatopellan, my mistake, my windows version is 18363. Unbelievable, the stable brunch version still not update to 18917 .

@onomatopellan
Copy link

onomatopellan commented Apr 19, 2020

@PaleNeutron build 19041 is already in Release Preview Ring. That means in 2 weeks should be released as Windows 10 2004 in the stable channel.

@jiucenglou
Copy link

jiucenglou commented Oct 7, 2020

Installing cpp-5:i386 and binutils:i386 harder eventually got me there. Pretty "normal" disarray for apt though. Could be just me.

Could you suggest your detailed install procedure ? On WSL1 Ubuntu 18.04, I cannot install either cpp-5:i386 or binutils:i386, with the following complaint...

E: Sub-process /usr/bin/dpkg returned an error code (1)

@ZHANGHSING
Copy link

ZHANGHSING commented Jan 19, 2021

Based on some tinkering I was doing with qemu for some ARM dev, I think I may have found a technique to allow general 32-bit support in WSL. Hat-tip to @therealkenc for the concept 😁

Edit: requires "Fall Creators Update", 1709, build 16299 or newer (I think)

Presuming a fresh Ubuntu WSL instance, you'll need to install the qemu-user-static package, add the i386 binfmt, enable the i386 architecture, update your package lists, and install some i386 packages:

Install qemu and binfmt

sudo apt update
sudo apt install qemu-user-static
sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'

[Edit: whoops, need to update package lists, added sudo apt update]

This will activate i386 support by causing them to be executed through qemu-i386-static, and drop a config file into /var/lib/binfmts/ for future reactivation.

You will need to reactivate this every time you restart WSL and want i386 support:

sudo service binfmt-support start

Enable i386 architecture and packages

sudo dpkg --add-architecture i386
sudo apt update
sudo apt install gcc:i386

Try it out

$ file /usr/bin/gcc-5
/usr/bin/gcc-5: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=2637bb7cb85f8f12b40f03cd015d404930c3c790, stripped

$ /usr/bin/gcc-5 --version
gcc-5 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc helloworld.c -o helloworld

$ ./helloworld
Hello, world!

$ file helloworld
helloworld: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=3a0c7be5c6a8d45613e4ef2b7b3474df6224a5da, not stripped

Proof

And to prove it really was working, disable i386 support and try again:

$ sudo service binfmt-support stop
 * Disabling additional executable binary formats binfmt-support [ OK ]

$ ./helloworld
-bash: ./helloworld: cannot execute binary file: Exec format error

update-binfmts: warning: unable to close /proc/sys/fs/binfmt_misc/register: Invalid argument
update-binfmts: exiting due to previous errors

this error due to ???

@RuiWang6188
Copy link

RuiWang6188 commented Mar 30, 2021

Based on some tinkering I was doing with qemu for some ARM dev, I think I may have found a technique to allow general 32-bit support in WSL. Hat-tip to @therealkenc for the concept 😁

Edit: requires "Fall Creators Update", 1709, build 16299 or newer (I think)

Presuming a fresh Ubuntu WSL instance, you'll need to install the qemu-user-static package, add the i386 binfmt, enable the i386 architecture, update your package lists, and install some i386 packages:

Install qemu and binfmt

sudo apt update
sudo apt install qemu-user-static
sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'

[Edit: whoops, need to update package lists, added sudo apt update]

This will activate i386 support by causing them to be executed through qemu-i386-static, and drop a config file into /var/lib/binfmts/ for future reactivation.

You will need to reactivate this every time you restart WSL and want i386 support:

sudo service binfmt-support start

Enable i386 architecture and packages

sudo dpkg --add-architecture i386
sudo apt update
sudo apt install gcc:i386

Try it out

$ file /usr/bin/gcc-5
/usr/bin/gcc-5: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=2637bb7cb85f8f12b40f03cd015d404930c3c790, stripped

$ /usr/bin/gcc-5 --version
gcc-5 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc helloworld.c -o helloworld

$ ./helloworld
Hello, world!

$ file helloworld
helloworld: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=3a0c7be5c6a8d45613e4ef2b7b3474df6224a5da, not stripped

Proof

And to prove it really was working, disable i386 support and try again:

$ sudo service binfmt-support stop
 * Disabling additional executable binary formats binfmt-support [ OK ]

$ ./helloworld
-bash: ./helloworld: cannot execute binary file: Exec format error

Thanks a lot! After using this, i can run it in wsl. But can u debug it using gdb? I tried but it seems that breakpoints cannot be inserted, and it says "warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64"...... what can I do

@liudonghua123
Copy link

liudonghua123 commented Mar 30, 2021

Based on some tinkering I was doing with qemu for some ARM dev, I think I may have found a technique to allow general 32-bit support in WSL. Hat-tip to @therealkenc for the concept 😁
Edit: requires "Fall Creators Update", 1709, build 16299 or newer (I think)
Presuming a fresh Ubuntu WSL instance, you'll need to install the qemu-user-static package, add the i386 binfmt, enable the i386 architecture, update your package lists, and install some i386 packages:

Install qemu and binfmt

sudo apt update
sudo apt install qemu-user-static
sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'

[Edit: whoops, need to update package lists, added sudo apt update]
This will activate i386 support by causing them to be executed through qemu-i386-static, and drop a config file into /var/lib/binfmts/ for future reactivation.

You will need to reactivate this every time you restart WSL and want i386 support:

sudo service binfmt-support start

Enable i386 architecture and packages

sudo dpkg --add-architecture i386
sudo apt update
sudo apt install gcc:i386

Try it out

$ file /usr/bin/gcc-5
/usr/bin/gcc-5: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=2637bb7cb85f8f12b40f03cd015d404930c3c790, stripped

$ /usr/bin/gcc-5 --version
gcc-5 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc helloworld.c -o helloworld

$ ./helloworld
Hello, world!

$ file helloworld
helloworld: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=3a0c7be5c6a8d45613e4ef2b7b3474df6224a5da, not stripped

Proof

And to prove it really was working, disable i386 support and try again:

$ sudo service binfmt-support stop
 * Disabling additional executable binary formats binfmt-support [ OK ]

$ ./helloworld
-bash: ./helloworld: cannot execute binary file: Exec format error

Thanks a lot! After using this, i can run it in wsl. But can u debug it using gdb? I tried but it seems that breakpoints cannot be inserted, and it says "warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64"...... what can I do

I followed the above steps. But I could not install gcc:i386. I have installed gcc/g++ 9 and 10 previously. And the ubuntu I used is 20.04.

liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:        20.04
Codename:       focal
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 10.2.0-5ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-WJNXnb/gcc-10-10.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-WJNXnb/gcc-10-10.2.0/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (Ubuntu 10.2.0-5ubuntu1~20.04)
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ ll /usr/bin/gcc*
lrwxrwxrwx 1 root root 21 Mar 30 13:55 /usr/bin/gcc -> /etc/alternatives/gcc*
lrwxrwxrwx 1 root root 23 Aug  8  2020 /usr/bin/gcc-10 -> x86_64-linux-gnu-gcc-10*
lrwxrwxrwx 1 root root 22 Aug  8  2020 /usr/bin/gcc-9 -> x86_64-linux-gnu-gcc-9*
lrwxrwxrwx 1 root root 24 Mar 30 13:55 /usr/bin/gcc-ar -> /etc/alternatives/gcc-ar*
lrwxrwxrwx 1 root root 26 Aug  8  2020 /usr/bin/gcc-ar-10 -> x86_64-linux-gnu-gcc-ar-10*
lrwxrwxrwx 1 root root 25 Aug  8  2020 /usr/bin/gcc-ar-9 -> x86_64-linux-gnu-gcc-ar-9*
lrwxrwxrwx 1 root root 24 Mar 30 13:55 /usr/bin/gcc-nm -> /etc/alternatives/gcc-nm*
lrwxrwxrwx 1 root root 26 Aug  8  2020 /usr/bin/gcc-nm-10 -> x86_64-linux-gnu-gcc-nm-10*
lrwxrwxrwx 1 root root 25 Aug  8  2020 /usr/bin/gcc-nm-9 -> x86_64-linux-gnu-gcc-nm-9*
lrwxrwxrwx 1 root root 28 Mar 30 13:55 /usr/bin/gcc-ranlib -> /etc/alternatives/gcc-ranlib*
lrwxrwxrwx 1 root root 30 Aug  8  2020 /usr/bin/gcc-ranlib-10 -> x86_64-linux-gnu-gcc-ranlib-10*
lrwxrwxrwx 1 root root 29 Aug  8  2020 /usr/bin/gcc-ranlib-9 -> x86_64-linux-gnu-gcc-ranlib-9*
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ sudo dpkg --print-architecture
amd64
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ sudo dpkg --print-foreign-architectures
i386
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ sudo apt install gcc:i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc:i386 : Depends: cpp:i386 (= 4:9.3.0-1ubuntu2) but it is not going to be installed
            Depends: gcc-9:i386 (>= 9.3.0-3~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ sudo apt install gcc-10:i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc-10:i386 : Depends: binutils:i386 (>= 2.34) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ sudo apt install gcc-9:i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc-9:i386 : Depends: cpp-9:i386 (= 9.3.0-17ubuntu1~20.04) but it is not going to be installed
              Depends: binutils:i386 (>= 2.34) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$

@RuiWang6188
Copy link

RuiWang6188 commented Mar 30, 2021

Based on some tinkering I was doing with qemu for some ARM dev, I think I may have found a technique to allow general 32-bit support in WSL. Hat-tip to @therealkenc for the concept 😁
Edit: requires "Fall Creators Update", 1709, build 16299 or newer (I think)
Presuming a fresh Ubuntu WSL instance, you'll need to install the qemu-user-static package, add the i386 binfmt, enable the i386 architecture, update your package lists, and install some i386 packages:

Install qemu and binfmt

sudo apt update
sudo apt install qemu-user-static
sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'

[Edit: whoops, need to update package lists, added sudo apt update]
This will activate i386 support by causing them to be executed through qemu-i386-static, and drop a config file into /var/lib/binfmts/ for future reactivation.

You will need to reactivate this every time you restart WSL and want i386 support:

sudo service binfmt-support start

Enable i386 architecture and packages

sudo dpkg --add-architecture i386
sudo apt update
sudo apt install gcc:i386

Try it out

$ file /usr/bin/gcc-5
/usr/bin/gcc-5: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=2637bb7cb85f8f12b40f03cd015d404930c3c790, stripped

$ /usr/bin/gcc-5 --version
gcc-5 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc helloworld.c -o helloworld

$ ./helloworld
Hello, world!

$ file helloworld
helloworld: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=3a0c7be5c6a8d45613e4ef2b7b3474df6224a5da, not stripped

Proof

And to prove it really was working, disable i386 support and try again:

$ sudo service binfmt-support stop
 * Disabling additional executable binary formats binfmt-support [ OK ]

$ ./helloworld
-bash: ./helloworld: cannot execute binary file: Exec format error

Thanks a lot! After using this, i can run it in wsl. But can u debug it using gdb? I tried but it seems that breakpoints cannot be inserted, and it says "warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64"...... what can I do

I followed the above steps. But I could not install gcc:i386. I have installed gcc/g++ 9 and 10 previously. And the ubuntu I used is 20.04.

liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:        20.04
Codename:       focal
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 10.2.0-5ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-WJNXnb/gcc-10-10.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-WJNXnb/gcc-10-10.2.0/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (Ubuntu 10.2.0-5ubuntu1~20.04)
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ ll /usr/bin/gcc*
lrwxrwxrwx 1 root root 21 Mar 30 13:55 /usr/bin/gcc -> /etc/alternatives/gcc*
lrwxrwxrwx 1 root root 23 Aug  8  2020 /usr/bin/gcc-10 -> x86_64-linux-gnu-gcc-10*
lrwxrwxrwx 1 root root 22 Aug  8  2020 /usr/bin/gcc-9 -> x86_64-linux-gnu-gcc-9*
lrwxrwxrwx 1 root root 24 Mar 30 13:55 /usr/bin/gcc-ar -> /etc/alternatives/gcc-ar*
lrwxrwxrwx 1 root root 26 Aug  8  2020 /usr/bin/gcc-ar-10 -> x86_64-linux-gnu-gcc-ar-10*
lrwxrwxrwx 1 root root 25 Aug  8  2020 /usr/bin/gcc-ar-9 -> x86_64-linux-gnu-gcc-ar-9*
lrwxrwxrwx 1 root root 24 Mar 30 13:55 /usr/bin/gcc-nm -> /etc/alternatives/gcc-nm*
lrwxrwxrwx 1 root root 26 Aug  8  2020 /usr/bin/gcc-nm-10 -> x86_64-linux-gnu-gcc-nm-10*
lrwxrwxrwx 1 root root 25 Aug  8  2020 /usr/bin/gcc-nm-9 -> x86_64-linux-gnu-gcc-nm-9*
lrwxrwxrwx 1 root root 28 Mar 30 13:55 /usr/bin/gcc-ranlib -> /etc/alternatives/gcc-ranlib*
lrwxrwxrwx 1 root root 30 Aug  8  2020 /usr/bin/gcc-ranlib-10 -> x86_64-linux-gnu-gcc-ranlib-10*
lrwxrwxrwx 1 root root 29 Aug  8  2020 /usr/bin/gcc-ranlib-9 -> x86_64-linux-gnu-gcc-ranlib-9*
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ sudo dpkg --print-architecture
amd64
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ sudo dpkg --print-foreign-architectures
i386
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ sudo apt install gcc:i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc:i386 : Depends: cpp:i386 (= 4:9.3.0-1ubuntu2) but it is not going to be installed
            Depends: gcc-9:i386 (>= 9.3.0-3~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ sudo apt install gcc-10:i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc-10:i386 : Depends: binutils:i386 (>= 2.34) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ sudo apt install gcc-9:i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc-9:i386 : Depends: cpp-9:i386 (= 9.3.0-17ubuntu1~20.04) but it is not going to be installed
              Depends: binutils:i386 (>= 2.34) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$

Actually I didn't install gcc:i386, I just run the following commands in bash of wsl

$sudo dpkg --add-architecture i386
$sudo apt update
$sudo apt install -y libc6:i386 libncurses5:i386 libstdc++6:i386 zlib1g:i386 zlib1g-dev:i386

$sudo apt install qemu-user-static
$sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'
$sudo service binfmt-support start

Hope this will help!

@liudonghua123
Copy link

liudonghua123 commented Mar 30, 2021

When I execute sudo apt install -y libc6:i386 libncurses5:i386 libstdc++6:i386 zlib1g:i386 zlib1g-dev:i386, I got the following errors. It seems I could not make it work.

liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ sudo apt install -y libc6:i386 libncurses5:i386 libstdc++6:i386 zlib1g:i386 zlib1g-dev:i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  bridge-utils dns-root-data dnsmasq-base libidn11 ubuntu-fan
Use 'sudo apt autoremove' to remove them.
Unpacking libc6-dev:i386 (2.31-0ubuntu9.2) ...
Selecting previously unselected package libgpm2:i386.
Preparing to unpack .../07-libgpm2_1.20.7-5_i386.deb ...
Unpacking libgpm2:i386 (1.20.7-5) ...
Selecting previously unselected package libtinfo5:i386.
Preparing to unpack .../08-libtinfo5_6.2-0ubuntu2_i386.deb ...
Unpacking libtinfo5:i386 (6.2-0ubuntu2) ...
Selecting previously unselected package libncurses5:i386.
Preparing to unpack .../09-libncurses5_6.2-0ubuntu2_i386.deb ...
Unpacking libncurses5:i386 (6.2-0ubuntu2) ...
Selecting previously unselected package zlib1g-dev:i386.
Preparing to unpack .../10-zlib1g-dev_1%3a1.2.11.dfsg-2ubuntu1.2_i386.deb ...
Unpacking zlib1g-dev:i386 (1:1.2.11.dfsg-2ubuntu1.2) ...
Setting up libgpm2:i386 (1.20.7-5) ...
Setting up libunistring2:i386 (0.9.10-2) ...
Setting up linux-libc-dev:amd64 (5.4.0-70.78) ...
Setting up linux-libc-dev:i386 (5.4.0-70.78) ...
Setting up libidn2-0:i386 (2.2.0-2) ...
Setting up zlib1g-dev:amd64 (1:1.2.11.dfsg-2ubuntu1.2) ...
Setting up libcrypt-dev:i386 (1:4.4.10-10ubuntu4) ...
Setting up libc6-dev:i386 (2.31-0ubuntu9.2) ...
Setting up libtinfo5:i386 (6.2-0ubuntu2) ...
Setting up libstdc++6:i386 (10.2.0-5ubuntu1~20.04) ...
Setting up libncurses5:i386 (6.2-0ubuntu2) ...
Setting up zlib1g-dev:i386 (1:1.2.11.dfsg-2ubuntu1.2) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...
E: Could not configure 'libc6:i386'.
E: Could not perform immediate configuration on 'libgcc-s1:i386'. Please see man 5 apt.conf under APT::Immediate-Configure for details. (2)
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ sudo apt install -y libc6:i386 libncurses5:i386 libstdc++6:i386 zlib1g:i386 zlib1g-dev:i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
libncurses5:i386 is already the newest version (6.2-0ubuntu2).
libc6:i386 is already the newest version (2.31-0ubuntu9.2).
libstdc++6:i386 is already the newest version (10.2.0-5ubuntu1~20.04).
zlib1g:i386 is already the newest version (1:1.2.11.dfsg-2ubuntu1.2).
zlib1g-dev:i386 is already the newest version (1:1.2.11.dfsg-2ubuntu1.2).
The following packages were automatically installed and are no longer required:
  bridge-utils dns-root-data dnsmasq-base libidn11 ubuntu-fan
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 250 not upgraded.
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ sudo apt install qemu-user-static
Reading package lists... Done
Building dependency tree
Reading state information... Done
qemu-user-static is already the newest version (1:4.2-3ubuntu6.14).
The following packages were automatically installed and are no longer required:
  bridge-utils dns-root-data dnsmasq-base libidn11 ubuntu-fan
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 250 not upgraded.
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ sudo service binfmt-support start
 * Enabling additional executable binary formats binfmt-support                                                                                                 [ OK ]
liudonghua@desktop-ldh:/mnt/c/Users/Liu.D.H$ cd /tmp/
liudonghua@desktop-ldh:/tmp$
liudonghua@desktop-ldh:/tmp/hello$ cat > hello.c
#include <stdio.h>

int main() {
  printf("hello\n");
  return 0;
}
liudonghua@desktop-ldh:/tmp/hello$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 10.2.0-5ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-WJNXnb/gcc-10-10.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-WJNXnb/gcc-10-10.2.0/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (Ubuntu 10.2.0-5ubuntu1~20.04)
liudonghua@desktop-ldh:/tmp/hello$ gcc hello.c -o hello
liudonghua@desktop-ldh:/tmp/hello$ file hello
hello: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=006d1d9833e3d2561b61ff2afbff854d80c9af81, for GNU/Linux 3.2.0, not stripped
liudonghua@desktop-ldh:/tmp/hello$ sudo apt-get install gcc-multilib g++-multilib
Reading package lists... Done
Building dependency tree
Reading state information... Done
g++-multilib is already the newest version (4:9.3.0-1ubuntu2).
gcc-multilib is already the newest version (4:9.3.0-1ubuntu2).
gcc-multilib set to manually installed.
The following packages were automatically installed and are no longer required:
  bridge-utils dns-root-data dnsmasq-base libidn11 ubuntu-fan
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 250 not upgraded.
liudonghua@desktop-ldh:/tmp/hello$ gcc -m32 hello.c -o hello_32
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/10/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/10/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
liudonghua@desktop-ldh:/tmp/hello$

@muteryx
Copy link

muteryx commented Nov 30, 2021

I just want to run arm-linux-gcc 4.5.3,but:

-bash: ./arm-arago-linux-gnueabi-gcc: No such file or directory。

The arm-arago-linux-gnueabi-gcc is existed,So,what's the problem?
The version:
Linux DESKTOP-DI54F8S 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests