[PATCH] D44753: [Preprocessor] Rename __is_{target -> host}_* function-like builtin macros

John Ericson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 21 15:10:32 PDT 2018


Ericson2314 added a comment.

> I'm sure I could fine a GCC example

FWIW  https://github.com/gcc-mirror/gcc/blob/master/gcc/config/aarch64/aarch64.c vs https://github.com/gcc-mirror/gcc/blob/master/gcc/common/config/aarch64/aarch64-common.c

@steven_wu

> It is not about matching command line name to builtin marco name.

Whew :)

> "target" is the platform we are compiling for, whether it is host or device or something else.

I'm in total agreement, if we are saying that from the compiler's perspective.

> It is a different concept when you talking about cross-compiling, which "target" is strictly not host and "build" or "host" doesn't matter to compiler at all.

So to be clear, I don't think there is a legitament reason *why* GHC and GCC care about the target platform at compile time. LLVM's approaching of always being multi-target and only choosing at run-time is far superior. Part of the philosophy behind that approach is moving towards a world where everything just works whether cross compiling or not. Redefining terminology based on whether we are cross compiling is counter to that goal.

> This example is bad because you do not know about runtime when you do compilation.

I'm intrigued you singled out my first `#if` and not my second. If the binary is compiled with `clang` targeting windows, then (absent wine or something) we can be sure it is running on windows. On the other hand it seems odd and gcc-like to decide at compile time whether the newly built binary is targeting Darwin. The "emit" platform of the newly-built binary is strictly more removed from `clang`'s purview than the "run" platform.


Repository:
  rC Clang

https://reviews.llvm.org/D44753





More information about the cfe-commits mailing list