Bug 955

Summary: Install NSC for NS3 in a Itanium Architecture (ia64) with Linux 2.6.16.6
Product: nsc Reporter: jframos45
Component: coreAssignee: Sam Jansen <sam.jansen>
Status: NEEDINFO ---    
Severity: major CC: jumeba04, ns-bugs, tomh
Priority: P5    
Version: unspecified   
Hardware: Other   
OS: Linux   
Attachments: The preprocessed output.
Preprocessed output from nsc/unimplemented.c

Description jframos45 2010-07-09 06:32:50 UTC
Hi,
we are trying build and install ns3 in a Intel Itanium Architecture (ia64). For this, we need install NSC. We have adapted NSC for accept ia64 and we have added kernel 2.6.16.6 with ia64 includes and libreries.
When we build it,
> python scons.py linux-2.6.16.6

scons: Reading SConscript files ...
Checking target architecure...(cached) ia64
scons: done reading SConscript files.
scons: Building targets ...
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 -include nsc_override.h -Ilinux-2.6.16.6/include -Ilinux-2.6.16.6/include/asm/mach-default -Isim -Ilinux-2.6.16.6/nsc -Ilinux-2.6.16.6/override -E linux-2.6.16.6/arch/ia64/lib/bitop.c -o - | globaliser/globaliser linux-2.6.16.6//global_list.txt > linux-2.6.16.6/arch/ia64/lib/bitop.globalised.c

linux-2.6.16.6/include/asm/current.h:15:1: warning: "current" redefined

... (more redefined warnings) ...

linux-2.6.16.6/nsc/nsc_override.h:17:1: warning: this is the location of the previous definition
Line 3057: Char 115133: syntax error, unexpected TYPEDEF_NAME (last token was ')')
scons: *** [linux-2.6.16.6/arch/ia64/lib/bitop.globalised.c] Error 1
scons: building terminated because of errors.

Can you help we?
Comment 1 Sam Jansen 2010-07-09 12:45:46 UTC
Looks like the "globaliser" isn't handling the input for some reason. Probably just a case of some odd syntax it hasn't seen before.

If you could provide me with the (preprocessed) source, I could try the globaliser here and see if I can make a quick fix.

Perhaps you could send me:
 * The bitop.c file (though I assume it is just http://lxr.linux.no/linux+v2.6.16.6/arch/ia64/lib/bitop.c ?)
 * The preprocessed output. You can copy and paste it from the compile line like so:

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 -include nsc_override.h
-Ilinux-2.6.16.6/include -Ilinux-2.6.16.6/include/asm/mach-default -Isim
-Ilinux-2.6.16.6/nsc -Ilinux-2.6.16.6/override -E
linux-2.6.16.6/arch/ia64/lib/bitop.c -o - > preprocessed.c

That way I should be able to reproduce the bug.
Comment 2 jframos45 2010-07-12 04:35:31 UTC
Created attachment 934 [details]
The preprocessed output.

This is the preprocessed output. The bitop.c is exactly that file (http://lxr.linux.no/linux+v2.6.16.6/arch/ia64/lib/bitop.c)

Thanks.
Comment 3 Sam Jansen 2010-07-12 12:20:31 UTC
Thanks.

I've fixed this and pushed the change to the NSC mercurial repository.
Comment 4 jframos45 2010-07-13 06:37:11 UTC
Your patch is correct! But I have other problem... I am trying fix it, but I don´t find the problem.

gcc -o linux-2.6.16.6/arch/ia64/lib/bitop.globalised.o -c -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 -Ilinux-2.6.16.6/include -Ilinux-2.6.16.6/include/asm/mach-default -Isim -Ilinux-2.6.16.6/nsc -Ilinux-2.6.16.6/override linux-2.6.16.6/arch/ia64/lib/bitop.globalised.c

In file included from linux-2.6.16.6/include/asm/thread_info.h:12,
                 from linux-2.6.16.6/include/linux/thread_info.h:22,
                 from linux-2.6.16.6/include/linux/preempt.h:11,
                 from linux-2.6.16.6/include/linux/spinlock.h:51,
                 from linux-2.6.16.6/include/linux/capability.h:46,
                 from linux-2.6.16.6/include/linux/sched.h:8,
                 from linux-2.6.16.6/include/linux/module.h:11,
                 from linux-2.6.16.6/arch/ia64/lib/bitop.c:5:
linux-2.6.16.6/include/asm/processor.h: In function 'ia64_clear_ic':
linux-2.6.16.6/include/asm/processor.h:469: error: address of global register variable 'global_ia64_r13' requested
linux-2.6.16.6/include/asm/processor.h: In function 'ia64_get_irr':
linux-2.6.16.6/include/asm/processor.h:570: error: address of global register variable 'global_ia64_r13' requested
linux-2.6.16.6/include/asm/processor.h:571: error: address of global register variable 'global_ia64_r13' requested
linux-2.6.16.6/include/asm/processor.h:572: error: address of global register variable 'global_ia64_r13' requested
linux-2.6.16.6/include/asm/processor.h:573: error: address of global register variable 'global_ia64_r13' requested
linux-2.6.16.6/include/asm/processor.h: In function 'ia64_get_ivr':
linux-2.6.16.6/include/asm/processor.h:645: error: address of global register variable 'global_ia64_r13' requested

... more similar errors with the "global_ia64_r13" variable ...

scons: *** [linux-2.6.16.6/arch/ia64/lib/bitop.globalised.o] Error 1
scons: building terminated because of errors.

Any idea for fix this problem?
Thanks!
Comment 5 Sam Jansen 2010-07-13 10:48:14 UTC
I'd suggest just making sure this isn't "globalised".

Try putting the following in your globals file ("global_list.txt"):

ia64_r13$ignored

This variable is just an alias for a register, so shouldn't be globalised I'm thinking.
Comment 6 jframos45 2010-07-18 13:45:57 UTC
Perfect! But... I get other error:

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 -include nsc_override.h -Ilinux-2.6.16.6/include -Ilinux-2.6.16.6/include/asm/mach-default -Isim -Ilinux-2.6.16.6/nsc -Ilinux-2.6.16.6/override -E linux-2.6.16.6/nsc/unimplemented.c -o - | globaliser/globaliser linux-2.6.16.6//global_list.txt > linux-2.6.16.6/nsc/unimplemented.globalised.c

Line 28004: Char 1114847: syntax error, unexpected IDENTIFIER (last token was '[')
scons: *** [linux-2.6.16.6/nsc/unimplemented.globalised.c] Error 1
scons: building terminated because of errors.

I am going to attach the preprocessed file.

Thanks!
Comment 7 jframos45 2010-07-18 13:50:05 UTC
Created attachment 936 [details]
Preprocessed output from nsc/unimplemented.c

Preprocessed output from nsc/unimplemented.c
Comment 8 Sam Jansen 2010-08-03 16:49:27 UTC
Sorry for the late reply.

I think the file you have provided is invalid C code, that is why the globaliser is breaking!

If I try to compile with gcc, I get a bunch of errors, but the one that is breaking the globaliser is this:

  error: `irq_cpustat_t' undeclared here (not in a function)

This looks like it should be a typedef'd type, but it is never typedef'd.

We can easily verify this:

  $ grep irq_cpustat preprocessed.c
  __attribute__((__section__(".data.percpu"))) __typeof__(irq_cpustat_t) per_cpu__irq_stat;
  irq_cpustat_t irq_stat[64];

Two lines there using "irq_cpustat_t" as a type, yet it is never defined.

I suspect you need to make sure all your code works without the globaliser first, then try enabling the globaliser later. If you'd like help with this I'm fairly sure I can find a small change to the SConstript.
Comment 9 jframos45 2010-08-09 13:13:02 UTC
Hi Sam, I will try to explain me.
My steps for build your NSC software in a Itanium architecture have been:
    - Downloading kernel linux-2.6.16.6
    - Building this kernel over ia64 architecture
    - Cleaning and Filtering the necesary files, looking the files that other kernels have in your NSC.
    - Adapting SConscript to build these. (Architecture, files, etc)
    - Building with "python scons.py linix-2.6.16.6"

The problem is that the kernel with ia64 architecture there are many "includes" that not appear similarly that x86 or i386 kernel. Then, there are structs or types that not found.
For example, in ia64, the "irq_cpustat_t" not appear. If I look in his include file in ia64:

/*
 * No irq_cpustat_t for IA-64.  The data is held in the per-CPU data structure.
 */

I have fixed it commenting this lines in nsc/unimplemented.c
   //DEFINE_PER_CPU(irq_cpustat_t, irq_stat);
   //irq_cpustat_t irq_stat[NR_CPUS];

Similar way, I have commented the "include lines" that not exist in ia64 includes files.

I don´t know if this is correct...
Comment 10 Sam Jansen 2010-08-11 13:36:41 UTC
That seems like a perfectly reasonable approach. If you have further problems don't hesitate to ask.
Comment 11 Tom Henderson 2012-03-27 14:23:09 UTC
Is someone still planning to work this, or should I mark as PATCH WANTED state?
Comment 12 Tom Henderson 2012-03-27 14:23:59 UTC
*** Bug 951 has been marked as a duplicate of this bug. ***