-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavioros-windows
Milestone
Description
Zig Version
0.11.0-dev.2298+5d63d1115
Steps to Reproduce and Observed Behavior
Operating System: Windows 10 Home 19045.2728
- Run
zig build
If you replace addSharedLibrary
with addStaticLibrary
, there are no errors.
zig build-exe sandbox Debug native: error: the following command failed with 1 compilation errors:
C:\Users\Personal\Programs\bin\zig\0.11.0-dev.2298+5d63d1115\files\zig.exe build-exe W:\c\duplicate_symbol_repro\source\main.c W:\c\duplicate_symbol_repro\zig-cache\o\068335d453b8dd6ae99ff5e57fc2a431\lib.lib -lc --cache-dir W:\c\duplicate_symbol_repro\zig-
cache --global-cache-dir C:\Users\Personal\AppData\Local\zig --name sandbox --enable-cache --listen=-
Build Summary: 1/4 steps succeeded; 1 failed (disable with -fno-summary)
install transitive failure
+- install sandbox transitive failure
+- zig build-exe sandbox Debug native 1 errors
+- zig build-lib lib Debug native success 1s MaxRSS:32M
error: lld-link: duplicate symbol: ___chkstk_ms
note: defined at compiler_rt.lib(compiler_rt.lib.obj)
note: defined at lib.dll
// build.zig
const std = @import("std");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const mode = b.standardOptimizeOption(.{});
const lib = b.addSharedLibrary(.{
.name = "lib",
.target = target,
.optimize = mode,
});
lib.addCSourceFile("source/lib.c", &.{});
lib.linkLibC();
const exe = b.addExecutable(.{
.name = "sandbox",
.target = target,
.optimize = mode,
});
exe.addCSourceFile("source/main.c", &.{});
exe.linkLibC();
exe.linkLibrary(lib);
exe.install();
const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}
// source/main.c
#include "lib.h"
int
main(void)
{
greeter("Fletcher");
return 0;
}
// source/lib.h
#if !defined(LIB_H)
#define LIB_H
void greeter(const char* name);
#endif // LIB_H
// source/lib.c
#include "lib.h"
#include <stdio.h>
void greeter(const char* name)
{
printf("Hello, %s!\n", name);
}
Expected Behavior
Compile with no warnings and errors.
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavioros-windows