fgsfdsfgs/perfect_dark

Any specific reason why gcc -m32 isn't used for Linux?

Closed this issue · 10 comments

In order to get it to build on my system I had to change the CFLAGS/CXXFLAGS/LDFLAGS to have -m32 in the string and deleted $(TOOLCHAIN) from CC and CXX, leaving them as gcc -std=c11 and g++ -std=c++20.

On Debian(and Ubuntu, I'm guessing), using gcc multilib, you can compile the 32-bit binary by using 64-bit gcc by simply adding -m32.

Is there some reason why the toolchain setup is complex? It results in a CC variable that is something like 'i686-linux-gnu-gcc' which is only available if you install a the 'i686-linux-gnu-gcc' package which breaks gcc-multilib.

Absolutely no reason, that's just how I have it set up locally. I do development in a 32-bit MinGW environment on Windows, so when I was testing it on Linux I set it up essentially the same way. Will probably change later.

Ah, okay. Thanks for supporting Linux.

Made it default to host gcc with -m32 on Linux specifically. Old behavior can be achieved by specifying TOOLCHAIN=i686-linux-gnu- on the command line. Thanks for the suggestion.
Note that you still have to pass TARGET_PLATFORM=i686-linux when building on x86_64.

It is broken now. Ends up dying at invitems.c, lots of errors about initializer element is not computable at load time. -std=c11 is getting passed so I don't know why this is happening.

EDIT: the file command is showing that the .o files are 64-bit and -m32 isn't being passed to gcc.

How are you invoking make?
Should be something like make -f Makefile.port TARGET_PLATFORM=i686-linux.
Also can you give me the output of uname -p and uname -s?

make -f Makefile.port
I have tried with TARGET_PLATFORM=i686-linux and it does the same thing.

uname -p: unknown
uname -s: Linux

I think uname -p is unreliable. The -m flag returns x86_64.

I think uname -p is unreliable. The -m flag returns x86_64.

Yeah, probably. I've only tested it on one Ubuntu VM and there it does indeed return x86_64. Under MSYS it does return unknown, but there I just check for MINGW64 instead.

Ah shit, misclicked. Can you try with -m? Change it on line 68 or just pull the latest commit. Seems to work on the VM.
Don't forget to run clean before you rebuild as well to get rid of the 64-bit objects.

$ make -f Makefile.port
Host platform: x86_64-linux
Target platform: x86_64-linux
Makefile.port:89: *** 64-bit target platforms are not supported yet.  Stop.

Adding TARGET_PLATFORM=i686-linux works.

Okay, cool, that's basically the intended behavior. Thanks for testing.