Hi all,I just tried to use the merger (together with cilly) but i noticed that it fails with error message:
Unimplemented: something.c:1: Int constant too large: 1341229737
It turns out that the problem is the "#pragma merger (...)"which is written by cilly as first line of the merged output file. The first pragma argument is the last modify time of the merged file in seconds sine the epoch. See lib/Cilly.pm.in, line 696. Nowadays, the "seconds since the epoch" is some integer greater than 1,341,229,737 (which was when i encountered the problem).
It seems that the actual problem is that the pragma is read by CIL which tries to store the modify time in an OCaml int, which is a 31 bit signed integer, during the CABS->CIL conversion. However, the largest positive integer an OCaml int can store is 2^30 = 1,073,741,824 which was in January 2004 if interpreted as unix timestamp.
A quick workaround is to set the system clock to a time before 2004. But this is not really a feasible solution. I think this issue can be fixed either by not using OCaml's native int for representing merger pragma constants or by changing cilly to use smaller numbers than the actual unix timestamp. I'm not sure which solution would be preferable or if there are better ones.
I currently use a hack to make the used timestamp a smaller integer, i.e. i just substract 1,000,000,000. It seems to work fine, but i haven't fully tested it. I appended a patch to Cilly.pm.in which contains my hack. Feel free to use it if it's of any use.
cheers oliver
diff --git a/lib/Cilly.pm.in b/lib/Cilly.pm.in index a119f49..c224f6e 100644 --- a/lib/Cilly.pm.in +++ b/lib/Cilly.pm.in @@ -63,6 +63,12 @@ $Cilly::savedSourceExt = "_saved.c"; $Cilly::m32model = "nogcc32model"; $Cilly::m64model = "nogcc64model"; +# fix file modify time such that it does not overflow a 30 bit unsigned +# representation. just substract a constant. +sub fixMtime { + return $_[0] - 1000000000; +} + # Pass to new a list of command arguments sub new { my ($proto, @args) = @_; @@ -683,7 +689,7 @@ sub compile { if(! defined($mtime_1)) { die "Cannot stat the result of compilation $dest->{filename}"; } - $mtime = $mtime_1; + $mtime = fixMtime($mtime_1); $outfile = $dest->{filename} . $Cilly::savedSourceExt; } my $srcname = ref $src ? $src->filename : $src; @@ -828,7 +834,7 @@ sub separateTrueObjects { if(-f $combsrcname) { my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime_1,$ctime,$blksize,$blocks) = stat($srcname); - $mtime = $mtime_1; + $mtime = fixMtime($mtime_1); } else { $mtime = 0; } @@ -926,9 +932,9 @@ sub link { my $combFile = new OutputFile($destname, "${destname}_comb.c"); my @tmp = stat($combFile); - my $combFileMtime = $tmp[9] || 0; + my $combFileMtime = fixMtime($tmp[9]) || 0; foreach my $mrg (@{$tomerge}) { - my @tmp = stat($mrg); my $mtime = $tmp[9]; + my @tmp = stat($mrg); my $mtime = fixMtime($tmp[9]); if($mtime >= $combFileMtime) { goto DoMerge; } } if($self->{VERBOSE}) {
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________ CIL-users mailing list CIL-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cil-users