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

Add ability to choose ubuntu version for llvm upstream repository #380

Closed
acmnpv opened this issue Jun 21, 2021 · 9 comments
Closed

Add ability to choose ubuntu version for llvm upstream repository #380

acmnpv opened this issue Jun 21, 2021 · 9 comments

Comments

@acmnpv
Copy link

acmnpv commented Jun 21, 2021

Hello,

I'm trying to add the upstream repository for llvm to the GROMACS docker image build (https://github.com/gromacs/gromacs/blob/master/admin/containers/scripted_gmx_docker_builds.py), but I'm running into issues with hpccm adding the Ubuntu Xenial repository by default for the upstream.

Changes to the python script to fetch the upstream

diff --git a/admin/containers/scripted_gmx_docker_builds.py b/admin/containers/scripted_gmx_docker_builds.py
index 3ed8cb7020..9e149c69b6 100755
--- a/admin/containers/scripted_gmx_docker_builds.py
+++ b/admin/containers/scripted_gmx_docker_builds.py
@@ -245,7 +245,7 @@ def get_compiler(args, compiler_build_stage: hpccm.Stage = None) -> bb_base:
                 raise RuntimeError('No TSAN compiler build stage!')
         # Build the default compiler if we don't need special support
         else:
-            compiler = hpccm.building_blocks.llvm(extra_repository=True, version=args.llvm)
+            compiler = hpccm.building_blocks.llvm(extra_repository=True, upstream=True, version=args.llvm)
 
     elif args.oneapi is not None:
         if compiler_build_stage is not Non

Log from building:

Step 3/80 : RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - &&     echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial main" >> /etc/apt/sources.list.d/hpccm.list &&     echo "deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial main" >> /etc/apt/sources.list.d/hpccm.list &&     apt-get update -y &&     DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends         clang-12         libomp-12-dev &&     rm -rf /var/lib/apt/lists/*

As you can see, instead of the current Ubuntu version 20.04 (Focal), the old Xenial release is picked up, and thus fails later to install clang-12.

Can this be changed in the config to pick up a different version, or to change the default?

Cheers

Paul

@samcmill
Copy link
Collaborator

Tracing through the linked recipe script, I think I understand the issue. Here's a short reproducer:

compiler = llvm(upstream=True)
image = baseimage(image='ubuntu:20.04')

Stage0 += image
Stage0 += compiler

Running this recipe through hpccm --recipe ... pulls in the xenial repo. Note that the llvm building block is referenced before the baseimage primitive.

The logic to set the Linux distribution type and version is in baseimage. Since llvm is called prior, it's using the default Ubuntu 16.

In the reproducer, if you exchange the first two lines, you get the expected focal repo.

I recommend moving the call to the baseimage primitive (stages['main'] += hpccm.primitives.baseimage(image=base_image_tag(args)) to the top of the build_stages function so that the correct Linux distribution is set before calling any of the building blocks.

@acmnpv
Copy link
Author

acmnpv commented Jun 22, 2021

Thanks for the tip, I'll see that we rework our script then!

@acmnpv acmnpv closed this as completed Jun 22, 2021
@mabraham
Copy link

I did rework the GROMACS script, but Sam's advice broke a cross-stage dependency we have. I found nothing more attractive to do than making a dummy stage that adds hpccm.primitives.baseimage(image=base_image_tag(args)) before any of the others. See https://gitlab.com/gromacs/gromacs/-/merge_requests/1764/diffs#14c7f142b515dba43cbfed3d95fe0b785b000384_636_636

@acmnpv
Copy link
Author

acmnpv commented Jun 24, 2021

There still seems to be an issue, even when using the correct order of includes. The script adds https://apt.llvm.org/focal llvm-toolchain-focal-8 Release to the package includes, but this repository doesn't exist.

@acmnpv acmnpv reopened this Jun 24, 2021
@samcmill
Copy link
Collaborator

If I'm following GROMACS script properly, I think the distro LLVM and upstream LLVM cases need to be separated. You're setting llvm(upstream=True, version='8') which isn't valid for the upstream. Or you could do something like llvm(upstream=False if v == '8' else True, version=v).

An alternative to the dummy stage approach is to use the hpccm.config.set_linux_distro().

@mabraham
Copy link

Thanks, those were very helpful suggestions. We're trying them out at https://gitlab.com/gromacs/gromacs/-/merge_requests/1764/diffs#14c7f142b515dba43cbfed3d95fe0b785b000384

@mabraham
Copy link

I think logic like upstream=True if int(args.llvm) > 11 else False is needed to have the comparison working correctly as an int, not a string.

@samcmill
Copy link
Collaborator

Closing. Please reopen if the issue persists.

@mabraham
Copy link

We resolved our issue, thanks!

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

No branches or pull requests

3 participants