I’m trying to upgrade the project ZigAndroidTemplate
to zig 0.12 and/or 0.13 and running into a problem when linking. I get about 300 of these errors:
error: ld.lld: relocation R_386_PC32 cannot be used against symbol '__multf3'; recompile with -fPIC
note: defined in /home/mark/.cache/zig/o/7c9d17811c5bad22da853bfbd92be439/libcompiler_rt.a(/home/mark/.cache/zig/o/7c9d17811c5bad22da853bfbd92be439/libcompiler_rt.a.o)
note: referenced by divc3.zig:54 (/home/mark/Projects/zig/zig-linux-x86_64-0.13.0/lib/compiler_rt/divc3.zig:54)
note: /home/mark/.cache/zig/o/7c9d17811c5bad22da853bfbd92be439/libcompiler_rt.a.o:(__divtc3) in archive /home/mark/.cache/zig/o/7c9d17811c5bad22da853bfbd92be439/libcompiler_rt.a
This doesn’t seem to happen with 0.12, only with 0.13 (but 0.12 doesn’t build for other reasons, so maybe I’m just not making it to this step.
I added .pic = true
in the one spot I could find - in SDK.zig:
const exe = sdk.b.addSharedLibrary(.{
.name = app_config.app_name,
.root_source_file = .{ .cwd_relative = src_file },
.target = sdk.b.resolveTargetQuery(
config.target,
),
.pic = true,
These errors go away if I don’t compile for android x86.
My second issue - now that I’ve disabled x86 builds - is I can’t seem to turn a GeneratedFile
into a LazyPath
pub fn getOutputDirectory(self: *Self) std.Build.LazyPath {
return .{ .generated = &self.directory };
}
This now gives me a compile error:
/home/mark/Projects/zig/ZigAndroidTemplate_mark/Sdk.zig:745:32: error: expected type 'Build.LazyPath.LazyPath__struct_6125', found pointer
return .{ .generated = &self.directory };
^
/home/mark/Projects/zig/ZigAndroidTemplate_mark/Sdk.zig:745:32: note: address-of operator always returns a pointer
Taking away the pointer yields:
error: expected type 'Build.LazyPath.LazyPath__struct_6125', found 'Build.GeneratedFile
Any help figuring out these 2 issues would be appreciated.