Skip to contentSkip to conversation

configure: Default to 'cc', not 'gcc', on MacOS X

PATCH Superseded Peter Maydell 3 participants 9 messages Nov 16, 2012 – Nov 22, 2012

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure: Default to 'cc', not 'gcc', on MacOS X

When building for MacOS X, default the C compiler to 'cc' (usually clang) rather than 'gcc'. This avoids the Apple 'gcc', which is generally an elderly llvm-gcc provided mostly for legacy purposes, in favour of the best supported compiler available on the platform.

---
I now seem to be getting failures to compile due to weak refs on clang as well, but defaulting to cc seems like a good long term plan anyway. I've mostly been building and testing with --cc=clang so this isn't a sudden compiler switch from my point of view. I'm ambivalent about whether this should go in 1.3 or not, given it doesn't actually fix the weakref issues.

 configure |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
configure +17 -2
index f847ee2..ec9932b 100755
@@ -116,7 +116,13 @@ audio_drv_list=""
 audio_card_list="ac97 es1370 sb16 hda"
 audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus hda"
 block_drv_whitelist=""
-host_cc="gcc"
+if test "$(uname -s)" = "Darwin"; then
+  # On MacOS X the standard supported system compiler is 'cc' (usually clang),
+  # and 'gcc' is a legacy llvm-gcc which is rather elderly and best avoided.
+  host_cc="cc"
+else
+  host_cc="gcc"
+fi
 libs_softmmu=""
 libs_tools=""
 audio_pt_int=""
@@ -250,7 +256,16 @@ done
 # Using uname is really, really broken.  Once we have the right set of checks
 # we can eliminate its usage altogether.
 
-cc="${CC-${cross_prefix}gcc}"
+# Preferred compiler:
+#  ${CC} (if set)
+#  ${cross_prefix}gcc (if cross-prefix specified)
+#  system compiler
+if test -z "${CC}${cross_prefix}"; then
+  cc="$host_cc"
+else
+  cc="${CC-${cross_prefix}gcc}"
+fi
+
 ar="${AR-${cross_prefix}ar}"
 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
 ld="${LD-${cross_prefix}ld}"
Signature · 1 line
1.7.9.5
#1 lore raw

Am 16.11.2012 17:37, schrieb Peter Maydell:

Quoted 22 lines

When building for MacOS X, default the C compiler to 'cc' (usually clang) rather than 'gcc'. This avoids the Apple 'gcc', which is generally an elderly llvm-gcc provided mostly for legacy purposes, in favour of the best supported compiler available on the platform.

---
I now seem to be getting failures to compile due to weak refs on clang as well, but defaulting to cc seems like a good long term plan anyway. I've mostly been building and testing with --cc=clang so this isn't a sudden compiler switch from my point of view. I'm ambivalent about whether this should go in 1.3 or not, given it doesn't actually fix the weakref issues.

 configure |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
configure +0 -0
index f847ee2..ec9932b 100755

configure audio_drv_list="" · line 121

Quoted 7 lines
configure +3 -1
@@ -116,7 +116,13 @@ audio_drv_list=""
 audio_card_list="ac97 es1370 sb16 hda"
 audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus hda"
 block_drv_whitelist=""
-host_cc="gcc"
+if test "$(uname -s)" = "Darwin"; then
+  # On MacOS X the standard supported system compiler is 'cc' (usually clang),
+  # and 'gcc' is a legacy llvm-gcc which is rather elderly and best avoided.

This comment strikes me as wrong in this generality. It should at least be qualified with OSX version numbers.

Andreas

Quoted 26 lines
configure +14 -1
+  host_cc="cc"
+else
+  host_cc="gcc"
+fi
 libs_softmmu=""
 libs_tools=""
 audio_pt_int=""
@@ -250,7 +256,16 @@ done
 # Using uname is really, really broken.  Once we have the right set of checks
 # we can eliminate its usage altogether.
 
-cc="${CC-${cross_prefix}gcc}"
+# Preferred compiler:
+#  ${CC} (if set)
+#  ${cross_prefix}gcc (if cross-prefix specified)
+#  system compiler
+if test -z "${CC}${cross_prefix}"; then
+  cc="$host_cc"
+else
+  cc="${CC-${cross_prefix}gcc}"
+fi
+
 ar="${AR-${cross_prefix}ar}"
 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
 ld="${LD-${cross_prefix}ld}"
#2 lore raw
Quoted 18 lines · Andreas Färber

Am 16.11.2012 17:37, schrieb Peter Maydell:

Quoted 17 lines

When building for MacOS X, default the C compiler to 'cc' (usually clang) rather than 'gcc'. This avoids the Apple 'gcc', which is generally an elderly llvm-gcc provided mostly for legacy purposes, in favour of the best supported compiler available on the platform.

---
I now seem to be getting failures to compile due to weak refs on clang as well, but defaulting to cc seems like a good long term plan anyway. I've mostly been building and testing with --cc=clang so this isn't a sudden compiler switch from my point of view. I'm ambivalent about whether this should go in 1.3 or not, given it doesn't actually fix the weakref issues.

 configure |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
Quoted 15 lines

configure audio_drv_list="" · line 121

Quoted 12 lines
configure +3 -1
index f847ee2..ec9932b 100755
@@ -116,7 +116,13 @@ audio_drv_list=""
 audio_card_list="ac97 es1370 sb16 hda"
 audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus hda"
 block_drv_whitelist=""
-host_cc="gcc"
+if test "$(uname -s)" = "Darwin"; then
+  # On MacOS X the standard supported system compiler is 'cc' (usually clang),
+  # and 'gcc' is a legacy llvm-gcc which is rather elderly and best avoided.

This comment strikes me as wrong in this generality. It should at least be qualified with OSX version numbers.

How about "and if 'gcc' is not the same as 'cc' then it is a legacy llvm-gcc which is rather elderly and best avoided" ? I'd rather not get into having to research which versions of OSX shipped with which compiler as 'cc', when really the point is that 'cc' will always give you whichever compiler Apple thought was the best default for that version.

-- PMM

#3 lore raw
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Andreas Färber

Am 16.11.2012 17:37, schrieb Peter Maydell:

Quoted 3 lines
configure +3 -0
+if test "$(uname -s)" = "Darwin"; then
+  # On MacOS X the standard supported system compiler is 'cc' (usually clang),
+  # and 'gcc' is a legacy llvm-gcc which is rather elderly and best avoided.
Quoted 8 lines
Quoted 2 lines

This comment strikes me as wrong in this generality. It should at least be qualified with OSX version numbers.

How about "and if 'gcc' is not the same as 'cc' then it is a legacy llvm-gcc which is rather elderly and best avoided" ? I'd rather not get into having to research which versions of OSX shipped with which compiler as 'cc', when really the point is that 'cc' will always give you whichever compiler Apple thought was the best default for that version.

Andreas: ping? are you happy with this suggested rephrasing? Do you think this is 1.3 material? (now the static-stublib stuff is in it's less critical, but it still seems like the right idea...)

thanks
-- PMM

#4 lore raw

Am 22.11.2012 00:19, schrieb Peter Maydell:

Quoted 10 lines · Peter Maydell
Quoted 9 lines · Andreas Färber
Quoted 7 lines

Am 16.11.2012 17:37, schrieb Peter Maydell:

configure audio_drv_list="" · line 121

Quoted 3 lines
configure +3 -0
+if test "$(uname -s)" = "Darwin"; then
+  # On MacOS X the standard supported system compiler is 'cc' (usually clang),
+  # and 'gcc' is a legacy llvm-gcc which is rather elderly and best avoided.

This comment strikes me as wrong in this generality. It should at least be qualified with OSX version numbers.

Quoted 7 lines
Quoted 5 lines

How about "and if 'gcc' is not the same as 'cc' then it is a legacy llvm-gcc which is rather elderly and best avoided" ? I'd rather not get into having to research which versions of OSX shipped with which compiler as 'cc', when really the point is that 'cc' will always give you whichever compiler Apple thought was the best default for that version.

Andreas: ping? are you happy with this suggested rephrasing?

Not quite... clang is a relatively new thing. On v10.5.8 ppc64 'cc' is a symlink to a real (well, Apple-flavoured) 'gcc-4.0'.

What about "... (clang on recent systems) and 'gcc' may be a legacy llvm-gcc ..."?

Quoted 3 lines

Do you
think this is 1.3 material? (now the static-stublib stuff is in it's less critical, but it still seems like the right idea...)

I wouldn't be opposed to taking the default change into 1.3 as long as we can still override it to a specific compiler.

But then again there's the question of why not doing it on Linux as well now that we seem to compile under clang, we have cc -> gcc-4.7 on openSUSE 12.2. Among our supported platforms only Solaris comes to my mind where cc might be an incompatible proprietary compiler.

Andreas

#5 lore raw
Quoted 17 lines · Andreas Färber

Am 22.11.2012 00:19, schrieb Peter Maydell:

Quoted 16 lines · Peter Maydell
Quoted 14 lines · Andreas Färber
Quoted 7 lines

Am 16.11.2012 17:37, schrieb Peter Maydell:

configure audio_drv_list="" · line 121

Quoted 3 lines
configure +3 -0
+if test "$(uname -s)" = "Darwin"; then
+  # On MacOS X the standard supported system compiler is 'cc' (usually clang),
+  # and 'gcc' is a legacy llvm-gcc which is rather elderly and best avoided.

This comment strikes me as wrong in this generality. It should at least be qualified with OSX version numbers.

How about "and if 'gcc' is not the same as 'cc' then it is a legacy llvm-gcc which is rather elderly and best avoided" ? I'd rather not get into having to research which versions of OSX shipped with which compiler as 'cc', when really the point is that 'cc' will always give you whichever compiler Apple thought was the best default for that version.

Quoted 4 lines
Quoted 1 line

Andreas: ping? are you happy with this suggested rephrasing?

Not quite... clang is a relatively new thing. On v10.5.8 ppc64 'cc' is a symlink to a real (well, Apple-flavoured) 'gcc-4.0'.

Yes, that's the case where gcc is the same as cc, ie the "if" condition in the comment is false. (I guess this is saying my rephrasing is at best not very clear...)

Quoted 2 lines

What about "... (clang on recent systems) and 'gcc' may be a legacy llvm-gcc ..."?

Sounds ok.

Quoted 6 lines
Quoted 3 lines

Do you
think this is 1.3 material? (now the static-stublib stuff is in it's less critical, but it still seems like the right idea...)

I wouldn't be opposed to taking the default change into 1.3 as long as we can still override it to a specific compiler.

--cc=whatever remains available.

Quoted 4 lines

But then again there's the question of why not doing it on Linux as well now that we seem to compile under clang, we have cc -> gcc-4.7 on openSUSE 12.2. Among our supported platforms only Solaris comes to my mind where cc might be an incompatible proprietary compiler.

Do any of the BSDs ship with some odd non-GPL thing as cc ?

-- PMM

#6 lore raw
Quoted 39 lines · Peter Maydell
Quoted 17 lines · Andreas F??rber

Am 22.11.2012 00:19, schrieb Peter Maydell:

Quoted 16 lines · Peter Maydell
Quoted 14 lines · Andreas F??rber
Quoted 7 lines

Am 16.11.2012 17:37, schrieb Peter Maydell:

configure audio_drv_list="" · line 121

Quoted 3 lines
configure +3 -0
+if test "$(uname -s)" = "Darwin"; then
+  # On MacOS X the standard supported system compiler is 'cc' (usually clang),
+  # and 'gcc' is a legacy llvm-gcc which is rather elderly and best avoided.

This comment strikes me as wrong in this generality. It should at least be qualified with OSX version numbers.

How about "and if 'gcc' is not the same as 'cc' then it is a legacy llvm-gcc which is rather elderly and best avoided" ? I'd rather not get into having to research which versions of OSX shipped with which compiler as 'cc', when really the point is that 'cc' will always give you whichever compiler Apple thought was the best default for that version.

Quoted 4 lines
Quoted 1 line

Andreas: ping? are you happy with this suggested rephrasing?

Not quite... clang is a relatively new thing. On v10.5.8 ppc64 'cc' is a symlink to a real (well, Apple-flavoured) 'gcc-4.0'.

Yes, that's the case where gcc is the same as cc, ie the "if" condition in the comment is false. (I guess this is saying my rephrasing is at best not very clear...)

Quoted 2 lines

What about "... (clang on recent systems) and 'gcc' may be a legacy llvm-gcc ..."?

Sounds ok.

Quoted 6 lines
Quoted 3 lines

Do you
think this is 1.3 material? (now the static-stublib stuff is in it's less critical, but it still seems like the right idea...)

I wouldn't be opposed to taking the default change into 1.3 as long as we can still override it to a specific compiler.

Quoted 8 lines

--cc=whatever remains available.

Quoted 4 lines

But then again there's the question of why not doing it on Linux as well now that we seem to compile under clang, we have cc -> gcc-4.7 on openSUSE 12.2. Among our supported platforms only Solaris comes to my mind where cc might be an incompatible proprietary compiler.

Do any of the BSDs ship with some odd non-GPL thing as cc ?

non-GPL yes, odd no.

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
#7 lore raw
Quoted 10 lines · Brad Smith
Quoted 7 lines · Peter Maydell
Quoted 4 lines · Andreas F??rber

But then again there's the question of why not doing it on Linux as well now that we seem to compile under clang, we have cc -> gcc-4.7 on openSUSE 12.2. Among our supported platforms only Solaris comes to my mind where cc might be an incompatible proprietary compiler.

Do any of the BSDs ship with some odd non-GPL thing as cc ?

non-GPL yes, odd no.

Does QEMU build OK with them? Should we be preferring them to gcc?

-- PMM

#8 lore raw
Quoted 8 lines · Peter Maydell
Quoted 7 lines · Brad Smith
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Andreas F??rber

But then again there's the question of why not doing it on Linux as well now that we seem to compile under clang, we have cc -> gcc-4.7 on openSUSE 12.2. Among our supported platforms only Solaris comes to my mind where cc might be an incompatible proprietary compiler.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Do any of the BSDs ship with some odd non-GPL thing as cc ?

non-GPL yes, odd no.

Does QEMU build OK with them? Should we be preferring them to gcc?

The release notes for 1.3 seem to indicate Clang is supported now so I would think so. AFAIK FreeBSD -current does not ship with gcc anymore. Bitrig is a fork of OpenBSD that only ships with Clang.

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.