From: "Andreas Färber" <afaerber@suse.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH 2/2] Support using a different compiler for Objective-C files
Date: Wed, 15 Aug 2012 16:47:03 +0200 [thread overview]
Message-ID: <502BB667.5080009@suse.de> (raw)
In-Reply-To: <1344720880-26881-3-git-send-email-peter.maydell@linaro.org>
Am 11.08.2012 23:34, schrieb Peter Maydell:
> MacOSX 10.8 ("Mountain Lion") requires us to compile our one
> Objective-C source file with clang even if the rest of QEMU
> requires a real gcc, because the system headers we use make
> use of Apple's "Blocks" extension to C/ObjC, and mainline
> gcc doesn't support that. Since we only need to use a true
> gcc for the parts of QEMU that use the fixed-register
> env variable, we can simply use clang to build the ObjC
> file: it will link to the gcc-built objects with no problems.
>
> Add the necessary support for an OBJCC variable in the
> makefile and configure machinery; we default to clang
> if we have it, otherwise whatever CC is (since gcc
> might be the Apple gcc which does support Blocks).
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> configure | 12 ++++++++++++
> rules.mak | 2 +-
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index be4a2bb..bd62d2c 100755
> --- a/configure
> +++ b/configure
> @@ -534,6 +534,13 @@ fi
> : ${python=${PYTHON-python}}
> : ${smbd=${SMBD-/usr/sbin/smbd}}
>
> +# Default objcc to clang if available, otherwise use CC
> +if has clang; then
> + objcc=clang
On IRC I had commented that I find defaulting to clang whenever clang is
available too aggressive (it may be some /usr/local/bin version that
doesn't even have the right host architecture support compiled in).
I won't object to this patch but would appreciate a follow-up limiting
this to v10.8+ where it's actually needed and keep using gcc elsewhere.
Andreas
> +else
> + objcc="$cc"
> +fi
> +
> if test "$mingw32" = "yes" ; then
> EXESUF=".exe"
> QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
> @@ -577,6 +584,8 @@ for opt do
> ;;
> --host-cc=*) host_cc="$optarg"
> ;;
> + --objcc=*) objcc="$optarg"
> + ;;
> --make=*) make="$optarg"
> ;;
> --install=*) install="$optarg"
> @@ -1024,6 +1033,7 @@ echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
> echo " --cc=CC use C compiler CC [$cc]"
> echo " --host-cc=CC use C compiler CC [$host_cc] for code run at"
> echo " build time"
> +echo " --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]"
> echo " --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS"
> echo " --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS"
> echo " --make=MAKE use specified make [$make]"
> @@ -3054,6 +3064,7 @@ fi
> echo "Source path $source_path"
> echo "C compiler $cc"
> echo "Host C compiler $host_cc"
> +echo "Objective-C compiler $objcc"
> echo "CFLAGS $CFLAGS"
> echo "QEMU_CFLAGS $QEMU_CFLAGS"
> echo "LDFLAGS $LDFLAGS"
> @@ -3521,6 +3532,7 @@ echo "PYTHON=$python" >> $config_host_mak
> echo "CC=$cc" >> $config_host_mak
> echo "CC_I386=$cc_i386" >> $config_host_mak
> echo "HOST_CC=$host_cc" >> $config_host_mak
> +echo "OBJCC=$objcc" >> $config_host_mak
> echo "AR=$ar" >> $config_host_mak
> echo "OBJCOPY=$objcopy" >> $config_host_mak
> echo "LD=$ld" >> $config_host_mak
> diff --git a/rules.mak b/rules.mak
> index a284946..1b173aa 100644
> --- a/rules.mak
> +++ b/rules.mak
> @@ -29,7 +29,7 @@ endif
> $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," AS $(TARGET_DIR)$@")
>
> %.o: %.m
> - $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," OBJC $(TARGET_DIR)$@")
> + $(call quiet-command,$(OBJCC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," OBJC $(TARGET_DIR)$@")
>
> LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(sort $(1)) $(LIBS)," LINK $(TARGET_DIR)$@")
>
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
next prev parent reply other threads:[~2012-08-15 14:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-11 21:34 [Qemu-devel] [PATCH 0/2] Fix compilation on MacOS X 10.8 ("Mountain Lion") Peter Maydell
2012-08-11 21:34 ` [Qemu-devel] [PATCH 1/2] configure: Define OS_OBJECT_USE_OBJC=0 for MacOSX builds Peter Maydell
2012-08-11 21:34 ` [Qemu-devel] [PATCH 2/2] Support using a different compiler for Objective-C files Peter Maydell
2012-08-15 14:47 ` Andreas Färber [this message]
2012-08-15 14:55 ` Peter Maydell
2012-08-15 16:05 ` Andreas Färber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=502BB667.5080009@suse.de \
--to=afaerber@suse.de \
--cc=patches@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).