diff options
| author | SineStriker <[email protected]> | 2025-04-19 03:18:11 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-04-23 11:30:30 +0800 |
| commit | 065761c9a6ac381458850efbd3185628eccd9a2a (patch) | |
| tree | d79679d969e7259855a705231e749c31965bc05c | |
| parent | 6551ed38c1250c0c41eada6db14f8601bf3ddb64 (diff) | |
Fix nil value exception in link proc when target type is package during package testing
| -rw-r--r-- | xmake/core/tool/linker.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 9 | ||||
| -rw-r--r-- | xmake/modules/core/tools/link.lua | 8 | ||||
| -rw-r--r-- | xmake/modules/core/tools/nvcc.lua | 10 |
4 files changed, 16 insertions, 16 deletions
diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua index d91da81d8..d18bf3bd3 100644 --- a/xmake/core/tool/linker.lua +++ b/xmake/core/tool/linker.lua @@ -228,6 +228,11 @@ function linker:link(objectfiles, targetfile, opt) local linkflags = opt.linkflags or self:linkflags(opt) opt = table.copy(opt) opt.target = self:target() + + if self:_targetkind() == "shared" and self:target():implibdir() then + opt.implibdir = self:target():implibdir() + end + profiler:enter(self:name(), "link", targetfile) local ok, errors = sandbox.load(self:_tool().link, self:_tool(), table.wrap(objectfiles), self:_targetkind(), targetfile, linkflags, opt) profiler:leave(self:name(), "link", targetfile) diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 09a5b589e..48e2ebe73 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -575,10 +575,7 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) -- add `-Wl,--out-implib,outputdir/libxxx.a` for xxx.dll on mingw/gcc if targetkind == "shared" and self:is_plat("mingw") then - local implibdir = path.directory(targetfile) - if opt.target then - implibdir = opt.target:implibdir() - end + local implibdir = opt.implibdir or path.directory(targetfile) table.insert(flags_extra, "-Wl,--out-implib," .. path.join(implibdir, path.basename(targetfile) .. ".dll.a")) end @@ -601,8 +598,8 @@ function link(self, objectfiles, targetkind, targetfile, flags, opt) os.mkdir(path.directory(targetfile)) -- ensure the implib directory - if opt and opt.target and opt.target:implibdir() then - os.mkdir(opt.target:implibdir()) + if opt.implibdir then + os.mkdir(opt.implibdir) end local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags, opt) diff --git a/xmake/modules/core/tools/link.lua b/xmake/modules/core/tools/link.lua index fb533eb92..7220b59c2 100644 --- a/xmake/modules/core/tools/link.lua +++ b/xmake/modules/core/tools/link.lua @@ -137,8 +137,8 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) table.insert(argv, 1, "-lib") elseif targetkind == "shared" then table.insert(argv, 1, "-dll") - if opt.target then - table.insert(argv, "/IMPLIB:" .. path.join(opt.target:implibdir(), path.basename(targetfile) .. ".lib")) + if opt.implibdir then + table.insert(argv, "/IMPLIB:" .. path.join(opt.implibdir, path.basename(targetfile) .. ".lib")) end end return self:program(), argv @@ -151,8 +151,8 @@ function link(self, objectfiles, targetkind, targetfile, flags, opt) os.mkdir(path.directory(targetfile)) -- ensure the implib directory - if opt and opt.target and opt.target:implibdir() then - os.mkdir(opt.target:implibdir()) + if opt and opt.implibdir then + os.mkdir(opt.implibdir) end try diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua index b68ed570e..58d614fbd 100644 --- a/xmake/modules/core/tools/nvcc.lua +++ b/xmake/modules/core/tools/nvcc.lua @@ -275,6 +275,7 @@ end -- make the link arguments list function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) + opt = opt or {} -- add rpath for dylib (macho), e.g. -install_name @rpath/file.dylib local flags_extra = {} @@ -287,10 +288,7 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) -- add `-Wl,--out-implib,outputdir/libxxx.a` for xxx.dll on mingw/gcc if targetkind == "shared" and self:is_plat("mingw") then - local implibdir = path.directory(targetfile) - if opt.target then - implibdir = opt.target:implibdir() - end + local implibdir = opt.implibdir or path.directory(targetfile) table.insert(flags_extra, "-Xlinker") table.insert(flags_extra, "-Wl,--out-implib," .. path.join(implibdir, path.basename(targetfile) .. ".dll.a")) end @@ -304,8 +302,8 @@ function link(self, objectfiles, targetkind, targetfile, flags, opt) os.mkdir(path.directory(targetfile)) -- ensure the implib directory - if opt and opt.target and opt.target:implibdir() then - os.mkdir(opt.target:implibdir()) + if opt and opt.implibdir then + os.mkdir(opt.implibdir) end local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags, opt) |
