feat(toolchain): cross compile through target triples and sysroots
A triple is set with --target or a target field in the toolchain block, and everything derived from it follows: platform, arch and the conditionals built on them come from the triple rather than uname, so a build file can branch on the platform it is building for instead of the one it is running on. Tools are taken from the triple prefix when a matching toolchain is installed (x86_64-w64-mingw32-gcc, -ar, -ranlib) and otherwise the host compiler is invoked with --target, which covers clang without a prefixed toolchain. An explicit cc, cxx, ar or ranlib in the build file always wins over the derived one. --sysroot adds --sysroot to both the compile and link lines. Each triple gets its own build directory and probe cache under builddir, so a host tree and a cross tree do not invalidate each other and neither reruns the other's checks. Probes never execute what they compile, sizeof included, so the configure stage needed no changes to work against a foreign target. Executables and shared libraries now take the extension the target platform uses. Without that the graph expected bin/app while mingw wrote bin/app.exe, and the link step repeated on every build. Verified against x86_64-w64-mingw32, which produces a PE32+ binary, and aarch64-linux-gnu through clang, which produces AArch64 objects.
This commit is contained in:
5 files changed
+120
-24
No files matched your search
@@ -73,3 +73,12 @@ let capture cmd =
|
||||
(code, out)
|
||||
|
||||
let ok cmd = fst (capture cmd) = 0
|
||||
|
||||
let which name =
|
||||
if String.contains name '/' then Sys.file_exists name
|
||||
else
|
||||
match Sys.getenv_opt "PATH" with
|
||||
| None -> false
|
||||
| Some path ->
|
||||
String.split_on_char ':' path
|
||||
|> List.exists (fun dir -> dir <> "" && Sys.file_exists (Filename.concat dir name))
|
||||
Reference in new issue
Block a user