This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: detecting if cross-compiler (in plugin)?

On Wed, Aug 29, 2012 at 1:59 AM, Basile Starynkevitch
<> wrote:
> What is the simplest way, for a plugin (and also for a GCC branch),
> to detect if the compiler is straight or not (i.e. cross, that is
> target & host are different, or even canadian-cross).
> I was thinking of some macro in auto-host.h or other header.
> (MELT is, during its building procedure, testing itself by running
> a simple MELT pass on the MELT runtime. Obviously this step makes
> no sense for cross compilers, hence the question)

It sounds like what you want to know is not whether host != target,
but whether build != target.  Actually you may want to know whether
the compiler produces executables that run on the build system, but
that is more complicated still--e.g., a cross-compiler from x86_64 to
i386 GNU/Linux can produce executables that run on the build system
even though it is configured as a cross-compiler.

Unfortunately I don't know of any way to check within GCC whether
build == target.  It's not something that GCC generally cares about.

One imperfect thing you can test is whether CROSS_DIRECTORY_STRUCTURE
is defined.  That is true when host != target.

In general I would support having ways for plugins to detect this sort
of thing, perhaps simply by making the build, host, and target triplet
strings available to the plugin in some way.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]