Commits

Jason Perkins committed 9fcdc6a

Fixed bug #176: Target prefix breaks GCC linking

Comments (0)

Files changed (4)

 * 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
 
 
 -------

src/tools/gcc.lua

 --
 -- 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 = {}
 
 		-- 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
 
 	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))

tests/actions/make/cpp/test_make_linking.lua

 --
 -- 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 = { }
 
 		prepare()
 		test.capture [[
-  ALL_LDFLAGS  += $(LDFLAGS) -Lbuild -s
+  ALL_LDFLAGS  += $(LDFLAGS) -s
   LIBS      += build/libMyProject2.a
   LDDEPS    += build/libMyProject2.a
 		]]
 
 		prepare()
 		test.capture [[
-  ALL_LDFLAGS  += $(LDFLAGS) -Lbuild -s
-  LIBS      += -lMyProject2
+  ALL_LDFLAGS  += $(LDFLAGS) -s
+  LIBS      += build/libMyProject2.so
   LDDEPS    += build/libMyProject2.so
 		]]
 	end

tests/tools/test_gcc.lua

 --
 -- 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 = { }
 -- Use the -lname format when linking to sibling shared libraries.
 --
 
-	function suite.links_onStaticSharedLibrary()
+	function suite.links_onSharedSiblingLibrary()
 		links { "MyProject2" }
 
 		test.createproject(sln)
 		targetdir "lib"
 
 		prepare()
-		test.isequal({ "-lMyProject2" }, gcc.getlinks(cfg))
+		test.isequal({ "lib/libMyProject2.so" }, gcc.getlinks(cfg))
 	end