News for hackers. Stuff that matters.
Re:FreeBSD Can Now Be Built From Linux/macOS Hosts, Transiti... by qwerty456127 on Thursday October 22, 2020 @11:20AM (#24858944)
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?
Re:FreeBSD Can Now Be Built From Linux/macOS Hosts, Transiti... by asveikau on Thursday October 22, 2020 @11:26AM (#24859028)
I 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.

Re:FreeBSD Can Now Be Built From Linux/macOS Hosts, Transiti... by bch on Thursday October 22, 2020 @02:12PM (#24861247)
> 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

[1]https://en.wikipedia.org/wiki/First_principle

Re:FreeBSD Can Now Be Built From Linux/macOS Hosts, Transiti... by Someone on Thursday October 22, 2020 @01:10PM (#24860369)
One 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.

Re:FreeBSD Can Now Be Built From Linux/macOS Hosts, Transiti... by trasz on Thursday October 22, 2020 @01:12PM (#24860391)
Because 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.