[Qemu-devel] [PATCH] configure: pick the right compiler for OpenBSD by default

Daniel P. Berrange posted 1 patch 8 years, 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20171013102812.29648-1-berrange@redhat.com
Test checkpatch passed
Test docker passed
Test s390x passed
configure | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
[Qemu-devel] [PATCH] configure: pick the right compiler for OpenBSD by default
Posted by Daniel P. Berrange 8 years, 3 months ago
The system compiler in OpenBSD is gcc 4.2.1 which is too
old for our needs. If doing 'pkg_add gcc' you can get a
much newer version (4.9.4 in OpenBSD 6.1) which works with
QEMU. This installs binaries with two naming schemes:

  $ pkg_info  -L gcc | grep bin
  /usr/local/bin/ecpp
  /usr/local/bin/egcc
  /usr/local/bin/egcc-ar
  /usr/local/bin/egcc-nm
  /usr/local/bin/egcc-ranlib
  /usr/local/bin/egcov
  /usr/local/bin/x86_64-unknown-openbsd6.0-egcc
  /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-ar
  /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-nm
  /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-ranlib
  /usr/local/bin/x86_64-unknown-openbsd6.0-gcc-4.9.3

We pick the short name this it won't change across OpenBSD
releases.

This means users don't need to manually pass custom --cc
and --cxx args to configure to avoid immediate failure.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 configure | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 06f18ea9af..fcb7523933 100755
--- a/configure
+++ b/configure
@@ -255,7 +255,21 @@ cross_prefix=""
 audio_drv_list=""
 block_drv_rw_whitelist=""
 block_drv_ro_whitelist=""
-host_cc="cc"
+
+case `uname -s` in
+    OpenBSD)
+    # Default system cc in OpenBSD is unsufficient
+    # we need the 'gcc' pkg added, whch provides
+    # these modified binary names
+    host_cc="egcc"
+    host_cxx="eg++"
+    ;;
+         *)
+    host_cc="cc"
+    host_cxx="c++"
+    ;;
+esac
+
 libs_softmmu=""
 libs_tools=""
 audio_pt_int=""
@@ -466,7 +480,7 @@ else
 fi
 
 if test -z "${CXX}${cross_prefix}"; then
-  cxx="c++"
+  cxx="$host_cxx"
 else
   cxx="${CXX-${cross_prefix}g++}"
 fi
-- 
2.13.5


Re: [Qemu-devel] [PATCH] configure: pick the right compiler for OpenBSD by default
Posted by Thomas Huth 8 years, 3 months ago
On 13.10.2017 12:28, Daniel P. Berrange wrote:
> The system compiler in OpenBSD is gcc 4.2.1 which is too
> old for our needs. If doing 'pkg_add gcc' you can get a
> much newer version (4.9.4 in OpenBSD 6.1) which works with
> QEMU. This installs binaries with two naming schemes:
> 
>   $ pkg_info  -L gcc | grep bin
>   /usr/local/bin/ecpp
>   /usr/local/bin/egcc
>   /usr/local/bin/egcc-ar
>   /usr/local/bin/egcc-nm
>   /usr/local/bin/egcc-ranlib
>   /usr/local/bin/egcov
>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc
>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-ar
>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-nm
>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-ranlib
>   /usr/local/bin/x86_64-unknown-openbsd6.0-gcc-4.9.3
> 
> We pick the short name this it won't change across OpenBSD
> releases.
> 
> This means users don't need to manually pass custom --cc
> and --cxx args to configure to avoid immediate failure.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  configure | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/configure b/configure
> index 06f18ea9af..fcb7523933 100755
> --- a/configure
> +++ b/configure
> @@ -255,7 +255,21 @@ cross_prefix=""
>  audio_drv_list=""
>  block_drv_rw_whitelist=""
>  block_drv_ro_whitelist=""
> -host_cc="cc"
> +
> +case `uname -s` in
> +    OpenBSD)
> +    # Default system cc in OpenBSD is unsufficient

s/unsufficient/insufficient/

> +    # we need the 'gcc' pkg added, whch provides

s/whch/which/

> +    # these modified binary names
> +    host_cc="egcc"
> +    host_cxx="eg++"
> +    ;;
> +         *)
> +    host_cc="cc"
> +    host_cxx="c++"
> +    ;;
> +esac

Do we really need such work-arounds in our configure script? GCC 4.2 is
really veeeery old nowadays, so if the OpenBSD folks refuse to update
the default in their distro, IMHO they should be punished by having to
select the C compiler manually everywhere.

 Thomas

Re: [Qemu-devel] [PATCH] configure: pick the right compiler for OpenBSD by default
Posted by Thomas Huth 8 years, 3 months ago
On 13.10.2017 12:52, Thomas Huth wrote:
> On 13.10.2017 12:28, Daniel P. Berrange wrote:
>> The system compiler in OpenBSD is gcc 4.2.1 which is too
>> old for our needs. If doing 'pkg_add gcc' you can get a
>> much newer version (4.9.4 in OpenBSD 6.1) which works with
>> QEMU. This installs binaries with two naming schemes:
>>
>>   $ pkg_info  -L gcc | grep bin
>>   /usr/local/bin/ecpp
>>   /usr/local/bin/egcc
>>   /usr/local/bin/egcc-ar
>>   /usr/local/bin/egcc-nm
>>   /usr/local/bin/egcc-ranlib
>>   /usr/local/bin/egcov
>>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc
>>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-ar
>>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-nm
>>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-ranlib
>>   /usr/local/bin/x86_64-unknown-openbsd6.0-gcc-4.9.3
>>
>> We pick the short name this it won't change across OpenBSD
>> releases.
>>
>> This means users don't need to manually pass custom --cc
>> and --cxx args to configure to avoid immediate failure.
>>
>> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
>> ---
>>  configure | 18 ++++++++++++++++--
>>  1 file changed, 16 insertions(+), 2 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 06f18ea9af..fcb7523933 100755
>> --- a/configure
>> +++ b/configure
>> @@ -255,7 +255,21 @@ cross_prefix=""
>>  audio_drv_list=""
>>  block_drv_rw_whitelist=""
>>  block_drv_ro_whitelist=""
>> -host_cc="cc"
>> +
>> +case `uname -s` in
>> +    OpenBSD)
>> +    # Default system cc in OpenBSD is unsufficient
> 
> s/unsufficient/insufficient/
> 
>> +    # we need the 'gcc' pkg added, whch provides
> 
> s/whch/which/
> 
>> +    # these modified binary names
>> +    host_cc="egcc"
>> +    host_cxx="eg++"
>> +    ;;
>> +         *)
>> +    host_cc="cc"
>> +    host_cxx="c++"
>> +    ;;
>> +esac
> 
> Do we really need such work-arounds in our configure script? GCC 4.2 is
> really veeeery old nowadays, so if the OpenBSD folks refuse to update
> the default in their distro, IMHO they should be punished by having to
> select the C compiler manually everywhere.

By the way, looks like OpenBSD is also switching to clang by default soon:

https://www.phoronix.com/scan.php?page=news_item&px=OpenBSD-Default-Clang

 Thomas

Re: [Qemu-devel] [PATCH] configure: pick the right compiler for OpenBSD by default
Posted by Daniel P. Berrange 8 years, 3 months ago
On Fri, Oct 13, 2017 at 12:55:40PM +0200, Thomas Huth wrote:
> On 13.10.2017 12:52, Thomas Huth wrote:
> > On 13.10.2017 12:28, Daniel P. Berrange wrote:
> >> The system compiler in OpenBSD is gcc 4.2.1 which is too
> >> old for our needs. If doing 'pkg_add gcc' you can get a
> >> much newer version (4.9.4 in OpenBSD 6.1) which works with
> >> QEMU. This installs binaries with two naming schemes:
> >>
> >>   $ pkg_info  -L gcc | grep bin
> >>   /usr/local/bin/ecpp
> >>   /usr/local/bin/egcc
> >>   /usr/local/bin/egcc-ar
> >>   /usr/local/bin/egcc-nm
> >>   /usr/local/bin/egcc-ranlib
> >>   /usr/local/bin/egcov
> >>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc
> >>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-ar
> >>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-nm
> >>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-ranlib
> >>   /usr/local/bin/x86_64-unknown-openbsd6.0-gcc-4.9.3
> >>
> >> We pick the short name this it won't change across OpenBSD
> >> releases.
> >>
> >> This means users don't need to manually pass custom --cc
> >> and --cxx args to configure to avoid immediate failure.
> >>
> >> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> >> ---
> >>  configure | 18 ++++++++++++++++--
> >>  1 file changed, 16 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/configure b/configure
> >> index 06f18ea9af..fcb7523933 100755
> >> --- a/configure
> >> +++ b/configure
> >> @@ -255,7 +255,21 @@ cross_prefix=""
> >>  audio_drv_list=""
> >>  block_drv_rw_whitelist=""
> >>  block_drv_ro_whitelist=""
> >> -host_cc="cc"
> >> +
> >> +case `uname -s` in
> >> +    OpenBSD)
> >> +    # Default system cc in OpenBSD is unsufficient
> > 
> > s/unsufficient/insufficient/
> > 
> >> +    # we need the 'gcc' pkg added, whch provides
> > 
> > s/whch/which/
> > 
> >> +    # these modified binary names
> >> +    host_cc="egcc"
> >> +    host_cxx="eg++"
> >> +    ;;
> >> +         *)
> >> +    host_cc="cc"
> >> +    host_cxx="c++"
> >> +    ;;
> >> +esac
> > 
> > Do we really need such work-arounds in our configure script? GCC 4.2 is
> > really veeeery old nowadays, so if the OpenBSD folks refuse to update
> > the default in their distro, IMHO they should be punished by having to
> > select the C compiler manually everywhere.
> 
> By the way, looks like OpenBSD is also switching to clang by default soon:
> 
> https://www.phoronix.com/scan.php?page=news_item&px=OpenBSD-Default-Clang

In a few years time we could potentially revert this patch, but in the
meantime it is clearly beneficial for anyone using OpenBSD and has no
significant maint burden for us to carry it while there are widely
supported OpenBSD releases which need it.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [Qemu-devel] [PATCH] configure: pick the right compiler for OpenBSD by default
Posted by Thomas Huth 8 years, 3 months ago
On 13.10.2017 13:38, Daniel P. Berrange wrote:
> On Fri, Oct 13, 2017 at 12:55:40PM +0200, Thomas Huth wrote:
>> On 13.10.2017 12:52, Thomas Huth wrote:
[...]
>> By the way, looks like OpenBSD is also switching to clang by default soon:
>>
>> https://www.phoronix.com/scan.php?page=news_item&px=OpenBSD-Default-Clang
> 
> In a few years time we could potentially revert this patch, but in the
> meantime it is clearly beneficial for anyone using OpenBSD and has no
> significant maint burden for us to carry it while there are widely
> supported OpenBSD releases which need it.

I disagree. If the next OpenBSD release uses Clang by default, we're not
building QEMU there with the *working default* C compiler anymore.
You're then rather forcing the OpenBSD users then to install an
additional (likely unliked, since GPLv3) GCC package on their systems.

So IMHO, just drop this patch and wait for the next OpenBSD release, and
the problem will be solved automatically. (and the few users who still
use an older release of OpenBSD will likely use the QEMU from their
ports system anyway)

 Thomas

Re: [Qemu-devel] [PATCH] configure: pick the right compiler for OpenBSD by default
Posted by Peter Maydell 8 years, 3 months ago
On 13 October 2017 at 12:46, Thomas Huth <thuth@redhat.com> wrote:
> I disagree. If the next OpenBSD release uses Clang by default, we're not
> building QEMU there with the *working default* C compiler anymore.
> You're then rather forcing the OpenBSD users then to install an
> additional (likely unliked, since GPLv3) GCC package on their systems.
>
> So IMHO, just drop this patch and wait for the next OpenBSD release, and
> the problem will be solved automatically. (and the few users who still
> use an older release of OpenBSD will likely use the QEMU from their
> ports system anyway)

Another possible approach would be to have a configure test
for whatever feature it is that we need in our compiler,
and then run through a list that starts with "cc" and
goes on to try "egcc" etc until it finds one that works.
That way we'll automatically DTRT when OpenBSD upgrades
their "cc" to a working one.

thanks
-- PMM

Re: [Qemu-devel] [PATCH] configure: pick the right compiler for OpenBSD by default
Posted by Brad Smith 8 years, 3 months ago
On 10/13/2017 12:14 PM, Peter Maydell wrote:

> On 13 October 2017 at 12:46, Thomas Huth<thuth@redhat.com>  wrote:
>> I disagree. If the next OpenBSD release uses Clang by default, we're not
>> building QEMU there with the *working default* C compiler anymore.
>> You're then rather forcing the OpenBSD users then to install an
>> additional (likely unliked, since GPLv3) GCC package on their systems.
>>
>> So IMHO, just drop this patch and wait for the next OpenBSD release, and
>> the problem will be solved automatically. (and the few users who still
>> use an older release of OpenBSD will likely use the QEMU from their
>> ports system anyway)
> Another possible approach would be to have a configure test
> for whatever feature it is that we need in our compiler,
> and then run through a list that starts with "cc" and
> goes on to try "egcc" etc until it finds one that works.
> That way we'll automatically DTRT when OpenBSD upgrades
> their "cc" to a working one.

The release is already out.

One issue that needs to be fixed in the configure script. Have the TLS test
link with libpthread if the initial test fails.
Re: [Qemu-devel] [PATCH] configure: pick the right compiler for OpenBSD by default
Posted by Gerd Hoffmann 8 years, 3 months ago
  Hi,

> By the way, looks like OpenBSD is also switching to clang by default
> soon:
> 
> https://www.phoronix.com/scan.php?page=news_item&px=OpenBSD-Default-
> Clang

It did happen already.  On openbsd 6.2 (released a week ago) cc is
clang:

$ cc --version
OpenBSD clang version 4.0.0 (tags/RELEASE_400/final) (based on LLVM
4.0.0)

cheers,
  Gerd


Re: [Qemu-devel] [PATCH] configure: pick the right compiler for OpenBSD by default
Posted by Daniel P. Berrange 8 years, 3 months ago
On Mon, Oct 16, 2017 at 09:44:42AM +0200, Gerd Hoffmann wrote:
>   Hi,
> 
> > By the way, looks like OpenBSD is also switching to clang by default
> > soon:
> > 
> > https://www.phoronix.com/scan.php?page=news_item&px=OpenBSD-Default-
> > Clang
> 
> It did happen already.  On openbsd 6.2 (released a week ago) cc is
> clang:
> 
> $ cc --version
> OpenBSD clang version 4.0.0 (tags/RELEASE_400/final) (based on LLVM
> 4.0.0)

Oh, I didn't notice that was out already. Lets drop my patch and I'll
update the BSD page on the wiki

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [Qemu-devel] [PATCH] configure: pick the right compiler for OpenBSD by default
Posted by Daniel P. Berrange 8 years, 3 months ago
On Fri, Oct 13, 2017 at 12:52:26PM +0200, Thomas Huth wrote:
> On 13.10.2017 12:28, Daniel P. Berrange wrote:
> > The system compiler in OpenBSD is gcc 4.2.1 which is too
> > old for our needs. If doing 'pkg_add gcc' you can get a
> > much newer version (4.9.4 in OpenBSD 6.1) which works with
> > QEMU. This installs binaries with two naming schemes:
> > 
> >   $ pkg_info  -L gcc | grep bin
> >   /usr/local/bin/ecpp
> >   /usr/local/bin/egcc
> >   /usr/local/bin/egcc-ar
> >   /usr/local/bin/egcc-nm
> >   /usr/local/bin/egcc-ranlib
> >   /usr/local/bin/egcov
> >   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc
> >   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-ar
> >   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-nm
> >   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-ranlib
> >   /usr/local/bin/x86_64-unknown-openbsd6.0-gcc-4.9.3
> > 
> > We pick the short name this it won't change across OpenBSD
> > releases.
> > 
> > This means users don't need to manually pass custom --cc
> > and --cxx args to configure to avoid immediate failure.
> > 
> > Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> > ---
> >  configure | 18 ++++++++++++++++--
> >  1 file changed, 16 insertions(+), 2 deletions(-)
> > 
> > diff --git a/configure b/configure
> > index 06f18ea9af..fcb7523933 100755
> > --- a/configure
> > +++ b/configure
> > @@ -255,7 +255,21 @@ cross_prefix=""
> >  audio_drv_list=""
> >  block_drv_rw_whitelist=""
> >  block_drv_ro_whitelist=""
> > -host_cc="cc"
> > +
> > +case `uname -s` in
> > +    OpenBSD)
> > +    # Default system cc in OpenBSD is unsufficient
> 
> s/unsufficient/insufficient/
> 
> > +    # we need the 'gcc' pkg added, whch provides
> 
> s/whch/which/
> 
> > +    # these modified binary names
> > +    host_cc="egcc"
> > +    host_cxx="eg++"
> > +    ;;
> > +         *)
> > +    host_cc="cc"
> > +    host_cxx="c++"
> > +    ;;
> > +esac
> 
> Do we really need such work-arounds in our configure script? GCC 4.2 is
> really veeeery old nowadays, so if the OpenBSD folks refuse to update
> the default in their distro, IMHO they should be punished by having to
> select the C compiler manually everywhere.

I really object to such a user hostile POV. It is not beneficial to QEMU
to punish our users for choices they make, and our punishment will do
nothing to encourage OpenBSD distro maintainers to switch their compiler.

This is a straightforward change to 'configure' that makes it 'just work'
with no special args on current OpenBSD releases. Making it 'just work' is
a goal we have for every aspect of the configure script, and there's no
reason why we shouldn't try this for OpenBSD, as we do for other platforms,
unless we're going to drop OpenBSD entirely.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [Qemu-devel] [PATCH] configure: pick the right compiler for OpenBSD by default
Posted by Kamil Rytarowski 8 years, 3 months ago
On 13.10.2017 12:52, Thomas Huth wrote:
> On 13.10.2017 12:28, Daniel P. Berrange wrote:
>> The system compiler in OpenBSD is gcc 4.2.1 which is too
>> old for our needs. If doing 'pkg_add gcc' you can get a
>> much newer version (4.9.4 in OpenBSD 6.1) which works with
>> QEMU. This installs binaries with two naming schemes:
>>
>>   $ pkg_info  -L gcc | grep bin
>>   /usr/local/bin/ecpp
>>   /usr/local/bin/egcc
>>   /usr/local/bin/egcc-ar
>>   /usr/local/bin/egcc-nm
>>   /usr/local/bin/egcc-ranlib
>>   /usr/local/bin/egcov
>>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc
>>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-ar
>>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-nm
>>   /usr/local/bin/x86_64-unknown-openbsd6.0-egcc-ranlib
>>   /usr/local/bin/x86_64-unknown-openbsd6.0-gcc-4.9.3
>>
>> We pick the short name this it won't change across OpenBSD
>> releases.
>>
>> This means users don't need to manually pass custom --cc
>> and --cxx args to configure to avoid immediate failure.
>>
>> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
>> ---
>>  configure | 18 ++++++++++++++++--
>>  1 file changed, 16 insertions(+), 2 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 06f18ea9af..fcb7523933 100755
>> --- a/configure
>> +++ b/configure
>> @@ -255,7 +255,21 @@ cross_prefix=""
>>  audio_drv_list=""
>>  block_drv_rw_whitelist=""
>>  block_drv_ro_whitelist=""
>> -host_cc="cc"
>> +
>> +case `uname -s` in
>> +    OpenBSD)
>> +    # Default system cc in OpenBSD is unsufficient
> 
> s/unsufficient/insufficient/
> 
>> +    # we need the 'gcc' pkg added, whch provides
> 
> s/whch/which/
> 
>> +    # these modified binary names
>> +    host_cc="egcc"
>> +    host_cxx="eg++"
>> +    ;;
>> +         *)
>> +    host_cc="cc"
>> +    host_cxx="c++"
>> +    ;;
>> +esac
> 
> Do we really need such work-arounds in our configure script? GCC 4.2 is
> really veeeery old nowadays, so if the OpenBSD folks refuse to update
> the default in their distro, IMHO they should be punished by having to
> select the C compiler manually everywhere.
> 
>  Thomas
> 

OpenBSD switched to Clang/LLVM and they insist to support older
releases. We can silently ignore their GCC 4.2.1 (the latest one GPLv2
release).