Bug 756 - Gracefully detect library issues during build
Gracefully detect library issues during build
Status: NEEDINFO
Product: ns-3
Classification: Unclassified
Component: build system
pre-release
All All
: P5 normal
Assigned To: Gustavo J. A. M. Carneiro
:
: 1245 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-11-30 04:54 EST by Lloyd Wood
Modified: 2011-10-21 12:43 EDT (History)
6 users (show)

See Also:


Attachments
Patch for bug 756 (2.90 KB, patch)
2011-08-23 15:43 EDT, Mitch Watrous
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lloyd Wood 2009-11-30 04:54:05 EST
ns-3 can make use of a number of optional libraries when building, such as gtk and freetype. These are, however, difficult to install correctly, and I've run into a situation where they're installed but ns-3 cannot use the libriaries - and the build failed rather than detecting the error and skipping optional libraries. Builds may fail due to a problem with a library that is optional and could have been skipped.

It should be possible to configure ns-3 to build without one or more optional libraries- to produce a stripped-down ns, to test that ns still builds when those components are not present (a series of regression tests trying various configuration combinations), or to avoid problems with those libraries when ns uses them.

Similarly, if a problem is encountered in using an optional library, use of that library should be skipped, rather than causing the build to fail.

(see mailing list discussion end of November 2009 - Mac OS X build problems...
Mathieu Lacage said:
"No, there is no explicit switch but I would support adding one. See
src/contrib/wscript. If you can't do this, please, file a bug.")
Comment 1 Tom Henderson 2010-10-30 17:12:11 EDT
(In reply to comment #0)
> ns-3 can make use of a number of optional libraries when building, such as gtk
> and freetype. These are, however, difficult to install correctly, and I've run
> into a situation where they're installed but ns-3 cannot use the libriaries -
> and the build failed rather than detecting the error and skipping optional
> libraries. Builds may fail due to a problem with a library that is optional and
> could have been skipped.
> 
> It should be possible to configure ns-3 to build without one or more optional
> libraries- to produce a stripped-down ns, to test that ns still builds when
> those components are not present (a series of regression tests trying various
> configuration combinations), or to avoid problems with those libraries when ns
> uses them.

The enable/disable modules feature that Gustavo is bringing back should address this capability, if you can identify what are the troublesome libraries (and we can isolate those ns-3 files to a separate module).  

We probably need to split out GTK Config Store to its own module, rather than including in contrib.

> 
> Similarly, if a problem is encountered in using an optional library, use of
> that library should be skipped, rather than causing the build to fail.

Does this patch temporarily cure your problem?

--- a/src/contrib/wscript	Wed Oct 27 21:19:12 2010 -0700
+++ b/src/contrib/wscript	Sat Oct 30 14:08:07 2010 -0700
@@ -2,7 +2,7 @@
 
 def configure(conf):
     have_gtk = conf.pkg_check_modules('GTK_CONFIG_STORE', 'gtk+-2.0 >= 2.12', mandatory=False)
-    conf.env['ENABLE_GTK_CONFIG_STORE'] = have_gtk
+    conf.env['ENABLE_GTK_CONFIG_STORE'] = False
     conf.report_optional_feature("GtkConfigStore", "GtkConfigStore",
                                  conf.env['ENABLE_GTK_CONFIG_STORE'],
                                  "library 'gtk+-2.0 >= 2.12' not found")

If so, I think you are asking for autoconf-like conftest of gtk (and possibly other related libraries) rather than pkg_check_module.
Comment 2 Pasi Sarolahti 2010-10-31 17:15:03 EDT
I'm having problems when trying to compile ns-3 with fink and Mac OS X / Snow Leopard. Building ends with complaints such as: "ld: warning: in /sw/lib/libxml2.dylib, file was built for i386 which is not the architecture being linked (x86_64)". In addition to gtk+2, libxml2 and libsqlite3 cause problems.

I tested this:

1) reinstalled fink (in 32-bit mode) with minimal set of packages -- ns-3 seemed to compile succesfully (without the problematic libraries installed)

2) added gtk+2 with bunch of other libraries -- ns-3 build failed with above errors

3) Tried your patch -- gtk+2 problem disappeared, but the mentioned two other libraries still cause problems.

My guess is that if I disabled the above two other libraries, build completes again. I wonder what features I might be missing in that case, though. Apparently ns-3 wants to build in 64-bit mode, while the libraries have been built in 32-bit mode by fink.
Comment 3 Tom Henderson 2011-08-09 13:44:39 EDT
I would like to mark this as resolved fixed as of ns-3.11's modular build system.

If a system has an optional library that is failing, the module that depends on that library can now be removed from the build manually.  There isn't any facility for automatically skipping optional libraries (such as labeling certain modules to "build if you can but skip if you run into problems")
Comment 4 Tom Henderson 2011-08-13 10:44:23 EDT
*** Bug 1245 has been marked as a duplicate of this bug. ***
Comment 5 Tom Henderson 2011-08-13 11:04:36 EDT
(In reply to comment #0 from bug 1245)
> tomh writes in bug 756:
> 
>   If a system has an optional library that is failing, the module that depends
> on
>   that library can now be removed from the build manually.  There isn't any
>   facility for automatically skipping optional libraries (such as labeling
>   certain modules to "build if you can but skip if you run into problems")
> 
> ns3 should build as much as possible for user adoption and use. It can finish
> with warnings on what was not built and what will not work, but it should
> always build from a straightforward build.py to give confidence to users.
> Warnings could be e.g off the top of my head.
> 
> ns3 has compiled and can be run as...
> ns3 was unable to build with gtk. This affects:
>  an optional ConfigStore front-end that you are unlikely to need.
> If you require this, install gtk and recompile.
> ns3 was unable to build with freetype. This affects:
>  nothing you'll miss.
> Run ns3 with...
> 
> I've just tried to build ns3 3.11 allinone on a Mac OS X Snow Leopard 10.6.8.
> The errors below are hard fails, and they should not happen. Why a network
> simulator should require the user interface frippery that is GTK is, frankly,
> beyond me -- especially since ns3 relies on python, and python's tkinter is
> very very good at user interface stuff.
> 

How about the following solution?  Add a small test for working xml and gtk libraries during the configure step, with ./waf configure reporting "unable to configure [xml|gtk]-config-store features due to library problems"

Another option which might help your situation (since you have 32-bit libraries installed) is to force 32-bit build by passing -m32 option.  Have you tried this?  (CXXFLAGS="-m32" LDFLAGS="-m32" ./waf configure)  I don't know if this works, offhand.
Comment 6 Mitch Watrous 2011-08-17 20:24:55 EDT
I will try do write conf.check calls in waf that check whether gtk, freetype, and libxml2 libraries work.

Would checking if libraries work necessarily fix this bug?  For example, how would you construct a test that could tell that the libraries had been built for a different architecture?

Here is an example from 

    bindings/python/wscript

that does such a check for the cxxabi:

    # check cxxabi stuff (which Mac OS X Lion breaks)
    fragment = r"""
# include <cxxabi.h>
int main ()
{
   const abi::__si_class_type_info *_typeinfo  __attribute__((unused)) = NULL;
   return 0;
}
"""
    gcc_rtti_abi = conf.check(fragment=fragment, msg="Checking for internal GCC cxxabi",
                              okmsg="complete", errmsg='incomplete',
                              mandatory=False)
    conf.env["GCC_RTTI_ABI_COMPLETE"] = str(bool(gcc_rtti_abi))
Comment 7 Mitch Watrous 2011-08-23 15:43:17 EDT
Created attachment 1223 [details]
Patch for bug 756

The attached patch checks to see whether the gtk and libxml2 libraries work.  If either of them doesn't work, then it is not used with ns-3.

If you have trouble with compiling ns-3 because these optional libraries were compiled with the wrong precision for your machine, then please try this patch on your machine and let me know if it solves your problem, i.e. if ns-3 can compile.
Comment 8 Tom Henderson 2011-10-21 12:43:47 EDT
(In reply to comment #7)
> Created attachment 1223 [details]
> Patch for bug 756
> 
> The attached patch checks to see whether the gtk and libxml2 libraries work. 
> If either of them doesn't work, then it is not used with ns-3.
> 
> If you have trouble with compiling ns-3 because these optional libraries were
> compiled with the wrong precision for your machine, then please try this patch
> on your machine and let me know if it solves your problem, i.e. if ns-3 can
> compile.


This patch gets past the initial problems but leads to other build failures, which I haven't looked into.

[ 624/1556] cxx: src/config-store/model/config-store.cc -> build/src/config-store/model/config-store.cc.1.o
In file included from ../src/config-store/model/config-store.cc:11:
../src/config-store/model/xml-config.h:5:30: error: libxml/xmlwriter.h: No such file or directory
../src/config-store/model/xml-config.h:6:30: error: libxml/xmlreader.h: No such file or directory
[ 625/1556] cxx: src/applications/helper/packet-sink-helper.cc -> build/src/applications/helper/packet-sink-helper.cc.1.o
../src/config-store/model/xml-config.h:26: error: 'xmlTextWriterPtr' does not name a type
Waf: Leaving directory `/Users/buildslave/buildbot/full-darwin-i686-g++-4.0/build/build'
Build failed
 -> task failed (exit status 1): 
	{task 4319343760: cxx config-store.cc -> config-store.cc.1.o}
['g++-4.0', '-O0', '-ggdb', '-g3', '-Wall', '-Werror', '-fstrict-aliasing', '-Wstrict-aliasing', '-fPIC', '-compatibility_version', '1', '-current_version', '1', '-Ibuild', '-I.', '-DNS3_ASSERT_ENABLE', '-DNS3_LOG_ENABLE', '-DSQLITE3=1', '-DPYTHONDIR="/usr/local/lib/python2.7/site-packages"', '-DPYTHONARCHDIR="/usr/local/lib/python2.7/site-packages"', '-DHAVE_PYEMBED=1', '../src/config-store/model/config-store.cc', '-c', '-o', 'src/config-store/model/config-store.cc.1.o']
bash-3.2$