Little endian compiling - GCC
Moderator: OpenTTD Developers
Little endian compiling - GCC
Hi, my first post on openttd forum
Been a fan for severl years
usually I'd go with distro version and lately decided try to compile it
Well it gets complicated having me crawling through many digi-rabit holes
about gcc ,cmake and general system maintenance issues. C
ausing my compile attempts to fail crashing with error 9 (thats out of memory ) from the system
My basic idea hear is to discuss the newest "big endian" and how to deal with them (or my attempts at them)
Pretty soon all big endins become small
at this time My computer is chewing on compiling oppen with a non-nornal compiler tweak and it is
SOOO Veeerrry SSSSLLLLLOOOOWWW (sorry for shouting)
at this rate it will take days to compile and I'll gain knowledge I didn't have before
https://github.com/OpenTTD/OpenTTD/issues/13359
is where this all started
Been a fan for severl years
usually I'd go with distro version and lately decided try to compile it
Well it gets complicated having me crawling through many digi-rabit holes
about gcc ,cmake and general system maintenance issues. C
ausing my compile attempts to fail crashing with error 9 (thats out of memory ) from the system
My basic idea hear is to discuss the newest "big endian" and how to deal with them (or my attempts at them)
Pretty soon all big endins become small
at this time My computer is chewing on compiling oppen with a non-nornal compiler tweak and it is
SOOO Veeerrry SSSSLLLLLOOOOWWW (sorry for shouting)
at this rate it will take days to compile and I'll gain knowledge I didn't have before
https://github.com/OpenTTD/OpenTTD/issues/13359
is where this all started
Re: Little endian compiling - GCC
Little endian and big endian has to do with how a CPU organizes data in memory, it's not something you change or something that affects memory usage. The basic architecture of the hardware and OS your computer is running determines whether it's a little endian or a big endian system.
OpenTTD's build system checks for endianness of the target system because the program needs to know how the CPU will lay out data in memory, to be able to correctly load various external data (such as saved games and NewGRF files) and participate in network games among computers of different architectures.
Fact is, that the game is just a large, complex system to build, much more than it was 10 years ago, and if your computer is underpowered it's going to take very long time, or be completely impossible. I strongly doubt there's going to be a solution for you that will not involve spending money. Either to buy a better computer or upgrades for your current, or to rent a server to make the builds for you.
Alternatively, you would need to work with an older version of the game.
OpenTTD's build system checks for endianness of the target system because the program needs to know how the CPU will lay out data in memory, to be able to correctly load various external data (such as saved games and NewGRF files) and participate in network games among computers of different architectures.
Fact is, that the game is just a large, complex system to build, much more than it was 10 years ago, and if your computer is underpowered it's going to take very long time, or be completely impossible. I strongly doubt there's going to be a solution for you that will not involve spending money. Either to buy a better computer or upgrades for your current, or to rent a server to make the builds for you.
Alternatively, you would need to work with an older version of the game.
-
- Engineer
- Posts: 114
- Joined: 26 Sep 2022 09:10
Re: Little endian compiling - GCC
What kind of hardware are you compiling on?
Re: Little endian compiling - GCC
I am rocking an Intel core 2 w 2gb ram 1 gb swap partion
still compatable with many android class devices
Which no code has crashed during compile/linking until now
which gott my attention ( therre is nothing special even in size ,libs used ... )
missing the debug symbols does dissapoint due to I want working with code profilers such as valgrind ( some other project perhaps )
Which has benn compiling lot of foss games and apps. While upgading is a solution , I thinka solution not requiring my spend money is availabe
So far I've found some settings that seam to help , at least I get successfule compilatio including using cxx flags -O0 -NDEBUG
As for ld configuration I found settings to redirect ( to hopefully to a tempfile on hdd, not sure how to (if possible ) to /etc/ld.so...
also notthat I ever cared before I cannot fing any /etc type file to gcc options,
been looking in many gcc docs a may even have missed it
As I delve into this the main iss is with "ld" which seams to link x86_64-linux-gnu/libgcc_s.so.1 a second time
when I gett error 9
I decided to wrie a CMakeList.txt of my to see f i can figure why - if only to prove I can
as cmake say listing each file seperately, when that version actually compiles sucessfully try to incorperate back into main if anything usefull is found
About the endian defines
Re: Little endian compiling - GCC
Just because it's plenty to run the game, doesn't mean it's enough to compile it. A computer with nearly 20 year old specs is just not something we can keep supporting forever as a development environment.
Is there any specific reason you want to compile the game yourself, and can't use the prebuilt binaries?
Is there any specific reason you want to compile the game yourself, and can't use the prebuilt binaries?
-
- Engineer
- Posts: 114
- Joined: 26 Sep 2022 09:10
Re: Little endian compiling - GCC
I have a 32bit dual core intel atom from 2015, 2gb of RAM and a swap file that I can't recall the size of atm. I'll check when I get home later today, but I think it's in the range of 1-2gb. I have no trouble compiling the game, except that it takes about an hour and a half
The linking stage at the very end is what really really needs a lot of memory. Compiling on my Raspberry Pi 3B+ also required a rather large swap file iirc.
When I get home I'll check my configurations and show the commands I use to compile.

When I get home I'll check my configurations and show the commands I use to compile.
Re: Little endian compiling - GCC
The real problem for Wirser is probably the tiny 1 GB swap partition. That simply is not enough memory to do the job. You will need to expand your swap space, make a swap file if you can't re-allocate your partitions. Swap files on Linux are less efficient than swap partitions, but are still better than not having that memory available at all.
-
- Engineer
- Posts: 114
- Joined: 26 Sep 2022 09:10
Re: Little endian compiling - GCC
So much easier to add a swap file than a swap partition, though.
I've checked now: I have 2GB of RAM and a 1GB swap file. That appears to be enough for me, but I guess it also depends on how much you have in RAM that needs to swap. Having a swap file/partition of 2GB or more is a good idea if you're low on RAM. As mentioned the linking stage can be quite demanding.
I've checked now: I have 2GB of RAM and a 1GB swap file. That appears to be enough for me, but I guess it also depends on how much you have in RAM that needs to swap. Having a swap file/partition of 2GB or more is a good idea if you're low on RAM. As mentioned the linking stage can be quite demanding.
Re: Little endian compiling - GCC
Despite all who would have me upgrade with more memory, I am not convinced
Since my last post Ive gotten doxygen to work -
Also I've been playing with CMakeList.txt - and found
ln 247
I neither am compiling on/for a windoze system nor for 32 bit. ( though removing "win32" didn't change results)
ln 246
I tried changing "OBJECT" for "SHARED", "STATIC", and ""
both "OBJECT" & "SHARED" would only compile release
both "STATIC and "" caused ar during link beggining to crash complaning about two different options (not showing in cmd line output during build)
possible that 3rdparty etc is slipping a hard codded shared object into the mix.
The "" or null is supposed to let cmake decide what to build but maybe it doesn't know how to resolve this conflict
What I have some limited cmake experience, but know the script dialect it uses is unique enough to cause some strange issues
I suspect both may be related. Untill I prove this ...
Since my last post Ive gotten doxygen to work -

Also I've been playing with CMakeList.txt - and found
ln 247
Code: Select all
add_executable(openttd WIN32)
ln 246
Code: Select all
add_library(openttd_lib OBJECT ${GENERATED_SOURCE_FILES})
both "OBJECT" & "SHARED" would only compile release
both "STATIC and "" caused ar during link beggining to crash complaning about two different options (not showing in cmd line output during build)
possible that 3rdparty etc is slipping a hard codded shared object into the mix.
The "" or null is supposed to let cmake decide what to build but maybe it doesn't know how to resolve this conflict
What I have some limited cmake experience, but know the script dialect it uses is unique enough to cause some strange issues
I suspect both may be related. Untill I prove this ...
Re: Little endian compiling - GCC
Yes if you want to mess with the CMakeLists you'd need to do a lot of reading up on how it works. Altering anything in those will be unlikely to help you at all. You can alter the compiler and linker settings by passing relevant variables when you run cmake to generate the makefiles.
For example that add_executable(openttd WIN32) thing you point to is completely unrelated, which you might be able to discover if you actually read the documentation. That should also be obvious if you knew some basics of what CMake is, how it operates, and what it produces.
What's more likely to be a cause of your troubles from insisting on using an antique computer is what happens on line 183 of CMakeLists.txt where it checks whether your compiler supports IPO, which is Inter-Procedural Optimization. That sets a flag, and if that flag is set then line 302 and forward enables the use of IPO. Performing IPO is something that is very memory-demanding because it requires the entire semi-compiled program to be in memory so the compiler/linker can perform the "magic".
Be aware that disabling IPO will cost performance of the final compiled binary.
For example that add_executable(openttd WIN32) thing you point to is completely unrelated, which you might be able to discover if you actually read the documentation. That should also be obvious if you knew some basics of what CMake is, how it operates, and what it produces.
What's more likely to be a cause of your troubles from insisting on using an antique computer is what happens on line 183 of CMakeLists.txt where it checks whether your compiler supports IPO, which is Inter-Procedural Optimization. That sets a flag, and if that flag is set then line 302 and forward enables the use of IPO. Performing IPO is something that is very memory-demanding because it requires the entire semi-compiled program to be in memory so the compiler/linker can perform the "magic".
Be aware that disabling IPO will cost performance of the final compiled binary.
Wow not only your computer but also your writing and "jokes" are 20 years out of date.windoze
Re: Little endian compiling - GCC
About clang
I installed 14.0.6 crashed on the first file with
All of which is something about clang and C++ 20 - which my gcc handles fine
seems to be a flagg about "expermental ..." which I just lost , lots of talk about this however on stackoverflow and elsewhere
just search "error: no type named 'source_location' in namespace 'std'"
I installed 14.0.6 crashed on the first file with
Code: Select all
build/OpenTTD-15.0-beta1/build-clang$ make
[ 0%] Building CXX object src/settingsgen/CMakeFiles/settingsgen.dir/settingsgen.cpp.o
In file included from /home/enon/build/OpenTTD-15.0-beta1/src/settingsgen/settingsgen.cpp:10:
/home/enon/build/OpenTTD-15.0-beta1/src/settingsgen/../stdafx.h:307:42: error: no type named 'source_location' in namespace 'std'
...
seems to be a flagg about "expermental ..." which I just lost , lots of talk about this however on stackoverflow and elsewhere
just search "error: no type named 'source_location' in namespace 'std'"
Last edited by Wirser on 16 Feb 2025 19:24, edited 1 time in total.
Re: Little endian compiling - GCC
Which is why I choose to see what happenns ,sometimes clues to problems display differently. I learn as much from what works as well what doesn'tjfs wrote: 16 Feb 2025 19:10 Yes if you want to mess with the CMakeLists you'd need to do a lot of reading up on how it works. Altering anything in those will be unlikely to help you at all. You can alter the compiler and linker settings by passing relevant variables when you run cmake to generate the makefiles.
For example that add_executable(openttd WIN32) thing you point to is completely unrelated, which you might be able to discover if you actually read the documentation. That should also be obvious if you knew some basics of what CMake is, how it operates, and what it produces.
does it have to be ram?jfs wrote: 16 Feb 2025 19:10 What's more likely to be a cause of your troubles from insisting on using an antique computer is what happens on line 183 of CMakeLists.txt where it checks whether your compiler supports IPO, which is Inter-Procedural Optimization. That sets a flag, and if that flag is set then line 302 and forward enables the use of IPO. Performing IPO is something that is very memory-demanding because it requires the entire semi-compiled program to be in memory so the compiler/linker can perform the "magic".
Be aware that disabling IPO will cost performance of the final compiled binary.
As far as performance goes I run openttd as single player only not a server - running off of bianaries compiled with -O0
But thanks for the info, I'll try it and post my findings
Both were free,and I haven't had to buy new hw when time to upgrade system comes alongjfs wrote: 16 Feb 2025 19:10Wow not only your computer but also your writing and "jokes" are 20 years out of date.windoze
As for being "antique" I have worked on real old systems - this pc is barely a newborn in comparison
Re: Little endian compiling - GCC
Here is what I got so far
looking into IPO I noyiced two things
one no Debug setting so I tried setting false in case of some uninitialized variable but debug still fails
However Release , MinsizRel and relwdebug all compiled and linked properly.
The only difference is debug flags " -g" while relwdebug has "-g DNDEBUG
And I have no sym file for debugging either
I found listing of "-g" class gcc flags but haven't tried any or if DDEBUG has any effect
looking into IPO I noyiced two things
one no Debug setting so I tried setting false in case of some uninitialized variable but debug still fails
However Release , MinsizRel and relwdebug all compiled and linked properly.
The only difference is debug flags " -g" while relwdebug has "-g DNDEBUG
And I have no sym file for debugging either
I found listing of "-g" class gcc flags but haven't tried any or if DDEBUG has any effect
Who is online
Users browsing this forum: Amazon [Bot] and 2 guests