summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-11-16 22:57:11 +0800
committerruki <[email protected]>2017-11-16 11:43:11 +0800
commit90d3eb8fbd05ffa02df5df18d2f7b6b6c5d7ae87 (patch)
tree77ec0085757430f1b79c6f9b4ec71119d788d087
parentb8e726a61ac0fef93528175dd360fb3844e8dfbe (diff)
improve to build share library on mingw
-rw-r--r--CHANGELOG.md2
-rw-r--r--xmake/modules/core/tools/gcc.lua14
2 files changed, 13 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ca352878e..c8abb92e7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@
### Changes
* Improve to configure cross-toolchains, add tool alias to support unknown tool name, .e.g `xmake f [email protected]`
+* [#151](https://github.com/tboox/xmake/issues/151): Improve to build the share library for the mingw platform
### Bugs fixed
@@ -417,6 +418,7 @@
### 改进
* 改进交叉工具链配置,通过指定工具别名定向到已知的工具链来支持未知编译工具名配置, 例如: `xmake f [email protected]`
+* [#151](https://github.com/tboox/xmake/issues/151): 改进mingw平台下动态库生成
## Bugs修复
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 649a2e48f..205921400 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -280,11 +280,19 @@ end
function linkargv(self, objectfiles, targetkind, targetfile, flags)
-- add rpath for dylib (macho), .e.g -install_name @rpath/file.dylib
- local flags_rpath = nil
+ local flags_extra = {}
if targetkind == "shared" and targetfile:endswith(".dylib") then
- flags_rpath = {"-install_name", "@rpath/" .. path.filename(targetfile)}
+ table.insert(flags_extra, "-install_name")
+ table.insert(flags_extra, "@rpath/" .. path.filename(targetfile))
end
- return self:program(), table.join("-o", targetfile, objectfiles, flags, flags_rpath)
+
+ -- 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, "-Wl,--out-implib," .. os.args(path.join(path.directory(targetfile), path.basename(targetfile) .. ".a")))
+ end
+
+ -- make link args
+ return self:program(), table.join("-o", targetfile, objectfiles, flags, flags_extra)
end
-- link the target file