autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

workaround for problem with VPATH-based builds on Solaris


From: Paul Eggert
Subject: workaround for problem with VPATH-based builds on Solaris
Date: Mon, 05 Jun 2006 13:34:51 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

This message is following up on two threads.

In <http://lists.gnu.org/archive/html/bug-coreutils/2006-05/msg00178.html>
Ralf Wildenhues reported a serious problem with a VPATH-based build
for coreutils using Solaris 'make', in which the build causes a fork
bomb that can bring the system and/or user to its knees.

In <http://lists.gnu.org/archive/html/autoconf-patches/2006-06/msg00018.html>
I responded by installing a patch into Autoconf so that it now
recommends VPATH-based builds only for GNU make.

I eventually tracked the coreutils bug down to the following problem.
With Automake-generated make files, you can't have a test whose name
is 'test', if you want to have VPATH builds that work with
Automake-generated makefiles on Solaris.  Nor can you have a test
whose name contains any of several other standard words like 'echo'.
This is because the VPATH builds mess up on Solaris, by prepending
".../" to all instances of these words, even when this is not intended.

I installed the following patch into the coreutils main branch.  It
works around the immediate problem.  But this is still a minefield,
and I can't recommend using Solaris make for VPATH builds..

I'm CC'ing this to bug-automake because it's not immediately obvious
that you can't put 'TESTS = test echo' etc. in Makefile.am, if you
want your code to work with VPATH builds and Solaris make.  I presume
the problem extends to variables other than TESTS.

Perhaps Automake should follow Autoconf's lead, and start recommending
VPATH builds only for GNU make?  If so, I could prepare a patch to the
Automake documentation along these lines.

Jim, should I also install this patch on the 5.9x branch of coreutils?

2006-06-05  Paul Eggert  <address@hidden>

        Fix problems when building with Solaris/SVR4/etc. make, which uses a
        different and somewhat bogus implementation of VPATH.  In the
        directory tests/misc, rename tests whose names might appear in the
        Automake-generated rules.  For example, we can't use a test named
        'test', since Automake generates a rule that contains the text
        "if test -f ./$$tst; ...", and this might expand to something like
        "if ../../../coreutils-6.0/tests/misc/test -f ./$$test; ...",
        which executes the 'test' script rather than the 'test' command.
        * tests/misc/false-status: Renamed from tests/misc/false.
        * tests/misc/pwd-long: Renamed from tests/misc/pwd.
        * tests/misc/sort-merge: Renamed from tests/misc/sort.
        ($prog): Set to 'sort' rather than to $PROG.
        * tests/misc/test-diag: Renamed from tests/misc/test.
        * tests/misc/Makefile.am (PROG): Take the basename of $$tst,
        in case Solaris make has prepended the directory.
        (TESTS): Adjust to above renamings.
        * tests/misc/expand: Don't assign to PROG; no longer needed
        now that Makefile.am sets PROG to the basename.
        * tests/misc/fold: Likewise.

Index: tests/misc/Makefile.am
===================================================================
RCS file: /fetish/cu/tests/misc/Makefile.am,v
retrieving revision 1.37
diff -p -u -r1.37 Makefile.am
--- tests/misc/Makefile.am      26 Mar 2006 11:48:19 -0000      1.37
+++ tests/misc/Makefile.am      5 Jun 2006 20:02:06 -0000
@@ -9,7 +9,13 @@ TESTS_ENVIRONMENT = \
   PERL="$(PERL)" \
   BUILD_SRC_DIR="`pwd`/../../src" \
   PATH="`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
-  PROG=$$tst
+  PROG=`../../src/basename -- "$$tst"`
+
+# Do not choose a name that is a shell keyword like 'if', or a
+# commonly-used utility like 'cat' or 'test', as the name of a test.
+# Otherwise, VPATH builds will fail on hosts like Solaris, since they
+# will expand 'if test ...' to 'if .../test ...', and the '.../test'
+# will execute the test script rather than the standard utility.
 
 TESTS = \
   base64 \
@@ -20,7 +26,7 @@ TESTS = \
   date-sec \
   dirname \
   expand \
-  false \
+  false-status \
   fold \
   head-c \
   head-elide-tail \
@@ -33,12 +39,12 @@ TESTS = \
   pathchk1 \
   printf \
   printf-hex \
-  pwd \
+  pwd-long \
   sha224sum \
   sha256sum \
   sha384sum \
   sha512sum \
-  sort \
+  sort-merge \
   sort-rand \
   split-a \
   split-fail \
@@ -46,5 +52,5 @@ TESTS = \
   stat-fmt \
   stat-printf \
   tac-continue \
-  test \
+  test-diag \
   tty-eof
Index: tests/misc/expand
===================================================================
RCS file: /fetish/cu/tests/misc/expand,v
retrieving revision 1.2
diff -p -u -r1.2 expand
--- tests/misc/expand   20 Apr 2005 07:54:54 -0000      1.2
+++ tests/misc/expand   5 Jun 2006 20:02:06 -0000
@@ -18,8 +18,6 @@ use strict;
 
 (my $program_name = $0) =~ s|.*/||;
 
-$ENV{PROG} = 'expand';
-
 # Turn off localization of executable's ouput.
 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
 
Index: tests/misc/fold
===================================================================
RCS file: /fetish/cu/tests/misc/fold,v
retrieving revision 1.3
diff -p -u -r1.3 fold
--- tests/misc/fold     20 Apr 2005 07:54:54 -0000      1.3
+++ tests/misc/fold     5 Jun 2006 20:02:06 -0000
@@ -31,8 +31,6 @@ use strict;
 
 (my $program_name = $0) =~ s|.*/||;
 
-$ENV{PROG} = 'fold';
-
 # Turn off localization of executable's ouput.
 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
 
--- /dev/null   2005-09-24 22:00:15.000000000 -0700
+++ tests/misc/false-status     2003-04-02 10:06:52.000000000 -0800
@@ -0,0 +1,28 @@
+#!/bin/sh
+# ensure that false exits nonzero even with --help or --version
+
+if test "$VERBOSE" = yes; then
+  set -x
+  false --version
+fi
+
+pwd=`pwd`
+t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
+trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
+trap '(exit $?); exit $?' 1 2 13 15
+
+framework_failure=0
+mkdir -p $tmp || framework_failure=1
+cd $tmp || framework_failure=1
+
+if test $framework_failure = 1; then
+  echo "$0: failure in testing framework" 1>&2
+  (exit 1); exit 1
+fi
+
+fail=0
+
+false --version > /dev/null && fail=1
+false --help > /dev/null && fail=1
+
+(exit $fail); exit $fail
--- /dev/null   2005-09-24 22:00:15.000000000 -0700
+++ tests/misc/pwd-long 2004-07-28 12:23:07.000000000 -0700
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+: ${PERL=perl}
+
+$PERL -e 1 > /dev/null 2>&1 || {
+  echo 1>&2 "$0: configure didn't find a usable version of Perl," \
+    "so can't run this test"
+  exit 77
+}
+
+framework_failure=0
+pwd=`${BUILD_SRC_DIR?}/pwd` || framework_failure=1
+t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
+trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
+trap '(exit $?); exit $?' 1 2 13 15
+
+mkdir -p $tmp || framework_failure=1
+cd $tmp || framework_failure=1
+
+if test $framework_failure = 1; then
+  echo "$0: failure in testing framework" 1>&2
+  (exit 1); exit 1
+fi
+
+ARGV_0=$0
+export ARGV_0
+
+CWD=$pwd/$tmp
+export CWD
+
+$PERL -w -- - <<\EOF
+
+# Show that pwd works even when the length of the resulting
+# directory name is longer than PATH_MAX.
+use strict;
+use Cwd;
+
+(my $ME = $ENV{ARGV_0}) =~ s|.*/||;
+
+my $cwd = $ENV{CWD};
+my $z = 'z' x 31;
+my $n = 256;
+my $expected = $cwd . ("/$z" x $n);
+
+my $i = 0;
+do
+  {
+    mkdir $z, 0700
+      or die "$ME: at depth $i: $!\n";
+    chdir $z;
+  }
+until (++$i == $n);
+
+my $build_src_dir = $ENV{BUILD_SRC_DIR};
+$build_src_dir
+  or die "$ME: envvar BUILD_SRC_DIR not defined\n";
+my $pwd_binary = "$build_src_dir/pwd";
+-x $pwd_binary
+  or die "$ME: $pwd_binary is not an executable file\n";
+chomp (my $actual = `$pwd_binary`);
+$expected eq $actual
+  or die "$ME: $expected\n$actual\n";
+EOF
--- /dev/null   2005-09-24 22:00:15.000000000 -0700
+++ tests/misc/sort-merge       2006-06-05 12:27:46.000000000 -0700
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+: ${PERL=perl}
+: ${srcdir=.}
+
+$PERL -e 1 > /dev/null 2>&1 || {
+  echo 1>&2 "$0: configure didn't find a usable version of Perl," \
+    "so can't run this test"
+  exit 77
+}
+
+exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF
+require 5.003;
+use strict;
+
+(my $program_name = $0) =~ s|.*/||;
+
+# Turn off localisation of executable's ouput.
address@hidden(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+
+my @Tests =
+    (
+     ['m1', '-m', {IN=> {empty=> ''}}, {IN=> {f=> "foo\n"}}, {OUT=>"foo\n"}],
+    );
+
+my $save_temps = $ENV{DEBUG};
+my $verbose = $ENV{VERBOSE};
+
+my $prog = 'sort';
+my $fail = run_tests ($program_name, $prog, address@hidden, $save_temps, 
$verbose);
+exit $fail;
+EOF
--- /dev/null   2005-09-24 22:00:15.000000000 -0700
+++ tests/misc/test-diag        2006-01-11 23:22:00.000000000 -0800
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+: ${PERL=perl}
+: ${srcdir=.}
+
+$PERL -e 1 > /dev/null 2>&1 || {
+  echo 1>&2 "$0: configure didn't find a usable version of Perl," \
+    "so can't run this test"
+  exit 77
+}
+
+exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF
+require 5.003;
+use strict;
+
+(my $program_name = $0) =~ s|.*/||;
+
+# Turn off localisation of executable's ouput.
address@hidden(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+
+my $prog = '../../src/test';
+my @Tests =
+    (
+     # In coreutils-5.93, this diagnostic lacked the newline.
+     ['o', '-o arg', {ERR => "$prog: extra argument `-o'\n"}, {EXIT => 2}],
+    );
+
+my $save_temps = $ENV{DEBUG};
+my $verbose = $ENV{VERBOSE};
+
+my $fail = run_tests ($program_name, $prog, address@hidden, $save_temps, 
$verbose);
+exit $fail;
+EOF




reply via email to

[Prev in Thread] Current Thread [Next in Thread]