Good question - I recently ran into some weird behavior with printing from device kernels so maybe (very unlikely) there’s something I can connect here.
Looking at the debug call, I found that it writes to stdErr:
/// Print to stderr, unbuffered, and silently returning on failure. Intended
/// for use in "printf debugging." Use `std.log` functions for proper logging.
pub fn print(comptime fmt: []const u8, args: anytype) void {
stderr_mutex.lock();
defer stderr_mutex.unlock();
const stderr = io.getStdErr().writer();
nosuspend stderr.print(fmt, args) catch return;
}
It also looks like logging functions write to stdErr by default:
As soon as I put the -femit-h or getEmittedH() to generate the header, the build process gets terminated. Without those options, I could create the object file (well, no header file).
I was able to build a static library object and a header file by adding the linkLibC function in my build.zig file.
I tried to use it from Go, but got a bunch of error since it doesn’t know where the zig.h is. I added to link it, then it says ZIG_TARGET_MAX_INT_ALIGNMENT is undeclared.
I guess being able to build my code as library is the very first step, and now I need to dig deeper to do more. Since now I can generate the header that can print (zig-zig situation, not go-zig situation), let me close this topic.