koreader / koreader-base

Base framework offering a Lua scriptable environment for creating document readers
http://koreader.rocks/
GNU Affero General Public License v3.0
136 stars 106 forks source link

Why is -m32 used for building luajit? #302

Closed lgeek closed 8 years ago

lgeek commented 9 years ago

On this line: https://github.com/koreader/koreader-base/blob/master/Makefile#L199

It's x86 specific and has to be removed to do native builds on ARM. Could it be removed and if not what would be the proper way to only enable it on x86_64 hosts?

Thanks

chrox commented 9 years ago

According to LuaJIT document, it's necessary to add "-m32" flag in HOST_CC when cross compiling for 32 bit architecture to make pointer size match.

Current Makefile is largely used for cross compiling except building the emulator that use SDL to handle input/output. I'm not sure if native compile is even supported without large portion of modification. But is there a particular reason to choose native compiling instead of cross compiling? I would never try to compile anything on a 800 MHz CPU plus 256 MB RAM of my Kindle device.

lgeek commented 9 years ago

I can confirm this is the only change required to build koreader-base (and koreader) natively on ARM (at least for Kobo devices).

As to why, it's because I'm building koreader as part of a larger collection of software, some of which is easier to just build natively. I'm using a more powerful machine, not my ereader, and the build time is entirely reasonable.

For my own use I can work around this with a local patch. However, since it seems to be the only issue blocking compilation on non-x86 hosts, I think it might be worth fixing upstream.

chrox commented 9 years ago

Then it seems easy to fix. Probably we can differentiate toolchains with $(CC) -dumpmachine (the MACHINE variable defined in Makefile.def) with findstring function like this

HOST_CC="$(HOSTCC) $(if $(findstring,x86_64,$(MACHINE)),-m32,)"
houqp commented 9 years ago

++ on what chrox's approach. @lgeek , feel free to send a PR