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

linux: detect if kernel defines intptr_t #16201

Merged
merged 1 commit into from
May 25, 2024

Conversation

robn
Copy link
Member

@robn robn commented May 16, 2024

Motivation and Context

Since Linux 6.7 the kernel has defined intptr_t. Clang 18 has -Wtypedef-redefinition by default, which causes the build to fail because we also have a typedef for intptr_t.

Description

Adds some autoconf rules to check kernel types, then checks for intptr_t. We define our own if we didn't find out.

Typical error before (clang-18):

make[3]: Entering directory '/home/robn/code/quiz/build/kernel/linux-6.7.12'
  CC [M]  /home/robn/code/zfs/module/os/linux/spl/spl-condvar.o
In file included from /home/robn/code/zfs/module/os/linux/spl/spl-condvar.c:26:
In file included from /home/robn/code/zfs/include/os/linux/spl/sys/condvar.h:29:
In file included from /home/robn/code/zfs/include/os/linux/spl/sys/mutex.h:27:
/home/robn/code/zfs/include/os/linux/spl/sys/types.h:41:16: error: redefinition of typedef 'intptr_t' is a C11 feature [-Werror,-Wtypedef-redefinition]
   41 | typedef long                    intptr_t;
      |                                 ^
./include/linux/types.h:43:16: note: previous definition is here
   43 | typedef long                    intptr_t;
      |                                 ^
1 error generated.
make[5]: *** [scripts/Makefile.build:243: /home/robn/code/zfs/module/os/linux/spl/spl-condvar.o] Error 1

How Has This Been Tested?

Compiled against 6.4.x and 6.7.x with GCC 13 and Clang 18. All seems well.

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:

Since Linux 6.7 the kernel has defined intptr_t. Clang has
-Wtypedef-redefinition by default, which causes the build to fail
because we also have a typedef for intptr_t.

Since its better to use the kernel's if it exists, detect it and skip
our own.

Signed-off-by: Rob Norris <robn@despairlabs.com>
Sponsored-by: https://despairlabs.com/sponsor/
@robn robn force-pushed the linux-kernel-types branch from f7f17cb to 94d13b3 Compare May 16, 2024 12:10
@behlendorf behlendorf added the Status: Accepted Ready to integrate (reviewed, tested) label May 25, 2024
@behlendorf behlendorf merged commit 708be0f into openzfs:master May 25, 2024
24 checks passed
robn added a commit to robn/zfs that referenced this pull request Jul 17, 2024
Since Linux 6.7 the kernel has defined intptr_t. Clang has
-Wtypedef-redefinition by default, which causes the build to fail
because we also have a typedef for intptr_t.

Since its better to use the kernel's if it exists, detect it and skip
our own.

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes openzfs#16201
(cherry picked from commit 708be0f)
robn added a commit to robn/zfs that referenced this pull request Jul 17, 2024
Since Linux 6.7 the kernel has defined intptr_t. Clang has
-Wtypedef-redefinition by default, which causes the build to fail
because we also have a typedef for intptr_t.

Since its better to use the kernel's if it exists, detect it and skip
our own.

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes openzfs#16201
(cherry picked from commit 708be0f)
@robn robn mentioned this pull request Jul 17, 2024
13 tasks
robn added a commit to robn/zfs that referenced this pull request Jul 17, 2024
Since Linux 6.7 the kernel has defined intptr_t. Clang has
-Wtypedef-redefinition by default, which causes the build to fail
because we also have a typedef for intptr_t.

Since its better to use the kernel's if it exists, detect it and skip
our own.

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes openzfs#16201
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Sep 4, 2024
Since Linux 6.7 the kernel has defined intptr_t. Clang has
-Wtypedef-redefinition by default, which causes the build to fail
because we also have a typedef for intptr_t.

Since its better to use the kernel's if it exists, detect it and skip
our own.

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes openzfs#16201
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