This commit causes gnu-config to recognize the *-*-uefi triples.
These triples describe binaries which use the PE object file format
and UEFI calling "convention" (which is actually a family of
completely unrelated calling conventions, one per CPU architecture):
- https://uefi.org/specs/UEFI/2.9_A/02_Overview.html#detailed-calling-convention
- https://uefi.org/specs/UEFI/2.9_A/02_Overview.html#detailed-calling-convention-1
- https://uefi.org/specs/UEFI/2.9_A/02_Overview.html#detailed-calling-convention-2
- https://wiki.osdev.org/UEFI#Calling_Conventions
This is in contrast to the *-w64-mingw32 triple of GNU-EFI, which
uses the ELF format and cdecl calling convention:
- https://wiki.osdev.org/UEFI#Calling_Conventions
Because *-*-uefi uses a different object file format (everywhere)
and calling convention (everywhere except x86_32) from
*-w64-mingw32, the resulting binaries cannot be linked against each
other. This is the primary justification for introducing a new
triple.
Since gnu-config does not yet have triples for these builds, we
might as well use the same ones already selected by LLVM. It
considers uefi to be an operating system:
- https://reviews.llvm.org/D131594
* config.sub (*-*-uefi): Recognize.
* testsuite/config-sub.data (i686-unknown-uefi, x86_64-unknown-uefi,
aarch64-unknown-uefi): New entries.
Signed-off-by: Adam Joseph <adam@westernsemico.com>
X-Disclaimer: This commit shall not be construed as the author's approval of the UEFI boondoggle in any way, shape or form.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
This is supported in this GCC fork. [1] It has been packaged in Nixpkgs
since 2019. [2]
Their change to `config.sub` [3] is similar, but also includes a `vc4`
-> `vc4-unknown-elf` shorthand; I don't see any reasons to add any new
legacy 1-component short-hands, so I just skipped that part.
[1]: https://github.com/itszor/vc4-toolchain
[2]: https://github.com/NixOS/nixpkgs/pull/72657
[3]: 91278afabe
* config.sub (vc4-*): Recognize.
* testsuite/config-sub.data (vc4-unknown-none-elf): New entry.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
`windows-gnu` has been used by LLVM and Rust to mean MinGW, but many
people on the mailing list object that it is in no way bona fide GNU on
Windows. Even under the interpretation of `-gnu` as a libc which LLVM
often goes with, it doesn't pass muster either because MinGW uses
msvcrt/ucrt, not any GNU libc. Arguably Cygwin, using a modified (GNU)
Newlib, is the closest thing we have to "GNU on Windows" today.
We couldn't decide on what `windows-*` should replace it, or even
whether there should be such a thing, so absent consensus it is better
to just remove it while it is still recently added and we don't need to
worry about backwards compatibility. We can always re-add it later, but
we can't do nothing now and remove it later.
This partially reverts commit 91f6a7f616b161c25ba2001861a40e662e18c4ad.
* config.sub (windows*-gnu*): Remove.
* doc/config.sub.1: Regenerate.
* testsuite/config-sub.data (x86_64-windows-gnu): Remove.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
ARM64EC is a custom ABI for AArch64 that allows for interoperability
with x86_64 compiled code. While technically just an ABI, it is treated
as its own machine type, with triples in the format arm64ec-*.
* config.sub (arm64ec): Recognize.
* doc/config.sub.1: Regenerate.
* testsuite/config-sub.data (arm64ec-pc-mingw32, arm64ec-windows): New
entries.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
config.guess says aarch64c-unknown-freebsd14.0 (cfarm240.cfarm.net,
an Arm Morello SoC, quad-core aarch64 Neoverse N1-based CPU
implementing CHERI), so let config.sub allow it.
* config.sub (aarch64c): Recognize.
* doc/config.sub.1: Regenerate.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Starting with commit afe1fa96bf32, "uname -p" from PATH is invoked in
case of FreeBSD on arm, while in other FreeBSD cases it was invoked
using a full pathname as "/usr/bin/uname -p". Fix this inconsistency
and invoke "uname -p" from PATH for all FreeBSD cases. This also allows
to test non-arm FreeBSD cases.
* config.guess (*:FreeBSD:*:*): Invoke "uname -p" from PATH.
* doc/config.guess.1: Regenerate.
* testsuite/config-guess.data (x86_64-unknown-freebsd5.2,
i586-unknown-freebsd7.0): Reintroduce the tests removed by commit
68873f3c11c6.
Here's a patch to recognize Android environments.
Such environments are "apps" with POSIX-like tools. Today, the most frequently
used one is Termux [1][2][3]; on devices with Android versions before 5.0
one can use Terminal-IDE [4][5].
config.sub already supports this environment:
$ sh config.sub armv7l-linux-androideabi
armv7l-unknown-linux-androideabi
I've built many GNU packages in this environment, with the following recipe:
CONFIG_SHELL=$PREFIX/bin/sh; export CONFIG_SHELL
CC="clang -ferror-limit=0" CXX="clang++ -ferror-limit=0"; export CC CXX
./configure --host=armv7l-linux-androideabi --prefix=$HOME/local
The Termux people have compiled or ported more than 1000 packages as well [6].
But the requirement to pass the --host parameter each time is an annoyance.
Without it, based only on the results of uname, config.guess guesses
$ sh config.guess
armv7l-unknown-linux-gnueabi
and many configuration results are wrong (because Android has many functions
in libc without declaring them in the .h files, depending on the so-called
"Android API level"), leading to many compilation errors.
With the attached patch, it produces
$ sh config.guess
armv7l-unknown-linux-androideabi
The patch does not include an addition to the config.guess test suite, since
the uname values are:
$ uname -m
armv7l
$ uname -r
4.19.127
$ uname -s
Linux
$ uname -v
#1 SMP PREEMPT Tue Apr 4 16:54:58 IST 2023
$ uname -p
unknown
which maps to armv7l-unknown-linux-gnueabi.
[1] https://github.com/termux/termux-app
[2] https://f-droid.org/en/packages/com.termux/
[3] https://wiki.termux.com/wiki/Main_Page
[4] https://en.wikibooks.org/wiki/Android/Terminal_IDE
[5] http://www.spartacusrex.com/terminalide.htm
[6] https://github.com/termux/termux-packages/tree/master/packages
* config.guess (Linux|GNU|GNU/*): Detect Android.
* doc/config.guess.1: Regenerate.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
GHC has been using a custom triple "javascript-unknown-ghcjs" for
their (non asm.js, non wasm) javascript-emitting kernel-less target.
This triple is a bit of an oddball, so the support for it is highly
restricted in order to discourage further proliferation of the
javascript "cpu" or ghcjs "operating system", which are valid only
in combination with each other.
* config.sub (javascript-*-ghcjs): Allow.
* doc/config.sub.1: Regenerate.
* testsuite/config-sub.data (javascript-ghcjs,
javascript-unknown-ghcjs): New entries.
Link: 6636b67023
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
While reimplementing config.sub for use in a situation where no bash
interpreter was available, I discovered several oddities about
config.sub's behavior.
One such oddity was the fact that an explicitly-provided vendor will
be clobbered by the inferred vendor for three cpu types: microblaze,
s390, and mmix. This commit adds test cases for this clobbering
behavior, so that unintentional changes to it will be noticed.
* testsuite/config-sub.data (microblaze-unknown-elf, mmix-unknown-elf,
s390-unknown-elf): New entries.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Instead of treating them as OSes, we treat them as their own category.
This is modeled on what LLVM does with its `ObjectFormatType` enum [1],
advancing my long-running project of trying to nudge GNU config and LLVM
towards each other, taking the best ideas of both.
Currently, my emphasis is just on code cleanup. There are just a few
tests for newly supported changes that fall out of this. But down the
road, this also opens the door to parsing configs with more than 4
components, like [2].
[1]: https://llvm.org/doxygen/classllvm_1_1Triple.html#a83e907e55fa50e093caa96a0aff96201
[2]: a18266473b/llvm/unittests/TargetParser/TripleTest.cpp (L1873C50-L1873C77)
added in
28b82bc39e
* config.sub: Save machine code format name separately from the OS name.
* doc/config.sub.1: Regenerate.
* testsuite/config-sub.data (arm-unknown-none-aout,
arm-unknown-none-pe): New entries.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
GNU binutils support the selection of the default MIPS subtarget via the
configuration triplet, e.g. `mips64octeon+el-unknown-linux-gnu' builds a
Linux/GNU 64-bit MIPS (n32 ABI) little-endian configuration with the CPU
set to Octeon+ by default. However `config.sub' rejects such a triplet
and indeed it only lets through a random choice of ones people submitted
changes for to support.
There is a large number of MIPS CPU configurations, 118 at the moment,
that GNU binutils know, so rather than adding them individually and then
hoping it will be kept up to date from now on accept any `mips*' pattern
for the machine part, just as we already do for a few of other targets.
* config.sub: Allow any `mips*' CPU rather than listing a choice
individually.
* doc/config.sub.1: Regenerate.
* testsuite/config-sub.data: Add test cases.
On x86_64 Linux, a C compiler producing 32bit code causes the guessed
CPU to be changed to i686.
Adapt this approach for aarch64 Linux, i.e. change the guessed CPU
to armv8l when a compiler producing arm eabi code is detected.
* config.guess (aarch64:Linux:*:*): Test for the 32-bit ABI.
* doc/config.guess.1: Regenerate.
Suggested-by: David Allsopp <david.allsopp@metastack.com>
These are distinct from "ios". They are also technically Darwin, so while
something like "aarch64-apple-darwin" could be used when targeting these,
on Apple-silicon based systems there could be cases where `--host` and
`--build` have the same value, and a ./configure script may determine that
we are not cross building, causing it to try to execute test programs for
the target OS that will not run on macOS.
These are functionally equivalent to iOS, and targets with "-tvos" and
"-watchos" are already used by clang.
* config.sub (tvos*, watchos*): Recognize.
* testsuite/config-sub.data (arm64-apple-tvos, arm64-apple-tvos10.0.0,
arm64-apple-watchos, arm64-apple-watchos5.0): New tests.
* doc/config.sub.1: Regenerate.
These are not real OSes, they are object file formats. There is a
longstanding tradition of using them for embedded/freestanding
programming, so it makes sense to parse them with `kernel=none`.
(I have a WIP future patch that systematizes parsing these non-OSes a
bit more. That also opens the door to parsing a 5th component as LLVM
can do.)
This change unblocks an issue we've been having with Nixpkgs (see
https://github.com/NixOS/nixpkgs/issues/165836 for the longer version).
* config.sub (none-coff*, none-elf*): Recognize.
* testsuite/config-sub.data (arm-unknown-none-coff,
arm-unknown-none-elf, riscv64-company-none-elf): New tests.
* doc/config.sub.1: Regenerate.
In older times, MinGW (GCC toolchain with modified windows headers) was
the only free software toolchain for Windows. But now, LLVM has support
both for MinGW ABI and Microsoft's own. The distinction matters for C++
more than C.
LLVM[1], Rust[2], and other projects have taken to differentiating these
two as `...windows-gnu` vs `...windows-msvc`. I think that makes a lot
of sense, as it correctly identifiers both their commonalities and their
differences.
A lot of MinGW-supporting software, most notably GCC itself, will
presumably continue to use configs like x86_64-pc-mingw32 and
i686-pc-mingw32. That's fine; this patch doesn't normalize them away
(like LLVM does) or remove them! If and when that software wants to
support the MSVC ABI without requiring MSVC itself, they can switch to
these newer configurations.
[1]: a18266473b/llvm/unittests/TargetParser/TripleTest.cpp (L1907-L1951)
[2]: 36fb58e433/compiler/rustc_target/src/spec/mod.rs (L1255-L1271)
In 2012 the GNU Coding Standards changed to recommend quoting
'like this' or "like this" instead of `like this'.
Alter diagnostics and comments accordingly.
Use a more-consistent quoting style in config.sub diagnostics,
preferring 'like this' to "like this" as the former is more
resistant to shell metacharacters.
Note: currently, there's no detection method for linux-mlibc in
config.guess, since there's no decided way to detect mlibc.
Signed-off-by: Arsen Arsenović <arsen@aarsen.me>
* config.sub (linux-mlibc*): Recognize.
* testsuite/config-sub.data (aarch64-linux-mlibc, riscv-linux-mlibc,
x86_64-linux-mlibc): New tests.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* config.guess (x86_64:Linux:*:*): Test for the 32-bit ABI. Don't assume that
__ILP32__ is a certain indicator for the x32 ABI; for GCC ≥ 9 it no longer is.
* doc/config.guess.1: Regenerate.
See: https://www.gnu.org/licenses/gpl-3.0.html#howto
Update license headers automatically using the following script:
$ git grep -l 'Foundation; either version 3' \
| xargs sed -i '/Foundation; either version 3/ s/n; e/n, e/'
* config.guess: Adjust via the above command.
(timestamp): Update.
* config.sub: Likewise.
* doc/config.guess.1: Regenerate.
* doc/config.sub.1: Likewise.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
ALT uses armh as an alias for armv7l-alt-linux-gnueabihf since 2012.
* config.sub (armh-unknown|armh-alt): Set cpu, vendor, and basic_os.
(timestamp): Update.
* doc/config.sub.1: Regenerate.
* testsuite/config-sub.data (armh, armh-alt-linux-gnueabihf): New tests.
config.guess guesses Solaris 11 to run on a 32-bit platform
despite Solaris 11 no longer supporting any 32-bit platform.
See the following code at lines 434 to 445:
| SUN_ARCH=i386
| # If there is a compiler, see if it is configured for 64-bit objects.
| # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
| # This test works for both compilers.
| if test "$CC_FOR_BUILD" != no_compiler_found; then
| if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
| (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
| grep IS_64BIT_ARCH >/dev/null
| then
| SUN_ARCH=x86_64
| fi
| fi
If "cc" is installed, i.e. the Oracle Studio compiler, this one is
chosen for $CC_FOR_BUILD. This compiler, the gcc provided by Oracle
and also gcc bootstrapped from sources on that platform with a default
configuration will by default generate 32-bit binaries -- even on
a 64-bit platform. And __amd64 will not be defined for compilations
targeting a 32-bit platform. This is different from the corresponding
behaviour on GNU/Linux systems where the local platform is targeted by
default.
Thus, as long as you do not add "-m64" or if you have a custom-built
gcc which defaults to 64 bit, you will get 32-bit binaries on Solaris
despite living on a 64-bit platform.
* config.guess (i86pc:SunOS:5.*:* || i86xen:SunOS:5.*:*): Adapt the
test by adding the "-m64" flag. This will work properly for Solaris
10 as well (the last Solaris release that supported x86 32-bit
platforms).
* doc/config.guess.1: Regenerate.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
When combining variable assignments with a shell command, some older
shells (notably heirloom-sh and presumably also Solaris 10 /bin/sh)
have a bug which causes the assignment to alter the current execution
environment whenever the command is a shell built-in. For example:
% dash -c 'x=good; x=bad echo >/dev/null; echo $x'
good
% jsh -c 'x=good; x=bad echo >/dev/null; echo $x'
bad
The config.sub script contains a few commands of the form:
IFS=- read ...
which triggers this bug, causing the IFS assignment to persist for the
remainder of the script. This can cause misbehaviour in certain cases,
for example:
% jsh config.sub i386-linux-gnu
config.sub: test: unknown operator gnu
% jsh config.sub i386-gnu/linux
sed: can't read s|gnu/linux|gnu|: No such file or directory
Invalid configuration `i386-gnu/linux': OS `' not recognized
* config.sub: Save and restore IFS explicitly to avoid shell bugs.
* doc/config.sub.1: Regenerate.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
This is in line with the recent config.guess change in commit
12fcf67c9108f4c4b581eaa302088782f0ee40ea
* config.sub (shellcheck disable): Add SC2006,SC2268.
Suggested-by: Jacob Bachmeyer <jcb@gnu.org>
Signed-off-by: Ozkan Sezer <sezero@users.sourceforge.net>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Some cases quote the argument to echo and some do not. At runtime
it probably does not matter because the substituted values will never
contain whitespace, but quoting them all would make shellcheck more
useful.
* config.sub: Consistently quote the argument of echo.
* doc/config.sub.1: Regenerate.
Suggested-by: Jacob Bachmeyer <jcb@gnu.org>
Signed-off-by: Ozkan Sezer <sezero@users.sourceforge.net>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
This is in line with the recent config.guess change in commit
d70c4fa934de164178054c3a60aaa0024ed07c91.
The patch was generated using patch-6.gawk script introduced in that
commit.
* config.sub: Revert POSIX command substitutions to classic form.
Signed-off-by: Ozkan Sezer <sezero@users.sourceforge.net>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
These tools have served their purposes and need not be kept outside of
the repository history any longer. This patch as a diff also collects
the contents of the various tools in one convenient place.
* patch-1.gawk: Remove.
* patch-3.gawk: Likewise.
* patch-6.gawk: Likewise.
The tool could not handle command substitutions that span lines, but
fortunately there were only two such substitutions in the script.
The test for which universe is active on Pyramid is rewritten into a
case block because it was the only use of a command substitution as an
argument to the test command, which would require quoting.
* config.guess: Rewrite "if" for Pyramid systems to "case".