authorgravatar for topolarity@tapscott.meCody Tapscott <topolarity@tapscott.me> 2022-07-23 09:02:51-07:00
committergravatar for topolarity@tapscott.meCody Tapscott <topolarity@tapscott.me> 2022-07-23 09:03:19-07:00
log5337934bcd174987e813e192cb5ef173c13eff37
tree3bc5787c229bd477068e82891803d6d187403e48
parent4113a790b0da56d7081aca52d0ca4e349d27a6a1

CMake: Add ZIG_LLVM_LINK_MODE to config.h

This is currently unused, but it will be needed soon so that we can avoid linking static libc++ if LLVM/Clang is configured as a shared library.

2 files changed, 10 insertions(+), 0 deletions(-)

build.zig+9
...@@ -660,6 +660,7 @@ fn addCMakeLibraryList(exe: *std.build.LibExeObjStep, list: []const u8) void {...@@ -660,6 +660,7 @@ fn addCMakeLibraryList(exe: *std.build.LibExeObjStep, list: []const u8) void {
660}660}
661661
662const CMakeConfig = struct {662const CMakeConfig = struct {
663 llvm_linkage: std.build.LibExeObjStep.Linkage,
663 cmake_binary_dir: []const u8,664 cmake_binary_dir: []const u8,
664 cmake_prefix_path: []const u8,665 cmake_prefix_path: []const u8,
665 cxx_compiler: []const u8,666 cxx_compiler: []const u8,
...@@ -698,6 +699,7 @@ fn findAndParseConfigH(b: *Builder, config_h_path_option: ?[]const u8) ?CMakeCon...@@ -698,6 +699,7 @@ fn findAndParseConfigH(b: *Builder, config_h_path_option: ?[]const u8) ?CMakeCon
698 };699 };
699700
700 var ctx: CMakeConfig = .{701 var ctx: CMakeConfig = .{
702 .llvm_linkage = undefined,
701 .cmake_binary_dir = undefined,703 .cmake_binary_dir = undefined,
702 .cmake_prefix_path = undefined,704 .cmake_prefix_path = undefined,
703 .cxx_compiler = undefined,705 .cxx_compiler = undefined,
...@@ -741,6 +743,7 @@ fn findAndParseConfigH(b: *Builder, config_h_path_option: ?[]const u8) ?CMakeCon...@@ -741,6 +743,7 @@ fn findAndParseConfigH(b: *Builder, config_h_path_option: ?[]const u8) ?CMakeCon
741 .prefix = "#define ZIG_DIA_GUIDS_LIB ",743 .prefix = "#define ZIG_DIA_GUIDS_LIB ",
742 .field = "dia_guids_lib",744 .field = "dia_guids_lib",
743 },745 },
746 // .prefix = ZIG_LLVM_LINK_MODE parsed manually below
744 };747 };
745748
746 var lines_it = mem.tokenize(u8, config_h_text, "\r\n");749 var lines_it = mem.tokenize(u8, config_h_text, "\r\n");
...@@ -753,6 +756,12 @@ fn findAndParseConfigH(b: *Builder, config_h_path_option: ?[]const u8) ?CMakeCon...@@ -753,6 +756,12 @@ fn findAndParseConfigH(b: *Builder, config_h_path_option: ?[]const u8) ?CMakeCon
753 @field(ctx, mapping.field) = toNativePathSep(b, quoted);756 @field(ctx, mapping.field) = toNativePathSep(b, quoted);
754 }757 }
755 }758 }
759 if (mem.startsWith(u8, line, "#define ZIG_LLVM_LINK_MODE ")) {
760 var it = mem.split(u8, line, "\"");
761 _ = it.next().?; // skip the stuff before the quote
762 const quoted = it.next().?; // the stuff inside the quote
763 ctx.llvm_linkage = if (mem.eql(u8, quoted, "shared")) .dynamic else .static;
764 }
756 }765 }
757 return ctx;766 return ctx;
758}767}
src/stage1/config.h.in+1
...@@ -16,6 +16,7 @@...@@ -16,6 +16,7 @@
1616
17// Used by build.zig for communicating build information to self hosted build.17// Used by build.zig for communicating build information to self hosted build.
18#define ZIG_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@"18#define ZIG_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@"
19#define ZIG_LLVM_LINK_MODE "@LLVM_LINK_MODE@"
19#define ZIG_CMAKE_PREFIX_PATH "@CMAKE_PREFIX_PATH@"20#define ZIG_CMAKE_PREFIX_PATH "@CMAKE_PREFIX_PATH@"
20#define ZIG_CXX_COMPILER "@CMAKE_CXX_COMPILER@"21#define ZIG_CXX_COMPILER "@CMAKE_CXX_COMPILER@"
21#define ZIG_LLD_INCLUDE_PATH "@LLD_INCLUDE_DIRS@"22#define ZIG_LLD_INCLUDE_PATH "@LLD_INCLUDE_DIRS@"