authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2022-10-12 18:11:46-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2022-10-12 18:11:46-04:00
log02d7292a8c1f478b77ef23dbe875b5443bba951c
treed8412c05815c00bdae296aae0a456df10ce2af22
parente78d7704a4fcde4e1851582212908b6762720216

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.

3 files changed, 18 insertions(+), 2 deletions(-)

build.zig+14
......@@ -554,6 +554,8 @@ fn addCmakeCfgOptionsToExe(
554554 }) catch unreachable);
555555 assert(cfg.lld_include_dir.len != 0);
556556 exe.addIncludePath(cfg.lld_include_dir);
557 exe.addIncludePath(cfg.llvm_include_dir);
558 exe.addLibraryPath(cfg.llvm_lib_dir);
557559 addCMakeLibraryList(exe, cfg.clang_libraries);
558560 addCMakeLibraryList(exe, cfg.lld_libraries);
559561 addCMakeLibraryList(exe, cfg.llvm_libraries);
......@@ -684,6 +686,8 @@ const CMakeConfig = struct {
684686 lld_include_dir: []const u8,
685687 lld_libraries: []const u8,
686688 clang_libraries: []const u8,
689 llvm_lib_dir: []const u8,
690 llvm_include_dir: []const u8,
687691 llvm_libraries: []const u8,
688692 dia_guids_lib: []const u8,
689693};
......@@ -745,6 +749,8 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig {
745749 .lld_include_dir = undefined,
746750 .lld_libraries = undefined,
747751 .clang_libraries = undefined,
752 .llvm_lib_dir = undefined,
753 .llvm_include_dir = undefined,
748754 .llvm_libraries = undefined,
749755 .dia_guids_lib = undefined,
750756 };
......@@ -782,6 +788,14 @@ fn parseConfigH(b: *Builder, config_h_text: []const u8) ?CMakeConfig {
782788 .prefix = "#define ZIG_DIA_GUIDS_LIB ",
783789 .field = "dia_guids_lib",
784790 },
791 .{
792 .prefix = "#define ZIG_LLVM_INCLUDE_PATH ",
793 .field = "llvm_include_dir",
794 },
795 .{
796 .prefix = "#define ZIG_LLVM_LIB_PATH ",
797 .field = "llvm_lib_dir",
798 },
785799 // .prefix = ZIG_LLVM_LINK_MODE parsed manually below
786800 };
787801
lib/std/math/big/int.zig+2-2
......@@ -399,7 +399,7 @@ pub const Mutable = struct {
399399 // use calcTwosCompLimbCount for a non-comptime_int scalar, which can be pessimistic
400400 // in the case that scalar happens to be small in magnitude within its type, but it
401401 // is well worth being able to use the stack and not needing an allocator passed in.
402 // Note that Mutable.init still sets operand.len to calcLimbLen(scalar) in any case.
402 // Note that Mutable.init still sets len to calcLimbLen(scalar) in any case.
403403 const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) {
404404 .ComptimeInt => calcLimbLen(scalar),
405405 .Int => |info| calcTwosCompLimbCount(info.bits),
......@@ -2322,7 +2322,7 @@ pub const Const = struct {
23222322 // use calcTwosCompLimbCount for a non-comptime_int scalar, which can be pessimistic
23232323 // in the case that scalar happens to be small in magnitude within its type, but it
23242324 // is well worth being able to use the stack and not needing an allocator passed in.
2325 // Note that Mutable.init still sets rhs.len to calcLimbLen(scalar) in any case.
2325 // Note that Mutable.init still sets len to calcLimbLen(scalar) in any case.
23262326 const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) {
23272327 .ComptimeInt => calcLimbLen(scalar),
23282328 .Int => |info| calcTwosCompLimbCount(info.bits),
src/stage1/config.h.in+2
......@@ -22,6 +22,8 @@
2222#define ZIG_LLD_INCLUDE_PATH "@LLD_INCLUDE_DIRS@"
2323#define ZIG_LLD_LIBRARIES "@LLD_LIBRARIES@"
2424#define ZIG_CLANG_LIBRARIES "@CLANG_LIBRARIES@"
25#define ZIG_LLVM_INCLUDE_PATH "@LLVM_INCLUDE_DIRS@"
26#define ZIG_LLVM_LIB_PATH "@LLVM_LIBDIRS@"
2527#define ZIG_LLVM_LIBRARIES "@LLVM_LIBRARIES@"
2628#define ZIG_DIA_GUIDS_LIB "@ZIG_DIA_GUIDS_LIB_ESCAPED@"
2729