Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross platform compilation error for Zmpl templates #42

Open
NPatel10 opened this issue Mar 28, 2025 · 1 comment
Open

Cross platform compilation error for Zmpl templates #42

NPatel10 opened this issue Mar 28, 2025 · 1 comment

Comments

@NPatel10
Copy link

I am having problem cross compiling Zmpl from one platform (windows) to another (x86_64-linux-gnu).

Steps to reproduce:

  1. Create a zmpl project with some zmpl template.
  2. use zig build install -Dtarget=x86_64-linux-gnu to compile the zig code. this will generate error.

Expected result

  • Above command should run without any error.
@NPatel10
Copy link
Author

One possible solution to this problem is using host target for manifest executable. So in build.zig instead of

const manifest_exe = b.addExecutable(.{
      .name = "manifest",
      .root_source_file = b.path("src/manifest/main.zig"),
      .target = target,
      .optimize = optimize,
      .use_llvm = use_llvm,
});

using below code resolves issue

const manifest_exe = b.addExecutable(.{
      .name = "manifest",
      .root_source_file = b.path("src/manifest/main.zig"),
      .target = b.graph.host, // <------------------------- Changed this
      .optimize = optimize,
      .use_llvm = use_llvm,
});

This works because manifest executable runs during build process to convert zmpl templates to zig functions. There for it's target should always be native.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant