Hello!
I’ve recently been trying to compile the raspberry pi pico sdk using zig instead of cmake, but I’ve run into an error where they use a linker script that includes another linker script via the normal “INCLUDE” syntax.
Specifically the script is memmap_default.ld, and I’m trying to auto-generate the “pico_flash_region.ld” script.
This is a little snippet of my build.zig:
const ldscript = try this.ldscript_gen_step(b);
firmobj.step.dependOn(&ldscript.step);
firmobj.root_module.addLibraryPath(ldscript.getDirectory());
firmobj.setVerboseLink(true);
// And set it
firmobj.setLinkerScript(try this.repo_root.join(b.allocator, try std.fmt.allocPrint(b.allocator, "src/rp2_common/pico_crt0/{s}/memmap_default.ld", .{@tagName(platform_by_board(this.board))})));
Where this.ldscript_gen_step(b) just returns a Step.WriteFile.
The output of the verbose link is:
ld.lld -r --error-limit=0 -mllvm -target-abi=aapcs -mllvm -float-abi=soft --build-id=none --image-base=65536 -T /Users/phitch/Purdue/microprocessor362/ta/pico-sdk/src/rp2_common/pico_crt0/rp2350/memmap_default.ld --eh-frame-hdr -znow -m armelf -Bstatic -o [output + all the input ofiles...]
So I think the Library is just not getting passed to the linker, however the “zig build-obj” command that gets printed includes the “-L .zig-cache/o/[big-hash]” flag, and I’ve verified that directory contains the correct “pico_flash_region.ld” file.
Any guidance would be appreciated! I saw some stuff in std’s Compile.zig around line 1700 about ommitting flags but that’s the only lead I have rn and it doesn’t look like it pertains to the linker, just zig build-obj.
I’m on macos running 0.15.1 (tried 0.15.2 too) if that helps.