summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-04-03 00:48:49 +0800
committerruki <[email protected]>2019-04-02 22:52:56 +0800
commit09a1f710f009c7b90deea8a0e2c788551c03e66c (patch)
tree352fefed6af060924cc665b4aa59f92b2f43b1bd
parent7175aa15a46eb6c6c8b87755719d39fbd904d983 (diff)
fix -fPIC for nvcc
-rw-r--r--xmake/core/tool/linker.lua22
-rw-r--r--xmake/modules/core/tools/clang.lua5
-rw-r--r--xmake/modules/core/tools/gcc.lua2
3 files changed, 15 insertions, 14 deletions
diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua
index 6d8eff546..1046d204b 100644
--- a/xmake/core/tool/linker.lua
+++ b/xmake/core/tool/linker.lua
@@ -43,7 +43,7 @@ local compiler = require("tool/compiler")
-- add flags from the platform
function linker:_add_flags_from_platform(flags, targetkind)
- -- attempt to add special lanugage flags first for target kind, .e.g binary.gc-ldflags, static.dc-arflags
+ -- attempt to add special lanugage flags first for target kind, .e.g binary.go.gc-ldflags, static.dc-arflags
if targetkind then
local toolkind = self:kind()
local toolname = self:name()
@@ -60,6 +60,7 @@ 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
@@ -67,24 +68,19 @@ function linker:_add_flags_from_compiler(flags, target, targetkind)
if instance then
for _, flagkind in ipairs(self:_flagkinds()) do
- -- attempt to add special lanugage flags first, e.g. gc-ldflags, dc-arflags
- table.join2(flags_of_compiler, instance:get(toolkind .. 'flags') or instance:get(flagkind))
+ -- 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.gc-ldflags, targetkind.dc-arflags
+ -- attempt to add special lanugage flags first for target kind, e.g. targetkind.gcc.ldflags, targetkind.gc-ldflags, targetkind.dc-arflags
if targetkind then
- table.join2(flags_of_compiler, instance:get(targetkind .. '.' .. toolkind .. 'flags') or instance:get(targetkind .. '.' .. flagkind))
+ 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
-
- -- check the compiler flags in linker and add them
- for _, flag in ipairs(flags_of_compiler) do
- -- we need check flags first, see https://github.com/xmake-io/xmake/issues/379
- if self:has_flags(flag) then
- table.insert(flags, flag)
- end
- end
+ table.join2(flags, flags_of_compiler)
end
-- add flags from the linker
diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua
index a54297a4d..7dcc02b5c 100644
--- a/xmake/modules/core/tools/clang.lua
+++ b/xmake/modules/core/tools/clang.lua
@@ -31,6 +31,11 @@ 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/gcc.lua b/xmake/modules/core/tools/gcc.lua
index c9dd32508..d21cbe99f 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("shflags", "-fPIC")
+ self:add("gcc.shflags", "-fPIC") -- only for gcc
self:add("shared.cxflags", "-fPIC")
end