Bug 8634 - New Makefile.in for shared library that reduces binary size 90%
Summary: New Makefile.in for shared library that reduces binary size 90%
Status: NEW
Alias: None
Product: Samba 3.6
Classification: Unclassified
Component: Build environment (show other bugs)
Version: 3.6.1
Hardware: All All
: P5 normal
Target Milestone: ---
Assignee: Björn Jacke
QA Contact: Samba QA Contact
Depends on:
Reported: 2011-11-29 05:03 UTC by Todd Richmond
Modified: 2011-12-01 08:18 UTC (History)
1 user (show)

See Also:

cleaned up Makefile.in for shared library and consistent formatting (120.38 KB, text/plain)
2011-11-29 05:07 UTC, Todd Richmond
no flags Details
smaller patch with build fix for Linux (119.63 KB, text/plain)
2011-11-29 23:45 UTC, Todd Richmond
no flags Details
Fix for Linux link errors and further size reduction (119.63 KB, text/plain)
2011-11-30 05:01 UTC, Todd Richmond
no flags Details
Link failures. (28.21 KB, application/octet-stream)
2011-11-30 21:34 UTC, Jeremy Allison
no flags Details
fixes for smbd crash and incorrect LDFLAGS (119.59 KB, text/plain)
2011-12-01 08:18 UTC, Todd Richmond
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Todd Richmond 2011-11-29 05:03:59 UTC
Here is a new source3/Makefile.in that creates a large libsmbclient.so that is then shared by all tools and test programs. This reduces the binary sizes by 90% and removes several the hacks like libballofmud. It also improves build times considerably

The goal is to get samba 3.6.1 working well on NAS devices and is a critical first step. I contributed this patch to openwrt.org and which allows it to run on 32MB systems. More work is required to chop it down to smaller routers, but this Makefile is useful for large Linux distros as well that want to ship more client programs

libnetapi must be static after this, but its files are only used by net and smbd so it is not very useful
Comment 1 Todd Richmond 2011-11-29 05:07:08 UTC
Created attachment 7148 [details]
cleaned up Makefile.in for shared library and consistent formatting

Significant diffs for code formatting consistency and library dependencies
Comment 2 Volker Lendecke 2011-11-29 15:32:51 UTC
Thanks a lot! Looking....

Comment 3 Volker Lendecke 2011-11-29 19:51:25 UTC
How exactly do you compile this? A normal ./autogen.sh; ./configure; make leaves undefined symbols for me. This is on a SLES11.
Comment 4 Todd Richmond 2011-11-29 23:44:20 UTC
Please skip the 1st Makefile.in and use the 2nd. It had a few issues when I went back to build on Ubuntu. I also did quite a bit more cleanup and size reduction

Also, there needs to be 2 changes to both configure and configure.in

1) comment out or remove the static linkage for libsmbclient

#   until we have organized other internal subsystems (as util, registry
#   and smbconf) into shared libraries, we CAN NOT link libnetapi
#   dynamically to samba programs.


2) remove POPTLIBS objects when using included popt so they can be shared

if test x"$INCLUDED_POPT" = x"yes"; then
Comment 5 Todd Richmond 2011-11-29 23:45:03 UTC
Created attachment 7150 [details]
smaller patch with build fix for Linux
Comment 6 Todd Richmond 2011-11-29 23:46:05 UTC
Looks like we noticed the problem at the same time. The second patch and change to configure/configure.in should resolve the linkage problems
Comment 7 Todd Richmond 2011-11-30 00:58:06 UTC
libsmbclient.so should probably also have its revision bumped to 1 in configure.in since this is such a big change

The only cleaner solution to having everything in libsmbclient.so would be to create a new libsamba.so that everything, including the other .so files depend on, but that is another big set of changes and forces changes to packaging scripts in various distributions oustide samba.org control
Comment 8 Todd Richmond 2011-11-30 01:56:18 UTC
no smbd is crashing - I'll have to look into which change before the two Makefiles broke things - some symbol override issue is most likely
Comment 9 Todd Richmond 2011-11-30 05:01:56 UTC
Created attachment 7151 [details]
Fix for Linux link errors and further size reduction

false alarm - I needed to do a completely clean build. This Makefile.in along with the configure.in change should be enough. Please include the top lines of any link failures if it does not work for you
Comment 10 Jeremy Allison 2011-11-30 21:34:03 UTC
Created attachment 7152 [details]
Link failures.

Here are the link failures I get. It's very close though - please keep working on it !
Comment 11 Todd Richmond 2011-12-01 08:18:42 UTC
Created attachment 7153 [details]
fixes for smbd crash and incorrect LDFLAGS

A few different issues

1) are you sure you commented out "LINK_LIBSMBCLIENT=STATIC" in configure.in (and configure if you don't re-run autogen.sh). Your link errors are caused by linking with libsmbclient.a which should only happen if that line (and the one to remove POPTLIBS) are still there - otherwise everything would link with libsmbclient.so

2) I found that LDFLAGS is incorrectly including @PIE_LDFLAGS@ in original source. This prevents gdb from debugging correctly (prints an error on Debian) because an executable (non library) should not be linked with -pic

3) my crash was caused by having a few more duplicate .o files in both libsmbclient.so and smbd which caused duplicate static data to remain unitialized in one or the other

This Makefile.in should fix the remaining dups as well as a couple errors linking test programs