3 ms·
I actually find it bizarre that it can be hard to build code for a particular platform on a different platform machine. Why does compiler logic have to depend o
by qwerty456127 6y ago
I actually find it bizarre that it can be hard to build code for a particular platform on a different platform machine. Why does compiler logic have to depend on the machine it runs on?
- asveikau 6y agoI imagine it's mostly build system scripting. FreeBSD builds using makefiles, and the BSD make is not the same as GNU make, especially for the sometimes-complicated scripting they have to do inside of them. Adding cross-compilation to a complicated set of makefiles isn't impossible but can be some work. Beyond that there are other issues... eg. The ELF binaries generated need to declare themselves as FreeBSD binaries. A C compiler set up to produce Linux binaries won't do that. Maybe also they depend on a specific compiler (FreeBSD is using clang lately). When you build FreeBSD you also build a compiler so maybe this part isn't such a big deal.
- bch 6y ago> I imagine it's mostly build system scripting. NetBSD has had this[0] for ~20 years (requiring only POSIX conformance from the build host). Think of it as a sort of first principle[1] in action. I wouldn’t be surprised if FreeBSD could achieve some success leaning on this work. [0] http://www.mewburn.net/luke/papers/build.sh.pdf http://www.mewburn.net/luke/papers/build.sh.pdf [1]https://en.wikipedia.org/wiki/First_principle https://en.wikipedia.org/wiki/First_principle
- Someone 6y agoOne factor used to be that constant folding can be problematic. The target platform may have different-precision doubles, or have a different way to represent them (fairly unlikely, nowadays, but back in the time, if you wanted to cross-compile to x87, you needed the ability to compute with its 80-bit doubles. Another that the compiler may use platform tools (assembler, linker) to build binaries, and those tools they may need a library (say one for writing ELF binaries) that isn’t available. All of them can be ported, but that can be a lot of work for a limited number of users. Moreover, those users typically have (access to) the target hardware, as they have to be able to test the end result. So, a ‘normal’ compiler may not be optimal, but still be good enough for them. Because of that, you tend to see more cross-compilers the slower the target hardware.
- trasz 6y agoBecause it’s not just building a program, it’s about bootstrapping the whole operating system. The process begins with building some FreeBSD tools used by the build process; the you need the FreeBSD compiler, since host compiler obviously can’t create FreeBSD executables, and so on.