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

zfs-test/mmap_seek: fix build on musl #12891

Merged
merged 1 commit into from
Dec 22, 2021

Conversation

gyakovlev
Copy link
Contributor

it needs linux/fs.h for SEEK_DATA and friends

Signed-off-by: Georgy Yakovlev gyakovlev@gentoo.org

Motivation and Context

zfs-2.1.2 fails to build on musl targets because of this change that added new test:
de198f2

Description

without linux/fs.h:

mmap_seek.c
mmap_seek.c: In function 'seek_data':
mmap_seek.c:37:40: error: 'SEEK_DATA' undeclared (first use in this function); did you mean 'SEEK_SET'?
   37 |  off_t data_offset = lseek(fd, offset, SEEK_DATA);

also it needs sys/sysmacros.h for P2ROUNDUP
without it:

make[5]: Entering directory '/var/tmp/portage/sys-fs/zfs-2.1.2-r1/work/zfs-2.1.2/tests/zfs-tests/cmd/mmap_seek'
powerpc64-gentoo-linux-musl-gcc -DHAVE_CONFIG_H -include ../../../../zfs_config.h -I../../../../include -I../../../../include -I../../../../module/icp/include -I../../../../lib/libspl/include -I../../../../lib/libspl/include/os/linu
x   -D_GNU_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DLIBEXECDIR=\"/usr/libexec\" -DRUNSTATEDIR=\"/var/run\" -DSBINDIR=\"/sbin\" -DSYSCONFDIR=\"/etc\" -DPKGDATADIR=\"/usr/share/zfs\" -UDEBUG -DNDEBUG  -DTEXT_
DOMAIN=\"zfs-linux-user\"   -std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes -fno-strict-aliasing -fno-omit-frame-pointer -Wimplicit-fallthrough    -Wno-format-zero-length  -O2 -pipe -frecord-gcc-switches -fdiagnostics-show
-option -c -o mmap_seek.o mmap_seek.c
mmap_seek.c: In function 'main':
mmap_seek.c:122:19: warning: implicit declaration of function 'P2ROUNDUP' [-Wimplicit-function-declaration]
  122 |  seek_hole(fd, 0, P2ROUNDUP(file_size / 2, block_size));
      |                   ^~~~~~~~~
/bin/sh ../../../../libtool  --tag=CC --silent  --mode=link powerpc64-gentoo-linux-musl-gcc -std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes -fno-strict-aliasing -fno-omit-frame-pointer -Wimplicit-fallthrough    -Wno-format
-zero-length  -O2 -pipe -frecord-gcc-switches -fdiagnostics-show-option    -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -o mmap_seek mmap_seek.o
/usr/lib/gcc/powerpc64-gentoo-linux-musl/10.3.0/../../../../powerpc64-gentoo-linux-musl/bin/ld: mmap_seek.o: in function `main':
mmap_seek.c:(.text.startup+0x1b8): undefined reference to `P2ROUNDUP'
/usr/lib/gcc/powerpc64-gentoo-linux-musl/10.3.0/../../../../powerpc64-gentoo-linux-musl/bin/ld: mmap_seek.c:(.text.startup+0x1d8): undefined reference to `P2ROUNDUP'
/usr/lib/gcc/powerpc64-gentoo-linux-musl/10.3.0/../../../../powerpc64-gentoo-linux-musl/bin/ld: mmap_seek.c:(.text.startup+0x21c): undefined reference to `P2ROUNDUP'
collect2: error: ld returned 1 exit status
make[5]: *** [Makefile:754: mmap_seek] Error 1

How Has This Been Tested?

I applied my change and it now builds fine.
I have NOT tested if the test-suite actually works after it.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@gyakovlev gyakovlev force-pushed the seek-test-include-fs.h branch from 6f90d23 to e7b231b Compare December 20, 2021 20:55
it needs linux/fs.h for SEEK_DATA and friends

without linux/fs.h:

```
mmap_seek.c
mmap_seek.c: In function 'seek_data':
mmap_seek.c:37:40: error: 'SEEK_DATA' undeclared (first use in this function);
did you mean 'SEEK_SET'?
   37 |  off_t data_offset = lseek(fd, offset, SEEK_DATA);
```

also it needs sys/sysmacros.h for P2ROUNDUP
without it:

```
mmap_seek.c: In function 'main':
mmap_seek.c:122:19: warning:
implicit declaration of function 'P2ROUNDUP' [-Wimplicit-function-declaration]
  122 |  seek_hole(fd, 0, P2ROUNDUP(file_size / 2, block_size));
      |                   ^~~~~~~~~
powerpc64-gentoo-linux-musl/bin/ld: mmap_seek.o: in function `main':
mmap_seek.c:(.text.startup+0x1b8): undefined reference to `P2ROUNDUP'
powerpc64-gentoo-linux-musl/bin/ld: mmap_seek.c:(.text.startup+0x1d8):
	undefined reference to `P2ROUNDUP'
powerpc64-gentoo-linux-musl/bin/ld: mmap_seek.c:(.text.startup+0x21c):
	undefined reference to `P2ROUNDUP'
collect2: error: ld returned 1 exit status
make[5]: *** [Makefile:754: mmap_seek] Error 1
```

Closes: openzfs#12891
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
@gyakovlev gyakovlev force-pushed the seek-test-include-fs.h branch from e7b231b to 123c87b Compare December 20, 2021 20:55
@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Dec 20, 2021
Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

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

Thanks!

@ericonr
Copy link
Contributor

ericonr commented Dec 21, 2021

For what it's worth I've sent a patch to musl adding those constants as well.

gentoo-bot pushed a commit to gentoo/gentoo that referenced this pull request Dec 21, 2021
PR: openzfs/zfs#12891
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Dec 21, 2021
@behlendorf behlendorf merged commit 2f41151 into openzfs:master Dec 22, 2021
@gyakovlev gyakovlev deleted the seek-test-include-fs.h branch December 22, 2021 01:32
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Feb 10, 2022
The build on musl needs linux/fs.h for SEEK_DATA and friends,
and sys/sysmacros.h for P2ROUNDUP.  Add the needed headers.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
Closes openzfs#12891
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Feb 14, 2022
The build on musl needs linux/fs.h for SEEK_DATA and friends,
and sys/sysmacros.h for P2ROUNDUP.  Add the needed headers.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
Closes openzfs#12891
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Feb 16, 2022
The build on musl needs linux/fs.h for SEEK_DATA and friends,
and sys/sysmacros.h for P2ROUNDUP.  Add the needed headers.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
Closes openzfs#12891
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Feb 17, 2022
The build on musl needs linux/fs.h for SEEK_DATA and friends,
and sys/sysmacros.h for P2ROUNDUP.  Add the needed headers.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
Closes openzfs#12891
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
The build on musl needs linux/fs.h for SEEK_DATA and friends,
and sys/sysmacros.h for P2ROUNDUP.  Add the needed headers.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
Closes openzfs#12891
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
The build on musl needs linux/fs.h for SEEK_DATA and friends,
and sys/sysmacros.h for P2ROUNDUP.  Add the needed headers.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
Closes openzfs#12891
gentoo-repo-qa-bot pushed a commit to gentoo-mirror/linux-be that referenced this pull request Jul 2, 2023
PR: openzfs/zfs#12891
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants