summaryrefslogtreecommitdiff
path: root/xmake/core/tool/linker.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-02-27 10:48:13 +0800
committerruki <[email protected]>2017-02-27 10:48:13 +0800
commit92c6f33e0d4a9c4e657f2f30ef277795062e2fc4 (patch)
treef552a523ec46e02318c5897d667d5335d727a70f /xmake/core/tool/linker.lua
parentb468766f9a45ffb721dd82363f44539644d3d08d (diff)
fix mix linking
Diffstat (limited to 'xmake/core/tool/linker.lua')
-rw-r--r--xmake/core/tool/linker.lua35
1 files changed, 23 insertions, 12 deletions
diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua
index 7b9afdbbe..04daaf6b1 100644
--- a/xmake/core/tool/linker.lua
+++ b/xmake/core/tool/linker.lua
@@ -83,27 +83,38 @@ function linker.load(targetkind, sourcekinds)
-- wrap sourcekinds first
sourcekinds = table.wrap(sourcekinds)
- -- get the linker info
- local linkerinfo, errors = language.linkerinfo_of(targetkind, sourcekinds)
+ -- get the linker infos
+ local linkerinfos, errors = language.linkerinfos_of(targetkind, sourcekinds)
+ if not linkerinfos then
+ return nil, errors
+ end
+
+ -- select the linker
+ local linkerinfo = nil
+ local linkertool = nil
+ for _, _linkerinfo in ipairs(linkerinfos) do
+ -- load the linker tool from the linker kind
+ linkertool, errors = tool.load(_linkerinfo.linkerkind)
+ if linkertool then
+ linkerinfo = _linkerinfo
+ break
+ end
+ end
if not linkerinfo then
return nil, errors
end
-- get it directly from cache dirst
builder._INSTANCES = builder._INSTANCES or {}
- if builder._INSTANCES[linkerinfo.kind] then
- return builder._INSTANCES[linkerinfo.kind]
+ if builder._INSTANCES[linkerinfo.linkerkind] then
+ return builder._INSTANCES[linkerinfo.linkerkind]
end
-- new instance
local instance = table.inherit(linker, builder)
- -- load the linker tool from the source file type
- local result, errors = tool.load(linkerinfo.kind)
- if not result then
- return nil, errors
- end
- instance._TOOL = result
+ -- save linker tool
+ instance._TOOL = linkertool
-- load the name flags of archiver
local nameflags = {}
@@ -131,10 +142,10 @@ function linker.load(targetkind, sourcekinds)
instance._TARGETKIND = targetkind
-- init flag kinds
- instance._FLAGKINDS = {linkerinfo.flag}
+ instance._FLAGKINDS = {linkerinfo.linkerflag}
-- save this instance
- builder._INSTANCES[linkerinfo.kind] = instance
+ builder._INSTANCES[linkerinfo.linkerkind] = instance
-- ok
return instance