@@ -246,6 +246,7 @@ pub fn build(b: *std.Build) !void {
246246 const llvm_minor = try std .fmt .parseUnsigned (u8 , llvm_version_iter .next ().? , 10 );
247247 const llvm_bin_dir = std .mem .trimRight (u8 , b .run (&.{ "llvm-config" , "--bindir" }), "\n " );
248248 const llvm_lib_dir = std .mem .trimRight (u8 , b .run (&.{ "llvm-config" , "--libdir" }), "\n " );
249+ const llvm_lib_path = std.Build.LazyPath { .cwd_relative = llvm_lib_dir };
249250 llvm_c_flags .appendSliceAssumeCapacity (&.{
250251 lib_path_flag ,
251252 bin_path_flag ,
@@ -335,6 +336,7 @@ pub fn build(b: *std.Build) !void {
335336 const llvm_libs_step = b .step ("llvm_libs" , "Install LLVM instrumentation library suite" );
336337
337338 const llvm_inc_dir = std .mem .trimRight (u8 , b .run (&.{ "llvm-config" , "--includedir" }), "\n " );
339+ const llvm_name = std .mem .trimRight (u8 , b .run (&.{ "llvm-config" , "--libs" }), "\n " )[2.. ];
338340 const llvm_inc_path = std.Build.LazyPath { .cwd_relative = llvm_inc_dir };
339341
340342 const llvm_common_obj = b .addObject (.{
@@ -349,6 +351,8 @@ pub fn build(b: *std.Build) !void {
349351 });
350352 llvm_common_obj .addIncludePath (AFLplusplus_inc_path );
351353 llvm_common_obj .addIncludePath (llvm_inc_path );
354+ llvm_common_obj .addLibraryPath (llvm_lib_path );
355+ llvm_common_obj .linkSystemLibrary (llvm_name );
352356 llvm_common_obj .linkLibCpp ();
353357
354358 var llvm_lib_names = std .BoundedArray ([]const u8 , 16 ){};
@@ -374,6 +378,8 @@ pub fn build(b: *std.Build) !void {
374378 });
375379 lib .addIncludePath (AFLplusplus_inc_path );
376380 lib .addIncludePath (llvm_inc_path );
381+ lib .addLibraryPath (llvm_lib_path );
382+ lib .linkSystemLibrary (llvm_name );
377383 lib .addObject (llvm_common_obj );
378384 lib .linkLibCpp ();
379385
@@ -401,6 +407,8 @@ pub fn build(b: *std.Build) !void {
401407 });
402408 cc_exe .addIncludePath (AFLplusplus_inc_path );
403409 cc_exe .addIncludePath (AFLplusplus_ins_path );
410+ cc_exe .addLibraryPath (llvm_lib_path );
411+ cc_exe .linkSystemLibrary (llvm_name );
404412 cc_exe .addObject (common_obj );
405413 cc_exe .linkLibC ();
406414
0 commit comments