Stream: ideas

Topic: Better linking support


view this post on Zulip Locria Cyber (Oct 27 2021 at 03:25):

I'll put it here without a better zulip "stream" .

view this post on Zulip Locria Cyber (Oct 27 2021 at 03:26):

Code examples from compiler/build/src/link.rs:

Ok((
        Command::new("ld")
            // Don't allow LD_ env vars to affect this
            .env_clear()
            .env("PATH", &env_path)
            // Keep NIX_ env vars
            .envs(
                env::vars()
                    .filter(|&(ref k, _)| k.starts_with("NIX_"))
                    .collect::<HashMap<String, String>>(),
            )
            .args(&[
                "--gc-sections",
                "--eh-frame-hdr",
                "--arch",
                arch_str(target),
                "-pie",
                libcrt_path.join("crti.o").to_str().unwrap(),
                libcrt_path.join("crtn.o").to_str().unwrap(),
            ])
let libgcc_name = "libgcc_s.so.1";
    let libgcc_path = library_path(["/lib", &architecture, libgcc_name])
        .or_else(|| library_path(["/usr", "lib", &architecture, libgcc_name]))
        .or_else(|| library_path(["/usr", "lib", libgcc_name]))
        .or_else(|| library_path([&nixos_path(), libgcc_name]))
        .unwrap();

view this post on Zulip Locria Cyber (Oct 27 2021 at 03:27):

Problems:

view this post on Zulip Locria Cyber (Oct 27 2021 at 03:29):

Again, it would be better to generate build files for a build system like Ninja and that to find libraries. Also don't find libraries in "/usr/lib" if the user doesn't specify that path, since we don't need legacy support for a new language.

view this post on Zulip Richard Feldman (Oct 27 2021 at 12:09):

yeah we're working on a linking system that replaces all this with a totally different approach, and runs way faster too!

view this post on Zulip Richard Feldman (Oct 27 2021 at 12:10):

it's not feature-complete enough to replace this yet though


Last updated: Jun 16 2026 at 16:19 UTC