@@ -1794,6 +1794,8 @@ pub const Input = union(enum) {
1794
1794
needed : bool ,
1795
1795
weak : bool ,
1796
1796
reexport : bool ,
1797
+ name : ? []const u8 ,
1798
+ lib_directory : Directory ,
1797
1799
};
1798
1800
1799
1801
pub const DsoExact = struct {
@@ -2121,7 +2123,7 @@ fn resolveLibInput(
2121
2123
else = > | e | fatal ("unable to search for tbd library '{}': {s}" , .{ test_path , @errorName (e ) }),
2122
2124
};
2123
2125
errdefer file .close ();
2124
- return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query );
2126
+ return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query , name_query . name , lib_directory );
2125
2127
}
2126
2128
2127
2129
{
@@ -2135,10 +2137,10 @@ fn resolveLibInput(
2135
2137
}),
2136
2138
};
2137
2139
try checked_paths .writer (gpa ).print ("\n {}" , .{test_path });
2138
- switch (try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , target , .{
2140
+ switch (try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , lib_directory , target , .{
2139
2141
.path = test_path ,
2140
2142
.query = name_query .query ,
2141
- }, link_mode , color )) {
2143
+ }, link_mode , color , name_query . name )) {
2142
2144
.no_match = > {},
2143
2145
.ok = > return .ok ,
2144
2146
}
@@ -2159,7 +2161,7 @@ fn resolveLibInput(
2159
2161
}),
2160
2162
};
2161
2163
errdefer file .close ();
2162
- return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query );
2164
+ return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query , name_query . name , lib_directory );
2163
2165
}
2164
2166
2165
2167
// In the case of MinGW, the main check will be .lib but we also need to
@@ -2175,7 +2177,7 @@ fn resolveLibInput(
2175
2177
else = > | e | fatal ("unable to search for static library '{}': {s}" , .{ test_path , @errorName (e ) }),
2176
2178
};
2177
2179
errdefer file .close ();
2178
- return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query );
2180
+ return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query , name_query . name , lib_directory );
2179
2181
}
2180
2182
2181
2183
return .no_match ;
@@ -2187,6 +2189,8 @@ fn finishResolveLibInput(
2187
2189
file : std.fs.File ,
2188
2190
link_mode : std.builtin.LinkMode ,
2189
2191
query : UnresolvedInput.Query ,
2192
+ name : ? []const u8 ,
2193
+ lib_directory : Directory ,
2190
2194
) ResolveLibInputResult {
2191
2195
switch (link_mode ) {
2192
2196
.static = > resolved_inputs .appendAssumeCapacity (.{ .archive = .{
@@ -2201,6 +2205,8 @@ fn finishResolveLibInput(
2201
2205
.needed = query .needed ,
2202
2206
.weak = query .weak ,
2203
2207
.reexport = query .reexport ,
2208
+ .name = name ,
2209
+ .lib_directory = lib_directory ,
2204
2210
} }),
2205
2211
}
2206
2212
return .ok ;
@@ -2220,8 +2226,8 @@ fn resolvePathInput(
2220
2226
color : std.zig.Color ,
2221
2227
) Allocator .Error ! ? ResolveLibInputResult {
2222
2228
switch (Compilation .classifyFileExt (pq .path .sub_path )) {
2223
- .static_library = > return try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , target , pq , .static , color ),
2224
- .shared_library = > return try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , target , pq , .dynamic , color ),
2229
+ .static_library = > return try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , Directory . cwd (), target , pq , .static , color , null ),
2230
+ .shared_library = > return try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , Directory . cwd (), target , pq , .dynamic , color , null ),
2225
2231
.object = > {
2226
2232
var file = pq .path .root_dir .handle .openFile (pq .path .sub_path , .{}) catch | err |
2227
2233
fatal ("failed to open object {}: {s}" , .{ pq .path , @errorName (err ) });
@@ -2257,10 +2263,12 @@ fn resolvePathInputLib(
2257
2263
resolved_inputs : * std .ArrayListUnmanaged (Input ),
2258
2264
/// Allocated via `gpa`.
2259
2265
ld_script_bytes : * std .ArrayListUnmanaged (u8 ),
2266
+ lib_directory : Directory ,
2260
2267
target : std.Target ,
2261
2268
pq : UnresolvedInput.PathQuery ,
2262
2269
link_mode : std.builtin.LinkMode ,
2263
2270
color : std.zig.Color ,
2271
+ name : ? []const u8 ,
2264
2272
) Allocator .Error ! ResolveLibInputResult {
2265
2273
try resolved_inputs .ensureUnusedCapacity (gpa , 1 );
2266
2274
@@ -2285,7 +2293,7 @@ fn resolvePathInputLib(
2285
2293
if (n != ld_script_bytes .items .len ) break :elf_file ;
2286
2294
if (! mem .eql (u8 , ld_script_bytes .items [0.. 4], "\x7f ELF" )) break :elf_file ;
2287
2295
// Appears to be an ELF file.
2288
- return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , pq .query );
2296
+ return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , pq .query , name , lib_directory );
2289
2297
}
2290
2298
const stat = file .stat () catch | err |
2291
2299
fatal ("failed to stat {}: {s}" , .{ test_path , @errorName (err ) });
@@ -2351,7 +2359,7 @@ fn resolvePathInputLib(
2351
2359
}),
2352
2360
};
2353
2361
errdefer file .close ();
2354
- return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , pq .query );
2362
+ return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , pq .query , name , lib_directory );
2355
2363
}
2356
2364
2357
2365
pub fn openObject (path : Path , must_link : bool , hidden : bool ) ! Input.Object {
@@ -2374,6 +2382,8 @@ pub fn openDso(path: Path, needed: bool, weak: bool, reexport: bool) !Input.Dso
2374
2382
.needed = needed ,
2375
2383
.weak = weak ,
2376
2384
.reexport = reexport ,
2385
+ .name = null ,
2386
+ .lib_directory = Directory .cwd (),
2377
2387
};
2378
2388
}
2379
2389
0 commit comments