Bug 413 - python bindings not portable to OS X
: python bindings not portable to OS X
Status: RESOLVED FIXED
: ns-3
python bindings
: ns-3-dev
: Macintosh Mac OS
: P1 normal
Assigned To:
:
:
:
:
  Show dependency treegraph
 
Reported: 2008-11-17 17:13 EDT by
Modified: 2008-11-25 07:48 EDT (History)


Attachments
darwin-ppc build fix (5.33 KB, patch)
2008-11-20 07:11 EDT, Gustavo J. A. M. Carneiro
Details | Diff


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2008-11-17 17:13:22 EDT
I'm getting the following error when trying to enable Python on OS X:
[531/532] cxx_link: build/debug/bindings/python/ns3module_3.o
build/debug/bindings/python/ns3module_helpers_3.o
build/debug/bindings/python/ns3_module_bridge_3.o
build/debug/bindings/python/ns3_module_common_3.o
build/debug/bindings/python/ns3_module_contrib_3.o
build/debug/bindings/python/ns3_module_core_3.o
build/debug/bindings/python/ns3_module_csma_3.o
build/debug/bindings/python/ns3_module_global_routing_3.o
build/debug/bindings/python/ns3_module_helper_3.o
build/debug/bindings/python/ns3_module_internet_stack_3.o
build/debug/bindings/python/ns3_module_mobility_3.o
build/debug/bindings/python/ns3_module_node_3.o
build/debug/bindings/python/ns3_module_olsr_3.o
build/debug/bindings/python/ns3_module_onoff_3.o
build/debug/bindings/python/ns3_module_packet_sink_3.o
build/debug/bindings/python/ns3_module_point_to_point_3.o
build/debug/bindings/python/ns3_module_simulator_3.o
build/debug/bindings/python/ns3_module_stats_3.o
build/debug/bindings/python/ns3_module_udp_echo_3.o
build/debug/bindings/python/ns3_module_wifi_3.o ->
build/debug/bindings/python/ns3/_ns3.so
/usr/bin/ld: Undefined symbols:
_environ
collect2: ld returned 1 exit status

This seems to be a common problem for OS X, but am not sure how to best address
it in our codebase:
http://wiki.finkproject.org/index.php/Fink:Porting_Notes#The__environ_symbol
------- Comment #1 From 2008-11-18 08:47:45 EDT -------
I don't get it.  Neither the NS-3 library nor the NS-3 Python module use any
kind of '_environ' symbol.

Moreover I am no longer able to ssh into darwin-ppc like I used to, so I am not
able to test this.
------- Comment #2 From 2008-11-20 07:11:01 EDT -------
Created an attachment (id=311) [details]
darwin-ppc build fix

This patch fixes build errors on the darwin-ppc regression host.  It builds
fine there and runs Python unit tests.  Still no idea about this _environ issue
reported here.
------- Comment #3 From 2008-11-22 07:09:33 EDT -------
(From update of attachment 311 [details])
I am waiting for approval from whoever owns the icmpv4 code to commit this.
------- Comment #4 From 2008-11-24 00:35:31 EDT -------
(In reply to comment #2)
> Created an attachment (id=311) [details] [details]
> darwin-ppc build fix
> 
> This patch fixes build errors on the darwin-ppc regression host.  It builds
> fine there and runs Python unit tests.  Still no idea about this _environ issue
> reported here.
> 

I really don't like this patch: the code should be fine without it. Would you
mind show me the compiler error message together with compiler version ?
------- Comment #5 From 2008-11-24 03:02:41 EDT -------
(In reply to comment #4)
> (In reply to comment #2)
> > Created an attachment (id=311) [details] [details] [details]
> > darwin-ppc build fix
> > 
> > This patch fixes build errors on the darwin-ppc regression host.  It builds
> > fine there and runs Python unit tests.  Still no idea about this _environ issue
> > reported here.
> > 
> 
> I really don't like this patch: the code should be fine without it. Would you
> mind show me the compiler error message together with compiler version ?

The bug happens because the python headers include /usr/include/sys/termios.h
which defines the macro ECHO to 0x000008 

This is really butt-ugly, especially since if you grep for ICMP_ECHO in
/usr/include/*, you will find netinet/ip_icmp.h which defines it so, adding the
ICMP prefix is not bullet-proof.

I don't really know what to do: the C preprocessor is a killer.
------- Comment #6 From 2008-11-24 06:34:11 EDT -------
(In reply to comment #5)
> The bug happens because the python headers include /usr/include/sys/termios.h
> which defines the macro ECHO to 0x000008 
> 
> This is really butt-ugly, especially since if you grep for ICMP_ECHO in
> /usr/include/*, you will find netinet/ip_icmp.h which defines it so, adding the
> ICMP prefix is not bullet-proof.

Similar approach was followed by e.g. SocketError.

> 
> I don't really know what to do: the C preprocessor is a killer.

If it were up to me I would still commit this patch as is.  It may not be
bullet proof, but it fixes our immediate problem.  I don't like fixing
potential/unlikely problems.

Another approach would be to #ifdef ECHO #undef ECHO #endif, after including
<Python.h> but before including ns-3 headers.
------- Comment #7 From 2008-11-24 06:47:00 EDT -------
(In reply to comment #6)

> Another approach would be to #ifdef ECHO #undef ECHO #endif, after including
> <Python.h> but before including ns-3 headers.

If that works, I would very much prefer this.
------- Comment #8 From 2008-11-24 07:40:59 EDT -------
(In reply to comment #7)
> (In reply to comment #6)
> 
> > Another approach would be to #ifdef ECHO #undef ECHO #endif, after including
> > <Python.h> but before including ns-3 headers.
> 
> If that works, I would very much prefer this.
> 

In that case, let's not argue about it.  Committed.

Only problem remaining is the _environ issue, which I cannot reproduce on
darwin-ppc unfortunately.
------- Comment #9 From 2008-11-24 23:14:52 EDT -------
(In reply to comment #8)
> (In reply to comment #7)
> > (In reply to comment #6)
> > 
> > > Another approach would be to #ifdef ECHO #undef ECHO #endif, after including
> > > <Python.h> but before including ns-3 headers.
> > 
> > If that works, I would very much prefer this.
> > 
> 
> In that case, let's not argue about it.  Committed.
> 
> Only problem remaining is the _environ issue, which I cannot reproduce on
> darwin-ppc unfortunately.
> 

I cannot reproduce the _environ issue anymore either, so please mark as fixed
if it passes the overnight tests.