Fixed bug #176: Target prefix breaks GCC linking

This commit is contained in:
Jason Perkins 2013-05-16 11:40:47 -04:00
parent 8be16d75b8
commit 621e59481f
4 changed files with 18 additions and 26 deletions

View File

@ -114,6 +114,8 @@
* Patch 154: Fix .def file support for VS2010 (Riccardo Ghetta)
* Patch 159: Validate all values passed to options (Moi_ioM)
* Pull 11: Add support for Visual Studio 2012 (Oliver Schneider)
* Bug 171: ImpLib used incorrectly in dependency paths
* Bug 176: Target prefix breaks GCC linking
-------

View File

@ -1,7 +1,7 @@
--
-- gcc.lua
-- Provides GCC-specific configuration strings.
-- Copyright (c) 2002-2012 Jason Perkins and the Premake project
-- Copyright (c) 2002-2013 Jason Perkins and the Premake project
--
premake.tools.gcc = {}
@ -173,7 +173,7 @@
-- Scan the list of linked libraries. If any are referenced with
-- paths, add those to the list of library search paths
for _, dir in ipairs(config.getlinks(cfg, "all", "directory")) do
for _, dir in ipairs(config.getlinks(cfg, "system", "directory")) do
table.insert(flags, '-L' .. project.getrelative(cfg.project, dir))
end
@ -216,27 +216,17 @@
function gcc.getlinks(cfg, systemonly)
local result = {}
local links
-- Don't use the -l form for sibling libraries, since they may have
-- custom prefixes or extensions that will confuse the linker. Instead
-- just list out the full relative path to the library.
if not systemonly then
links = config.getlinks(cfg, "siblings", "object")
for _, link in ipairs(links) do
-- skip external project references, since I have no way
-- to know the actual output target path
if not link.project.external then
if link.kind == premake.STATICLIB then
-- Don't use "-l" flag when linking static libraries; instead use
-- path/libname.a to avoid linking a shared library of the same
-- name if one is present
table.insert(result, project.getrelative(cfg.project, link.linktarget.abspath))
else
table.insert(result, "-l" .. link.linktarget.basename)
end
end
end
result = config.getlinks(cfg, "siblings", "fullpath")
end
-- The "-l" flag is fine for system libraries
links = config.getlinks(cfg, "system", "fullpath")
local links = config.getlinks(cfg, "system", "fullpath")
for _, link in ipairs(links) do
if path.isframework(link) then
table.insert(result, "-framework " .. path.getbasename(link))

View File

@ -1,7 +1,7 @@
--
-- tests/actions/make/cpp/test_make_linking.lua
-- Validate the link step generation for makefiles.
-- Copyright (c) 2010-2012 Jason Perkins and the Premake project
-- Copyright (c) 2010-2013 Jason Perkins and the Premake project
--
T.make_linking = { }
@ -104,7 +104,7 @@
prepare()
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -Lbuild -s
ALL_LDFLAGS += $(LDFLAGS) -s
LIBS += build/libMyProject2.a
LDDEPS += build/libMyProject2.a
]]
@ -124,8 +124,8 @@
prepare()
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -Lbuild -s
LIBS += -lMyProject2
ALL_LDFLAGS += $(LDFLAGS) -s
LIBS += build/libMyProject2.so
LDDEPS += build/libMyProject2.so
]]
end

View File

@ -1,7 +1,7 @@
--
-- tests/test_gcc.lua
-- Automated test suite for the GCC toolset interface.
-- Copyright (c) 2009-2012 Jason Perkins and the Premake project
-- Copyright (c) 2009-2013 Jason Perkins and the Premake project
--
T.tools_gcc = { }
@ -238,7 +238,7 @@
-- Use the -lname format when linking to sibling shared libraries.
--
function suite.links_onStaticSharedLibrary()
function suite.links_onSharedSiblingLibrary()
links { "MyProject2" }
test.createproject(sln)
@ -247,7 +247,7 @@
targetdir "lib"
prepare()
test.isequal({ "-lMyProject2" }, gcc.getlinks(cfg))
test.isequal({ "lib/libMyProject2.so" }, gcc.getlinks(cfg))
end