| ... | ... | @@ -2008,28 +2008,34 @@ fn buildOutputType( |
| 2008 | 2008 | // are part of libc or libc++. We remove them from the list and communicate their |
| 2009 | 2009 | // existence via flags instead. |
| 2010 | 2010 | { |
| 2011 | // Similarly, if any libs in this list are statically provided, we remove |
| 2012 | // them from this list and populate the link_objects array instead. |
| 2013 | const sep = fs.path.sep_str; |
| 2014 | var test_path = std.ArrayList(u8).init(gpa); |
| 2015 | defer test_path.deinit(); |
| 2016 | |
| 2011 | 2017 | var i: usize = 0; |
| 2012 | | while (i < system_libs.count()) { |
| 2018 | syslib: while (i < system_libs.count()) { |
| 2013 | 2019 | const lib_name = system_libs.keys()[i]; |
| 2014 | 2020 | |
| 2015 | 2021 | if (target_util.is_libc_lib_name(target_info.target, lib_name)) { |
| 2016 | 2022 | link_libc = true; |
| 2017 | | _ = system_libs.orderedRemove(lib_name); |
| 2023 | system_libs.orderedRemoveAt(i); |
| 2018 | 2024 | continue; |
| 2019 | 2025 | } |
| 2020 | 2026 | if (target_util.is_libcpp_lib_name(target_info.target, lib_name)) { |
| 2021 | 2027 | link_libcpp = true; |
| 2022 | | _ = system_libs.orderedRemove(lib_name); |
| 2028 | system_libs.orderedRemoveAt(i); |
| 2023 | 2029 | continue; |
| 2024 | 2030 | } |
| 2025 | 2031 | if (mem.eql(u8, lib_name, "unwind")) { |
| 2026 | 2032 | link_libunwind = true; |
| 2027 | | _ = system_libs.orderedRemove(lib_name); |
| 2033 | system_libs.orderedRemoveAt(i); |
| 2028 | 2034 | continue; |
| 2029 | 2035 | } |
| 2030 | 2036 | if (target_util.is_compiler_rt_lib_name(target_info.target, lib_name)) { |
| 2031 | 2037 | std.log.warn("ignoring superfluous library '{s}': this dependency is fulfilled instead by compiler-rt which zig unconditionally provides", .{lib_name}); |
| 2032 | | _ = system_libs.orderedRemove(lib_name); |
| 2038 | system_libs.orderedRemoveAt(i); |
| 2033 | 2039 | continue; |
| 2034 | 2040 | } |
| 2035 | 2041 | if (std.fs.path.isAbsolute(lib_name)) { |
| ... | ... | @@ -2038,10 +2044,30 @@ fn buildOutputType( |
| 2038 | 2044 | if (target_info.target.os.tag == .wasi) { |
| 2039 | 2045 | if (wasi_libc.getEmulatedLibCRTFile(lib_name)) |crt_file| { |
| 2040 | 2046 | try wasi_emulated_libs.append(crt_file); |
| 2041 | | _ = system_libs.orderedRemove(lib_name); |
| 2047 | system_libs.orderedRemoveAt(i); |
| 2042 | 2048 | continue; |
| 2043 | 2049 | } |
| 2044 | 2050 | } |
| 2051 | |
| 2052 | for (lib_dirs.items) |lib_dir_path| { |
| 2053 | test_path.clearRetainingCapacity(); |
| 2054 | try test_path.writer().print("{s}" ++ sep ++ "{s}{s}{s}", .{ |
| 2055 | lib_dir_path, |
| 2056 | target_info.target.libPrefix(), |
| 2057 | lib_name, |
| 2058 | target_info.target.staticLibSuffix(), |
| 2059 | }); |
| 2060 | fs.cwd().access(test_path.items, .{}) catch |err| switch (err) { |
| 2061 | error.FileNotFound => continue, |
| 2062 | else => |e| fatal("unable to search for static library '{s}': {s}", .{ |
| 2063 | test_path.items, @errorName(e), |
| 2064 | }), |
| 2065 | }; |
| 2066 | try link_objects.append(.{ .path = try arena.dupe(u8, test_path.items) }); |
| 2067 | system_libs.orderedRemoveAt(i); |
| 2068 | continue :syslib; |
| 2069 | } |
| 2070 | |
| 2045 | 2071 | i += 1; |
| 2046 | 2072 | } |
| 2047 | 2073 | } |
| ... | ... | @@ -2068,7 +2094,9 @@ fn buildOutputType( |
| 2068 | 2094 | want_native_include_dirs = true; |
| 2069 | 2095 | } |
| 2070 | 2096 | |
| 2071 | | if (sysroot == null and cross_target.isNativeOs() and (system_libs.count() != 0 or want_native_include_dirs)) { |
| 2097 | if (sysroot == null and cross_target.isNativeOs() and |
| 2098 | (system_libs.count() != 0 or want_native_include_dirs)) |
| 2099 | { |
| 2072 | 2100 | const paths = std.zig.system.NativePaths.detect(arena, target_info) catch |err| { |
| 2073 | 2101 | fatal("unable to detect native system paths: {s}", .{@errorName(err)}); |
| 2074 | 2102 | }; |