Skip to content

Fix UMF build on Alpine OS #1294

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/docker/alpine-3.20.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (C) 2025 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#
# Dockerfile - a 'recipe' for Docker to build an image of Alpine
# environment for building the Unified Memory Framework project.
#

# Pull base Alpine image version 3.20
FROM alpine:3.20
Copy link
Contributor

Choose a reason for hiding this comment

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

pls use the full link to the image, pls the pinned, hash version, as e.g. here:
https://github.com/oneapi-src/unified-memory-framework/blob/main/.github/docker/ubuntu-22.04.Dockerfile#L11


# Set environment variables
ENV OS alpine
ENV OS_VER 3.20

# Base development packages
ARG BASE_DEPS="\
cmake \
git \
g++ \
make"

# UMF's dependencies
ARG UMF_DEPS="\
hwloc-dev"

# Dependencies for tests
ARG TEST_DEPS="\
numactl-dev"

# Update and install required packages
RUN apk update \
&& apk add \
${BASE_DEPS} \
${TEST_DEPS} \
${UMF_DEPS}
Copy link
Contributor

Choose a reason for hiding this comment

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

pls add a non-root user (see other dockers as an example)

13 changes: 13 additions & 0 deletions .github/scripts/alpine_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# Copyright (C) 2025 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# alpine_build.sh - Script for building UMF on Alpine image

set -e

cd unified-memory-framework
Copy link
Contributor

Choose a reason for hiding this comment

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

I somehow dislike this random cd... but I'm not sure how to better handle this... At the moment I can only think of updating HOST_WORKDIR and WORKDIR to already include it... but not sure if this is better...?


cmake -B build -DCMAKE_BUILD_TYPE=$1 -DUMF_BUILD_TESTS=ON -DUMF_BUILD_EXAMPLES=ON
Copy link
Contributor

Choose a reason for hiding this comment

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

pls assign $1 (unnamed param) into a variable with meaningful name

cmake --build build
24 changes: 24 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ permissions:
env:
BUILD_DIR : "${{github.workspace}}/build"
INSTALL_DIR: "${{github.workspace}}/build/install"
HOST_WORKDIR: ${{github.workspace}}
Copy link
Contributor

Choose a reason for hiding this comment

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

we can specify these envs only in the job that actually uses it

WORKDIR: /unified-memory-framework

jobs:
fuzz-test:
Expand Down Expand Up @@ -370,3 +372,25 @@ jobs:

SYCL:
uses: ./.github/workflows/reusable_sycl.yml

alpine:
name: Alpine
strategy:
fail-fast: false
Copy link
Contributor

Choose a reason for hiding this comment

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

not needed

matrix:
build_type: [Debug, Release]
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we already moved on to new version

with:
fetch-depth: 0

- name: Build Alpine image
run: |
docker build . -f .github/docker/alpine-3.20.Dockerfile -t alpine_image
Copy link
Contributor

Choose a reason for hiding this comment

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

tag could be probably something more customized, e.g. umf-alpine-3.20


- name: Run UMF build on Alpine image
Copy link
Contributor

Choose a reason for hiding this comment

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

we could also run tests on the build (not sure if as part of build.sh or as a separate step here)

run: |
docker run --rm --name alpine_container -i -v $HOST_WORKDIR:$WORKDIR alpine_image $WORKDIR/.github/scripts/alpine_build.sh ${{matrix.build_type}}
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm.. I'm not sure if we need the --name alpine_container - if possible, pls omit, to shorten the command a little

Copy link
Contributor

Choose a reason for hiding this comment

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

also, you can break the line, the command is quite long

13 changes: 10 additions & 3 deletions src/utils/utils_log.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2024 Intel Corporation
* Copyright (C) 2024-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Expand All @@ -10,7 +10,6 @@
#ifdef _WIN32
#include <windows.h>
#else
#define _GNU_SOURCE 1
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
Expand Down Expand Up @@ -153,13 +152,21 @@ static void utils_log_internal(utils_log_level_t level, int perror,
}
errno = saveno;
#else
char err_buff[1024]; // max size according to manpage.
int saveno = errno;
errno = 0;
#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE
char err[1024];
int err_ret = strerror_r(saveno, err, sizeof(err));
if (err_ret == ERANGE) {
postfix = "[truncated...]";
}
#else
Comment on lines +157 to +163
Copy link
Contributor

@lplewa lplewa May 5, 2025

Choose a reason for hiding this comment

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

is it different from the apple version? can you just update apple ifdef?

char err_buff[1024]; // max size according to manpage.
const char *err = strerror_r(saveno, err_buff, sizeof(err_buff));
if (errno == ERANGE) {
postfix = "[truncated...]";
}
#endif
errno = saveno;
#endif
strncpy(b_pos, err, b_size);
Expand Down
Loading