@@ -1929,18 +1929,6 @@ static void add_msvc_link_args(LinkJob *lj, bool is_library) {
1929
1929
lj->args .append (" ntdll.lib" );
1930
1930
}
1931
1931
1932
- static const char *get_libc_file (ZigLibCInstallation *lib, const char *file) {
1933
- Buf *out_buf = buf_alloc ();
1934
- os_path_join (&lib->crt_dir , buf_create_from_str (file), out_buf);
1935
- return buf_ptr (out_buf);
1936
- }
1937
-
1938
- static const char *get_libc_static_file (ZigLibCInstallation *lib, const char *file) {
1939
- Buf *out_buf = buf_alloc ();
1940
- os_path_join (&lib->static_crt_dir , buf_create_from_str (file), out_buf);
1941
- return buf_ptr (out_buf);
1942
- }
1943
-
1944
1932
static void print_zig_cc_cmd (ZigList<const char *> *args) {
1945
1933
for (size_t arg_i = 0 ; arg_i < args->length ; arg_i += 1 ) {
1946
1934
const char *space_str = (arg_i == 0 ) ? " " : " " ;
@@ -2104,75 +2092,37 @@ static void add_mingw_link_args(LinkJob *lj, bool is_library) {
2104
2092
lj->args .append (" -ALTERNATENAME:__image_base__=__ImageBase" );
2105
2093
}
2106
2094
2107
- if (g->libc == nullptr ) {
2108
- if (is_dll) {
2109
- lj->args .append (get_libc_crt_file (g, " dllcrt2.o" ));
2110
- } else {
2111
- lj->args .append (get_libc_crt_file (g, " crt2.o" ));
2112
- }
2113
-
2114
- lj->args .append (get_libc_crt_file (g, " mingw32.lib" ));
2115
- lj->args .append (get_libc_crt_file (g, " mingwex.lib" ));
2116
- lj->args .append (get_libc_crt_file (g, " msvcrt-os.lib" ));
2117
-
2118
- for (size_t def_i = 0 ; def_i < array_length (mingw_def_list); def_i += 1 ) {
2119
- const char *name = mingw_def_list[def_i].name ;
2120
- Buf *path = buf_create_from_str (mingw_def_list[def_i].path );
2121
- bool always_link = mingw_def_list[def_i].always_link ;
2122
- bool is_this_arch = false ;
2123
- if (buf_starts_with_str (path, " lib-common" OS_SEP)) {
2124
- is_this_arch = true ;
2125
- } else if (target_is_arm (g->zig_target )) {
2126
- if (target_arch_pointer_bit_width (g->zig_target ->arch ) == 32 ) {
2127
- is_this_arch = buf_starts_with_str (path, " libarm32" OS_SEP);
2128
- } else {
2129
- is_this_arch = buf_starts_with_str (path, " libarm64" OS_SEP);
2130
- }
2131
- } else if (g->zig_target ->arch == ZigLLVM_x86) {
2132
- is_this_arch = buf_starts_with_str (path, " lib32" OS_SEP);
2133
- } else if (g->zig_target ->arch == ZigLLVM_x86_64) {
2134
- is_this_arch = buf_starts_with_str (path, " lib64" OS_SEP);
2135
- }
2136
- if (is_this_arch && (always_link || is_linking_system_lib (g, name))) {
2137
- lj->args .append (get_def_lib (g, name, path));
2138
- }
2139
- }
2140
-
2095
+ if (is_dll) {
2096
+ lj->args .append (get_libc_crt_file (g, " dllcrt2.o" ));
2141
2097
} else {
2142
- if (is_dll) {
2143
- lj->args .append (get_libc_file (g->libc , " dllcrt2.o" ));
2144
- } else {
2145
- lj->args .append (get_libc_file (g->libc , " crt2.o" ));
2146
- }
2147
-
2148
- lj->args .append (get_libc_static_file (g->libc , " crtbegin.o" ));
2098
+ lj->args .append (get_libc_crt_file (g, " crt2.o" ));
2099
+ }
2149
2100
2150
- lj->args .append (get_libc_file (g->libc , " libmingw32.a" ));
2101
+ lj->args .append (get_libc_crt_file (g, " mingw32.lib" ));
2102
+ lj->args .append (get_libc_crt_file (g, " mingwex.lib" ));
2103
+ lj->args .append (get_libc_crt_file (g, " msvcrt-os.lib" ));
2151
2104
2152
- if (is_dll) {
2153
- lj->args .append (get_libc_static_file (g->libc , " libgcc_s.a" ));
2154
- lj->args .append (get_libc_static_file (g->libc , " libgcc.a" ));
2155
- } else {
2156
- lj->args .append (get_libc_static_file (g->libc , " libgcc.a" ));
2157
- lj->args .append (get_libc_static_file (g->libc , " libgcc_eh.a" ));
2105
+ for (size_t def_i = 0 ; def_i < array_length (mingw_def_list); def_i += 1 ) {
2106
+ const char *name = mingw_def_list[def_i].name ;
2107
+ Buf *path = buf_create_from_str (mingw_def_list[def_i].path );
2108
+ bool always_link = mingw_def_list[def_i].always_link ;
2109
+ bool is_this_arch = false ;
2110
+ if (buf_starts_with_str (path, " lib-common" OS_SEP)) {
2111
+ is_this_arch = true ;
2112
+ } else if (target_is_arm (g->zig_target )) {
2113
+ if (target_arch_pointer_bit_width (g->zig_target ->arch ) == 32 ) {
2114
+ is_this_arch = buf_starts_with_str (path, " libarm32" OS_SEP);
2115
+ } else {
2116
+ is_this_arch = buf_starts_with_str (path, " libarm64" OS_SEP);
2117
+ }
2118
+ } else if (g->zig_target ->arch == ZigLLVM_x86) {
2119
+ is_this_arch = buf_starts_with_str (path, " lib32" OS_SEP);
2120
+ } else if (g->zig_target ->arch == ZigLLVM_x86_64) {
2121
+ is_this_arch = buf_starts_with_str (path, " lib64" OS_SEP);
2158
2122
}
2159
-
2160
- lj->args .append (get_libc_static_file (g->libc , " libssp.a" ));
2161
- lj->args .append (get_libc_file (g->libc , " libmoldname.a" ));
2162
- lj->args .append (get_libc_file (g->libc , " libmingwex.a" ));
2163
- lj->args .append (get_libc_file (g->libc , " libmsvcrt.a" ));
2164
-
2165
- if (detect_subsystem (g) == TargetSubsystemWindows) {
2166
- lj->args .append (get_libc_file (g->libc , " libgdi32.a" ));
2167
- lj->args .append (get_libc_file (g->libc , " libcomdlg32.a" ));
2123
+ if (is_this_arch && (always_link || is_linking_system_lib (g, name))) {
2124
+ lj->args .append (get_def_lib (g, name, path));
2168
2125
}
2169
-
2170
- lj->args .append (get_libc_file (g->libc , " libadvapi32.a" ));
2171
- lj->args .append (get_libc_file (g->libc , " libshell32.a" ));
2172
- lj->args .append (get_libc_file (g->libc , " libuser32.a" ));
2173
- lj->args .append (get_libc_file (g->libc , " libkernel32.a" ));
2174
-
2175
- lj->args .append (get_libc_static_file (g->libc , " crtend.o" ));
2176
2126
}
2177
2127
}
2178
2128
0 commit comments