automake-patches
[Top][All Lists]
Advanced

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

Always use -c -o when compiling C


From: Peter Rosin
Subject: Always use -c -o when compiling C
Date: Thu, 30 May 2013 00:14:48 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6

Hi!

I just tried the testsuite on maint with MSYS/MSVC and I have one
failure, namely in silent-many-languages.sh. The reason it fails is
that while I have specified MSVC as the C and C++ compiler, I didn't
bother to say that I wasn't interested in fortran. The many-lang
test then mixes the output from the GCC fortran compiler with the
output from MSVC, which is perhaps not very wise but appears to work
for the trivial code in the testcase once you fix the automake
machinery to allow it.

The problem with the automake machinery in this case is that GCC
uses foo.o, while MSVC uses foo.obj, and it so happens that GCC
"wins" and OBJEXT is set to "o". This, coupled with the fact that
automake tries not to use the -o option unless it's really needed
causes make rules to be created w/o -o, but MSVC will then create
foo.obj, which fails badly during linking when automake expects
foo.$OBJEXT, i.e. foo.o.

So, since the maint branch already assumes that -c -o works, how
about the below change? It makes the test PASS for me, and I see
no regression in any other test (but I have a lot of SKIPs, so
I'm not really confident that the change will not cause some
spurious FAILs in any of those).

The concept seems sound to me, but it's perhaps too dangerous?

Cheers,
Peter

diff --git a/bin/automake.in b/bin/automake.in
index 24ff2a6..40b3181 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -632,6 +632,7 @@ register_language ('name' => 'c',
                   'linker' => 'LINK',
                   'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDF
                   'compile_flag' => '-c',
+                  'output_flag' => '-o',
                   'libtool_tag' => 'CC',
                   'extensions' => ['.c']);

@@ -1313,14 +1314,6 @@ sub handle_languages ()
        if (((! option 'no-dependencies') && $lang->autodep ne 'no')
            || defined $lang->compile)
        {
-           # Some C compilers don't support -c -o.  Use it only if really
-           # needed.
-           my $output_flag = $lang->output_flag || '';
-           $output_flag = '-o'
-             if (! $output_flag
-                 && $lang->name eq 'c'
-                 && option 'subdir-objects');
-
            # Compute a possible derived extension.
            # This is not used by depend2.am.
            my $der_ext = ($lang->output_extensions->($ext))[0];
@@ -1364,7 +1357,7 @@ sub handle_languages ()

                             COMPILE   => '$(' . $lang->compiler . ')',
                             LTCOMPILE => '$(LT' . $lang->compiler . ')',
-                            -o        => $output_flag,
+                            -o        => $lang->output_flag,
                             SUBDIROBJ => !! option 'subdir-objects');
        }




reply via email to

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