mirror of
git://git.savannah.gnu.org/config.git
synced 2025-05-26 09:06:38 +12:00
config.sub: Systematize parsing of machine code formats
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 in28b82bc39e
* 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>
This commit is contained in:
parent
d4e37b5868
commit
39c49ea712
135
config.sub
vendored
135
config.sub
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
# shellcheck disable=SC2006,SC2268 # see below for rationale
|
# shellcheck disable=SC2006,SC2268 # see below for rationale
|
||||||
|
|
||||||
timestamp='2023-07-31'
|
timestamp='2023-08-07'
|
||||||
|
|
||||||
# This file is free software; you can redistribute it and/or modify it
|
# This file is free software; you can redistribute it and/or modify it
|
||||||
# under the terms of the GNU General Public License as published by
|
# under the terms of the GNU General Public License as published by
|
||||||
@ -1284,11 +1284,12 @@ esac
|
|||||||
|
|
||||||
# Decode manufacturer-specific aliases for certain operating systems.
|
# Decode manufacturer-specific aliases for certain operating systems.
|
||||||
|
|
||||||
if test x$basic_os != x
|
if test x"$basic_os" != x
|
||||||
then
|
then
|
||||||
|
|
||||||
# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
|
# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
|
||||||
# set os.
|
# set os.
|
||||||
|
obj=
|
||||||
case $basic_os in
|
case $basic_os in
|
||||||
gnu/linux*)
|
gnu/linux*)
|
||||||
kernel=linux
|
kernel=linux
|
||||||
@ -1488,10 +1489,16 @@ case $os in
|
|||||||
os=eabi
|
os=eabi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
os=elf
|
os=
|
||||||
|
obj=elf
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
aout* | coff* | elf* | pe*)
|
||||||
|
# These are machine code file formats, not OSes
|
||||||
|
obj=$os
|
||||||
|
os=
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
# No normalization, but not necessarily accepted, that comes below.
|
# No normalization, but not necessarily accepted, that comes below.
|
||||||
;;
|
;;
|
||||||
@ -1510,12 +1517,15 @@ else
|
|||||||
# system, and we'll never get to this point.
|
# system, and we'll never get to this point.
|
||||||
|
|
||||||
kernel=
|
kernel=
|
||||||
|
obj=
|
||||||
case $cpu-$vendor in
|
case $cpu-$vendor in
|
||||||
score-*)
|
score-*)
|
||||||
os=elf
|
os=
|
||||||
|
obj=elf
|
||||||
;;
|
;;
|
||||||
spu-*)
|
spu-*)
|
||||||
os=elf
|
os=
|
||||||
|
obj=elf
|
||||||
;;
|
;;
|
||||||
*-acorn)
|
*-acorn)
|
||||||
os=riscix1.2
|
os=riscix1.2
|
||||||
@ -1525,28 +1535,35 @@ case $cpu-$vendor in
|
|||||||
os=gnu
|
os=gnu
|
||||||
;;
|
;;
|
||||||
arm*-semi)
|
arm*-semi)
|
||||||
os=aout
|
os=
|
||||||
|
obj=aout
|
||||||
;;
|
;;
|
||||||
c4x-* | tic4x-*)
|
c4x-* | tic4x-*)
|
||||||
os=coff
|
os=
|
||||||
|
obj=coff
|
||||||
;;
|
;;
|
||||||
c8051-*)
|
c8051-*)
|
||||||
os=elf
|
os=
|
||||||
|
obj=elf
|
||||||
;;
|
;;
|
||||||
clipper-intergraph)
|
clipper-intergraph)
|
||||||
os=clix
|
os=clix
|
||||||
;;
|
;;
|
||||||
hexagon-*)
|
hexagon-*)
|
||||||
os=elf
|
os=
|
||||||
|
obj=elf
|
||||||
;;
|
;;
|
||||||
tic54x-*)
|
tic54x-*)
|
||||||
os=coff
|
os=
|
||||||
|
obj=coff
|
||||||
;;
|
;;
|
||||||
tic55x-*)
|
tic55x-*)
|
||||||
os=coff
|
os=
|
||||||
|
obj=coff
|
||||||
;;
|
;;
|
||||||
tic6x-*)
|
tic6x-*)
|
||||||
os=coff
|
os=
|
||||||
|
obj=coff
|
||||||
;;
|
;;
|
||||||
# This must come before the *-dec entry.
|
# This must come before the *-dec entry.
|
||||||
pdp10-*)
|
pdp10-*)
|
||||||
@ -1568,19 +1585,24 @@ case $cpu-$vendor in
|
|||||||
os=sunos3
|
os=sunos3
|
||||||
;;
|
;;
|
||||||
m68*-cisco)
|
m68*-cisco)
|
||||||
os=aout
|
os=
|
||||||
|
obj=aout
|
||||||
;;
|
;;
|
||||||
mep-*)
|
mep-*)
|
||||||
os=elf
|
os=
|
||||||
|
obj=elf
|
||||||
;;
|
;;
|
||||||
mips*-cisco)
|
mips*-cisco)
|
||||||
os=elf
|
os=
|
||||||
|
obj=elf
|
||||||
;;
|
;;
|
||||||
mips*-*)
|
mips*-*)
|
||||||
os=elf
|
os=
|
||||||
|
obj=elf
|
||||||
;;
|
;;
|
||||||
or32-*)
|
or32-*)
|
||||||
os=coff
|
os=
|
||||||
|
obj=coff
|
||||||
;;
|
;;
|
||||||
*-tti) # must be before sparc entry or we get the wrong os.
|
*-tti) # must be before sparc entry or we get the wrong os.
|
||||||
os=sysv3
|
os=sysv3
|
||||||
@ -1589,7 +1611,8 @@ case $cpu-$vendor in
|
|||||||
os=sunos4.1.1
|
os=sunos4.1.1
|
||||||
;;
|
;;
|
||||||
pru-*)
|
pru-*)
|
||||||
os=elf
|
os=
|
||||||
|
obj=elf
|
||||||
;;
|
;;
|
||||||
*-be)
|
*-be)
|
||||||
os=beos
|
os=beos
|
||||||
@ -1670,10 +1693,12 @@ case $cpu-$vendor in
|
|||||||
os=uxpv
|
os=uxpv
|
||||||
;;
|
;;
|
||||||
*-rom68k)
|
*-rom68k)
|
||||||
os=coff
|
os=
|
||||||
|
obj=coff
|
||||||
;;
|
;;
|
||||||
*-*bug)
|
*-*bug)
|
||||||
os=coff
|
os=
|
||||||
|
obj=coff
|
||||||
;;
|
;;
|
||||||
*-apple)
|
*-apple)
|
||||||
os=macos
|
os=macos
|
||||||
@ -1691,7 +1716,8 @@ esac
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Now, validate our (potentially fixed-up) OS.
|
# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).
|
||||||
|
|
||||||
case $os in
|
case $os in
|
||||||
# Sometimes we do "kernel-libc", so those need to count as OSes.
|
# Sometimes we do "kernel-libc", so those need to count as OSes.
|
||||||
musl* | newlib* | relibc* | uclibc*)
|
musl* | newlib* | relibc* | uclibc*)
|
||||||
@ -1719,11 +1745,11 @@ case $os in
|
|||||||
| mirbsd* | netbsd* | dicos* | openedition* | ose* \
|
| mirbsd* | netbsd* | dicos* | openedition* | ose* \
|
||||||
| bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
|
| bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
|
||||||
| ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
|
| ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
|
||||||
| bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
|
| bosx* | nextstep* | cxux* | oabi* \
|
||||||
| ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
|
| ptx* | ecoff* | winnt* | domain* | vsta* \
|
||||||
| udi* | lites* | ieee* | go32* | aux* | hcos* \
|
| udi* | lites* | ieee* | go32* | aux* | hcos* \
|
||||||
| chorusrdb* | cegcc* | glidix* | serenity* \
|
| chorusrdb* | cegcc* | glidix* | serenity* \
|
||||||
| cygwin* | msys* | pe* | moss* | proelf* | rtems* \
|
| cygwin* | msys* | moss* | proelf* | rtems* \
|
||||||
| midipix* | mingw32* | mingw64* | mint* \
|
| midipix* | mingw32* | mingw64* | mint* \
|
||||||
| uxpv* | beos* | mpeix* | udk* | moxiebox* \
|
| uxpv* | beos* | mpeix* | udk* | moxiebox* \
|
||||||
| interix* | uwin* | mks* | rhapsody* | darwin* \
|
| interix* | uwin* | mks* | rhapsody* | darwin* \
|
||||||
@ -1747,60 +1773,81 @@ case $os in
|
|||||||
kernel* | msvc* )
|
kernel* | msvc* )
|
||||||
# Restricted further below
|
# Restricted further below
|
||||||
;;
|
;;
|
||||||
|
'')
|
||||||
|
if test x"$obj" = x
|
||||||
|
then
|
||||||
|
echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2
|
||||||
|
fi
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
|
echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
case $obj in
|
||||||
|
aout* | coff* | elf* | pe*)
|
||||||
|
;;
|
||||||
|
'')
|
||||||
|
# empty is fine
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# As a final step for OS-related things, validate the OS-kernel combination
|
# As a final step for OS-related things, validate the OS-kernel combination
|
||||||
# (given a valid OS), if there is a kernel.
|
# (given a valid OS), if there is a kernel.
|
||||||
case $kernel-$os in
|
case $kernel-$os-$obj in
|
||||||
linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
|
linux-gnu*- | linux-dietlibc*- | linux-android*- | linux-newlib*- \
|
||||||
| linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
|
| linux-musl*- | linux-relibc*- | linux-uclibc*- | linux-mlibc*- )
|
||||||
;;
|
;;
|
||||||
uclinux-uclibc* )
|
uclinux-uclibc*- )
|
||||||
;;
|
;;
|
||||||
managarm-mlibc* | managarm-kernel* )
|
managarm-mlibc*- | managarm-kernel*- )
|
||||||
;;
|
;;
|
||||||
windows*-gnu* | windows*-msvc*)
|
windows*-gnu*- | windows*-msvc*-)
|
||||||
;;
|
;;
|
||||||
-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
|
-dietlibc*- | -newlib*- | -musl*- | -relibc*- | -uclibc*- | -mlibc*- )
|
||||||
# These are just libc implementations, not actual OSes, and thus
|
# These are just libc implementations, not actual OSes, and thus
|
||||||
# require a kernel.
|
# require a kernel.
|
||||||
echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
|
echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
-kernel* )
|
-kernel*- )
|
||||||
echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
|
echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
*-kernel* )
|
*-kernel*- )
|
||||||
echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
|
echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
*-msvc* )
|
*-msvc*- )
|
||||||
echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
|
echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
kfreebsd*-gnu* | kopensolaris*-gnu*)
|
kfreebsd*-gnu*- | kopensolaris*-gnu*-)
|
||||||
;;
|
;;
|
||||||
vxworks-simlinux | vxworks-simwindows | vxworks-spe)
|
vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
|
||||||
;;
|
;;
|
||||||
nto-qnx*)
|
nto-qnx*-)
|
||||||
;;
|
;;
|
||||||
os2-emx)
|
os2-emx-)
|
||||||
;;
|
;;
|
||||||
*-eabi* | *-gnueabi*)
|
*-eabi*- | *-gnueabi*-)
|
||||||
;;
|
;;
|
||||||
none-coff* | none-elf*)
|
none--*)
|
||||||
# None (no kernel, i.e. freestanding / bare metal),
|
# None (no kernel, i.e. freestanding / bare metal),
|
||||||
# can be paired with an output format "OS"
|
# can be paired with an machine code file format
|
||||||
;;
|
;;
|
||||||
-*)
|
-*-)
|
||||||
# Blank kernel with real OS is always fine.
|
# Blank kernel with real OS is always fine.
|
||||||
;;
|
;;
|
||||||
*-*)
|
--*)
|
||||||
|
# Blank kernel and OS with real machine code file format is always fine.
|
||||||
|
;;
|
||||||
|
*-*-*)
|
||||||
echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
|
echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
@ -1884,7 +1931,7 @@ case $vendor in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "$cpu-$vendor-${kernel:+$kernel-}$os"
|
echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
|
||||||
exit
|
exit
|
||||||
|
|
||||||
# Local variables:
|
# Local variables:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.5.
|
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.5.
|
||||||
.TH CONFIG.SUB "1" "July 2023" "GNU config.sub (2023-07-31)" "User Commands"
|
.TH CONFIG.SUB "1" "August 2023" "GNU config.sub (2023-08-07)" "User Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
config.sub \- validate and canonicalize a configuration triplet
|
config.sub \- validate and canonicalize a configuration triplet
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
@ -91,9 +91,11 @@ arm-sysgo-pikeos arm-sysgo-eabi
|
|||||||
arm-tirtos arm-unknown-tirtos
|
arm-tirtos arm-unknown-tirtos
|
||||||
arm-uclinux-uclibcgnueabi arm-unknown-uclinux-uclibcgnueabi
|
arm-uclinux-uclibcgnueabi arm-unknown-uclinux-uclibcgnueabi
|
||||||
arm-unknown-netbsdelf7.0 arm-unknown-netbsdelf7.0
|
arm-unknown-netbsdelf7.0 arm-unknown-netbsdelf7.0
|
||||||
|
arm-unknown-none-aout arm-unknown-none-aout
|
||||||
arm-unknown-none-coff arm-unknown-none-coff
|
arm-unknown-none-coff arm-unknown-none-coff
|
||||||
arm-unknown-none-eabi arm-unknown-none-eabi
|
arm-unknown-none-eabi arm-unknown-none-eabi
|
||||||
arm-unknown-none-elf arm-unknown-none-elf
|
arm-unknown-none-elf arm-unknown-none-elf
|
||||||
|
arm-unknown-none-pe arm-unknown-none-pe
|
||||||
arm-unknown-riscos arm-unknown-riscos
|
arm-unknown-riscos arm-unknown-riscos
|
||||||
arm-zephyr arm-unknown-zephyr
|
arm-zephyr arm-unknown-zephyr
|
||||||
arm64-apple-darwin20.0.0 aarch64-apple-darwin20.0.0
|
arm64-apple-darwin20.0.0 aarch64-apple-darwin20.0.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user