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

commit 42aaf0e7c4b9cf0fe9c18d218f291f12dd5b26a2 breaks the FreeBSD build #12984

Closed
markjdb opened this issue Jan 17, 2022 · 5 comments
Closed
Labels
Type: Building Indicates an issue related to building binaries Type: Defect Incorrect behavior (e.g. crash, hang)

Comments

@markjdb
Copy link
Contributor

markjdb commented Jan 17, 2022

System information

Type Version/Name
Distribution Name FreeBSD
Distribution Version 14.0-CURRENT
Kernel Version 14.0-CURRENT
Architecture amd64
OpenZFS Version latest

Describe the problem you're observing

The kernel module build fails for me when using the system compiler (clang 13.0).

--- zfs_vnops_os.o ---                                                                                                                        
/usr/home/markj/src/zfs/module/os/freebsd/zfs/zfs_vnops_os.c:3706:2: error: invalid application of 'sizeof' to bit-field                      
        ASSERT3S(ZTOV(tdzp)->v_type, ==, VDIR);                                                                                               
        ^                                                                                                                                     
/usr/home/markj/src/zfs/include/os/freebsd/spl/sys/debug.h:138:39: note: expanded from macro 'ASSERT3S'
#define ASSERT3S(x,y,z)         ((void)sizeof(x), (void)sizeof(z))                                                                            
                                             ^                                                                                                

Describe how to reproduce the problem

Build OpenZFS without debugging enabled on FreeBSD-CURRENT. I'm not sure if this is a problem with other compilers.

@markjdb markjdb added the Type: Defect Incorrect behavior (e.g. crash, hang) label Jan 17, 2022
@behlendorf
Copy link
Contributor

@nabijaczleweli mind taking a look at this, it appears 42aaf0e introduced a build issue.

@behlendorf behlendorf added the Type: Building Indicates an issue related to building binaries label Jan 18, 2022
nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Jan 18, 2022
sizeof(bitfield.member) is invalid: work around this

Fixes: 42aaf0e ("libspl: ASSERT*: mark arguments as used")
Closes: openzfs#12984
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Jan 18, 2022
sizeof(bitfield.member) is invalid, and this shows up in some FreeBSD
build configurations: work around this

Fixes: 42aaf0e ("libspl: ASSERT*: mark arguments as used")
Closes: openzfs#12984
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
@nabijaczleweli
Copy link
Contributor

Interesting that CI didn't pick it up, but yeah, sizeof(bitfield.member) is invalid.
@markjdb can you try #12986?

nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Jan 19, 2022
sizeof(bitfield.member) is invalid, and this shows up in some FreeBSD
build configurations: work around this by +0ing ‒ this takes the size of
the arithmetic result type, instead

Fixes: 42aaf0e ("libspl: ASSERT*: mark arguments as used")
Closes: openzfs#12984
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Jan 19, 2022
sizeof(bitfield.member) is invalid, and this shows up in some FreeBSD
build configurations: work around this by +0ing ‒ this takes the size of
the arithmetic result type, instead

Fixes: 42aaf0e ("libspl: ASSERT*: mark arguments as used")
Closes: openzfs#12984
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
@markjdb
Copy link
Contributor Author

markjdb commented Jan 19, 2022

Interesting that CI didn't pick it up, but yeah, sizeof(bitfield.member) is invalid. @markjdb can you try #12986?

I get this now:

In file included from ../../include/sys/zfs_context.h:97,
                 from ../../module/zstd/zfs_zstd.c:44:
../../include/sys/zstd/zstd.h: In function 'zfs_set_hdrversion':
../../include/sys/bitops.h:53:22: error: suggest parentheses around '+' inside '<<' [-Werror=parentheses]
   53 |  ASSERT3U(val, <, 1U << (len)); \
      |                      ^~
../../lib/libspl/include/assert.h:125:66: note: in definition of macro 'ASSERT3U'
  125 | #define ASSERT3U(x, y, z) ((void) sizeof (x + 0), (void) sizeof (z + 0))
      |                                                                  ^

If I parenthesize the macro parameters, I later get:

In file included from zfs_main.c:36:
zfs_main.c: In function 'zfs_do_clone':
../../lib/libspl/include/assert.h:126:47: error: invalid use of undefined type 'struct zfs_handle'
  126 | #define ASSERT3P(x, y, z) ((void) sizeof ((x) + 0), (void) sizeof ((z) + 0))
      |                                               ^
zfs_main.c:912:2: note: in expansion of macro 'ASSERT3P'
  912 |  ASSERT3P(zhp, ==, NULL);
      |  ^~~~~~~~

nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Jan 19, 2022
sizeof(bitfield.member) is invalid, and this shows up in some FreeBSD
build configurations: work around this by !!ing ‒
this makes the sizeof target the ! result type (_Bool), instead

Fixes: 42aaf0e ("libspl: ASSERT*: mark arguments as used")
Closes: openzfs#12984
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
@nabijaczleweli
Copy link
Contributor

Hm. Yeah, you can't do pointer arithmetic on pointers-to-incomplete, I guess. I'm, like, almost out of ideas before "dont pass bitfields to asserts". That being said, doing sizeof(!!(x)) seems to be building fine so far – PR updated, please try?

@markjdb
Copy link
Contributor Author

markjdb commented Jan 19, 2022

Thanks, builds fine now.

nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Jan 21, 2022
sizeof(bitfield.member) is invalid, and this shows up in some FreeBSD
build configurations: work around this by !!ing ‒
this makes the sizeof target the ! result type (_Bool), instead

Fixes: 42aaf0e ("libspl: ASSERT*: mark arguments as used")
Closes: openzfs#12984
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
nicman23 pushed a commit to nicman23/zfs that referenced this issue Aug 22, 2022
sizeof(bitfield.member) is invalid, and this shows up in some FreeBSD
build configurations: work around this by !!ing ‒
this makes the sizeof target the ! result type (_Bool), instead

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Fixes: 42aaf0e ("libspl: ASSERT*: mark arguments as used")
Closes openzfs#12984
Closes openzfs#12986
nicman23 pushed a commit to nicman23/zfs that referenced this issue Aug 22, 2022
sizeof(bitfield.member) is invalid, and this shows up in some FreeBSD
build configurations: work around this by !!ing ‒
this makes the sizeof target the ! result type (_Bool), instead

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Fixes: 42aaf0e ("libspl: ASSERT*: mark arguments as used")
Closes openzfs#12984
Closes openzfs#12986
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Building Indicates an issue related to building binaries Type: Defect Incorrect behavior (e.g. crash, hang)
Projects
None yet
Development

No branches or pull requests

3 participants