Skip to content

Commit

Permalink
build: only add llvm library path if its not a native path
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan200101 committed Nov 8, 2023
1 parent c523058 commit 3df62ed
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const fs = std.fs;
const InstallDirectoryOptions = std.Build.InstallDirectoryOptions;
const assert = std.debug.assert;
const GenerateDef = @import("deps/aro/build/GenerateDef.zig");
const NativePaths = std.zig.system.NativePaths;

const zig_version = std.SemanticVersion{ .major = 0, .minor = 12, .patch = 0 };
const stack_size = 32 * 1024 * 1024;
Expand Down Expand Up @@ -633,10 +634,25 @@ fn addCmakeCfgOptionsToExe(
cfg.cmake_static_library_suffix,
}),
}) });

const add_llvm_lib_dir = blk: {
const native_paths = NativePaths.detect(b.allocator, exe.target_info) catch {
break :blk true;
};

for (native_paths.lib_dirs.items) |lib_dir| {
if (mem.eql(u8, lib_dir, cfg.llvm_lib_dir))
break :blk false;
}

break :blk true;
};

assert(cfg.lld_include_dir.len != 0);
exe.addIncludePath(.{ .cwd_relative = cfg.lld_include_dir });
exe.addIncludePath(.{ .cwd_relative = cfg.llvm_include_dir });
exe.addLibraryPath(.{ .cwd_relative = cfg.llvm_lib_dir });
if (add_llvm_lib_dir)
exe.addLibraryPath(.{ .cwd_relative = cfg.llvm_lib_dir });
addCMakeLibraryList(exe, cfg.clang_libraries);
addCMakeLibraryList(exe, cfg.lld_libraries);
addCMakeLibraryList(exe, cfg.llvm_libraries);
Expand Down

0 comments on commit 3df62ed

Please sign in to comment.