diff options
| author | ruki <[email protected]> | 2015-12-25 11:20:45 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-12-25 11:20:45 +0800 |
| commit | 3ab31ee7ce09cfb58a3058fb7653991618b2e895 (patch) | |
| tree | 3a30d33d9047fc31478e1e675782c1cc18d447f0 | |
| parent | 757741ef501c2160d08b33dbdfa50ed59a6b7b6a (diff) | |
fix compile error for share library
| -rw-r--r-- | xmake/scripts/base/compiler.lua | 17 | ||||
| -rw-r--r-- | xmake/scripts/base/linker.lua | 6 | ||||
| -rw-r--r-- | xmake/scripts/tools/gcc.lua | 4 |
3 files changed, 25 insertions, 2 deletions
diff --git a/xmake/scripts/base/compiler.lua b/xmake/scripts/base/compiler.lua index 530c70a29..ab6ee1960 100644 --- a/xmake/scripts/base/compiler.lua +++ b/xmake/scripts/base/compiler.lua @@ -112,14 +112,21 @@ function compiler._getflags(module, names, flags) end -- add flags from the compiler -function compiler._addflags_from_compiler(module, flags, flagnames) +function compiler._addflags_from_compiler(module, flags, flagnames, kind) -- check assert(module and flags and flagnames) -- done for _, flagname in ipairs(flagnames) do + + -- add compiler.xxflags table.join2(flags, module, module[flagname]) + + -- add compiler.kind.xxflags + if kind ~= nil and module[kind] ~= nil then + table.join2(flags, module, module[kind][flagname]) + end end end @@ -374,6 +381,9 @@ function compiler._make_for_option(module, opt, srcfile, objfile, logfile) -- add flags from the compiler compiler._addflags_from_compiler(module, flags, flagnames) + -- remove repeat + flags = utils.unique(flags) + -- execute the compile command return module:command_compile(srcfile, objfile, table.concat(flags, " "):trim(), logfile) end @@ -429,7 +439,10 @@ function compiler.make(module, target, srcfile, objfile, logfile) compiler._addflags_from_platform(module, flags, flagnames) -- add flags from the compiler - compiler._addflags_from_compiler(module, flags, flagnames) + compiler._addflags_from_compiler(module, flags, flagnames, target.kind) + + -- remove repeat + flags = utils.unique(flags) -- make the compile command return module:command_compile(srcfile, objfile, table.concat(flags, " "):trim(), logfile) diff --git a/xmake/scripts/base/linker.lua b/xmake/scripts/base/linker.lua index 0c4fdb54f..9a0388757 100644 --- a/xmake/scripts/base/linker.lua +++ b/xmake/scripts/base/linker.lua @@ -337,6 +337,9 @@ function linker.make(module, target, srcfiles, objfiles, targetfile, logfile) -- add flags from the linker linker._addflags_from_linker(module, flags, flagname) + -- remove repeat + flags = utils.unique(flags) + -- make the link command return module:command_link(table.concat(objfiles, " "), targetfile, table.concat(flags, " "):trim(), logfile) end @@ -372,6 +375,9 @@ function linker.check_links(opt, links, sourcefile, objectfile, targetfile) -- add flags from the linker linker._addflags_from_linker(module, flags, "ldflags") + -- remove repeat + flags = utils.unique(flags) + -- execute the link command return module:main(module:command_link(objectfile, targetfile, table.concat(flags, " "):trim(), utils.ifelse(xmake._OPTIONS.verbose, nil, xmake._NULDEV))) end diff --git a/xmake/scripts/tools/gcc.lua b/xmake/scripts/tools/gcc.lua index f1b2f4d55..ab5e94ccb 100644 --- a/xmake/scripts/tools/gcc.lua +++ b/xmake/scripts/tools/gcc.lua @@ -76,6 +76,10 @@ function gcc.init(self, name) self.shflags = { "-shared", "-fPIC" } end + -- init cxflags for the kind: shared + self.shared = {} + self.shared.cxflags = {"-fPIC"} + -- suppress warning for the clang local isclang = false if name:find("clang") then |
