| ... | @@ -5567,11 +5567,6 @@ fn funcCommon( | ... | @@ -5567,11 +5567,6 @@ fn funcCommon( |
| 5567 | if (opt_lib_name) |lib_name| blk: { | 5567 | if (opt_lib_name) |lib_name| blk: { |
| 5568 | const lib_name_src: LazySrcLoc = .{ .node_offset_lib_name = src_node_offset }; | 5568 | const lib_name_src: LazySrcLoc = .{ .node_offset_lib_name = src_node_offset }; |
| 5569 | log.debug("extern fn symbol expected in lib '{s}'", .{lib_name}); | 5569 | log.debug("extern fn symbol expected in lib '{s}'", .{lib_name}); |
| 5570 | mod.comp.stage1AddLinkLib(lib_name) catch |err| { | | |
| 5571 | return sema.fail(block, lib_name_src, "unable to add link lib '{s}': {s}", .{ | | |
| 5572 | lib_name, @errorName(err), | | |
| 5573 | }); | | |
| 5574 | }; | | |
| 5575 | if (target_util.is_libc_lib_name(target, lib_name)) { | 5570 | if (target_util.is_libc_lib_name(target, lib_name)) { |
| 5576 | if (!mod.comp.bin_file.options.link_libc) { | 5571 | if (!mod.comp.bin_file.options.link_libc) { |
| 5577 | return sema.fail( | 5572 | return sema.fail( |
| ... | @@ -5581,6 +5576,7 @@ fn funcCommon( | ... | @@ -5581,6 +5576,7 @@ fn funcCommon( |
| 5581 | .{}, | 5576 | .{}, |
| 5582 | ); | 5577 | ); |
| 5583 | } | 5578 | } |
| | 5579 | mod.comp.bin_file.options.link_libc = true; |
| 5584 | break :blk; | 5580 | break :blk; |
| 5585 | } | 5581 | } |
| 5586 | if (target_util.is_libcpp_lib_name(target, lib_name)) { | 5582 | if (target_util.is_libcpp_lib_name(target, lib_name)) { |
| ... | @@ -5592,6 +5588,11 @@ fn funcCommon( | ... | @@ -5592,6 +5588,11 @@ fn funcCommon( |
| 5592 | .{}, | 5588 | .{}, |
| 5593 | ); | 5589 | ); |
| 5594 | } | 5590 | } |
| | 5591 | mod.comp.bin_file.options.link_libcpp = true; |
| | 5592 | break :blk; |
| | 5593 | } |
| | 5594 | if (mem.eql(u8, lib_name, "unwind")) { |
| | 5595 | mod.comp.bin_file.options.link_libunwind = true; |
| 5595 | break :blk; | 5596 | break :blk; |
| 5596 | } | 5597 | } |
| 5597 | if (!target.isWasm() and !mod.comp.bin_file.options.pic) { | 5598 | if (!target.isWasm() and !mod.comp.bin_file.options.pic) { |
| ... | @@ -5602,6 +5603,11 @@ fn funcCommon( | ... | @@ -5602,6 +5603,11 @@ fn funcCommon( |
| 5602 | .{ lib_name, lib_name }, | 5603 | .{ lib_name, lib_name }, |
| 5603 | ); | 5604 | ); |
| 5604 | } | 5605 | } |
| | 5606 | mod.comp.stage1AddLinkLib(lib_name) catch |err| { |
| | 5607 | return sema.fail(block, lib_name_src, "unable to add link lib '{s}': {s}", .{ |
| | 5608 | lib_name, @errorName(err), |
| | 5609 | }); |
| | 5610 | }; |
| 5605 | } | 5611 | } |
| 5606 | | 5612 | |
| 5607 | if (is_extern) { | 5613 | if (is_extern) { |