diff options
author | Jason Perkins <starkos@industriousone.com> | 2013-05-15 17:30:45 +0400 |
---|---|---|
committer | Jason Perkins <starkos@industriousone.com> | 2013-05-15 17:30:45 +0400 |
commit | bb679254e1c25e93611d0a81b49353338de987c4 (patch) | |
tree | db2208070c000646d145540a026b1a259dc30dec | |
parent | 745f63d5e1cf228184fed3ab49e5f8da2867518d (diff) |
Fixed bug #176: Target prefix breaks GCC linking
-rw-r--r-- | CHANGES.txt | 1 | ||||
-rw-r--r-- | src/actions/make/make_cpp.lua | 2 | ||||
-rw-r--r-- | src/tools/gcc.lua | 26 | ||||
-rw-r--r-- | src/tools/snc.lua | 13 | ||||
-rw-r--r-- | tests/actions/make/test_make_linking.lua | 19 | ||||
-rw-r--r-- | tests/test_gmake_cpp.lua | 8 |
6 files changed, 27 insertions, 42 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 07aa41e..5a4c6b7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -73,6 +73,7 @@ * 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 ------- diff --git a/src/actions/make/make_cpp.lua b/src/actions/make/make_cpp.lua index 8f34455..99387ad 100644 --- a/src/actions/make/make_cpp.lua +++ b/src/actions/make/make_cpp.lua @@ -262,8 +262,8 @@ -- Patch #3401184 changed the order _p(' ALL_LDFLAGS += $(LDFLAGS)%s', make.list(table.join(cc.getlibdirflags(cfg), cc.getldflags(cfg), cfg.linkoptions))) - _p(' LIBS +=%s', make.list(cc.getlinkflags(cfg))) _p(' LDDEPS +=%s', make.list(_MAKE.esc(premake.getlinks(cfg, "siblings", "fullpath")))) + _p(' LIBS += $(LDDEPS)%s', make.list(cc.getlinkflags(cfg))) if cfg.kind == "StaticLib" then if cfg.platform:startswith("Universal") then diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index 6fcc88c..403f532 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -186,31 +186,13 @@ -- --- Returns a list of linker flags for library search directories and library --- names. See bug #1729227 for background on why the path must be split. +-- This is poorly named: returns a list of linker flags for external +-- (i.e. system, or non-sibling) libraries. See bug #1729227 for +-- background on why the path must be split. -- function premake.gcc.getlinkflags(cfg) - local result = { } - - for _, value in ipairs(premake.getlinks(cfg, "siblings", "object")) do - if (value.kind == "StaticLib") then - -- don't use "-lname" when linking static libraries - -- instead use path/Name.ext so as not to link with a SharedLib of the same name - -- if one is present. - local pathstyle = premake.getpathstyle(value) - local namestyle = premake.getnamestyle(value) - local linktarget = premake.gettarget(value, "link", pathstyle, namestyle, cfg.system) - local rebasedpath = path.rebase(linktarget.fullpath, value.location, cfg.location) - table.insert(result, rebasedpath) - else - --premake does not support creating frameworks so this is just a SharedLib link - --link using -lname - table.insert(result, '-l' .. _MAKE.esc(value.linktarget.basename)) - end - end - - -- "-llib" is fine for system dependencies + local result = {} for _, value in ipairs(premake.getlinks(cfg, "system", "name")) do if path.getextension(value) == ".framework" then table.insert(result, '-framework ' .. _MAKE.esc(path.getbasename(value))) diff --git a/src/tools/snc.lua b/src/tools/snc.lua index c4c7d42..e829d68 100644 --- a/src/tools/snc.lua +++ b/src/tools/snc.lua @@ -123,14 +123,15 @@ --- --- Returns a list of linker flags for library search directories and library --- names. See bug #1729227 for background on why the path must be split. --- + -- + -- This is poorly named: returns a list of linker flags for external + -- (i.e. system, or non-sibling) libraries. See bug #1729227 for + -- background on why the path must be split. + -- function premake.snc.getlinkflags(cfg) - local result = { } - for _, value in ipairs(premake.getlinks(cfg, "all", "basename")) do + local result = {} + for _, value in ipairs(premake.getlinks(cfg, "system", "name")) do table.insert(result, '-l' .. _MAKE.esc(value)) end return result diff --git a/tests/actions/make/test_make_linking.lua b/tests/actions/make/test_make_linking.lua index ef85353..bf43581 100644 --- a/tests/actions/make/test_make_linking.lua +++ b/tests/actions/make/test_make_linking.lua @@ -27,8 +27,9 @@ -- --- Check linking to a shared library sibling project. Should add the library --- path using -L, and link using the base name with -l flag. +-- Check linking to a shared library sibling project. In order to support +-- custom target prefixes and extensions, use the full, relative path +-- to the library. -- function suite.onSharedLibrarySibling() @@ -39,15 +40,15 @@ prepare() test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -Llibs -s - LIBS += -lMyProject2 LDDEPS += libs/libMyProject2.so + LIBS += $(LDDEPS) ]] end -- --- Check linking to a static library sibling project. Should use the full --- decorated library name, relative path, and no -l flag. +-- Check linking to a static library sibling project. As with shared +-- libraries, it should list out the full relative path. -- function suite.onStaticLibrarySibling() @@ -58,8 +59,8 @@ prepare() test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -Llibs -s - LIBS += libs/libMyProject2.a LDDEPS += libs/libMyProject2.a + LIBS += $(LDDEPS) ]] end @@ -77,8 +78,8 @@ prepare() test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -s - LIBS += LDDEPS += + LIBS += $(LDDEPS) ]] end @@ -101,8 +102,8 @@ prepare() test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -L../MyProject2 -s - LIBS += -lMyProject2 LDDEPS += ../MyProject2/libMyProject2.so + LIBS += $(LDDEPS) ]] end @@ -119,7 +120,7 @@ prepare() test.capture [[ ALL_LDFLAGS += $(LDFLAGS) -L../libs -s - LIBS += -lSomeLib LDDEPS += + LIBS += $(LDDEPS) -lSomeLib ]] end diff --git a/tests/test_gmake_cpp.lua b/tests/test_gmake_cpp.lua index 4a6992e..ec895bd 100644 --- a/tests/test_gmake_cpp.lua +++ b/tests/test_gmake_cpp.lua @@ -83,8 +83,8 @@ ifeq ($(config),debug) ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) ALL_LDFLAGS += $(LDFLAGS) -s - LIBS += LDDEPS += + LIBS += $(LDDEPS) LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(ALL_LDFLAGS) define PREBUILDCMDS endef @@ -117,8 +117,8 @@ ifeq ($(config),debugps3) ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) ALL_LDFLAGS += $(LDFLAGS) -s - LIBS += LDDEPS += + LIBS += $(LDDEPS) LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(ALL_LDFLAGS) define PREBUILDCMDS endef @@ -148,8 +148,8 @@ ifeq ($(config),debug64) ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) ALL_LDFLAGS += $(LDFLAGS) -s -m64 -L/usr/lib64 - LIBS += LDDEPS += + LIBS += $(LDDEPS) LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(ALL_LDFLAGS) define PREBUILDCMDS endef @@ -180,8 +180,8 @@ ifeq ($(config),debuguniv32) ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) ALL_LDFLAGS += $(LDFLAGS) -s -arch i386 -arch ppc - LIBS += LDDEPS += + LIBS += $(LDDEPS) LINKCMD = libtool -o $(TARGET) $(OBJECTS) define PREBUILDCMDS endef |