Browse files

Fixed compile failure with new --no-whole-archve libs.

  • Loading branch information...
1 parent 8cc6c8c commit 327710767d2257dad27e3885effba1d49d4557f0 Jim Carroll committed Jun 10, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −4
@@ -122,7 +122,7 @@ ifeq (@HAVE_XBMC_NONFREE@,1)
DIRECTORY_ARCHIVES += lib/UnrarXLib/UnrarXLib.a
lib/xbadpcm \
@@ -238,6 +238,9 @@ endif
xbmc/cores/paplayer/paplayer.a: papcodecs
$(DVDPLAYER_ARCHIVES) : dvdpcodecs
+$(NWAOBJSXBMC): force
+ @$(MAKE) $(if $(V),,-s) -C $(@D)
@$(MAKE) $(if $(V),,-s) -C $(@D)
@@ -346,12 +349,12 @@ LIBS += @PYTHON_LDFLAGS@ $(OBJSXBMC) $(DYNOBJSXBMC)
ifeq ($(findstring osx,@ARCH@), osx)
- $(SILENT_LD) $(CXX) $(LDFLAGS) -bundle -o $@ -Wl,-all_load,-ObjC $(DYNOBJSXBMC) $(OBJSXBMC) $(LIBS)
+ $(SILENT_LD) $(CXX) $(LDFLAGS) -bundle -o $@ -Wl,-all_load,-ObjC $(DYNOBJSXBMC) $(NWAOBJSXBMC) $(OBJSXBMC) $(LIBS)
- $(SILENT_LD) $(CXX) $(CXXFLAGS) $(LDFLAGS) -shared -o $@ -Wl,--whole-archive $(DYNOBJSXBMC) $(OBJSXBMC) -Wl,--no-whole-archive $(LIBS)
+ $(SILENT_LD) $(CXX) $(CXXFLAGS) $(LDFLAGS) -shared -o $@ -Wl,--whole-archive $(DYNOBJSXBMC) $(OBJSXBMC) -Wl,--no-whole-archive $(NWAOBJSXBMC) $(LIBS)
ifeq ($(findstring osx,@ARCH@), osx)
$(SILENT_LD) $(CXX) $(LDFLAGS) -o xbmc.bin -Wl,-all_load,-ObjC $(DYNOBJSXBMC) $(NWAOBJSXBMC) $(OBJSXBMC) $(LIBS) -rdynamic

7 comments on commit 3277107


what does the -no-whole-archive-libs build flag do? i'm confused


--whole-archive: This linker directive specifies that the libraries listed following this directive (in this case AA_libs) shall be included in the resulting output even though there may not be any calls requiring its presence. This option is used to specify libraries which the loadable libraries will require at run time.

-no-whole-archive: This needs to be specified whether you list additional object files or not. The gcc/g++ compiler will add its own list of archive libraries and you would not want all the object code in the archive library linked in if not needed. It toggles the behavior back to normal for the rest of the archive libraries.

Team Kodi member

Ideally the default should be used (--no-whole-archive) but since the linker step is only one pass, if your libraries contain circular references you need to either: 1) include the libraries multiple times on the link line. or 2) use the --whole-archive option.

As circular dependencies are removed from the libraries they can be moved from the --whole-archive list to the --no-whole-archive list. Once they are all moved we can remove both parameters.

Team Kodi member

@jimfcarroll fyi, it doesn't have to be no-whole-archive. If multi-pass is needed, groups can be used. no-whole-archive is really for use in other situtations like building a shared lib where some functions might be stripped out, when you know they might be needed.

I can play with grouping if you haven't already given it a shot.

Team Kodi member

@jimfcarroll confirmed that grouping works, but doesn't seem to buy us much. I was hoping for a size reduction, but notsomuch. -ffunction-sections + -Wl,--gc-sections may be more helpful now though, unsure about that.

Fyi, the link-line (for xbmc.bin) becomes:

$(SILENT_LD) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o xbmc.bin -Wl,--start-group $(DYNOBJSXBMC) $(OBJSXBMC) -Wl,--end-group $(NWAOBJSXBMC) $(LIBS) -rdynamic
Team Kodi member

Yeah. I didn't know you could do that. A while back I did a test by dumping all of the libs on the link line multiple times and it saved about 1%.

If you think that's a better way to do it I can change it but I'm not sure it makes a real difference. The goal of getting everything over to the NWAOBJSXBMC list has more to do with a clean/maintainable (testable) library structure than an executable file size.


Team Kodi member

I think the grouping is probably more 'correct', though as you said there's really no gain here. So let's just keep it as-is; no reason to chance breakage.

Understood about NWAOBJSXBMC, and that's definitely a nice goal.

Please sign in to comment.