qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org
Cc: Roman Bolshakov <roman@roolebo.dev>,
	peter.maydell@linaro.org, f4bug@amsat.org,
	Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>,
	eblake@redhat.com, jasowang@redhat.com, phillip.ennen@gmail.com,
	dirty@apple.com, armbru@redhat.com, r.bolshakov@yadro.com,
	agraf@csgraf.de, kraxel@redhat.com, akihiko.odaki@gmail.com,
	hsp.cat7@gmail.com, hello@adns.io, alex.bennee@linaro.org,
	phillip@axleos.com
Subject: Re: [PATCH v13 2/7] net/vmnet: add vmnet backends to qapi/net
Date: Mon, 24 Jan 2022 21:00:55 +0100	[thread overview]
Message-ID: <15953310.Q2fixzbDzB@silver> (raw)
In-Reply-To: <Ye7mwcl/rB714vgl@roolebo.dev>

On Montag, 24. Januar 2022 18:49:53 CET Roman Bolshakov wrote:
> On Mon, Jan 24, 2022 at 12:27:40PM +0100, Christian Schoenebeck wrote:
> > On Montag, 24. Januar 2022 10:56:00 CET Roman Bolshakov wrote:
> > > On Thu, Jan 13, 2022 at 08:22:14PM +0300, Vladislav Yaroshchuk wrote:
> > > >  net/vmnet-bridged.m |  25 +++++++++
> > > >  net/vmnet-common.m  |  20 +++++++
> > > 
> > > It seems the last two files should have .c extension rather than .m.
> > 
> > I would not do that. Mind cross-compilers, please.
> 
> Hi Christian,
> 
> Cross-compilers for Apple platforms can be constructed using à la carte
> approach where toolchain comes from the source, SDK from Apple and a
> port of cctools from GitHub (mind all library dependencies of QEMU).
> That's quite an effort!
> 
> I very much doubt this is a relevant and typical case for QEMU on macOS.
> And if cross-compiler is constructed properly it'll pass required flags
> that enable blocks and will link block runtime in its default build
> recipe like all cross-compilers do for the platform of interest.
> 
> Gladly, there's osxcross [1] and crossbuild image with Darwin support [2].
> They can deal with blocks just fine:
> 
>   # CROSS_TRIPLE=i386-apple-darwin
>   $ cc block.c && file a.out
>   a.out: Mach-O i386 executable,
> flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|NO_HEAP_EXECUTION>
> 
>   # CROSS_TRIPLE=x86_64-apple-darwin
>   $ cc block.c && file a.out
>   $ file a.out
>   a.out: Mach-O 64-bit x86_64 executable,
> flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>
> > > Unlike Cocoa UI code, the files do not contain Objective-C classes. They
> > > are just C code with blocks (which is supported by compilers shipped
> > > with Xcode SDK), e.g this program can be compiled without extra
> > > compiler flags:
> > > 
> > > $ cat block.c
> > > int main() {
> > > 
> > >         int (^x)(void) = ^{
> > >         
> > >                 return 0;
> > >         
> > >         };
> > >         
> > >         return x();
> > > 
> > > }
> > > $ cc block.c && ./a.out
> > > $
> > 
> > Such blocks are still Objective-C language specific, they are not C and
> > therefore won't work with GCC.
> 
> I'm not sure why blocks are Objective-C specific. All the data I have
> shows the opposite [3][4][5]. They're just extensively used in Apple APIs.

Because blocks are automatically available if you are using an Objective-C or 
Objective-C++ frontend, but not necessarily if you use a C or C++ frontend.

> > $ gcc block.c
> > 
> > block.c: In function ‘main’:
> > block.c:2:14: error: expected identifier or ‘(’ before ‘^’ token
> > 
> >          int (^x)(void) = ^{
> >          
> >               ^
> > 
> > block.c:6:16: warning: implicit declaration of function ‘x’ [-Wimplicit-
> > function-declaration]
> > 
> >          return x();
> >          
> >                 ^
> 
> You might do this on Linux and it'll work:
> 
> $ clang -g -fblocks -lBlocksRuntime block.c && ./a.out

Yes, which is an unnecesary complicated & limiting variant of just:

	clang/gcc block.m

Don't get me wrong, I don't care too much about this issue. It's just that I 
really see no advantage in renaming this into a C file, but I do see 
disadvantages. That's all.

> However, vmnet code won't be compiled on non-Apple platforms because the
> compilation happens only if vmnet is available which happens only if
> appleframeworks dependency is available, that is not available on
> non-OSX hosts [6]:
> 
>   "These dependencies can never be found for non-OSX hosts."
> 
> 1. https://github.com/tpoechtrager/osxcross
> 2. https://github.com/multiarch/crossbuild
> 3. http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1370.pdf
> 4. https://clang.llvm.org/docs/BlockLanguageSpec.html
> 5. https://clang.llvm.org/docs/Block-ABI-Apple.html
> 6. https://mesonbuild.com/Dependencies.html#appleframeworks
> 
> Regards,
> Roman




  reply	other threads:[~2022-01-24 20:31 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-13 17:22 [PATCH v13 0/7] Add vmnet.framework based network backend Vladislav Yaroshchuk
2022-01-13 17:22 ` [PATCH v13 1/7] net/vmnet: add vmnet dependency and customizable option Vladislav Yaroshchuk
2022-01-20  7:14   ` Roman Bolshakov
2022-01-21 11:58     ` Vladislav Yaroshchuk
2022-01-13 17:22 ` [PATCH v13 2/7] net/vmnet: add vmnet backends to qapi/net Vladislav Yaroshchuk
2022-01-14  8:43   ` Akihiko Odaki
2022-01-15 13:00     ` Vladislav Yaroshchuk
2022-01-18 15:00   ` Markus Armbruster
2022-01-18 16:16     ` Vladislav Yaroshchuk
2022-01-18 16:26       ` Markus Armbruster
2022-01-18 16:46         ` Vladislav Yaroshchuk
2022-01-20  8:32   ` Roman Bolshakov
2022-01-21 12:19     ` Vladislav Yaroshchuk
2022-01-21 13:03       ` Akihiko Odaki
2022-01-28 14:29         ` Vladislav Yaroshchuk
2022-01-28 23:00           ` Akihiko Odaki
2022-01-24  9:56   ` Roman Bolshakov
2022-01-24 11:27     ` Christian Schoenebeck
2022-01-24 17:49       ` Roman Bolshakov
2022-01-24 20:00         ` Christian Schoenebeck [this message]
2022-01-24 20:14         ` Peter Maydell
2022-01-24 23:00           ` Roman Bolshakov
2022-01-25  4:14             ` Akihiko Odaki
2022-01-25 10:32               ` Peter Maydell
2022-01-25 11:08                 ` Akihiko Odaki
2022-01-25 17:30                   ` Christian Schoenebeck
2022-01-29 21:03               ` Roman Bolshakov
2022-01-13 17:22 ` [PATCH v13 3/7] net/vmnet: implement shared mode (vmnet-shared) Vladislav Yaroshchuk
2022-01-14  8:43   ` Akihiko Odaki
2022-01-13 17:22 ` [PATCH v13 4/7] net/vmnet: implement host mode (vmnet-host) Vladislav Yaroshchuk
2022-01-13 17:22 ` [PATCH v13 5/7] net/vmnet: implement bridged mode (vmnet-bridged) Vladislav Yaroshchuk
2022-01-14  8:43   ` Akihiko Odaki
2022-01-13 17:22 ` [PATCH v13 6/7] net/vmnet: update qemu-options.hx Vladislav Yaroshchuk
2022-01-14  8:43   ` Akihiko Odaki
2022-01-13 17:22 ` [PATCH v13 7/7] net/vmnet: update MAINTAINERS list Vladislav Yaroshchuk

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=15953310.Q2fixzbDzB@silver \
    --to=qemu_oss@crudebyte.com \
    --cc=agraf@csgraf.de \
    --cc=akihiko.odaki@gmail.com \
    --cc=alex.bennee@linaro.org \
    --cc=armbru@redhat.com \
    --cc=dirty@apple.com \
    --cc=eblake@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=hello@adns.io \
    --cc=hsp.cat7@gmail.com \
    --cc=jasowang@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=phillip.ennen@gmail.com \
    --cc=phillip@axleos.com \
    --cc=qemu-devel@nongnu.org \
    --cc=r.bolshakov@yadro.com \
    --cc=roman@roolebo.dev \
    --cc=yaroshchuk2000@gmail.com \
    /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).