Subject: Setting sysroots

From: Simon Mavi Stewart <[email-masked]>
Date: Tue, 31 Jan 2023 18:30:21 +0000

Hi,

Is there any recommended way of passing a sysroot to use to the zig-cc toolchains that are created? And also to pass additional linker flags?

I'm trying to use bazel-zig-cc to compile code using Rust, and some of the dependencies need to link against `libiconv`. For macOS compiles, I know that I need to supply my own sysroot, and that needs to contain not just the libraries, but also the frameworks that are linked against. Being able to specify additional linker flags would help with that a lot.

Kind regards,

Simon

Sent from my iPhone

---

From: Motiejus Jakštys <[email-masked]>
Date: Tue, 31 Jan 2023 22:41:57 -0800

Hi,

Yes. See this snippet in the README:

    version = "<...>",
    url_formats = [
        "https://example.org/zig/zig-{host_platform}-{version}.{_ext}",
    ],
    host_platform_sha256 = { ... },

Does that explain it?

> I'm trying to use bazel-zig-cc to compile code using Rust, and some of the dependencies need to link against `libiconv`. For macOS compiles, I know that I need to supply my own sysroot, and that ne…

Linking to libraries outside the sandbox is highly, highly
discouraged. Normally you would build libiconv with bazel (cc_library
et al) and statically (recommended; you can also link dynamically, but
that has its own caveats) link to it in your application.

As far as *.tbd files of MacOS are concerned (do I correctly
understand that this is what you mean by sysroot?), this is currently
unsupported, and, honestly, I have very little idea how to implement
it. But I will review/accept patches that do it.

Motiejus