In CPython there is a configuration option for the build machine's system type
$ wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
$ tar -xzvf Python-3.7.3.tgz
$ cd Python-3.7.3
$ ./configure --help | grep -A 3 "System types"
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
--target=TARGET configure for building compilers for TARGET [HOST]
How does one properly determine what BUILD
should be here for any Linux distribution? Through searching I found CPython Issue 3754 (cross-compilation support for python build) I can see that valid BUILD
values are --build=x86_64-linux-gnu
and --build=x86_64-redhat-linux-gnu
. I can also see from the CPython Dockerfile for Python 3.7 that --build
is being set to the output of $(dpkg-architecture --query DEB_BUILD_GNU_TYPE)
, which on Debian stretch gives
$ docker run --rm debian:stretch /bin/bash -c "echo '$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)'"
x86_64-linux-gnu
but if I am on something like CentOS 7 then how would I properly determine this using OS commands?
Ideally what I would like is some documentation that better describes the --build
option. So if this is known and can be linked to that would sufficiently answer the question.
Edit: Thanks to Anthony Shaw I learned that this is not a CPython issue but related to autoconf. From this information given to me, I see in the autoconf manual (Section 16.7 Specifying the System Type) that
...give it the
--build=type
option.type
can either be a short name for the system type, such as ‘sun4’, or a canonical name which has the form:cpu-company-system
where system can have one of these forms:
os kernel-os
See the file
config.sub
for the possible values of each field. Ifconfig.sub
isn't included in this package, then this package doesn't need to know the machine type.
CPython has a config.sub
$ wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
$ tar -xzvf Python-3.7.3.tgz
$ cd Python-3.7.3
$ ./config.sub --help
Usage: ./config.sub [OPTION] CPU-MFR-OPSYS or ALIAS
Canonicalize a configuration name.
Options:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to <[email protected]>.
but it still isn't very clear to me if there is a general Linux wide solution to determining with OS commands how to get this information.
Given what my question was it seems that from The GNU configure and build system documentation's section on Configuration Names that what I'm describing when I ask for "[Linux] OS commands" is basically what config.guess
already provides:
The shell script
config.guess
will normally print the correct configuration name for the system on which it is run. It does by runninguname
and by examining other characteristics of the system.Because
config.guess
can normally determine the configuration name for a machine, it is normally only necessary to specify a configuration name when building a cross-compiler or when building using a cross-compiler.
So the answer to my question appears to be that configure
already supports what I wanted to do, and by trying to pass in --build
information when I'm building on the same machine as I will be running I'm not helping things if I'm trying to write a Shell script to automate the configure and build process.
The question What's the difference of “./configure” option “--build”, “--host” and “--target”? was helpful in coming to this conclusion.