Skip to content

Commit f779cfa

Browse files
authored
Merge pull request #1294 from wlemkows/alpine-umf
Fix UMF build on Alpine OS
2 parents 856058d + d622165 commit f779cfa

File tree

4 files changed

+98
-10
lines changed

4 files changed

+98
-10
lines changed

.github/docker/alpine-3.21.Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
#
6+
# Dockerfile - a 'recipe' for Docker to build an image of Alpine
7+
# environment for building the Unified Memory Framework project.
8+
#
9+
10+
# Pull base Alpine image version 3.21
11+
FROM registry.hub.docker.com/library/alpine@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c
12+
13+
# Set environment variables
14+
ENV OS=alpine
15+
ENV OS_VER=3.21
16+
17+
# Base development packages
18+
ARG BASE_DEPS="\
19+
bash \
20+
cmake \
21+
git \
22+
g++ \
23+
make \
24+
sudo"
25+
26+
# UMF's dependencies
27+
ARG UMF_DEPS="\
28+
hwloc-dev"
29+
30+
# Dependencies for tests
31+
ARG TEST_DEPS="\
32+
numactl-dev"
33+
34+
# Update and install required packages
35+
RUN apk update \
36+
&& apk add --no-cache \
37+
${BASE_DEPS} \
38+
${TEST_DEPS} \
39+
${UMF_DEPS}
40+
41+
# Add a new (non-root) 'test_user'
42+
ENV USER=test_user
43+
RUN adduser -D -G wheel ${USER}
44+
RUN echo '%wheel ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
45+
46+
USER test_user

.github/scripts/alpine_build.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
# Copyright (C) 2025 Intel Corporation
3+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
# alpine_build.sh - Script for building UMF on Alpine image
7+
8+
set -e
9+
10+
UMF_BUILD_TYPE=$1
11+
WORKDIR=$2
12+
13+
sudo chown $USER $WORKDIR
14+
cd unified-memory-framework
15+
16+
cmake -B build -DCMAKE_BUILD_TYPE=$UMF_BUILD_TYPE -DUMF_BUILD_TESTS=ON -DUMF_BUILD_EXAMPLES=ON
17+
cmake --build build

.github/workflows/nightly.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,3 +519,28 @@ jobs:
519519

520520
SYCL:
521521
uses: ./.github/workflows/reusable_sycl.yml
522+
523+
alpine:
524+
name: Alpine
525+
env:
526+
HOST_WORKDIR: ${{github.workspace}}
527+
WORKDIR: /unified-memory-framework
528+
strategy:
529+
matrix:
530+
build_type: [Debug, Release]
531+
runs-on: ubuntu-latest
532+
533+
steps:
534+
- name: Checkout repository
535+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
536+
with:
537+
fetch-depth: 0
538+
539+
- name: Build Alpine image
540+
run: |
541+
docker build . -f .github/docker/alpine-3.21.Dockerfile -t umf-alpine-3.21
542+
543+
- name: Run UMF build on Alpine image
544+
run: |
545+
docker run --rm -i -v $HOST_WORKDIR:$WORKDIR \
546+
umf-alpine-3.21 $WORKDIR/.github/scripts/alpine_build.sh ${{matrix.build_type}} $WORKDIR

src/utils/utils_log.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#ifdef _WIN32
1111
#include <windows.h>
1212
#else
13-
#define _GNU_SOURCE 1
1413
#include <sys/syscall.h>
1514
#include <sys/types.h>
1615
#include <unistd.h>
@@ -141,28 +140,29 @@ static void utils_log_internal(utils_log_level_t level, int perror,
141140
*err = '\0';
142141
postfix = "[strerror_s failed]";
143142
}
144-
#elif defined(__APPLE__)
145-
char err[1024]; // max size according to manpage.
143+
#else
146144
int saveno = errno;
147145
errno = 0;
148-
if (strerror_r(saveno, err, sizeof(err))) {
149-
/* should never happen */
146+
147+
#if defined(__APPLE__) || \
148+
((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE)
149+
char err[1024];
150+
int ret = strerror_r(saveno, err, sizeof(err));
151+
if (ret) {
150152
*err = '\0';
151153
postfix = "[strerror_r failed]";
152154
}
153-
154155
if (errno == ERANGE) {
155156
postfix = "[truncated...]";
156157
}
157-
errno = saveno;
158158
#else
159-
char err_buff[1024]; // max size according to manpage.
160-
int saveno = errno;
161-
errno = 0;
159+
char err_buff[1024];
162160
const char *err = strerror_r(saveno, err_buff, sizeof(err_buff));
163161
if (errno == ERANGE) {
164162
postfix = "[truncated...]";
165163
}
164+
#endif
165+
166166
errno = saveno;
167167
#endif
168168
strncpy(b_pos, err, b_size);

0 commit comments

Comments
 (0)