PlutoLang / Pluto

A superset of Lua 5.4 with a focus on general-purpose programming.
https://pluto-lang.org
MIT License
367 stars 22 forks source link

Add platform auto-detection #847

Closed Sainan closed 5 months ago

alerque commented 5 months ago

Better make sure you're not loosing the ability to cross-compile while doing this. That's the usual pitfall of trying to do platform detection at compile time.

Sainan commented 5 months ago

Fair point, although I think it's not a huge concern, e.g. if you're on a Linux machine, you're not gonna be targeting Windows — I'm not sure that would even be possible.

And otherwise I do think the compiler should be setting the correct macros, e.g. if you're on a X86 machine targeting ARM64, MSVC would stop defining _M_IX86 and start defining _M_ARM64.

alerque commented 5 months ago

Is is possible with Lua, that's why I thought to mention it. I build Lua interpreter binaries and various apps with Lua interpreters bundled into them targeting Windows from Linux all the time (see e.g. the luacheck.exe assets on LuaCheck project releases, those are all built on Linux).

Sainan commented 5 months ago

That's interesting. Do you think these changes would break your cross-compiling workflow?