mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
build.zig: Forward LLVM lib/include dirs from CMake
Previously, you might obtain `-lLLVM-15` from the CMake configuration, but we might not be able to locate the library if it's not in your system library path.
This commit is contained in:
parent
e78d7704a4
commit
02d7292a8c
3 changed files with 18 additions and 2 deletions
14
build.zig
14
build.zig
|
|
@ -554,6 +554,8 @@ fn addCmakeCfgOptionsToExe(
|
||||||
}) catch unreachable);
|
}) catch unreachable);
|
||||||
assert(cfg.lld_include_dir.len != 0);
|
assert(cfg.lld_include_dir.len != 0);
|
||||||
exe.addIncludePath(cfg.lld_include_dir);
|
exe.addIncludePath(cfg.lld_include_dir);
|
||||||
|
exe.addIncludePath(cfg.llvm_include_dir);
|
||||||
|
exe.addLibraryPath(cfg.llvm_lib_dir);
|
||||||
addCMakeLibraryList(exe, cfg.clang_libraries);
|
addCMakeLibraryList(exe, cfg.clang_libraries);
|
||||||
addCMakeLibraryList(exe, cfg.lld_libraries);
|
addCMakeLibraryList(exe, cfg.lld_libraries);
|
||||||
addCMakeLibraryList(exe, cfg.llvm_libraries);
|
addCMakeLibraryList(exe, cfg.llvm_libraries);
|
||||||
|
|
@ -684,6 +686,8 @@ const CMakeConfig = struct {
|
||||||
lld_include_dir: []const u8,
|
lld_include_dir: []const u8,
|
||||||
lld_libraries: []const u8,
|
lld_libraries: []const u8,
|
||||||
clang_libraries: []const u8,
|
clang_libraries: []const u8,
|
||||||
|
llvm_lib_dir: []const u8,
|
||||||
|
llvm_include_dir: []const u8,
|
||||||
llvm_libraries: []const u8,
|
llvm_libraries: []const u8,
|
||||||
dia_guids_lib: []const u8,
|
dia_guids_lib: []const u8,
|
||||||
};
|
};
|
||||||
|
|
@ -745,6 +749,8 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig {
|
||||||
.lld_include_dir = undefined,
|
.lld_include_dir = undefined,
|
||||||
.lld_libraries = undefined,
|
.lld_libraries = undefined,
|
||||||
.clang_libraries = undefined,
|
.clang_libraries = undefined,
|
||||||
|
.llvm_lib_dir = undefined,
|
||||||
|
.llvm_include_dir = undefined,
|
||||||
.llvm_libraries = undefined,
|
.llvm_libraries = undefined,
|
||||||
.dia_guids_lib = undefined,
|
.dia_guids_lib = undefined,
|
||||||
};
|
};
|
||||||
|
|
@ -782,6 +788,14 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig {
|
||||||
.prefix = "#define ZIG_DIA_GUIDS_LIB ",
|
.prefix = "#define ZIG_DIA_GUIDS_LIB ",
|
||||||
.field = "dia_guids_lib",
|
.field = "dia_guids_lib",
|
||||||
},
|
},
|
||||||
|
.{
|
||||||
|
.prefix = "#define ZIG_LLVM_INCLUDE_PATH ",
|
||||||
|
.field = "llvm_include_dir",
|
||||||
|
},
|
||||||
|
.{
|
||||||
|
.prefix = "#define ZIG_LLVM_LIB_PATH ",
|
||||||
|
.field = "llvm_lib_dir",
|
||||||
|
},
|
||||||
// .prefix = ZIG_LLVM_LINK_MODE parsed manually below
|
// .prefix = ZIG_LLVM_LINK_MODE parsed manually below
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -399,7 +399,7 @@ pub const Mutable = struct {
|
||||||
// use calcTwosCompLimbCount for a non-comptime_int scalar, which can be pessimistic
|
// use calcTwosCompLimbCount for a non-comptime_int scalar, which can be pessimistic
|
||||||
// in the case that scalar happens to be small in magnitude within its type, but it
|
// in the case that scalar happens to be small in magnitude within its type, but it
|
||||||
// is well worth being able to use the stack and not needing an allocator passed in.
|
// is well worth being able to use the stack and not needing an allocator passed in.
|
||||||
// Note that Mutable.init still sets operand.len to calcLimbLen(scalar) in any case.
|
// Note that Mutable.init still sets len to calcLimbLen(scalar) in any case.
|
||||||
const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) {
|
const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) {
|
||||||
.ComptimeInt => calcLimbLen(scalar),
|
.ComptimeInt => calcLimbLen(scalar),
|
||||||
.Int => |info| calcTwosCompLimbCount(info.bits),
|
.Int => |info| calcTwosCompLimbCount(info.bits),
|
||||||
|
|
@ -2322,7 +2322,7 @@ pub const Const = struct {
|
||||||
// use calcTwosCompLimbCount for a non-comptime_int scalar, which can be pessimistic
|
// use calcTwosCompLimbCount for a non-comptime_int scalar, which can be pessimistic
|
||||||
// in the case that scalar happens to be small in magnitude within its type, but it
|
// in the case that scalar happens to be small in magnitude within its type, but it
|
||||||
// is well worth being able to use the stack and not needing an allocator passed in.
|
// is well worth being able to use the stack and not needing an allocator passed in.
|
||||||
// Note that Mutable.init still sets rhs.len to calcLimbLen(scalar) in any case.
|
// Note that Mutable.init still sets len to calcLimbLen(scalar) in any case.
|
||||||
const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) {
|
const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) {
|
||||||
.ComptimeInt => calcLimbLen(scalar),
|
.ComptimeInt => calcLimbLen(scalar),
|
||||||
.Int => |info| calcTwosCompLimbCount(info.bits),
|
.Int => |info| calcTwosCompLimbCount(info.bits),
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@
|
||||||
#define ZIG_LLD_INCLUDE_PATH "@LLD_INCLUDE_DIRS@"
|
#define ZIG_LLD_INCLUDE_PATH "@LLD_INCLUDE_DIRS@"
|
||||||
#define ZIG_LLD_LIBRARIES "@LLD_LIBRARIES@"
|
#define ZIG_LLD_LIBRARIES "@LLD_LIBRARIES@"
|
||||||
#define ZIG_CLANG_LIBRARIES "@CLANG_LIBRARIES@"
|
#define ZIG_CLANG_LIBRARIES "@CLANG_LIBRARIES@"
|
||||||
|
#define ZIG_LLVM_INCLUDE_PATH "@LLVM_INCLUDE_DIRS@"
|
||||||
|
#define ZIG_LLVM_LIB_PATH "@LLVM_LIBDIRS@"
|
||||||
#define ZIG_LLVM_LIBRARIES "@LLVM_LIBRARIES@"
|
#define ZIG_LLVM_LIBRARIES "@LLVM_LIBRARIES@"
|
||||||
#define ZIG_DIA_GUIDS_LIB "@ZIG_DIA_GUIDS_LIB_ESCAPED@"
|
#define ZIG_DIA_GUIDS_LIB "@ZIG_DIA_GUIDS_LIB_ESCAPED@"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue