@@ -246,6 +246,7 @@ pub fn build(b: *std.Build) !void {
246
246
const llvm_minor = try std .fmt .parseUnsigned (u8 , llvm_version_iter .next ().? , 10 );
247
247
const llvm_bin_dir = std .mem .trimRight (u8 , b .run (&.{ "llvm-config" , "--bindir" }), "\n " );
248
248
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 };
249
250
llvm_c_flags .appendSliceAssumeCapacity (&.{
250
251
lib_path_flag ,
251
252
bin_path_flag ,
@@ -335,6 +336,7 @@ pub fn build(b: *std.Build) !void {
335
336
const llvm_libs_step = b .step ("llvm_libs" , "Install LLVM instrumentation library suite" );
336
337
337
338
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.. ];
338
340
const llvm_inc_path = std.Build.LazyPath { .cwd_relative = llvm_inc_dir };
339
341
340
342
const llvm_common_obj = b .addObject (.{
@@ -349,6 +351,8 @@ pub fn build(b: *std.Build) !void {
349
351
});
350
352
llvm_common_obj .addIncludePath (AFLplusplus_inc_path );
351
353
llvm_common_obj .addIncludePath (llvm_inc_path );
354
+ llvm_common_obj .addLibraryPath (llvm_lib_path );
355
+ llvm_common_obj .linkSystemLibrary (llvm_name );
352
356
llvm_common_obj .linkLibCpp ();
353
357
354
358
var llvm_lib_names = std .BoundedArray ([]const u8 , 16 ){};
@@ -374,6 +378,8 @@ pub fn build(b: *std.Build) !void {
374
378
});
375
379
lib .addIncludePath (AFLplusplus_inc_path );
376
380
lib .addIncludePath (llvm_inc_path );
381
+ lib .addLibraryPath (llvm_lib_path );
382
+ lib .linkSystemLibrary (llvm_name );
377
383
lib .addObject (llvm_common_obj );
378
384
lib .linkLibCpp ();
379
385
@@ -401,6 +407,8 @@ pub fn build(b: *std.Build) !void {
401
407
});
402
408
cc_exe .addIncludePath (AFLplusplus_inc_path );
403
409
cc_exe .addIncludePath (AFLplusplus_ins_path );
410
+ cc_exe .addLibraryPath (llvm_lib_path );
411
+ cc_exe .linkSystemLibrary (llvm_name );
404
412
cc_exe .addObject (common_obj );
405
413
cc_exe .linkLibC ();
406
414
0 commit comments