summaryrefslogtreecommitdiff
path: root/xmake
diff options
context:
space:
mode:
authorruki <[email protected]>2019-04-03 22:18:36 +0800
committerruki <[email protected]>2019-04-03 07:51:38 +0800
commitadbcc87f0699702c32fa8dc63aa8aafaa1deca9d (patch)
treee0bc6b981218c77081878e2ec1ff0d14296c3c01 /xmake
parent09a1f710f009c7b90deea8a0e2c788551c03e66c (diff)
improve linker
Diffstat (limited to 'xmake')
-rw-r--r--xmake/core/tool/linker.lua35
-rw-r--r--xmake/modules/core/tools/clang.lua5
-rw-r--r--xmake/modules/core/tools/dmd.lua4
-rw-r--r--xmake/modules/core/tools/gcc.lua2
-rw-r--r--xmake/modules/core/tools/go.lua2
-rw-r--r--xmake/modules/core/tools/ldc2.lua2
-rw-r--r--xmake/modules/core/tools/nvcc.lua3
-rw-r--r--xmake/modules/core/tools/rustc.lua6
8 files changed, 13 insertions, 46 deletions
diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua
index 1046d204b..4aea7740c 100644
--- a/xmake/core/tool/linker.lua
+++ b/xmake/core/tool/linker.lua
@@ -54,35 +54,6 @@ function linker:_add_flags_from_platform(flags, targetkind)
end
end
--- add flags from the compiler
-function linker:_add_flags_from_compiler(flags, target, targetkind)
-
- -- make flags
- local flags_of_compiler = {}
- local toolkind = self:kind()
- local toolname = self:name()
- for _, sourcekind in ipairs(self._SOURCEKINDS) do
-
- -- load compiler
- local instance, errors = compiler.load(sourcekind, target)
- if instance then
- for _, flagkind in ipairs(self:_flagkinds()) do
-
- -- attempt to add special lanugage flags first, e.g. gcc.ldflags, gc-ldflags, dc-arflags
- local toolflags = instance:get(toolname .. '.' .. toolkind .. 'flags') or instance:get(toolname .. '.' .. flagkind)
- table.join2(flags_of_compiler, toolflags or instance:get(toolkind .. 'flags') or instance:get(flagkind))
-
- -- attempt to add special lanugage flags first for target kind, e.g. targetkind.gcc.ldflags, targetkind.gc-ldflags, targetkind.dc-arflags
- if targetkind then
- toolflags = instance:get(targetkind .. '.' .. toolname .. '.' .. toolkind .. 'flags') or instance:get(targetkind .. '.' .. toolname .. '.' .. flagkind)
- table.join2(flags_of_compiler, toolflags or instance:get(targetkind .. '.' .. toolkind .. 'flags') or instance:get(targetkind .. '.' .. flagkind))
- end
- end
- end
- end
- table.join2(flags, flags_of_compiler)
-end
-
-- add flags from the linker
function linker:_add_flags_from_linker(flags)
@@ -204,9 +175,6 @@ function linker.load(targetkind, sourcekinds, target)
-- init target kind
instance._TARGETKIND = targetkind
- -- init source kinds
- instance._SOURCEKINDS = sourcekinds
-
-- init flag kinds
instance._FLAGKINDS = {linkerinfo.linkerflag}
@@ -278,10 +246,11 @@ function linker:linkflags(opt)
-- add flags from the platform
self:_add_flags_from_platform(flags, targetkind)
+ --[[
-- add flags from the compiler
if target then
self:_add_flags_from_compiler(flags, target, targetkind)
- end
+ end]]
-- add flags from the linker
self:_add_flags_from_linker(flags)
diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua
index 7dcc02b5c..a54297a4d 100644
--- a/xmake/modules/core/tools/clang.lua
+++ b/xmake/modules/core/tools/clang.lua
@@ -31,11 +31,6 @@ function init(self)
-- init super
_super.init(self)
- -- add -fPIC for shared
- if not is_plat("windows", "mingw") then
- self:add("clang.shflags", "-fPIC") -- only for clang
- end
-
-- suppress warning
self:add("cxflags", "-Qunused-arguments")
self:add("mxflags", "-Qunused-arguments")
diff --git a/xmake/modules/core/tools/dmd.lua b/xmake/modules/core/tools/dmd.lua
index c11fea5fc..63e9a8313 100644
--- a/xmake/modules/core/tools/dmd.lua
+++ b/xmake/modules/core/tools/dmd.lua
@@ -31,10 +31,10 @@ import("core.project.project")
function init(self)
-- init arflags
- self:set("arflags", "-lib")
+ self:set("dc-arflags", "-lib")
-- init shflags
- self:set("shflags", "-shared", "-fPIC")
+ self:set("dc-shflags", "-shared", "-fPIC")
-- init dcflags for the kind: shared
self:set("shared.dcflags", "-fPIC")
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index d21cbe99f..c9dd32508 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -45,7 +45,7 @@ function init(self)
-- add -fPIC for shared
if not is_plat("windows", "mingw") then
- self:add("gcc.shflags", "-fPIC") -- only for gcc
+ self:add("shflags", "-fPIC")
self:add("shared.cxflags", "-fPIC")
end
diff --git a/xmake/modules/core/tools/go.lua b/xmake/modules/core/tools/go.lua
index 5bda5022b..d23bbd0a2 100644
--- a/xmake/modules/core/tools/go.lua
+++ b/xmake/modules/core/tools/go.lua
@@ -31,7 +31,7 @@ import("core.project.project")
function init(self)
-- init arflags
- self:set("arflags", "grc")
+ self:set("gc-arflags", "grc")
-- init the file formats
self:set("formats", { static = "$(name).a" })
diff --git a/xmake/modules/core/tools/ldc2.lua b/xmake/modules/core/tools/ldc2.lua
index c21f90a8f..a9b95af5e 100644
--- a/xmake/modules/core/tools/ldc2.lua
+++ b/xmake/modules/core/tools/ldc2.lua
@@ -32,7 +32,7 @@ function init(self)
_super.init(self)
-- init shflags
- self:set("shflags", "-shared")
+ self:set("dc-shflags", "-shared")
-- init cxflags for the kind: shared
self:set("shared.dcflags", "")
diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua
index 1e8186401..64bb24bad 100644
--- a/xmake/modules/core/tools/nvcc.lua
+++ b/xmake/modules/core/tools/nvcc.lua
@@ -32,6 +32,9 @@ import("detect.tools.find_ccache")
-- init it
function init(self)
+ -- init shflags
+ self:set("cu-shflags", "-shared")
+
-- init flags
if not is_plat("windows") then
self:set("shared.cuflags", "-Xcompiler -fPIC")
diff --git a/xmake/modules/core/tools/rustc.lua b/xmake/modules/core/tools/rustc.lua
index d98d96e5a..0fa38598a 100644
--- a/xmake/modules/core/tools/rustc.lua
+++ b/xmake/modules/core/tools/rustc.lua
@@ -31,13 +31,13 @@ import("core.project.project")
function init(self)
-- init arflags
- self:set("arflags", "--crate-type=lib")
+ self:set("rc-arflags", "--crate-type=lib")
-- init shflags
- self:set("shflags", "--crate-type=dylib")
+ self:set("rc-shflags", "--crate-type=dylib")
-- init ldflags
- self:set("ldflags", "--crate-type=bin")
+ self:set("rc-ldflags", "--crate-type=bin")
-- init the file formats
self:set("formats", { static = "lib$(name).rlib" })