@@ -1609,6 +1609,8 @@ pub const Input = union(enum) {
1609
1609
needed : bool ,
1610
1610
weak : bool ,
1611
1611
reexport : bool ,
1612
+ name : ? []const u8 ,
1613
+ lib_directory : Directory ,
1612
1614
};
1613
1615
1614
1616
pub const DsoExact = struct {
@@ -1661,6 +1663,8 @@ pub fn hashInputs(man: *Cache.Manifest, link_inputs: []const Input) !void {
1661
1663
man .hash .add (dso .needed );
1662
1664
man .hash .add (dso .weak );
1663
1665
man .hash .add (dso .reexport );
1666
+ man .hash .addOptionalBytes (dso .name );
1667
+ man .hash .addOptionalBytes (dso .lib_directory .path );
1664
1668
},
1665
1669
.dso_exact = > | dso_exact | {
1666
1670
man .hash .addBytes (dso_exact .name );
@@ -1936,7 +1940,7 @@ fn resolveLibInput(
1936
1940
else = > | e | fatal ("unable to search for tbd library '{f}': {s}" , .{ test_path , @errorName (e ) }),
1937
1941
};
1938
1942
errdefer file .close ();
1939
- return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query );
1943
+ return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query , name_query . name , lib_directory );
1940
1944
}
1941
1945
1942
1946
{
@@ -1949,11 +1953,11 @@ fn resolveLibInput(
1949
1953
},
1950
1954
}),
1951
1955
};
1952
- try checked_paths .writer (gpa ).print ("\n {f }" , .{test_path });
1953
- switch (try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , target , .{
1956
+ try checked_paths .writer (gpa ).print ("\n {}" , .{test_path });
1957
+ switch (try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , lib_directory , target , .{
1954
1958
.path = test_path ,
1955
1959
.query = name_query .query ,
1956
- }, link_mode , color )) {
1960
+ }, link_mode , color , name_query . name )) {
1957
1961
.no_match = > {},
1958
1962
.ok = > return .ok ,
1959
1963
}
@@ -1974,7 +1978,7 @@ fn resolveLibInput(
1974
1978
}),
1975
1979
};
1976
1980
errdefer file .close ();
1977
- return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query );
1981
+ return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query , name_query . name , lib_directory );
1978
1982
}
1979
1983
1980
1984
// In the case of MinGW, the main check will be .lib but we also need to
@@ -1990,7 +1994,7 @@ fn resolveLibInput(
1990
1994
else = > | e | fatal ("unable to search for static library '{f}': {s}" , .{ test_path , @errorName (e ) }),
1991
1995
};
1992
1996
errdefer file .close ();
1993
- return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query );
1997
+ return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , name_query .query , name_query . name , lib_directory );
1994
1998
}
1995
1999
1996
2000
return .no_match ;
@@ -2002,6 +2006,8 @@ fn finishResolveLibInput(
2002
2006
file : std.fs.File ,
2003
2007
link_mode : std.builtin.LinkMode ,
2004
2008
query : UnresolvedInput.Query ,
2009
+ name : ? []const u8 ,
2010
+ lib_directory : Directory ,
2005
2011
) ResolveLibInputResult {
2006
2012
switch (link_mode ) {
2007
2013
.static = > resolved_inputs .appendAssumeCapacity (.{ .archive = .{
@@ -2016,6 +2022,8 @@ fn finishResolveLibInput(
2016
2022
.needed = query .needed ,
2017
2023
.weak = query .weak ,
2018
2024
.reexport = query .reexport ,
2025
+ .name = name ,
2026
+ .lib_directory = lib_directory ,
2019
2027
} }),
2020
2028
}
2021
2029
return .ok ;
@@ -2035,8 +2043,8 @@ fn resolvePathInput(
2035
2043
color : std.zig.Color ,
2036
2044
) Allocator .Error ! ? ResolveLibInputResult {
2037
2045
switch (Compilation .classifyFileExt (pq .path .sub_path )) {
2038
- .static_library = > return try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , target , pq , .static , color ),
2039
- .shared_library = > return try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , target , pq , .dynamic , color ),
2046
+ .static_library = > return try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , Directory . cwd (), target , pq , .static , color , null ),
2047
+ .shared_library = > return try resolvePathInputLib (gpa , arena , unresolved_inputs , resolved_inputs , ld_script_bytes , Directory . cwd (), target , pq , .dynamic , color , null ),
2040
2048
.object = > {
2041
2049
var file = pq .path .root_dir .handle .openFile (pq .path .sub_path , .{}) catch | err |
2042
2050
fatal ("failed to open object {f}: {s}" , .{ pq .path , @errorName (err ) });
@@ -2072,10 +2080,12 @@ fn resolvePathInputLib(
2072
2080
resolved_inputs : * std .ArrayListUnmanaged (Input ),
2073
2081
/// Allocated via `gpa`.
2074
2082
ld_script_bytes : * std .ArrayListUnmanaged (u8 ),
2083
+ lib_directory : Directory ,
2075
2084
target : * const std.Target ,
2076
2085
pq : UnresolvedInput.PathQuery ,
2077
2086
link_mode : std.builtin.LinkMode ,
2078
2087
color : std.zig.Color ,
2088
+ name : ? []const u8 ,
2079
2089
) Allocator .Error ! ResolveLibInputResult {
2080
2090
try resolved_inputs .ensureUnusedCapacity (gpa , 1 );
2081
2091
@@ -2100,7 +2110,7 @@ fn resolvePathInputLib(
2100
2110
const buf = ld_script_bytes .items [0.. n ];
2101
2111
if (mem .startsWith (u8 , buf , std .elf .MAGIC ) or mem .startsWith (u8 , buf , std .elf .ARMAG )) {
2102
2112
// Appears to be an ELF or archive file.
2103
- return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , pq .query );
2113
+ return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , pq .query , name , lib_directory );
2104
2114
}
2105
2115
const stat = file .stat () catch | err |
2106
2116
fatal ("failed to stat {f}: {s}" , .{ test_path , @errorName (err ) });
@@ -2166,7 +2176,7 @@ fn resolvePathInputLib(
2166
2176
}),
2167
2177
};
2168
2178
errdefer file .close ();
2169
- return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , pq .query );
2179
+ return finishResolveLibInput (resolved_inputs , test_path , file , link_mode , pq .query , name , lib_directory );
2170
2180
}
2171
2181
2172
2182
pub fn openObject (path : Path , must_link : bool , hidden : bool ) ! Input.Object {
@@ -2189,6 +2199,8 @@ pub fn openDso(path: Path, needed: bool, weak: bool, reexport: bool) !Input.Dso
2189
2199
.needed = needed ,
2190
2200
.weak = weak ,
2191
2201
.reexport = reexport ,
2202
+ .name = null ,
2203
+ .lib_directory = Directory .cwd (),
2192
2204
};
2193
2205
}
2194
2206
0 commit comments