diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua index d90ccb7c17..02e38c2d16 100644 --- a/xmake/core/tool/compiler.lua +++ b/xmake/core/tool/compiler.lua @@ -205,7 +205,7 @@ function compiler:build(sourcefiles, targetfile, opt) opt = opt or {} -- get compile flags - local compflags = opt.compflags + local compflags = opt.compflags and self:_preprocess_flags(opt.compflags) if not compflags then -- patch sourcefile to get flags of the given source file if type(sourcefiles) == "string" then diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua index d91da81d88..7f0aded45a 100644 --- a/xmake/core/tool/linker.lua +++ b/xmake/core/tool/linker.lua @@ -225,7 +225,7 @@ end -- link the target file function linker:link(objectfiles, targetfile, opt) opt = opt or {} - local linkflags = opt.linkflags or self:linkflags(opt) + local linkflags = opt.linkflags and self:_preprocess_flags(opt.linkflags) or self:linkflags(opt) opt = table.copy(opt) opt.target = self:target() profiler:enter(self:name(), "link", targetfile) diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 2ff5be449d..76ddd0678b 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -428,7 +428,7 @@ function nf_rpathdir(self, dir, opt) end return flags elseif self:has_flags("-Xlinker -rpath -Xlinker " .. dir, "ldflags") then - return {"-Xlinker", "-rpath", "-Xlinker", (dir:gsub("%$ORIGIN", "@loader_path"))} + return {"-Xlinker -rpath", "-Xlinker " .. (dir:gsub("%$ORIGIN", "@loader_path"))} end end