[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Building a cross-compiler

From: Sébastien Hinderer
Subject: Building a cross-compiler
Date: Wed, 20 Jan 2021 14:57:27 +0100

Dear all,

Sorry if what follows is unclear. I am writing because things are
unclear in my brain and I am looking for help to clarify them.

I am in charge of making cross-compilation possible for the OCaml
language, given that the compiler's build system uses autoconf. The
compiler is written in OCaml itself and has a runtime written in C.

To start experimenting, I am trying to build a Linux to Windows64(MINGW)
cross-compiler. So the compiler's build and host system types are Linux
64 and the target type is Windows64(MinGW).

Since the compiler itself is written in OCaml, we also assume that the
Linux box has a working "straight" Linux OCaml compiler installed.

I am trying to figure out in which way the build system needs to be
modified to support such a scheme.

I started with

./configure \
  --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu \

Since this invocation does not detect the C compiler properly, I
switched to:

./configure \
  --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu \
  --target=x86_64-w64-mingw32 \

But that does not quite work because, since build and host system types
are equal, autoconf assumes we are not in cross-compiling mode and thus
tries to run the test programs it compiles, which is actually not

I assume that what's wrong here is that autoconf expects CC to point to
a C compiler that runs on the build system and produces code that runs
on the host system and my definition of CC breaks this assumption. So,
should I perhaps introduce a second variable to designate a compiler
that runs on the build system but produces code for the target system,
with a name like TARGETCC?
Or, since we will also need a C compiler running on host and producing
code for target, would it perhaps be better to introduce a HOSTCC
variable, which can also be used on the buildhost under the hypothesis
given above that build==host?

Any comment would be more than welcome.

Many thanks in advance,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]