@@ -7567,45 +7567,46 @@ fn handleExternLibName(
75677567) CompileError![:0]u8 {
75687568 blk: {
75697569 const mod = sema.mod;
7570+ const comp = mod.comp;
75707571 const target = mod.getTarget();
75717572 log.debug("extern fn symbol expected in lib '{s}'", .{lib_name});
75727573 if (target_util.is_libc_lib_name(target, lib_name)) {
7573- if (!mod. comp.bin_file.options.link_libc) {
7574+ if (!comp.bin_file.options.link_libc and !comp.bin_file.options.parent_compilation_link_libc ) {
75747575 return sema.fail(
75757576 block,
75767577 src_loc,
75777578 "dependency on libc must be explicitly specified in the build command",
75787579 .{},
75797580 );
75807581 }
7581- mod. comp.bin_file.options.link_libc = true;
7582+ comp.bin_file.options.link_libc = true;
75827583 break :blk;
75837584 }
75847585 if (target_util.is_libcpp_lib_name(target, lib_name)) {
7585- if (!mod. comp.bin_file.options.link_libcpp) {
7586+ if (!comp.bin_file.options.link_libcpp) {
75867587 return sema.fail(
75877588 block,
75887589 src_loc,
75897590 "dependency on libc++ must be explicitly specified in the build command",
75907591 .{},
75917592 );
75927593 }
7593- mod. comp.bin_file.options.link_libcpp = true;
7594+ comp.bin_file.options.link_libcpp = true;
75947595 break :blk;
75957596 }
75967597 if (mem.eql(u8, lib_name, "unwind")) {
7597- mod. comp.bin_file.options.link_libunwind = true;
7598+ comp.bin_file.options.link_libunwind = true;
75987599 break :blk;
75997600 }
7600- if (!target.isWasm() and !mod. comp.bin_file.options.pic) {
7601+ if (!target.isWasm() and !comp.bin_file.options.pic) {
76017602 return sema.fail(
76027603 block,
76037604 src_loc,
76047605 "dependency on dynamic library '{s}' requires enabling Position Independent Code. Fixed by `-l{s}` or `-fPIC`.",
76057606 .{ lib_name, lib_name },
76067607 );
76077608 }
7608- mod. comp.stage1AddLinkLib(lib_name) catch |err| {
7609+ comp.stage1AddLinkLib(lib_name) catch |err| {
76097610 return sema.fail(block, src_loc, "unable to add link lib '{s}': {s}", .{
76107611 lib_name, @errorName(err),
76117612 });
0 commit comments