unified-memory-framework icon indicating copy to clipboard operation
unified-memory-framework copied to clipboard

Build failure with musl due to GNU libc strerror_r used

Open rafbiels opened this issue 10 months ago • 0 comments

Environment Information

  • UMF version (hash commit or a tag): main
  • OS(es) version(s): latest Alpine Linux
  • kernel version(s): 6.5.0-15-generic
  • compiler, libraries, and other related tools version(s): gcc 14.2.0, musl 1.2.5

Please provide a reproduction of the bug:

$ docker run -it alpine:latest
$ apk update && apk add git g++ cmake make hwloc-dev
$ git clone https://github.com/oneapi-src/unified-memory-framework.git
$ cd unified-memory-framework
$ cmake -B build -DCMAKE_BUILD_TYPE=Release -DUMF_BUILD_TESTS=OFF -DUMF_BUILD_EXAMPLES=OFF
$ cmake --build build
/unified-memory-framework/src/utils/utils_log.c:159:31: error: initialization of 'const char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  159 |             const char *err = strerror_r(saveno, err_buff, sizeof(err_buff));
      |                               ^~~~~~~~~~

How often bug is revealed:

always

Actual behavior:

compilation error

Expected behavior:

compilation succeeds

Details

utils_log.c uses GNU libc extension version of strerror_r but the README requirements claim any C compiler can be used to build UMF, implying any libc implementation should work. Possible solutions:

  • use the XSI version returning int (GNU libc also supports it since 2.3.4, POSIX-compliant since 2.13)
  • use preprocessor directives to select which stderror_r is used
  • refactor code to use something else
  • say only GNU libc is supported in requirements

man stderror says:

strerror_r(): The XSI-compliant version is provided if: (_POSIX_C_SOURCE >= 200112L) && ! _GNU_SOURCE Otherwise, the GNU-specific version is provided.

Additional information about Priority and Help Requested:

Are you willing to submit a pull request with a proposed change? Yes

Requested priority: Very low (I don't have an actual use case, just playing around)

rafbiels avatar Feb 13 '25 13:02 rafbiels