Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
std.Build: allow adding exact search prefixes with function and comma…
…nd option This allows more granurality when adding search pathes for cross-compiling. By default old (all variant) system added `bin`, `include` and `lib` subdirectories from `search-prefix` argument path when cross-compiling, but on some distros it's not correct and can lead to some errors. For example, on my Gentoo system I have libcurl installed as both 32-bit and 64-bit versions, which are located in `/usr/lib` and `/usr/lib64` directories respectively. If I use plain `--search-prefix`, it fails because it tries to add 32-bit libraries: ```console $ zig build -Dtarget=x86_64-linux-gnu.2.35 --search-prefix /usr/ install └─ install true_or_false └─ zig build-exe true_or_false Debug x86_64-linux.6.11.7-gnu.2.40 3 errors error: ld.lld: /usr/lib/libcurl.so is incompatible with elf_x86_64 error: ld.lld: /usr/lib/libssl.so is incompatible with elf_x86_64 error: ld.lld: /usr/lib/libcrypto.so is incompatible with elf_x86_64 ``` Another example is `libgccjit` library, which shared objects are located (at least on my system) in `/usr/lib/gcc/x86_64-pc-linux-gnu/14/`, and include files in include subdir there. One solution I used recently was to create temporary directory and symlink files so that they have names expected by Zig, but it's not the best solution. With this PR you can now supply file which will instruct build system to add pathes written there as-is, without trying to guess subdirs there. Something like: ```zig .{ .libraries = "/usr/lib64", } ``` or ```zig .{ .binaries = "/usr/x86_64-pc-linux-gnu/gcc-bin/14/", .libraries = "/usr/lib/gcc/x86_64-pc-linux-gnu/14", .includes = "/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/", } ``` can be saved in some file like paths.zon and then passed using `--search-prefix-exact paths.zon`. This also helps to use this config on a system (distro) level, without messing with build.zig. Signed-off-by: Eric Joldasov <[email protected]>
- Loading branch information