@@ -1818,6 +1818,8 @@ pub const Input = union(enum) {
1818
1818
needed : bool ,
1819
1819
weak : bool ,
1820
1820
reexport : bool ,
1821
+ name : ? []const u8 ,
1822
+ lib_directory : Directory ,
1821
1823
};
1822
1824
1823
1825
pub const DsoExact = struct {
@@ -2145,7 +2147,7 @@ fn resolveLibInput(
2145
2147
else = > | e | fatal ("unable to search for tbd library '{}': {s}" , .{ test_path , @errorName (e ) }),
2146
2148
};
2147
2149
errdefer file .close ();
2148
- return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query );
2150
+ return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query , name_query . name , lib_directory );
2149
2151
}
2150
2152
2151
2153
{
@@ -2159,10 +2161,10 @@ fn resolveLibInput(
2159
2161
}),
2160
2162
};
2161
2163
try checked_paths .writer (gpa ).print ("\n {}" , .{test_path });
2162
- switch (try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , target , .{
2164
+ switch (try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , lib_directory , target , .{
2163
2165
.path = test_path ,
2164
2166
.query = name_query .query ,
2165
- }, link_mode , color )) {
2167
+ }, link_mode , color , name_query . name )) {
2166
2168
.no_match = > {},
2167
2169
.ok = > return .ok ,
2168
2170
}
@@ -2183,7 +2185,7 @@ fn resolveLibInput(
2183
2185
}),
2184
2186
};
2185
2187
errdefer file .close ();
2186
- return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query );
2188
+ return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query , name_query . name , lib_directory );
2187
2189
}
2188
2190
2189
2191
// In the case of MinGW, the main check will be .lib but we also need to
@@ -2199,7 +2201,7 @@ fn resolveLibInput(
2199
2201
else = > | e | fatal ("unable to search for static library '{}': {s}" , .{ test_path , @errorName (e ) }),
2200
2202
};
2201
2203
errdefer file .close ();
2202
- return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query );
2204
+ return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query , name_query . name , lib_directory );
2203
2205
}
2204
2206
2205
2207
return .no_match ;
@@ -2211,6 +2213,8 @@ fn finishResolveLibInput(
2211
2213
file : std.fs.File ,
2212
2214
link_mode : std.builtin.LinkMode ,
2213
2215
query : UnresolvedInput.Query ,
2216
+ name : ? []const u8 ,
2217
+ lib_directory : Directory ,
2214
2218
) ResolveLibInputResult {
2215
2219
switch (link_mode ) {
2216
2220
.static = > resolved_inputs .appendAssumeCapacity (.{ .archive = .{
@@ -2225,6 +2229,8 @@ fn finishResolveLibInput(
2225
2229
.needed = query .needed ,
2226
2230
.weak = query .weak ,
2227
2231
.reexport = query .reexport ,
2232
+ .name = name ,
2233
+ .lib_directory = lib_directory ,
2228
2234
} }),
2229
2235
}
2230
2236
return .ok ;
@@ -2244,8 +2250,8 @@ fn resolvePathInput(
2244
2250
color : std.zig.Color ,
2245
2251
) Allocator .Error ! ? ResolveLibInputResult {
2246
2252
switch (Compilation .classifyFileExt (pq .path .sub_path )) {
2247
- .static_library = > return try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , target , pq , .static , color ),
2248
- .shared_library = > return try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , target , pq , .dynamic , color ),
2253
+ .static_library = > return try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , Directory . cwd (), target , pq , .static , color , null ),
2254
+ .shared_library = > return try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , Directory . cwd (), target , pq , .dynamic , color , null ),
2249
2255
.object = > {
2250
2256
var file = pq .path .root_dir .handle .openFile (pq .path .sub_path , .{}) catch | err |
2251
2257
fatal ("failed to open object {}: {s}" , .{ pq .path , @errorName (err ) });
@@ -2281,10 +2287,12 @@ fn resolvePathInputLib(
2281
2287
resolved_inputs : * std .ArrayListUnmanaged (Input ),
2282
2288
/// Allocated via `gpa`.
2283
2289
ld_script_bytes : * std .ArrayListUnmanaged (u8 ),
2290
+ lib_directory : Directory ,
2284
2291
target : std.Target ,
2285
2292
pq : UnresolvedInput.PathQuery ,
2286
2293
link_mode : std.builtin.LinkMode ,
2287
2294
color : std.zig.Color ,
2295
+ name : ? []const u8 ,
2288
2296
) Allocator .Error ! ResolveLibInputResult {
2289
2297
try resolved_inputs .ensureUnusedCapacity (gpa , 1 );
2290
2298
@@ -2309,7 +2317,7 @@ fn resolvePathInputLib(
2309
2317
if (n != ld_script_bytes .items .len ) break :elf_file ;
2310
2318
if (! mem .eql (u8 , ld_script_bytes .items [0.. 4], "\x7f ELF" )) break :elf_file ;
2311
2319
// Appears to be an ELF file.
2312
- return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , pq .query );
2320
+ return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , pq .query , name , lib_directory );
2313
2321
}
2314
2322
const stat = file .stat () catch | err |
2315
2323
fatal ("failed to stat {}: {s}" , .{ test_path , @errorName (err ) });
@@ -2375,7 +2383,7 @@ fn resolvePathInputLib(
2375
2383
}),
2376
2384
};
2377
2385
errdefer file .close ();
2378
- return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , pq .query );
2386
+ return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , pq .query , name , lib_directory );
2379
2387
}
2380
2388
2381
2389
pub fn openObject (path : Path , must_link : bool , hidden : bool ) ! Input.Object {
@@ -2398,6 +2406,8 @@ pub fn openDso(path: Path, needed: bool, weak: bool, reexport: bool) !Input.Dso
2398
2406
.needed = needed ,
2399
2407
.weak = weak ,
2400
2408
.reexport = reexport ,
2409
+ .name = null ,
2410
+ .lib_directory = Directory .cwd (),
2401
2411
};
2402
2412
}
2403
2413
0 commit comments