mirror of
https://github.com/ziglang/zig.git
synced 2024-11-13 23:52:57 +00:00
build.zig: add support for using "zig c++" as the bootstrap c++ compiler
The build was previously failing with `error: unknown command: -print-file-name=libstdc++.a` because the command invocation was `zig -print-file-name=libstdc++.a` instead of `zig c++ -print-file-name=libstdc++.a` note: .cxx_compiler_arg1 = "" instead of undefined to avoid breaking existing setups without requiring to run cmake again.
This commit is contained in:
parent
0afead5651
commit
69d6f2e1b8
15
build.zig
15
build.zig
@ -735,7 +735,11 @@ fn addCxxKnownPath(
|
||||
) !void {
|
||||
if (!std.process.can_spawn)
|
||||
return error.RequiredLibraryNotFound;
|
||||
const path_padded = b.exec(&.{ ctx.cxx_compiler, b.fmt("-print-file-name={s}", .{objname}) });
|
||||
|
||||
const path_padded = if (ctx.cxx_compiler_arg1.len > 0)
|
||||
b.exec(&.{ ctx.cxx_compiler, ctx.cxx_compiler_arg1, b.fmt("-print-file-name={s}", .{objname}) })
|
||||
else
|
||||
b.exec(&.{ ctx.cxx_compiler, b.fmt("-print-file-name={s}", .{objname}) });
|
||||
var tokenizer = mem.tokenizeAny(u8, path_padded, "\r\n");
|
||||
const path_unpadded = tokenizer.next().?;
|
||||
if (mem.eql(u8, path_unpadded, objname)) {
|
||||
@ -778,6 +782,7 @@ const CMakeConfig = struct {
|
||||
cmake_static_library_prefix: []const u8,
|
||||
cmake_static_library_suffix: []const u8,
|
||||
cxx_compiler: []const u8,
|
||||
cxx_compiler_arg1: []const u8,
|
||||
lld_include_dir: []const u8,
|
||||
lld_libraries: []const u8,
|
||||
clang_libraries: []const u8,
|
||||
@ -844,6 +849,7 @@ fn parseConfigH(b: *std.Build, config_h_text: []const u8) ?CMakeConfig {
|
||||
.cmake_static_library_prefix = undefined,
|
||||
.cmake_static_library_suffix = undefined,
|
||||
.cxx_compiler = undefined,
|
||||
.cxx_compiler_arg1 = "",
|
||||
.lld_include_dir = undefined,
|
||||
.lld_libraries = undefined,
|
||||
.clang_libraries = undefined,
|
||||
@ -875,6 +881,10 @@ fn parseConfigH(b: *std.Build, config_h_text: []const u8) ?CMakeConfig {
|
||||
.prefix = "#define ZIG_CXX_COMPILER ",
|
||||
.field = "cxx_compiler",
|
||||
},
|
||||
.{
|
||||
.prefix = "#define ZIG_CXX_COMPILER_ARG1 ",
|
||||
.field = "cxx_compiler_arg1",
|
||||
},
|
||||
.{
|
||||
.prefix = "#define ZIG_LLD_INCLUDE_PATH ",
|
||||
.field = "lld_include_dir",
|
||||
@ -917,7 +927,8 @@ fn parseConfigH(b: *std.Build, config_h_text: []const u8) ?CMakeConfig {
|
||||
var it = mem.splitScalar(u8, line, '"');
|
||||
_ = it.first(); // skip the stuff before the quote
|
||||
const quoted = it.next().?; // the stuff inside the quote
|
||||
@field(ctx, mapping.field) = toNativePathSep(b, quoted);
|
||||
const trimmed = mem.trim(u8, quoted, " ");
|
||||
@field(ctx, mapping.field) = toNativePathSep(b, trimmed);
|
||||
}
|
||||
}
|
||||
if (mem.startsWith(u8, line, "#define ZIG_LLVM_LINK_MODE ")) {
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define ZIG_CMAKE_STATIC_LIBRARY_PREFIX "@CMAKE_STATIC_LIBRARY_PREFIX@"
|
||||
#define ZIG_CMAKE_STATIC_LIBRARY_SUFFIX "@CMAKE_STATIC_LIBRARY_SUFFIX@"
|
||||
#define ZIG_CXX_COMPILER "@CMAKE_CXX_COMPILER@"
|
||||
#define ZIG_CXX_COMPILER_ARG1 "@CMAKE_CXX_COMPILER_ARG1@"
|
||||
#define ZIG_DIA_GUIDS_LIB "@ZIG_DIA_GUIDS_LIB_ESCAPED@"
|
||||
#define ZIG_LLD_INCLUDE_PATH "@LLD_INCLUDE_DIRS@"
|
||||
#define ZIG_LLD_LIBRARIES "@LLD_LIBRARIES@"
|
||||
|
Loading…
Reference in New Issue
Block a user