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

Install devtoolset-7 for RHEL 7 derivatives #86

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dra27
Copy link
Collaborator

@dra27 dra27 commented Jan 24, 2022

RHEL 7 and clones (CentOS, Oracle Linux, etc.) have GCC 4.8 which is too old for multicore. It is possible to get GCC 7 via RedHat Software Collections which this PR starts to enable.

Accessing the commands needs some trickery via the scl command (scl enable devtoolset-7 bash gives you a shell with the appropriate tweaks - I haven't looked in enough detail to see if you can persist it).

There'd then be the question of whether to have all CentOS 7 and Oracle Linux 7 images using GCC 7 (probably bad - better for the images for the older compilers to use the stock GCC, however old it is) or to build a separate opam image specifically for use by OCaml 5.00.0+ (more work, more space).

Anyway, this is what I'd done so far.

@avsm
Copy link
Member

avsm commented Oct 13, 2022

See #31 -- the difficult bit is persisting the scl. If we had that, it would also unlock better Rust support in our CI for RHEL7

@edwintorok
Copy link
Contributor

There is also devtoolset-11 which is newer, and works on CentOS 7 too (I'm using it).
Here is the change I had to make to ocaml.spec to enable it (albeit for 4.13.x, not 5.0 yet):

diff --git a/ocaml.spec b/ocaml.spec
index 08c48e5..8e409ae 100644
--- a/ocaml.spec
+++ b/ocaml.spec
@@ -64,7 +64,7 @@ Source0:        https://repo.citrite.net/ctx-local-contrib/xs-opam/ocaml-%{versi

 BuildRequires:  make
 BuildRequires:  git
-BuildRequires:  gcc
+BuildRequires: devtoolset-11-gcc devtoolset-11-binutils
 BuildRequires:  autoconf
 BuildRequires:  binutils-devel
 BuildRequires:  ncurses-devel
@@ -76,7 +76,7 @@ BuildRequires:  /usr/bin/annocheck

 # ocamlopt runs gcc to link binaries.  Because Fedora includes
 # hardening flags automatically, redhat-rpm-config is also required.
-Requires:       gcc
+Requires:       devtoolset-11-gcc
 Requires:       redhat-rpm-config

 # Because we pass -c flag to ocaml-find-requires (to avoid circular
@@ -174,6 +174,8 @@ unset MAKEFLAGS
 make=make
 %endif

+source /opt/rh/devtoolset-11/enable
+
 # Don't use %%configure macro because it sets --build, --host which
 # breaks some incorrect assumptions made by OCaml's configure.ac
 #

devtoolset doesn't modify the PATH on purpose, each package has to opt-in by sourcing the appropriate file.

This is not persisted in 'native_c_compiler' output of 'ocamlc -config' because that still refers to 'gcc' (although using older GCC to compile stubs "works", but obviously won't help if the headers themselves want newer compiler).

It might be possible to "persist" the devtoolset compiler by overriding CC (and related) flags instead of just extending the PATH, another alternative is to drop a script into /etc/profile.d in the container that sources this script.

This would be similar to how we handle 'eval $(opam env)' in RPM builds:

mkdir -p %{buildroot}/etc/profile.d
mkdir -p %{buildroot}%{_opamroot}
echo 'export OPAMROOT=%{_opamroot}' > %{buildroot}/etc/profile.d/opam.sh
echo 'export OPAMROOT=%{_opamroot}' > %{buildroot}/etc/profile.d/opam.sh
echo 'eval `opam config env`' >> %{buildroot}/etc/profile.d/opam.sh```

@dra27
Copy link
Collaborator Author

dra27 commented Jan 24, 2023

This is not persisted in 'native_c_compiler' output of 'ocamlc -config' because that still refers to 'gcc' (although using older GCC to compile stubs "works", but obviously won't help if the headers themselves want newer compiler).

This will matter for 5.0 - the _Atomic is required by pretty much every header.

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.

3 participants