@@ -1281,7 +1281,7 @@ function _instance:toolconfig(name)
1281
1281
end
1282
1282
end
1283
1283
1284
- -- get the target compiler
1284
+ -- get the package compiler
1285
1285
function _instance :compiler (sourcekind )
1286
1286
local compilerinst = self :_memcache ():get (" compiler" )
1287
1287
if not compilerinst then
@@ -1298,6 +1298,20 @@ function _instance:compiler(sourcekind)
1298
1298
return compilerinst
1299
1299
end
1300
1300
1301
+ -- get the package linker
1302
+ function _instance :linker (targetkind , sourcekinds )
1303
+ local linkerinst = self :_memcache ():get (" linker" )
1304
+ if not linkerinst then
1305
+ local instance , errors = linker .load (targetkind , sourcekinds , self )
1306
+ if not instance then
1307
+ os .raise (errors )
1308
+ end
1309
+ linkerinst = instance
1310
+ self :_memcache ():set (" linker" , linkerinst )
1311
+ end
1312
+ return linkerinst
1313
+ end
1314
+
1301
1315
-- has the given tool for the current package?
1302
1316
--
1303
1317
-- e.g.
@@ -2358,11 +2372,7 @@ function _instance:_generate_build_configs(configs, opt)
2358
2372
end
2359
2373
if runtimes then
2360
2374
local sourcekind = opt .sourcekind or " cxx"
2361
- local tool , name = self :tool (" ld" )
2362
- local linker , errors = linker .load (" binary" , sourcekind , {target = package })
2363
- if not linker then
2364
- os .raise (errors )
2365
- end
2375
+ local linker = self :linker (" binary" , sourcekind )
2366
2376
local fake_target = {is_shared = function (_ ) return false end ,
2367
2377
sourcekinds = function (_ ) return sourcekind end }
2368
2378
local compiler = self :compiler (sourcekind )
0 commit comments