Zig Version
0.15.2
Steps to Reproduce and Observed Behavior
The build failed silently.
dmesg shows:

lldb:

build.zig
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const hello = b.addObject(.{
.name = "hello",
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libcpp = true,
}),
});
hello.root_module.addCSourceFiles(.{
.files = &.{
"foo.cpp",
"bar.cpp",
},
});
hello.root_module.addIncludePath(.{
.cwd_relative = ".",
});
const exe = b.addExecutable(.{
.name = "lca",
.root_module = b.createModule(.{
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
.link_libcpp = true,
.imports = &.{},
}),
// .use_llvm = true,
});
exe.root_module.addObject(hello);
exe.root_module.addIncludePath(.{
.cwd_relative = ".",
});
b.installArtifact(exe);
}
foo.cpp
#include "foo.h"
#include <string>
#include <vector>
void foo() { std::vector<std::string> keys{"xxx", "yyy"}; }
foo.h
#ifndef _FOO_H_
#define _FOO_H_
#ifdef __cplusplus
extern "C" {
#endif
void foo();
#ifdef __cplusplus
}
#endif
#endif
bar.cpp (similar to foo.cpp)
#include "bar.h"
#include <string>
#include <vector>
void bar() { std::vector<std::string> keys{"xxx", "yyy"}; }
bar.h
#ifndef _BAR_H_
#define _BAR_H_
#ifdef __cplusplus
extern "C" {
#endif
void bar();
#ifdef __cplusplus
}
#endif
#endif
main.zig
const std = @import("std");
pub fn main() void {
std.debug.print("Hello, World!\n", .{});
}
Using .use_llvm=true or removing one of foo.cpp and bar.cpp from build.zig can fix this.
Expected Behavior
No error
Zig Version
0.15.2
Steps to Reproduce and Observed Behavior
The build failed silently.
dmesg shows:

lldb:

build.zig
foo.cpp
foo.h
bar.cpp (similar to foo.cpp)
bar.h
main.zig
Using
.use_llvm=trueor removing one of foo.cpp and bar.cpp from build.zig can fix this.Expected Behavior
No error