Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the range of values used for Config.system #12405

Merged
merged 7 commits into from
Aug 9, 2023

Conversation

dra27
Copy link
Member

@dra27 dra27 commented Jul 21, 2023

As @kit-ty-kate notes in #10613, the values used for Config.system (and displayed in ocamlopt -config) are quite inconsistent. At the time (in 2021), that felt a too bit tricky to address, but I've had cause to be looking at this as part of something else and I think two important things have changed:

  1. Most of the affected systems are 32-bit, and therefore do not have native compilers in 5.x (and won't).
  2. The use of OCaml stacks has vastly simplified the signal and C stack processing code, which is where most of these values were used.

Note that since #10044, ocamlc -config displays the detected values for architecture, model and system even when the native code compiler is not built.

This PR proposes:

  • Using system=linux for all Linux variants, in particular:
    • ppc64 and s390x use it instead of system=elf (@Octachron - given that s390x is only being restored to full native support in 5.1, might this commit be suitable for 5.1?)
    • x86_32 uses it instead of linux_elf
    • aarch32 in all its forms uses it instead of linux_eabi / linux_eabihf. The eabi/eabihf is now preserved in a new Config.abi (abi: in ocamlc -config). NB We don't use this (or SYS_linux_eabi / SYS_linux_eabihf) in the runtime, which uses ARM's own C preprocessor defines.
  • FreeBSD, NetBSD and OpenBSD now always have system=freebsd, system=netbsd or system=openbsd as appropriate; in particular:
    • aarch32 on OpenBSD no longer reports system=bsd, but system=openbsd (as aarch64 and x86_64 already did)
    • x86_32 no longer reports system=bsd for everything matching *bsd (very pedantically, this means that a system matching *bsd but not matching freebsd*|netbsd*|openbsd* now reports unknown for system (and none for architecture), but remember that these are bytecode only systems)

That implements the suggestions in #10613, apart from the bsd and Windows ones. I'd prefer to leave the Windows ones as they are - the biggest inconsistency before was that both Cygwin and Cygwin64 reported system=cygwin, but the world has made that easy for us by eliminating 32-bit Cygwin completely. Apart from worrying about how many years it would take to remember the changed values, a more practical reason for leaving them be is that they are used in the compiler's codebase, and elsewhere - all the other values I'm changing here affect largely retired systems and the values themselves are not used at all in the compiler's codebase anymore.

This then gives us:

system: OS (and possible architecture: values)
beos Haiku; amd64, i386
cygwin Cygwin; amd64, i3861
dragonfly DragonFly BSD; amd64
freebsd FreeBSD; amd64, arm64, arm, i386
gnu GNU Operating System using GNU Hurd; amd64, i386
linux Linux; amd64, arm64, arm, i386, power, riscv, s390x
macosx macOS; amd64, arm64
mingw Microsoft Windows, mingw-w64 32-bit GCC; i386
mingw64 Microsoft Windows, mingw-w64 64-bit GCC; amd64
netbsd NetBSD; amd64, arm64, arm, i386
openbsd OpenBSD; amd64, arm64, arm, i386
solaris Solaris; amd64
win32 Microsoft Windows, Microsoft Visual Studio x86 (32-bit); i386
win64 Microsoft Windows, Microsoft Visual Studio x64 (64-bit); amd64
unknown Everthing else; none

Footnotes

  1. the x86 version of Cygwin was retired in 2022

@dra27 dra27 linked an issue Jul 21, 2023 that may be closed by this pull request
@shindere
Copy link
Contributor

shindere commented Jul 24, 2023 via email

@xavierleroy
Copy link
Contributor

I would suggest to not bother with Config.abi: it matters only for native-code compilation for ARM 32 bits, which is no longer supported in OCaml 5. Moreover, most ARM systems use the "hard float" ABI these days, the "soft float" ABI being a relic of a past when ARM chips did not have VFP hardware support.

These two ports are only supported on Linux.
The various flavours of aarch32 now report system=linux and abi=eabi or
abi=eabihf.
The 64-bit ports of OCaml have `Config.system` being freebsd, netbsd or
openbsd, as appropriate but the 32-bit Intel ports have bsd for all of
them. The x86_32 now reports the same value as for x86_64, which in
particular means that BSDs matching *bsd but not {free,net,open}bsd are
no longer identified.
Previously the 32-bit version reported linux_elf.
@dra27
Copy link
Member Author

dra27 commented Jul 26, 2023

Config.abi gone, with the nice side-effect that the PR only changes the configure-time constants. I've used a mix of the wonderful Sherlocode and opam-grep tools to go through opam-repository. I couldn't find anything that would be broken by this change (apart from a couple of tests in OASIS...).

@dra27
Copy link
Member Author

dra27 commented Jul 26, 2023

As an aside, I spotted that a possible i386 BSD which would have been matched before and isn't here is Debian GNU/kFreeBSD. I was tempted to make the i386 FreeBSD case *freebsd*, therefore, except that the last release of kFreeBSD is long-expired (Debian 8) and we never handled the amd64 version of it anyway.

@glondu
Copy link
Contributor

glondu commented Jul 27, 2023

https://lists.debian.org/debian-devel/2023/07/msg00176.html

Copy link
Contributor

@xavierleroy xavierleroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a useful clean-up and simplification. The amount of breakage in OPAM packages seems manageable. I think it's better to merge now than let this PR bit-rot.

@xavierleroy xavierleroy merged commit eb2153b into ocaml:trunk Aug 9, 2023
9 checks passed
@dra27
Copy link
Member Author

dra27 commented Aug 21, 2023

Thank you!

@dra27 dra27 deleted the harmonise-system branch August 21, 2023 12:25
rlepigre added a commit to rlepigre/coq that referenced this pull request Nov 6, 2023
This fixes coq#18257 following the recommendations given in
ocaml/dune#4895. Starting with OCaml 5.2, testing "linux"
will be enough thanks to ocaml/ocaml#12405.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get the system variable to be consistent
4 participants