@@ -1283,7 +1283,7 @@ end
1283
1283
1284
1284
-- get the package compiler
1285
1285
function _instance :compiler (sourcekind )
1286
- local compilerinst = self :_memcache ():get (" compiler" )
1286
+ local compilerinst = self :_memcache ():get2 (" compiler" , sourcekind )
1287
1287
if not compilerinst then
1288
1288
if not sourcekind then
1289
1289
os .raise (" please pass sourcekind to the first argument of package:compiler(), e.g. cc, cxx, as" )
@@ -1293,21 +1293,24 @@ function _instance:compiler(sourcekind)
1293
1293
os .raise (errors )
1294
1294
end
1295
1295
compilerinst = instance
1296
- self :_memcache ():set (" compiler" , compilerinst )
1296
+ self :_memcache ():set2 (" compiler" , sourcekind , compilerinst )
1297
1297
end
1298
1298
return compilerinst
1299
1299
end
1300
1300
1301
1301
-- get the package linker
1302
1302
function _instance :linker (targetkind , sourcekinds )
1303
- local linkerinst = self :_memcache ():get (" linker" )
1303
+ local linkerinst = self :_memcache ():get3 (" linker" , targetkind , sourcekinds )
1304
1304
if not linkerinst then
1305
+ if not sourcekinds then
1306
+ os .raise (" please pass sourcekinds to the second argument of package:linker(), e.g. cc, cxx, as" )
1307
+ end
1305
1308
local instance , errors = linker .load (targetkind , sourcekinds , self )
1306
1309
if not instance then
1307
1310
os .raise (errors )
1308
1311
end
1309
1312
linkerinst = instance
1310
- self :_memcache ():set (" linker" , linkerinst )
1313
+ self :_memcache ():set3 (" linker" , targetkind , sourcekinds , linkerinst )
1311
1314
end
1312
1315
return linkerinst
1313
1316
end
@@ -2371,7 +2374,11 @@ function _instance:_generate_build_configs(configs, opt)
2371
2374
end
2372
2375
end
2373
2376
if runtimes then
2377
+ -- @note we need to patch package:sourcekinds(), because it wiil be called nf_runtime for gcc/clang
2374
2378
local sourcekind = opt .sourcekind or " cxx"
2379
+ self .sourcekinds = function (self )
2380
+ return sourcekind
2381
+ end
2375
2382
local compiler = self :compiler (sourcekind )
2376
2383
local cxflags = compiler :map_flags (" runtime" , runtimes , {target = self })
2377
2384
configs .cxflags = table .wrap (configs .cxflags )
@@ -2384,6 +2391,7 @@ function _instance:_generate_build_configs(configs, opt)
2384
2391
local shflags = self :linker (" shared" , sourcekind ):map_flags (" runtime" , runtimes , {target = self })
2385
2392
configs .shflags = table .wrap (configs .shflags )
2386
2393
table .join2 (configs .shflags , shflags )
2394
+ self .sourcekinds = nil
2387
2395
end
2388
2396
if self :config (" lto" ) then
2389
2397
local configs_lto = self :_generate_lto_configs (opt .sourcekind or " cxx" )
0 commit comments