diff --git a/build.zig b/build.zig index 31347f8e7e..220c9760f7 100644 --- a/build.zig +++ b/build.zig @@ -660,6 +660,7 @@ fn addCMakeLibraryList(exe: *std.build.LibExeObjStep, list: []const u8) void { } const CMakeConfig = struct { + llvm_linkage: std.build.LibExeObjStep.Linkage, cmake_binary_dir: []const u8, cmake_prefix_path: []const u8, cxx_compiler: []const u8, @@ -698,6 +699,7 @@ fn findAndParseConfigH(b: *Builder, config_h_path_option: ?[]const u8) ?CMakeCon }; var ctx: CMakeConfig = .{ + .llvm_linkage = undefined, .cmake_binary_dir = undefined, .cmake_prefix_path = undefined, .cxx_compiler = undefined, @@ -741,6 +743,7 @@ fn findAndParseConfigH(b: *Builder, config_h_path_option: ?[]const u8) ?CMakeCon .prefix = "#define ZIG_DIA_GUIDS_LIB ", .field = "dia_guids_lib", }, + // .prefix = ZIG_LLVM_LINK_MODE parsed manually below }; 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 @field(ctx, mapping.field) = toNativePathSep(b, quoted); } } + if (mem.startsWith(u8, line, "#define ZIG_LLVM_LINK_MODE ")) { + var it = mem.split(u8, line, "\""); + _ = it.next().?; // skip the stuff before the quote + const quoted = it.next().?; // the stuff inside the quote + ctx.llvm_linkage = if (mem.eql(u8, quoted, "shared")) .dynamic else .static; + } } return ctx; } diff --git a/src/stage1/config.h.in b/src/stage1/config.h.in index 4d375652ff..2be0839996 100644 --- a/src/stage1/config.h.in +++ b/src/stage1/config.h.in @@ -16,6 +16,7 @@ // Used by build.zig for communicating build information to self hosted build. #define ZIG_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@" +#define ZIG_LLVM_LINK_MODE "@LLVM_LINK_MODE@" #define ZIG_CMAKE_PREFIX_PATH "@CMAKE_PREFIX_PATH@" #define ZIG_CXX_COMPILER "@CMAKE_CXX_COMPILER@" #define ZIG_LLD_INCLUDE_PATH "@LLD_INCLUDE_DIRS@"