[arm-embedded] [PATCH, GCC/x86 mingw32] Add configure option to force wildcard behavior on Windows

2017-05-04 Thread Thomas Preudhomme

Hi,

We've decided to apply the following patch to the ARM/embedded-7-branch as we 
did earlier for the ARM/embedded-6-branch. Patch attached for reference.


Best regards,

Thomas

On 17/02/17 22:52, JonY wrote:

On 02/17/2017 11:31 AM, Thomas Preudhomme wrote:

Here you are:

2017-01-24  Thomas Preud'homme  

* configure.ac (--enable-mingw-wildcard): Add new configurable
feature.
* configure: Regenerate.
* config.in: Regenerate.
* config/i386/driver-mingw32.c: new file.
* config/i386/x-mingw32: Add rule to build driver-mingw32.o.
* config.host: Link driver-mingw32.o on MinGW host.
* doc/install.texi: Document new --enable-mingw-wildcard configure
option.

Must have forgotten to paste it.


Thanks, I'll stage it locally until stage 1 opens.



diff --git a/gcc/ChangeLog.arm b/gcc/ChangeLog.arm
new file mode 100644
index ..d336f6a29a7f68fb938b2fae45f453bd20f35903
--- /dev/null
+++ b/gcc/ChangeLog.arm
@@ -0,0 +1,13 @@
+2017-05-04  Thomas Preud'homme  
+
+	Backport from mainline
+	2017-05-04  Thomas Preud'homme  
+
+	* configure.ac (--enable-mingw-wildcard): Add new configurable feature.
+	* configure: Regenerate.
+	* config.in: Regenerate.
+	* config/i386/driver-mingw32.c: new file.
+	* config/i386/x-mingw32: Add rule to build driver-mingw32.o.
+	* config.host: Link driver-mingw32.o on MinGW host.
+	* doc/install.texi: Document new --enable-mingw-wildcard configure
+	option.
diff --git a/gcc/config.host b/gcc/config.host
index 6b28f3033ef92f1f0e09cc41f3a90be05c5e1e43..5e2db5327e3094a19cd29c81ceb1a9e2b11797c9 100644
--- a/gcc/config.host
+++ b/gcc/config.host
@@ -239,6 +239,7 @@ case ${host} in
 host_xmake_file="${host_xmake_file} i386/x-mingw32"
 host_exeext=.exe
 out_host_hook_obj=host-mingw32.o
+host_extra_gcc_objs="${host_extra_gcc_objs} driver-mingw32.o"
 host_lto_plugin_soname=liblto_plugin-0.dll
 ;;
   x86_64-*-mingw*)
@@ -247,6 +248,7 @@ case ${host} in
 host_xmake_file="${host_xmake_file} i386/x-mingw32"
 host_exeext=.exe
 out_host_hook_obj=host-mingw32.o
+host_extra_gcc_objs="${host_extra_gcc_objs} driver-mingw32.o"
 host_lto_plugin_soname=liblto_plugin-0.dll
 ;;
   i[34567]86-*-darwin* | x86_64-*-darwin*)
diff --git a/gcc/config.in b/gcc/config.in
index d87cb3c9fab0499137702be24085e6f61d7f89e4..bf2aa7b2e7d81a593b72a8d0359864773754ef5d 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -2009,6 +2009,12 @@
 #endif
 
 
+/* Value to set mingw's _dowildcard to. */
+#ifndef USED_FOR_TARGET
+#undef MINGW_DOWILDCARD
+#endif
+
+
 /* Define if host mkdir takes a single argument. */
 #ifndef USED_FOR_TARGET
 #undef MKDIR_TAKES_ONE_ARG
diff --git a/gcc/config/i386/driver-mingw32.c b/gcc/config/i386/driver-mingw32.c
new file mode 100644
index ..b70363ad26a7dc8ffccbb273e46d4dd6de1a6f8c
--- /dev/null
+++ b/gcc/config/i386/driver-mingw32.c
@@ -0,0 +1,26 @@
+/* Host OS specific configuration for the gcc driver.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+.  */
+
+#include "config.h"
+
+/* When defined, force the use (if non null) or not (otherwise) of CLI
+   globbing.  */
+#ifdef MINGW_DOWILDCARD
+int _dowildcard = MINGW_DOWILDCARD;
+#endif
diff --git a/gcc/config/i386/x-mingw32 b/gcc/config/i386/x-mingw32
index 6a2d5a5069461b93884fa68ffbcbb13585d24c37..85f2793e5e934b6bf5629667578940cf3f172be3 100644
--- a/gcc/config/i386/x-mingw32
+++ b/gcc/config/i386/x-mingw32
@@ -29,3 +29,6 @@ host-mingw32.o : $(srcdir)/config/i386/host-mingw32.c $(CONFIG_H) $(SYSTEM_H) \
   coretypes.h hosthooks.h hosthooks-def.h toplev.h $(DIAGNOSTIC_H) $(HOOKS_H)
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 		$(srcdir)/config/i386/host-mingw32.c
+
+driver-mingw32.o : $(srcdir)/config/i386/driver-mingw32.c $(CONFIG_H)
+	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
diff --git a/gcc/configure b/gcc/configure
index ea73b151a4e1797983665a7f5437136dc8dcb46e..1a295674eb448725e24df85b2fe85e74b32f02d7 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -921,6 +921,7 @@ with_libiconv_prefix
 enable_sjlj_exceptions
 with_gcc_major_version_only
 enable_secureplt
+enable_mingw_wildcard
 

[wwwdocs] gcc-8/porting_to.html (was: [PATCH, GCC/x86 mingw32] Add configure option to force wildcard behavior on Windows)

2017-03-04 Thread Gerald Pfeifer
On Thu, 2 Mar 2017, Thomas Preudhomme wrote:
>> This should be mentioned in the "porting to" page when it eventually 
>> goes in, as it may be surprising behavior.
> Will do once the file is created for gcc-8. Thanks for the suggestion

Here we go. :-)  Applied.

Gerald

Index: porting_to.html
===
RCS file: porting_to.html
diff -N porting_to.html
--- /dev/null   1 Jan 1970 00:00:00 -
+++ porting_to.html 4 Mar 2017 14:20:46 -
@@ -0,0 +1,37 @@
+
+
+
+Porting to GCC 8
+
+
+
+Porting to GCC 8
+
+
+The GCC 8 release series differs from previous GCC releases in
+a number of ways. Some of these are a result
+of bug fixing, and some old behaviors have been intentionally changed
+to support new standards, or relaxed in standards-conforming ways to
+facilitate compilation or run-time performance.
+
+
+
+Some of these changes are user visible and can cause grief when
+porting to GCC 8. This document is an effort to identify common issues
+and provide solutions. Let us know if you have suggestions for improvements!
+
+
+
+Preprocessor issues
+
+
+C language issues
+
+
+C++ language issues
+
+
+Links
+
+
+


Re: [PATCH, GCC/x86 mingw32] Add configure option to force wildcard behavior on Windows

2017-02-22 Thread Thomas Preudhomme

Oh great thanks!

Best regards,

Thomas

On 17/02/17 22:52, JonY wrote:

On 02/17/2017 11:31 AM, Thomas Preudhomme wrote:

Here you are:

2017-01-24  Thomas Preud'homme  

* configure.ac (--enable-mingw-wildcard): Add new configurable
feature.
* configure: Regenerate.
* config.in: Regenerate.
* config/i386/driver-mingw32.c: new file.
* config/i386/x-mingw32: Add rule to build driver-mingw32.o.
* config.host: Link driver-mingw32.o on MinGW host.
* doc/install.texi: Document new --enable-mingw-wildcard configure
option.

Must have forgotten to paste it.


Thanks, I'll stage it locally until stage 1 opens.





Re: [PATCH, GCC/x86 mingw32] Add configure option to force wildcard behavior on Windows

2017-02-17 Thread JonY
On 02/17/2017 11:31 AM, Thomas Preudhomme wrote:
> Here you are:
> 
> 2017-01-24  Thomas Preud'homme  
> 
> * configure.ac (--enable-mingw-wildcard): Add new configurable
> feature.
> * configure: Regenerate.
> * config.in: Regenerate.
> * config/i386/driver-mingw32.c: new file.
> * config/i386/x-mingw32: Add rule to build driver-mingw32.o.
> * config.host: Link driver-mingw32.o on MinGW host.
> * doc/install.texi: Document new --enable-mingw-wildcard configure
> option.
> 
> Must have forgotten to paste it.

Thanks, I'll stage it locally until stage 1 opens.





signature.asc
Description: OpenPGP digital signature


Re: [PATCH, GCC/x86 mingw32] Add configure option to force wildcard behavior on Windows

2017-02-17 Thread Thomas Preudhomme

Here you are:

2017-01-24  Thomas Preud'homme  

* configure.ac (--enable-mingw-wildcard): Add new configurable feature.
* configure: Regenerate.
* config.in: Regenerate.
* config/i386/driver-mingw32.c: new file.
* config/i386/x-mingw32: Add rule to build driver-mingw32.o.
* config.host: Link driver-mingw32.o on MinGW host.
* doc/install.texi: Document new --enable-mingw-wildcard configure
option.

Must have forgotten to paste it.

On 17/02/17 10:52, JonY wrote:

On 02/14/2017 10:42 AM, JonY wrote:

On 02/14/2017 09:32 AM, Thomas Preudhomme wrote:


Looks good, be sure to emphasize this option affects mingw hosted GCC
only, not the compiler output.


I think that should be pretty clear in the latest version of the patch,
doc/install.texi contains:

"Note that this option only affects wildcard expansion for GCC itself.
It does
not affect wildcard expansion of executables built by the resulting GCC."

If you think a part of that sentence is still confusing please let me
know and I'll improve it.

Best regards,

Thomas



Yes, that should be good, no more objections.




Before I forget, please also provide a changelog, thanks.




Re: [PATCH, GCC/x86 mingw32] Add configure option to force wildcard behavior on Windows

2017-02-17 Thread JonY
On 02/14/2017 10:42 AM, JonY wrote:
> On 02/14/2017 09:32 AM, Thomas Preudhomme wrote:
>>>
>>> Looks good, be sure to emphasize this option affects mingw hosted GCC
>>> only, not the compiler output.
>>
>> I think that should be pretty clear in the latest version of the patch,
>> doc/install.texi contains:
>>
>> "Note that this option only affects wildcard expansion for GCC itself. 
>> It does
>> not affect wildcard expansion of executables built by the resulting GCC."
>>
>> If you think a part of that sentence is still confusing please let me
>> know and I'll improve it.
>>
>> Best regards,
>>
>> Thomas
>>
> 
> Yes, that should be good, no more objections.
> 
> 

Before I forget, please also provide a changelog, thanks.




signature.asc
Description: OpenPGP digital signature


Re: [PATCH, GCC/x86 mingw32] Add configure option to force wildcard behavior on Windows

2017-02-14 Thread JonY
On 02/14/2017 09:32 AM, Thomas Preudhomme wrote:
>>
>> Looks good, be sure to emphasize this option affects mingw hosted GCC
>> only, not the compiler output.
> 
> I think that should be pretty clear in the latest version of the patch,
> doc/install.texi contains:
> 
> "Note that this option only affects wildcard expansion for GCC itself. 
> It does
> not affect wildcard expansion of executables built by the resulting GCC."
> 
> If you think a part of that sentence is still confusing please let me
> know and I'll improve it.
> 
> Best regards,
> 
> Thomas
> 

Yes, that should be good, no more objections.




signature.asc
Description: OpenPGP digital signature


Re: [PATCH, GCC/x86 mingw32] Add configure option to force wildcard behavior on Windows

2017-02-14 Thread Thomas Preudhomme

Hi Jonathan,

Sorry for the delay answering.

On 07/02/17 08:47, JonY wrote:

On 01/26/2017 01:04 PM, Thomas Preudhomme wrote:

Hi JonY,

On 19/01/17 01:37, JonY wrote:

On 01/18/2017 09:48 AM, Thomas Preudhomme wrote:

By default, wildcard support on Windows for programs compiled with mingw
depends on how the mingw runtime was configured. This means if one wants
to build GCC for Windows with a consistent behavior with Wildcard
(enabled or disabled) the mingw runtime must be built as well. This
patch adds an option to GCC configuration to force the behavior with
wildcard when building GCC for Windows host. It does so by setting the
_dowildcard variable in the driver to a given value depending on the
configure option value (yes or no), thus overriding the variable from
mingw runtime.

Testing: I've successfully done a build of the arm-none-eabi cross GCC
for Windows with Ubuntu system mingw runtime (configured without
wildcard support by default) with the three configure options:
  1) --enable-wildcard: wildcard can be used successfully and nm of
driver-mingw32.o shows that _dowildcard is in .data section
  2) --disable-wildcard: wildcard cannot be used and nm of
driver-mingw32.o shows that _dowildcard is in .bss section
  3) no option: wildcard cannot be used and nm of driver-mingw32.o shows
no _dowildcard defined and all sections are empty

Is this ok for stage1?



Looks good, be sure to emphasize this option affects mingw hosted GCC
only, not the compiler output.


I think that should be pretty clear in the latest version of the patch, 
doc/install.texi contains:


"Note that this option only affects wildcard expansion for GCC itself.  It does
not affect wildcard expansion of executables built by the resulting GCC."

If you think a part of that sentence is still confusing please let me know and 
I'll improve it.


Best regards,

Thomas


Re: [PATCH, GCC/x86 mingw32] Add configure option to force wildcard behavior on Windows

2017-02-07 Thread JonY
On 01/26/2017 01:04 PM, Thomas Preudhomme wrote:
> Hi JonY,
> 
> On 19/01/17 01:37, JonY wrote:
>> On 01/18/2017 09:48 AM, Thomas Preudhomme wrote:
>>> By default, wildcard support on Windows for programs compiled with mingw
>>> depends on how the mingw runtime was configured. This means if one wants
>>> to build GCC for Windows with a consistent behavior with Wildcard
>>> (enabled or disabled) the mingw runtime must be built as well. This
>>> patch adds an option to GCC configuration to force the behavior with
>>> wildcard when building GCC for Windows host. It does so by setting the
>>> _dowildcard variable in the driver to a given value depending on the
>>> configure option value (yes or no), thus overriding the variable from
>>> mingw runtime.
>>>
>>> Testing: I've successfully done a build of the arm-none-eabi cross GCC
>>> for Windows with Ubuntu system mingw runtime (configured without
>>> wildcard support by default) with the three configure options:
>>>   1) --enable-wildcard: wildcard can be used successfully and nm of
>>> driver-mingw32.o shows that _dowildcard is in .data section
>>>   2) --disable-wildcard: wildcard cannot be used and nm of
>>> driver-mingw32.o shows that _dowildcard is in .bss section
>>>   3) no option: wildcard cannot be used and nm of driver-mingw32.o shows
>>> no _dowildcard defined and all sections are empty
>>>
>>> Is this ok for stage1?
>>>

Looks good, be sure to emphasize this option affects mingw hosted GCC
only, not the compiler output.





signature.asc
Description: OpenPGP digital signature


Re: [PATCH, GCC/x86 mingw32] Add configure option to force wildcard behavior on Windows

2017-01-26 Thread Thomas Preudhomme

Hi JonY,

On 19/01/17 01:37, JonY wrote:

On 01/18/2017 09:48 AM, Thomas Preudhomme wrote:

By default, wildcard support on Windows for programs compiled with mingw
depends on how the mingw runtime was configured. This means if one wants
to build GCC for Windows with a consistent behavior with Wildcard
(enabled or disabled) the mingw runtime must be built as well. This
patch adds an option to GCC configuration to force the behavior with
wildcard when building GCC for Windows host. It does so by setting the
_dowildcard variable in the driver to a given value depending on the
configure option value (yes or no), thus overriding the variable from
mingw runtime.

Testing: I've successfully done a build of the arm-none-eabi cross GCC
for Windows with Ubuntu system mingw runtime (configured without
wildcard support by default) with the three configure options:
  1) --enable-wildcard: wildcard can be used successfully and nm of
driver-mingw32.o shows that _dowildcard is in .data section
  2) --disable-wildcard: wildcard cannot be used and nm of
driver-mingw32.o shows that _dowildcard is in .bss section
  3) no option: wildcard cannot be used and nm of driver-mingw32.o shows
no _dowildcard defined and all sections are empty

Is this ok for stage1?

Best regards,

Thomas


No objections, but documentation should mention that wildcard expansion
is not handled by the CMD shell on Windows, it is up to individual
programs to interpret it.


How about the attached updated patch? Here's the associated ChangeLog entry:

2017-01-24  Thomas Preud'homme  

* configure.ac (--enable-mingw-wildcard): Add new configurable feature.
* configure: Regenerate.
* config.in: Regenerate.
* config/i386/driver-mingw32.c: new file.
* config/i386/x-mingw32: Add rule to build driver-mingw32.o.
* config.host: Link driver-mingw32.o on MinGW host.
* doc/install.texi: Document new --enable-mingw-wildcard configure
option.

Best regards,

Thomas
diff --git a/gcc/config.host b/gcc/config.host
index 6b28f3033ef92f1f0e09cc41f3a90be05c5e1e43..5e2db5327e3094a19cd29c81ceb1a9e2b11797c9 100644
--- a/gcc/config.host
+++ b/gcc/config.host
@@ -239,6 +239,7 @@ case ${host} in
 host_xmake_file="${host_xmake_file} i386/x-mingw32"
 host_exeext=.exe
 out_host_hook_obj=host-mingw32.o
+host_extra_gcc_objs="${host_extra_gcc_objs} driver-mingw32.o"
 host_lto_plugin_soname=liblto_plugin-0.dll
 ;;
   x86_64-*-mingw*)
@@ -247,6 +248,7 @@ case ${host} in
 host_xmake_file="${host_xmake_file} i386/x-mingw32"
 host_exeext=.exe
 out_host_hook_obj=host-mingw32.o
+host_extra_gcc_objs="${host_extra_gcc_objs} driver-mingw32.o"
 host_lto_plugin_soname=liblto_plugin-0.dll
 ;;
   i[34567]86-*-darwin* | x86_64-*-darwin*)
diff --git a/gcc/config.in b/gcc/config.in
index 1959dd7a603f121b6f2a3e0f80563d6290299c8a..b1f8018acfc5e8bf12503130a4707a2f6c21a1fd 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -2015,6 +2015,12 @@
 #endif
 
 
+/* Value to set MinGW's _dowildcard to. */
+#ifndef USED_FOR_TARGET
+#undef MINGW_DOWILDCARD
+#endif
+
+
 /* Define if host mkdir takes a single argument. */
 #ifndef USED_FOR_TARGET
 #undef MKDIR_TAKES_ONE_ARG
diff --git a/gcc/config/i386/driver-mingw32.c b/gcc/config/i386/driver-mingw32.c
new file mode 100644
index ..b70363ad26a7dc8ffccbb273e46d4dd6de1a6f8c
--- /dev/null
+++ b/gcc/config/i386/driver-mingw32.c
@@ -0,0 +1,26 @@
+/* Host OS specific configuration for the gcc driver.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+.  */
+
+#include "config.h"
+
+/* When defined, force the use (if non null) or not (otherwise) of CLI
+   globbing.  */
+#ifdef MINGW_DOWILDCARD
+int _dowildcard = MINGW_DOWILDCARD;
+#endif
diff --git a/gcc/config/i386/x-mingw32 b/gcc/config/i386/x-mingw32
index b5cef97512032a223605fb4db592fab05b1bb521..d0fa05245c4566c56aab6a1a6683a13a4392f864 100644
--- a/gcc/config/i386/x-mingw32
+++ b/gcc/config/i386/x-mingw32
@@ -63,3 +63,6 @@ host-mingw32.o : $(srcdir)/config/i386/host-mingw32.c $(CONFIG_H) $(SYSTEM_H) \
   coretypes.h hosthooks.h hosthooks-def.h toplev.h $(DIAGNOSTIC_H) $(HOOKS_H)
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 		$(srcdir)/config/i386/host-mingw32.c
+
+driver-mingw32.o : 

Re: [PATCH, GCC/x86 mingw32] Add configure option to force wildcard behavior on Windows

2017-01-20 Thread Thomas Preudhomme

Hi JonY,

On 19/01/17 01:37, JonY wrote:

On 01/18/2017 09:48 AM, Thomas Preudhomme wrote:

By default, wildcard support on Windows for programs compiled with mingw
depends on how the mingw runtime was configured. This means if one wants
to build GCC for Windows with a consistent behavior with Wildcard
(enabled or disabled) the mingw runtime must be built as well. This
patch adds an option to GCC configuration to force the behavior with
wildcard when building GCC for Windows host. It does so by setting the
_dowildcard variable in the driver to a given value depending on the
configure option value (yes or no), thus overriding the variable from
mingw runtime.

Testing: I've successfully done a build of the arm-none-eabi cross GCC
for Windows with Ubuntu system mingw runtime (configured without
wildcard support by default) with the three configure options:
  1) --enable-wildcard: wildcard can be used successfully and nm of
driver-mingw32.o shows that _dowildcard is in .data section
  2) --disable-wildcard: wildcard cannot be used and nm of
driver-mingw32.o shows that _dowildcard is in .bss section
  3) no option: wildcard cannot be used and nm of driver-mingw32.o shows
no _dowildcard defined and all sections are empty

Is this ok for stage1?

Best regards,

Thomas


No objections, but documentation should mention that wildcard expansion
is not handled by the CMD shell on Windows, it is up to individual
programs to interpret it.


Do you mean that this configuration option should make it clear that it only 
affects wildcard expansion for GCC itself but not for programs built by GCC?


Best regards,

Thomas


Re: [PATCH, GCC/x86 mingw32] Add configure option to force wildcard behavior on Windows

2017-01-18 Thread JonY
On 01/18/2017 09:48 AM, Thomas Preudhomme wrote:
> By default, wildcard support on Windows for programs compiled with mingw
> depends on how the mingw runtime was configured. This means if one wants
> to build GCC for Windows with a consistent behavior with Wildcard
> (enabled or disabled) the mingw runtime must be built as well. This
> patch adds an option to GCC configuration to force the behavior with
> wildcard when building GCC for Windows host. It does so by setting the
> _dowildcard variable in the driver to a given value depending on the
> configure option value (yes or no), thus overriding the variable from
> mingw runtime.
> 
> Testing: I've successfully done a build of the arm-none-eabi cross GCC
> for Windows with Ubuntu system mingw runtime (configured without
> wildcard support by default) with the three configure options:
>   1) --enable-wildcard: wildcard can be used successfully and nm of
> driver-mingw32.o shows that _dowildcard is in .data section
>   2) --disable-wildcard: wildcard cannot be used and nm of
> driver-mingw32.o shows that _dowildcard is in .bss section
>   3) no option: wildcard cannot be used and nm of driver-mingw32.o shows
> no _dowildcard defined and all sections are empty
> 
> Is this ok for stage1?
> 
> Best regards,
> 
> Thomas

No objections, but documentation should mention that wildcard expansion
is not handled by the CMD shell on Windows, it is up to individual
programs to interpret it.




signature.asc
Description: OpenPGP digital signature


[PATCH, GCC/x86 mingw32] Add configure option to force wildcard behavior on Windows

2017-01-18 Thread Thomas Preudhomme
By default, wildcard support on Windows for programs compiled with mingw depends 
on how the mingw runtime was configured. This means if one wants to build GCC 
for Windows with a consistent behavior with Wildcard (enabled or disabled) the 
mingw runtime must be built as well. This patch adds an option to GCC 
configuration to force the behavior with wildcard when building GCC for Windows 
host. It does so by setting the _dowildcard variable in the driver to a given 
value depending on the configure option value (yes or no), thus overriding the 
variable from mingw runtime.


Testing: I've successfully done a build of the arm-none-eabi cross GCC for 
Windows with Ubuntu system mingw runtime (configured without wildcard support by 
default) with the three configure options:
  1) --enable-wildcard: wildcard can be used successfully and nm of 
driver-mingw32.o shows that _dowildcard is in .data section
  2) --disable-wildcard: wildcard cannot be used and nm of driver-mingw32.o 
shows that _dowildcard is in .bss section
  3) no option: wildcard cannot be used and nm of driver-mingw32.o shows no 
_dowildcard defined and all sections are empty


Is this ok for stage1?

Best regards,

Thomas
diff --git a/gcc/config.host b/gcc/config.host
index 6b28f3033ef92f1f0e09cc41f3a90be05c5e1e43..5e2db5327e3094a19cd29c81ceb1a9e2b11797c9 100644
--- a/gcc/config.host
+++ b/gcc/config.host
@@ -239,6 +239,7 @@ case ${host} in
 host_xmake_file="${host_xmake_file} i386/x-mingw32"
 host_exeext=.exe
 out_host_hook_obj=host-mingw32.o
+host_extra_gcc_objs="${host_extra_gcc_objs} driver-mingw32.o"
 host_lto_plugin_soname=liblto_plugin-0.dll
 ;;
   x86_64-*-mingw*)
@@ -247,6 +248,7 @@ case ${host} in
 host_xmake_file="${host_xmake_file} i386/x-mingw32"
 host_exeext=.exe
 out_host_hook_obj=host-mingw32.o
+host_extra_gcc_objs="${host_extra_gcc_objs} driver-mingw32.o"
 host_lto_plugin_soname=liblto_plugin-0.dll
 ;;
   i[34567]86-*-darwin* | x86_64-*-darwin*)
diff --git a/gcc/config.in b/gcc/config.in
index 1959dd7a603f121b6f2a3e0f80563d6290299c8a..a6afc623c5d8c2064eb43252235bc2b90e5de0e7 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -2015,6 +2015,12 @@
 #endif
 
 
+/* Value to set mingw's _dowildcard to. */
+#ifndef USED_FOR_TARGET
+#undef MINGW_DOWILDCARD
+#endif
+
+
 /* Define if host mkdir takes a single argument. */
 #ifndef USED_FOR_TARGET
 #undef MKDIR_TAKES_ONE_ARG
diff --git a/gcc/config/i386/driver-mingw32.c b/gcc/config/i386/driver-mingw32.c
new file mode 100644
index ..b70363ad26a7dc8ffccbb273e46d4dd6de1a6f8c
--- /dev/null
+++ b/gcc/config/i386/driver-mingw32.c
@@ -0,0 +1,26 @@
+/* Host OS specific configuration for the gcc driver.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+.  */
+
+#include "config.h"
+
+/* When defined, force the use (if non null) or not (otherwise) of CLI
+   globbing.  */
+#ifdef MINGW_DOWILDCARD
+int _dowildcard = MINGW_DOWILDCARD;
+#endif
diff --git a/gcc/config/i386/x-mingw32 b/gcc/config/i386/x-mingw32
index b5cef97512032a223605fb4db592fab05b1bb521..d0fa05245c4566c56aab6a1a6683a13a4392f864 100644
--- a/gcc/config/i386/x-mingw32
+++ b/gcc/config/i386/x-mingw32
@@ -63,3 +63,6 @@ host-mingw32.o : $(srcdir)/config/i386/host-mingw32.c $(CONFIG_H) $(SYSTEM_H) \
   coretypes.h hosthooks.h hosthooks-def.h toplev.h $(DIAGNOSTIC_H) $(HOOKS_H)
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 		$(srcdir)/config/i386/host-mingw32.c
+
+driver-mingw32.o : $(srcdir)/config/i386/driver-mingw32.c $(CONFIG_H)
+	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
diff --git a/gcc/configure b/gcc/configure
index 60cb979b558431949a20fc83482b198a091c5efe..db2d114a52d8795265ca4d4348dfc695455e56f5 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -919,6 +919,7 @@ enable_rpath
 with_libiconv_prefix
 enable_sjlj_exceptions
 enable_secureplt
+enable_mingw_wildcard
 enable_leading_mingw64_underscores
 enable_cld
 enable_frame_pointer
@@ -1631,6 +1632,8 @@ Optional Features:
   --enable-sjlj-exceptions
   arrange to use setjmp/longjmp exception handling
   --enable-secureplt  enable -msecure-plt by default for PowerPC
+  --enable-mingw-wildcard Set whether to expand wildcard on command-line.
+  Default to platform