7022271 set-elf-comments.pl can induce race conditions in X gate builds
authorAlan Coopersmith <Alan.Coopersmith@Oracle.COM>
Thu, 24 Feb 2011 14:59:34 -0800
changeset 1078 7f847d8722f1
parent 1077 64da78e16b04
child 1079 86981537ef98
7022271 set-elf-comments.pl can induce race conditions in X gate builds
open-src/common/set-elf-comments.pl
pkg/manifests/developer-opensolaris-X.mf
--- a/open-src/common/set-elf-comments.pl	Fri Feb 18 14:58:47 2011 -0800
+++ b/open-src/common/set-elf-comments.pl	Thu Feb 24 14:59:34 2011 -0800
@@ -1,4 +1,4 @@
-#! /usr/perl5/bin/perl
+#! /usr/perl5/5.10.0/bin/perl
 #
 # Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
 #
@@ -38,11 +38,14 @@
 # If -X is specified, it gives a regular expresion for filenames to skip
 # for this module.
 
+require 5.10.0;		# needed for Time::Hires::stat
+
 use strict;
 use warnings;
 use Getopt::Std;
 use POSIX qw(strftime);
 use File::Find;
+use Time::HiRes qw();
 
 $Getopt::Std::STANDARD_HELP_VERSION = 1;
 
@@ -110,6 +113,8 @@
 
 $module_version_info =~ s/\s+$//ms;
 
+my %elf_files;
+
 sub scan_file {
   # skip sources & intermediate build files that we don't ship
   return if $_ =~ m/\.[acho]$/ims;
@@ -124,7 +129,7 @@
 
   # If the file is not a symlink, is a regular file, and is at least 256 bytes
   if ((! -l $_) && (-f _) && (-s _ > 256)) {
-    open my $IN, '<', $_ 
+    open my $IN, '<', $_
       or die "Can't open $_ for reading: $!\n";
 
     my $magic_number;
@@ -134,14 +139,21 @@
     close $IN;
 
     if ($magic_number eq "\177ELF") {
-      my @cmd = ('/usr/bin/mcs', '-a', $module_version_info, '-c', $_);
-
-      print join(' ', @cmd), "\n";
-      system(@cmd) == 0
-	or die "*** mcs $File::Find::name failed: $?\n";
+      my @sb = Time::HiRes::stat($_);
+      $elf_files{$File::Find::name} = $sb[9]; # mtime
     }
   }
 }
 
+find(\&scan_file, @ARGV);
 
-find(\&scan_file, @ARGV);
+if (scalar(keys %elf_files) > 0) {
+    my @filelist = sort { $elf_files{$a} <=> $elf_files{$b} } keys %elf_files;
+
+    my @cmd = ('/usr/bin/mcs', '-a', $module_version_info, '-c', @filelist);
+
+    print join(' ', map { if ($_ =~ /\s+/) { qq("$_") } else { $_ } } @cmd),
+	       "\n";
+    system(@cmd) == 0
+	or die "*** mcs failed: $?\n";
+}
--- a/pkg/manifests/developer-opensolaris-X.mf	Fri Feb 18 14:58:47 2011 -0800
+++ b/pkg/manifests/developer-opensolaris-X.mf	Thu Feb 24 14:59:34 2011 -0800
@@ -1,4 +1,4 @@
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -122,6 +122,7 @@
 depend fmri=pkg:/library/zlib type=require
 
 # Build runs a number of perl scripts
+depend fmri=pkg:/runtime/perl-510 type=require
 depend fmri=pkg:/runtime/perl-584 type=require
 depend fmri=pkg:/runtime/perl-584/extra type=require