Bug 1263

Summary: waf configure fails on FreeBSD 9.0-BETA2 amd64
Product: ns-3 Reporter: Vedran Miletić <vedran>
Component: build systemAssignee: Gustavo J. A. M. Carneiro <gjcarneiro>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs, sam.jansen
Priority: P5    
Version: pre-release   
Hardware: PC   
OS: FreeBSD   

Description Vedran Miletić 2011-09-22 10:25:24 UTC
Running ./waf configure on FreeBSD 9.0-BETA2 amd64 gives:

Traceback (most recent call last):
  File "/usr/home/vedranm/ns-3-allinone/ns-3-dev/.waf-1.6.7-0a94702c61504c487a251b8d0a04ca9a/waflib/Scripting.py", line 96, in waf_entry_point
    run_commands()
  File "/usr/home/vedranm/ns-3-allinone/ns-3-dev/.waf-1.6.7-0a94702c61504c487a251b8d0a04ca9a/waflib/Scripting.py", line 148, in run_commands
    run_command(cmd_name)
  File "/usr/home/vedranm/ns-3-allinone/ns-3-dev/.waf-1.6.7-0a94702c61504c487a251b8d0a04ca9a/waflib/Scripting.py", line 141, in run_command
    ctx.execute()
  File "/usr/home/vedranm/ns-3-allinone/ns-3-dev/.waf-1.6.7-0a94702c61504c487a251b8d0a04ca9a/waflib/Configure.py", line 127, in execute
    super(ConfigurationContext,self).execute()
  File "/usr/home/vedranm/ns-3-allinone/ns-3-dev/.waf-1.6.7-0a94702c61504c487a251b8d0a04ca9a/waflib/Context.py", line 87, in execute
    self.recurse([os.path.dirname(g_module.root_path)])
  File "/usr/home/vedranm/ns-3-allinone/ns-3-dev/.waf-1.6.7-0a94702c61504c487a251b8d0a04ca9a/waflib/Context.py", line 127, in recurse
    user_function(self)
  File "/usr/home/vedranm/ns-3-allinone/ns-3-dev/wscript", line 354, in configure
    conf.sub_config('src')
  File "/usr/home/vedranm/ns-3-allinone/ns-3-dev/.waf-1.6.7-0a94702c61504c487a251b8d0a04ca9a/waflib/Context.py", line 127, in recurse
    user_function(self)
  File "/usr/home/vedranm/ns-3-allinone/ns-3-dev/src/wscript", line 56, in configure
    conf.sub_config(module, mandatory=False)
  File "/usr/home/vedranm/ns-3-allinone/ns-3-dev/.waf-1.6.7-0a94702c61504c487a251b8d0a04ca9a/waflib/Context.py", line 127, in recurse
    user_function(self)
  File "/usr/home/vedranm/ns-3-allinone/ns-3-dev/src/internet/wscript", line 66, in configure
    conf.msg('Checking for NSC supported architecture ' + arch, ok)
TypeError: cannot concatenate 'str' and 'NoneType' objects
Comment 1 Vedran Miletić 2011-09-23 06:07:35 UTC
NSC also fails, so it's either something broken on FreeBSD side or SConstruct and waf don't support FreeBSD well.

$ ./build.py
# Build NSC
Entering directory `nsc'
 =>  /usr/local/bin/python scons.py
scons: Reading SConscript files ...
OSError: Unsupported architecture, if you want to crosscompile, use "scons target=x86" (or amd64):
  File "/usr/home/vedranm/ns-3-allinone/nsc/SConstruct", line 155:
    if not conf.get_target_architecture():
  File "/usr/home/vedranm/ns-3-allinone/nsc/scons-local-1.2.0.d20090223/SCons/SConf.py", line 647:
    ret = apply(self.test, (context,) +  args, kw)
  File "/usr/home/vedranm/ns-3-allinone/nsc/SConstruct", line 69:
    raise OSError, ('Unsupported architecture, if you want to '
Checking target architecure...# Build NSC: failure (ignoring NSC)
Leaving directory `nsc'
Comment 2 Vedran Miletić 2011-09-23 06:19:37 UTC
OK, this seems very easy. FreeBSD uses name 'amd64' for 'x86_64'. On nsc side this can be patched like:

$ hg diff
diff -r 8a65cb678a50 SConstruct
--- a/SConstruct        Sun May 22 12:24:42 2011 -0700
+++ b/SConstruct        Fri Sep 23 12:18:15 2011 +0200
@@ -58,7 +58,7 @@
   context.Message('Checking target architecure...')
   if arch == 'i686' or arch == 'i586' or arch == 'i486' or arch == 'i386':
     result = 'x86'
-  elif arch == 'x86_64':
+  elif arch in ['amd64', 'x86_64']:
     source = 'int main(void)\n{return 0;}\n'
     context.Message('amd64, checking userland ...')
     result = context.TryCompile(source, '.c')
@@ -66,6 +66,7 @@
       return result
     result = get_elf_class(context.lastTarget)
   else:
+    print arch # ends up being 'amd64'
     raise OSError, ('Unsupported architecture, if you want to '
                     'crosscompile, use \"scons target=x86\" (or amd64)')

In that case, Linux 2.6.18 fails with:

gcc -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -nostdinc -fno-inline -iwithprefix include -DKBUILD_BASENAME=\"clnt\" -DKBUILD_MODNAME=\"nsc\" -DMODVERSIONS -DEXPORT_SYMTAB -include linux/config.h -g -U__FreeBSD__ -D__linux__=1 -Dlinux=1 -D__linux=1 -fPIC -include nsc_override.h -Ilinux-2.6.18/include -Ilinux-2.6.18/include/asm/mach-default -Isim -Ilinux-2.6.18/nsc -Ilinux-2.6.18/override -E linux-2.6.18/net/socket.c -o - | globaliser/globaliser linux-2.6.18//global_list.txt > linux-2.6.18/net/socket.globalised.c
In file included from linux-2.6.18/include/linux/cache.h:4,
                 from linux-2.6.18/include/asm/pda.h:7,
                 from linux-2.6.18/include/asm/thread_info.h:14,
                 from linux-2.6.18/include/linux/thread_info.h:21,
                 from linux-2.6.18/include/linux/preempt.h:9,
                 from linux-2.6.18/include/linux/spinlock.h:49,
                 from linux-2.6.18/include/linux/capability.h:45,
                 from linux-2.6.18/include/linux/sched.h:44,
                 from linux-2.6.18/include/linux/mm.h:4,
                 from linux-2.6.18/net/socket.c:61:
linux-2.6.18/include/linux/kernel.h:10:20: error: stdarg.h: No such file or directory
Line 1015: Char 24594: syntax error, unexpected IDENTIFIER (last token was ')')
<built-in>:0: fatal error: when writing output to : Broken pipe
compilation terminated.
scons: *** [linux-2.6.18/net/socket.globalised.c] Error 1
scons: building terminated because of errors.

Haven't tested much else.
Comment 3 Sam Jansen 2011-09-23 06:22:30 UTC
(In reply to comment #2)
> OK, this seems very easy. FreeBSD uses name 'amd64' for 'x86_64'. On nsc side
> this can be patched like:
> 
> $ hg diff
> diff -r 8a65cb678a50 SConstruct
> --- a/SConstruct        Sun May 22 12:24:42 2011 -0700
> +++ b/SConstruct        Fri Sep 23 12:18:15 2011 +0200
> @@ -58,7 +58,7 @@
>    context.Message('Checking target architecure...')
>    if arch == 'i686' or arch == 'i586' or arch == 'i486' or arch == 'i386':
>      result = 'x86'
> -  elif arch == 'x86_64':
> +  elif arch in ['amd64', 'x86_64']:
>      source = 'int main(void)\n{return 0;}\n'
>      context.Message('amd64, checking userland ...')
>      result = context.TryCompile(source, '.c')
> @@ -66,6 +66,7 @@
>        return result
>      result = get_elf_class(context.lastTarget)
>    else:
> +    print arch # ends up being 'amd64'
>      raise OSError, ('Unsupported architecture, if you want to '
>                      'crosscompile, use \"scons target=x86\" (or amd64)')

That patch is reasonable.

> In that case, Linux 2.6.18 fails with:
> 
> gcc -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -nostdinc -fno-inline
> -iwithprefix include -DKBUILD_BASENAME=\"clnt\" -DKBUILD_MODNAME=\"nsc\"
> -DMODVERSIONS -DEXPORT_SYMTAB -include linux/config.h -g -U__FreeBSD__
> -D__linux__=1 -Dlinux=1 -D__linux=1 -fPIC -include nsc_override.h
> -Ilinux-2.6.18/include -Ilinux-2.6.18/include/asm/mach-default -Isim
> -Ilinux-2.6.18/nsc -Ilinux-2.6.18/override -E linux-2.6.18/net/socket.c -o - |
> globaliser/globaliser linux-2.6.18//global_list.txt >
> linux-2.6.18/net/socket.globalised.c
> In file included from linux-2.6.18/include/linux/cache.h:4,
>                  from linux-2.6.18/include/asm/pda.h:7,
>                  from linux-2.6.18/include/asm/thread_info.h:14,
>                  from linux-2.6.18/include/linux/thread_info.h:21,
>                  from linux-2.6.18/include/linux/preempt.h:9,
>                  from linux-2.6.18/include/linux/spinlock.h:49,
>                  from linux-2.6.18/include/linux/capability.h:45,
>                  from linux-2.6.18/include/linux/sched.h:44,
>                  from linux-2.6.18/include/linux/mm.h:4,
>                  from linux-2.6.18/net/socket.c:61:
> linux-2.6.18/include/linux/kernel.h:10:20: error: stdarg.h: No such file or
> directory
> Line 1015: Char 24594: syntax error, unexpected IDENTIFIER (last token was ')')
> <built-in>:0: fatal error: when writing output to : Broken pipe
> compilation terminated.
> scons: *** [linux-2.6.18/net/socket.globalised.c] Error 1
> scons: building terminated because of errors.
> 
> Haven't tested much else.

This is a bit nasty. I don't have a current FreeBSD box at the moment... Maybe I can setup a virtual machine to test this.

In the mean time, it may be reasonable to disable NSC on this architecture in the ns-3 WAF build.
Comment 4 Vedran Miletić 2011-09-23 06:27:41 UTC
> This is a bit nasty. I don't have a current FreeBSD box at the moment... Maybe
> I can setup a virtual machine to test this.

I will have one working VM soon. If you want to test this, I can mail you the details.

> In the mean time, it may be reasonable to disable NSC on this architecture in
> the ns-3 WAF build.

Something like this is enough to make ns-3 configure pass (NSC will not be enabled since it hasn't been built):

$ hg diff
diff -r f137df528676 src/internet/wscript
--- a/src/internet/wscript      Thu Sep 22 19:09:47 2011 -0400
+++ b/src/internet/wscript      Fri Sep 23 12:21:31 2011 +0200
@@ -53,12 +53,12 @@
                                      "NSC not found (see option --with-nsc)")
        return

-    if sys.platform in ['linux2']:
+    if sys.platform in ['linux2', 'freebsd9']:
         arch = os.uname()[4]
     else:
         arch = None
     ok = False
-    if arch in ('x86_64', 'i686', 'i586', 'i486', 'i386'):
+    if arch in ('amd64', 'x86_64', 'i686', 'i586', 'i486', 'i386'):
         conf.env['NSC_ENABLED'] = True
         conf.env.append_value('CXXDEFINES', 'NETWORK_SIMULATION_CRADLE')
         conf.check_nonfatal(mandatory=True, lib='dl', define_name='HAVE_DL', uselib_store='DL')

However we need to think if 'freebsd9' should be something like 'freebsd7', 'freebsd8', 'freebsd9'.
Comment 5 Gustavo J. A. M. Carneiro 2011-09-23 06:45:06 UTC
(In reply to comment #4)
> > This is a bit nasty. I don't have a current FreeBSD box at the moment... Maybe
> > I can setup a virtual machine to test this.
> 
> I will have one working VM soon. If you want to test this, I can mail you the
> details.
> 
> > In the mean time, it may be reasonable to disable NSC on this architecture in
> > the ns-3 WAF build.
> 
> Something like this is enough to make ns-3 configure pass (NSC will not be
> enabled since it hasn't been built):
> 
> $ hg diff
> diff -r f137df528676 src/internet/wscript
> --- a/src/internet/wscript      Thu Sep 22 19:09:47 2011 -0400
> +++ b/src/internet/wscript      Fri Sep 23 12:21:31 2011 +0200
> @@ -53,12 +53,12 @@
>                                       "NSC not found (see option --with-nsc)")
>         return
> 
> -    if sys.platform in ['linux2']:
> +    if sys.platform in ['linux2', 'freebsd9']:
>          arch = os.uname()[4]
>      else:
>          arch = None
>      ok = False
> -    if arch in ('x86_64', 'i686', 'i586', 'i486', 'i386'):
> +    if arch in ('amd64', 'x86_64', 'i686', 'i586', 'i486', 'i386'):
>          conf.env['NSC_ENABLED'] = True
>          conf.env.append_value('CXXDEFINES', 'NETWORK_SIMULATION_CRADLE')
>          conf.check_nonfatal(mandatory=True, lib='dl', define_name='HAVE_DL',
> uselib_store='DL')
> 
> However we need to think if 'freebsd9' should be something like 'freebsd7',
> 'freebsd8', 'freebsd9'.

Thanks, I pushed a similar patch.  This should fix the ns-3 part of the problem, so I am closing the bug report.  Open a similar bug report for NSC directly, if needed.


changeset:   7534:a42c512034f3
tag:         tip
user:        Gustavo J. A. M. Carneiro  <gjc@inescporto.pt>
date:        Fri Sep 23 11:42:49 2011 +0100
summary:     Bug 1263 - waf configure fails on FreeBSD 9.0-BETA2 amd64