#Passing linker arguments for cross-compile

1 messages · Page 1 of 1 (latest)

wind wing
#

I am trying to cross-compile Vex V5 PROS kernel with Zig, which is built of C/C++. It is built by a hot package and cold package, cold is the pre-built library, and hot is the user code, the Makefile from the github source basically link the hot package to the cold package, and objcopy it to a flat binary. And now I am stuggle on passing -Wl, -R firmware/cold.package.elf to lld/linker, since I didn't find any function that deal with pass arguments to linker in Zig 0.15.2

#

My current build.zig:

const std = @import("std");

pub fn build(b: *std.Build) void {
    const root = b.addModule("src/main.zig", .{ .root_source_file = b.path("src/main.zig"), .optimize = .ReleaseSmall, .strip = true, .target = b.resolveTargetQuery(.{ .abi = .gnueabihf, .cpu_arch = .arm, .os_tag = .freestanding, .cpu_model = .{ .explicit = &std.Target.arm.cpu.cortex_a9 }, .cpu_features_add = std.Target.arm.featureSet(&.{ .neon, .fp16 }) }) });
    root.addIncludePath(b.path("include/"));

    const elf = b.addExecutable(.{
        .linkage = .static,
        .name = "hot.package.elf",
        .root_module = root,
    });
    elf.setLinkerScript(b.path("firmware/v5.ld"));
    elf.bundle_compiler_rt = true;
    elf.link_gc_sections = true;

    b.installArtifact(elf);
}