[GASPP] Don't pass the MSVC CRT compiler options to cpp

Message ID 1399540671-5072-1-git-send-email-martin@martin.st
State New
Headers show

Commit Message

Martin Storsjö May 8, 2014, 9:17 a.m.
The -MD option (that specifies using a dynamically linked CRT)
can be interpreted by cpp to create a bogus dependency file named
'-.d'.
---
 gas-preprocessor.pl | 1 +
 1 file changed, 1 insertion(+)

Comments

Janne Grunau May 8, 2014, 10:45 a.m. | #1
On 2014-05-08 12:17:51 +0300, Martin Storsjö wrote:
> The -MD option (that specifies using a dynamically linked CRT)
> can be interpreted by cpp to create a bogus dependency file named
> '-.d'.
> ---
>  gas-preprocessor.pl | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
> index f4a55a9..5216621 100755
> --- a/gas-preprocessor.pl
> +++ b/gas-preprocessor.pl
> @@ -150,6 +150,7 @@ if ($as_type ne "armasm") {
>      @preprocess_c_cmd = grep ! /^-fp/, @preprocess_c_cmd;
>      @preprocess_c_cmd = grep ! /^-EHsc$/, @preprocess_c_cmd;
>      @preprocess_c_cmd = grep ! /^-O/, @preprocess_c_cmd;
> +    @preprocess_c_cmd = grep ! /^-M(D|T)d?$/, @preprocess_c_cmd;

Where is this regexp pattern coming from? Are that the possible crt linking 
options MSVC accepts in CFLAGS?

I would have expected only '/^-MD$/ to be removed since that is a valid 
armsasm option which can't be supported while using it from 
gas-preprocessor.pl.

Making the cmd line options compatible with gas is in scope but I not sure 
whether ignoring unkown options just because libav's configure adds without 
checking if they are supported by the assember is a good idea. I tend to 
think it should fail like gas on unknow options.

I can look at the configure changes.

Janne
Martin Storsjö May 8, 2014, 11:11 a.m. | #2
On Thu, 8 May 2014, Janne Grunau wrote:

> On 2014-05-08 12:17:51 +0300, Martin Storsjö wrote:
>> The -MD option (that specifies using a dynamically linked CRT)
>> can be interpreted by cpp to create a bogus dependency file named
>> '-.d'.
>> ---
>>  gas-preprocessor.pl | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
>> index f4a55a9..5216621 100755
>> --- a/gas-preprocessor.pl
>> +++ b/gas-preprocessor.pl
>> @@ -150,6 +150,7 @@ if ($as_type ne "armasm") {
>>      @preprocess_c_cmd = grep ! /^-fp/, @preprocess_c_cmd;
>>      @preprocess_c_cmd = grep ! /^-EHsc$/, @preprocess_c_cmd;
>>      @preprocess_c_cmd = grep ! /^-O/, @preprocess_c_cmd;
>> +    @preprocess_c_cmd = grep ! /^-M(D|T)d?$/, @preprocess_c_cmd;
>
> Where is this regexp pattern coming from? Are that the possible crt linking
> options MSVC accepts in CFLAGS?

Yes, there's -MD for dynamically linked crt, and -MT for the statically 
linked (threaded) crt (the old non-threaded one doesn't exist any longer), 
and the optional suffix d is for choosing the debug version of said crt.

> I would have expected only '/^-MD$/ to be removed since that is a valid
> armsasm option which can't be supported while using it from
> gas-preprocessor.pl.

It could just as well be -MT, which doesn't happen to work quite as 
coincidentally as -MD did. If I use -MT (to ask for a static crt), the 
build fails (since cpp doesn't understand -MT on its own without -M or 
-MM).

Also, -MD (or -MT) aren't armasm options at all (we strip them out from 
the parameters we pass to armasm.exe as well), they're cl.exe options that 
just ends up here since these cflags end up being passed to the assembler 
as well (since we normally assemble these files with gcc, not with 'as' 
directly, and options, in particular defines, set in --extra-cflags might 
be relevant).

The same happens similarly in openh264 as well - the arm .S sources are 
normally built with gcc, and all normal cflags are included. When I plug 
in gas-preprocessor+armasm there, I end up with -MD passed to 
gas-preprocessor.

FWIW, we already have a bunch of code in the armasm branch for filtering 
out msvc specific cflags that neither cpp nor armasm should be using.

> Making the cmd line options compatible with gas is in scope but I not sure
> whether ignoring unkown options just because libav's configure adds without
> checking if they are supported by the assember is a good idea. I tend to
> think it should fail like gas on unknow options.

That's a very valid point. Then I'd have to try to filter them out in 
openh264 as well though.

If we'd go this way, we should probably remove the filtering of the 
existing MSVC flags in gas-preprocessor as well. However, that would break 
building of existing openh264, so I'd postpone that for a little while.

// Martin

Patch

diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
index f4a55a9..5216621 100755
--- a/gas-preprocessor.pl
+++ b/gas-preprocessor.pl
@@ -150,6 +150,7 @@  if ($as_type ne "armasm") {
     @preprocess_c_cmd = grep ! /^-fp/, @preprocess_c_cmd;
     @preprocess_c_cmd = grep ! /^-EHsc$/, @preprocess_c_cmd;
     @preprocess_c_cmd = grep ! /^-O/, @preprocess_c_cmd;
+    @preprocess_c_cmd = grep ! /^-M(D|T)d?$/, @preprocess_c_cmd;
 
     @gcc_cmd = grep ! /^-G/, @gcc_cmd;
     @gcc_cmd = grep ! /^-W/, @gcc_cmd;