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