[PATCH] D144654: [Lex] Warn when defining or undefining any builtin macro

Nathan Chancellor via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 26 09:40:21 PDT 2023


nathanchance added subscribers: nickdesaulniers, nathanchance.
nathanchance added a comment.

For what it's worth, this change is quite noisy for the Linux kernel, as there are certain macros undefined in header files that are included in many other headers. Additionally, at least one new instance is in a UAPI header, so it cannot be changed to my knowledge (honestly, all of these appear to be intentional, so I am not sure any of them should be changed). Is there any way for us to opt out of this? It would be a shame if we had to outright disable `-Wbuiltin-macro-redefined`, it has caught issues before (the kernel is generally against opting out on a per-location basis but does have the infrastructure to do so, not sure if it will be available for all these locations though...).

`arch/arm/include/uapi/asm/types.h`: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/include/uapi/asm/types.h?h=v6.4-rc3

  In file included from scripts/mod/devicetable-offsets.c:3:
  In file included from include/linux/mod_devicetable.h:12:
  In file included from include/uapi/linux/mei.h:10:
  In file included from include/uapi/linux/mei_uuid.h:12:
  In file included from include/linux/types.h:6:
  In file included from include/uapi/linux/types.h:5:
  arch/arm/include/uapi/asm/types.h:27:8: error: undefining builtin macro [-Werror,-Wbuiltin-macro-redefined]
  #undef __INT32_TYPE__
         ^
  arch/arm/include/uapi/asm/types.h:32:8: error: undefining builtin macro [-Werror,-Wbuiltin-macro-redefined]
  #undef __UINT32_TYPE__
         ^
  arch/arm/include/uapi/asm/types.h:37:8: error: undefining builtin macro [-Werror,-Wbuiltin-macro-redefined]
  #undef __UINTPTR_TYPE__
         ^
  3 errors generated.

`arch/arm64/include/asm/neon-intrinsics.h`: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/include/asm/neon-intrinsics.h?h=v6.4-rc3

  In file included from arch/arm64/lib/xor-neon.c:11:
  arch/arm64/include/asm/neon-intrinsics.h:18:8: error: undefining builtin macro [-Werror,-Wbuiltin-macro-redefined]
  #undef __INT64_TYPE__
         ^
  arch/arm64/include/asm/neon-intrinsics.h:23:8: error: undefining builtin macro [-Werror,-Wbuiltin-macro-redefined]
  #undef __UINT64_TYPE__
         ^
  2 errors generated.

`include/linux/drbd_genl_api.h` (this may be unnecessary now?): https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/drbd_genl_api.h?h=v6.4-rc3

  In file included from drivers/block/drbd/drbd_debugfs.c:11:
  In file included from drivers/block/drbd/drbd_int.h:35:
  include/linux/drbd_genl_api.h:47:8: error: undefining builtin macro [-Werror,-Wbuiltin-macro-redefined]
  #undef linux
         ^
  1 error generated.

`arch/mips/kernel/vmlinux.lds.S` (there is little context available as to why this exists): https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/mips/kernel/vmlinux.lds.S?h=v6.4-rc3

  In file included from <built-in>:357:
  <command line>:6:8: error: undefining builtin macro [-Werror,-Wbuiltin-macro-redefined]
  #undef mips
         ^
  1 error generated.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144654/new/

https://reviews.llvm.org/D144654



More information about the cfe-commits mailing list