summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-04-03 00:39:22 +0800
committerruki <[email protected]>2019-04-02 21:56:14 +0800
commit7175aa15a46eb6c6c8b87755719d39fbd904d983 (patch)
treeb849bbd4aed5643320d3c644bec1c7abffa11133
parent305f4158f7f18883d2d88ab31542ab6050644961 (diff)
improve nvcc shflags
-rw-r--r--xmake/core/tool/linker.lua9
-rw-r--r--xmake/languages/cuda/xmake.lua3
-rw-r--r--xmake/modules/core/tools/nvcc.lua6
-rw-r--r--xmake/platforms/macosx/load.lua9
4 files changed, 19 insertions, 8 deletions
diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua
index d582d62bb..6d8eff546 100644
--- a/xmake/core/tool/linker.lua
+++ b/xmake/core/tool/linker.lua
@@ -78,8 +78,13 @@ function linker:_add_flags_from_compiler(flags, target, targetkind)
end
end
- -- add flags
- table.join2(flags, flags_of_compiler)
+ -- 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
end
-- add flags from the linker
diff --git a/xmake/languages/cuda/xmake.lua b/xmake/languages/cuda/xmake.lua
index 7651a4d56..7500bdbbb 100644
--- a/xmake/languages/cuda/xmake.lua
+++ b/xmake/languages/cuda/xmake.lua
@@ -131,6 +131,9 @@ language("cuda")
, {nil, "cu-ar", "kv", nil, "The Cuda Static Library Archiver" }
, {nil, "cu-sh", "kv", nil, "The Cuda Shared Library Linker" }
+ , {category = "Cross Complation Configuration/Compiler Flags Configuration" }
+ , {nil, "cuflags", "kv", nil, "The Cuda Compiler Flags" }
+
, {category = "Cross Complation Configuration/Builtin Flags Configuration" }
, {nil, "links", "kv", nil, "The Link Libraries" }
, {nil, "syslinks", "kv", nil, "The System Link Libraries" }
diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua
index 0c64e1b43..1e8186401 100644
--- a/xmake/modules/core/tools/nvcc.lua
+++ b/xmake/modules/core/tools/nvcc.lua
@@ -34,8 +34,7 @@ function init(self)
-- init flags
if not is_plat("windows") then
- self:set("shflags", "-shared", "-fPIC")
- self:set("shared.cuflags", "-fPIC")
+ self:set("shared.cuflags", "-Xcompiler -fPIC")
end
-- init flags map
@@ -180,12 +179,15 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags)
-- add rpath for dylib (macho), .e.g -install_name @rpath/file.dylib
local flags_extra = {}
if targetkind == "shared" and targetfile:endswith(".dylib") then
+ table.insert(flags_extra, "-Xlinker")
table.insert(flags_extra, "-install_name")
+ table.insert(flags_extra, "-Xlinker")
table.insert(flags_extra, "@rpath/" .. path.filename(targetfile))
end
-- add `-Wl,--out-implib,outputdir/libxxx.a` for xxx.dll on mingw/gcc
if targetkind == "shared" and config.plat() == "mingw" then
+ table.insert(flags_extra, "-Xlinker")
table.insert(flags_extra, "-Wl,--out-implib," .. os.args(path.join(path.directory(targetfile), path.basename(targetfile) .. ".lib")))
end
diff --git a/xmake/platforms/macosx/load.lua b/xmake/platforms/macosx/load.lua
index 5b4b2c659..133521e69 100644
--- a/xmake/platforms/macosx/load.lua
+++ b/xmake/platforms/macosx/load.lua
@@ -94,10 +94,11 @@ function main(platform)
platform:set("rc-ldflags", "")
-- init flags for cuda
- local cu_archs = { i386 = "-m32 -Xcompiler -arch -Xcompiler i386", x86_64 = "-m64 -Xcompiler -arch -Xcompiler x86_64" }
- platform:add("cuflags", cu_archs[arch] or "")
- platform:add("cu-shflags", cu_archs[arch] or "")
- platform:add("cu-ldflags", cu_archs[arch] or "")
+ local cuflags_arch = { i386 = "-m32 -Xcompiler -arch -Xcompiler i386", x86_64 = "-m64 -Xcompiler -arch -Xcompiler x86_64" }
+ local ldflags_arch = { i386 = "-m32 -Xlinker -arch -Xlinker i386", x86_64 = "-m64 -Xlinker -arch -Xlinker x86_64" }
+ platform:add("cuflags", cuflags_arch[arch] or "")
+ platform:add("cu-shflags", ldflags_arch[arch] or "")
+ platform:add("cu-ldflags", ldflags_arch[arch] or "")
local cuda_dir = config.get("cuda")
if cuda_dir then
platform:add("cuflags", "-I" .. os.args(path.join(cuda_dir, "include")))