Skip to content

Commit 724eb49

Browse files
authored
Merge pull request #8417 from jsquyres/pr/config-dot-what
Use newer config.guess / config.sub files when relevant
2 parents 75bce1c + 4a002ce commit 724eb49

File tree

5 files changed

+3677
-3
lines changed

5 files changed

+3677
-3
lines changed

autogen.pl

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env perl
22
#
3-
# Copyright (c) 2009-2019 Cisco Systems, Inc. All rights reserved
3+
# Copyright (c) 2009-2021 Cisco Systems, Inc. All rights reserved
44
# Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
55
# Copyright (c) 2013 Mellanox Technologies, Inc.
66
# All rights reserved.
@@ -1149,6 +1149,102 @@ sub in_tarball {
11491149
return $tarball;
11501150
}
11511151

1152+
##############################################################################
1153+
1154+
sub replace_config_sub_guess {
1155+
# This could be simpler if we could use some Perl modules for this
1156+
# functionality (e.g., DateTime). But I don't want to introduce
1157+
# any CPAN dependencies here, so just do sometime simple, even if
1158+
# it's a bit laborious. Use a few private helper functions for
1159+
# this kind of functionality.
1160+
1161+
sub _get_timestamp {
1162+
my $filename = shift;
1163+
1164+
my $ret;
1165+
if (-x $filename) {
1166+
my $out = `$filename --version`;
1167+
$out =~ m/GNU config\.[a-z]+ \((.+)\)/;
1168+
$ret = $1;
1169+
}
1170+
1171+
return $ret;
1172+
}
1173+
1174+
sub _split_timestamp {
1175+
my $ts = shift;
1176+
1177+
$ts =~ m/(\d+)-(\d+)-(\d+)/;
1178+
return $1, $2, $3;
1179+
}
1180+
1181+
# Returns true if timestamp $a > timestamp $b.
1182+
sub _timestamp_gt {
1183+
my ($a, $b) = @_;
1184+
1185+
my ($year_a, $month_a, $day_a) = _split_timestamp($a);
1186+
my ($year_b, $month_b, $day_b) = _split_timestamp($b);
1187+
1188+
# Don't try to be clever -- just do a simple set of explicit
1189+
# comparisons.
1190+
if ($year_a > $year_b) {
1191+
return 1;
1192+
} elsif ($year_a < $year_b) {
1193+
return 0;
1194+
} else {
1195+
if ($month_a > $month_b) {
1196+
return 1;
1197+
} elsif ($month_a < $month_b) {
1198+
return 0;
1199+
} else {
1200+
if ($day_a > $day_b) {
1201+
return 1;
1202+
} else {
1203+
return 0;
1204+
}
1205+
}
1206+
}
1207+
}
1208+
1209+
my ($topdir) = @_;
1210+
1211+
# Find the stashed known-good files, and get their version
1212+
# timestamps.
1213+
my $cached_dir = "$topdir/config/from-savannah";
1214+
my @files = qw/config.guess config.sub/;
1215+
my %known_good_timestamps;
1216+
foreach my $file (@files) {
1217+
my $filename = "$cached_dir/upstream-$file";
1218+
my_die("Cannot find $filename")
1219+
if (! -f $filename);
1220+
1221+
my $ts = _get_timestamp($filename);
1222+
$known_good_timestamps{$file} = $ts;
1223+
}
1224+
1225+
# Find all config.guess/config.sub files in the tree. If their
1226+
# versions are older than the stashed known-good files, update
1227+
# them from the stash.
1228+
my @files;
1229+
File::Find::find(sub {
1230+
push(@files, $File::Find::name)
1231+
if ($_ eq "config.guess" ||
1232+
$_ eq "config.sub") }, $topdir);
1233+
1234+
foreach my $file (@files) {
1235+
# Skip anything in the 3rd-party tree
1236+
next
1237+
if ($file =~ /\/3rd-party\//);
1238+
1239+
my $base = basename($file);
1240+
my $ts = _get_timestamp($file);
1241+
if (_timestamp_gt($known_good_timestamps{$base}, $ts)) {
1242+
print("=== Replacing $file with newer version\n");
1243+
safe_system("cp -f $cached_dir/upstream-$base $file");
1244+
}
1245+
}
1246+
}
1247+
11521248
##############################################################################
11531249
##############################################################################
11541250
## main - do the real work...
@@ -1590,6 +1686,11 @@ sub in_tarball {
15901686

15911687
patch_autotools_output(".");
15921688

1689+
# Per https://github.com/open-mpi/ompi/issues/8410, replace config.sub
1690+
# and config.guess with known-good versions if the Autoconf-installed
1691+
# versions are older.
1692+
replace_config_sub_guess(".");
1693+
15931694
#---------------------------------------------------------------------------
15941695

15951696
verbose "

config/Makefile.am

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# University of Stuttgart. All rights reserved.
1010
# Copyright (c) 2004-2005 The Regents of the University of California.
1111
# All rights reserved.
12-
# Copyright (c) 2006-2018 Cisco Systems, Inc. All rights reserved.
12+
# Copyright (c) 2006-2021 Cisco Systems, Inc. All rights reserved.
1313
# Copyright (c) 2010 Oracle and/or its affiliates. All rights
1414
# reserved.
1515
# Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
@@ -31,7 +31,9 @@ EXTRA_DIST = \
3131
find_common_syms \
3232
getdate.sh \
3333
make_manpage.pl \
34-
md2nroff.pl
34+
md2nroff.pl \
35+
from-savannah/upstream-config.guess \
36+
from-savannah/upstream-config.sub
3537

3638
maintainer-clean-local:
3739
rm -f opal_get_version.sh

config/from-savannah/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
These files downloaded from
2+
https://git.savannah.gnu.org/gitweb/?p=config.git at git hash
3+
6faca61810d335c7837f320733fe8e15a1431fc2 on 26 Jan 2021.
4+
5+
They were stashed here in the Open MPI repository in response to
6+
https://github.com/open-mpi/ompi/issues/8410, where it was determined
7+
that the responses from `config.*` installed by Autoconf were not
8+
sufficient for some modern platforms (e.g., Apple M1 Macs).
9+
10+
`autogen.pl` will copy in these files if they are, in fact, newer than
11+
the corresponding files installed by Autoconf.

0 commit comments

Comments
 (0)