Skip to content

MUSL can not compiles OpenZFS 2.3.2 because of S_IFMT #17293

Closed
@jlsalvador

Description

@jlsalvador

Hello!

It's me again; that's means that a compiler does not compiles OpenZFS anymore. This time is MUSL compiling a test cmd from the commit 6503f8c (that was added to the zfs-2.3.2 branch. zfs-2.3.1 works correctly for GLIBC, MUSL, and UCLIBC).

Ps: UCLIBC is broken for another reason, I have no idea yet why.

System information

Type Version/Name
Distribution Name buildroot
Distribution Version master
Kernel Version 6.12.9
Architecture aarch64
OpenZFS Version 2.3.2

Describe the problem you're observing

I saw that the test cmd (tests/zfs-tests/cmd/statx.c) includes some definitions safeguards, but it does not includes S_IFMT. From my view point there are two alternatives:

  • Add the #ifndef S_IFMT as the others.
  • #include <stat.h>.

Can someone propose a better solution?

Describe how to reproduce the problem

Try to compile openzfs-2.3.2 with musl.

Include any warning/errors/backtraces from the system logs

[...]
  CC       cmd/zfs_ids_to_path.o                                                                                                                          
  CC       cmd/zhack-zhack.o                                                                                                                              
  CC       cmd/ztest-ztest.o                                                                                                                              
  CC       cmd/zgenhostid.o
  CC       tests/zfs-tests/cmd/getversion.o
  CC       tests/zfs-tests/cmd/user_ns_exec.o
  CC       tests/zfs-tests/cmd/renameat2.o
  CC       tests/zfs-tests/cmd/xattrtest.o
  CC       tests/zfs-tests/cmd/statx.o 
tests/zfs-tests/cmd/statx.c: In function 'main':
tests/zfs-tests/cmd/statx.c:254:61: error: 'S_IFMT' undeclared (first use in this function)
  254 |                         printf("type: %u\n", stx.stx_mode & S_IFMT);
      |                                                             ^~~~~~
tests/zfs-tests/cmd/statx.c:254:61: note: each undeclared identifier is reported only once for each function it appears in
make[4]: *** [Makefile:8949: tests/zfs-tests/cmd/statx.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [Makefile:12621: all-recursive] Error 1
make[2]: *** [Makefile:4779: all] Error 2
make[1]: *** [package/pkg-generic.mk:273: /tmp/tmp.QADMx4LtMA/TestZfsMusl/build/zfs-2.3.2/.stamp_built] Error 2
make: *** [Makefile:23: _all] Error 2
make: Leaving directory '/tmp/tmp.QADMx4LtMA/TestZfsMusl'
E
======================================================================
ERROR: test_run (tests.package.test_zfs.TestZfsMusl.test_run)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/support/testing/infra/basetest.py", line 74, in setUp
    self.b.build()
  File "/data/support/testing/infra/builder.py", line 105, in build
    raise SystemError("Build failed")
SystemError: Build failed

----------------------------------------------------------------------
Ran 1 test in 599.316s

FAILED (errors=1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: DefectIncorrect behavior (e.g. crash, hang)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions