diff mbox series

kbuild: use objcopy to generate asm-offsets

Message ID 20240828083605.3093701-1-vegard.nossum@oracle.com (mailing list archive)
State New
Headers show
Series kbuild: use objcopy to generate asm-offsets | expand

Commit Message

Vegard Nossum Aug. 28, 2024, 8:36 a.m. UTC
In order to give assembly code access to C structs without having to
hardcore member offsets, the kernel compiles a C source file listing all
the structs and offsets that are needed in assembly code. Using some
C preprocessor trickery and a sed script, the compiled assembly code is
turned back into C preprocessor code that in turn can be used by the
asssembly code.

This sed script is very hard to read and understand.

Remove the sed script and compile the C source listing structs and
offsets to an object file (instead of assembly code) that embeds C source
directly. Then extract the C source using objcopy.

The resulting code is more readable, less fragile, and sligthly shorter.

Note to reviewers: The 'objcopy ... /dev/stdout | cat' bit is needed to
force the correct ordering of the objcopy lines vs. the surrounding echo
commands; without it, objcopy will open /dev/stdout (which refers to a
temporary file created by kbuild) and reset the file offset to 0. In
other words, the pipe ensures that objcopy doesn't overwrite the lines
that already exist in /dev/stdout.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
---
 Kbuild                       | 10 +++++-----
 arch/arm/mach-at91/Makefile  |  4 ++--
 arch/arm/mach-omap2/Makefile |  4 ++--
 arch/arm64/kvm/Makefile      |  9 +++++----
 arch/x86/kvm/Makefile        |  4 ++--
 arch/x86/um/Makefile         |  6 +++---
 drivers/memory/Makefile      |  4 ++--
 include/linux/kbuild.h       | 15 +++++++++++----
 samples/bpf/Makefile         |  4 ++--
 scripts/Makefile.lib         | 13 +------------
 scripts/mod/Makefile         |  4 ++--
 11 files changed, 37 insertions(+), 40 deletions(-)

Comments

Vegard Nossum Aug. 28, 2024, 10:07 a.m. UTC | #1
On 28/08/2024 10:36, Vegard Nossum wrote:
> In order to give assembly code access to C structs without having to
> hardcore member offsets, the kernel compiles a C source file listing all
> the structs and offsets that are needed in assembly code. Using some
> C preprocessor trickery and a sed script, the compiled assembly code is
> turned back into C preprocessor code that in turn can be used by the
> asssembly code.
> 
> This sed script is very hard to read and understand.
> 
> Remove the sed script and compile the C source listing structs and
> offsets to an object file (instead of assembly code) that embeds C source
> directly. Then extract the C source using objcopy.
> 
> The resulting code is more readable, less fragile, and sligthly shorter.
> 
> Note to reviewers: The 'objcopy ... /dev/stdout | cat' bit is needed to
> force the correct ordering of the objcopy lines vs. the surrounding echo
> commands; without it, objcopy will open /dev/stdout (which refers to a
> temporary file created by kbuild) and reset the file offset to 0. In
> other words, the pipe ensures that objcopy doesn't overwrite the lines
> that already exist in /dev/stdout.

Turns out LLVM's objcopy doesn't support writing to /dev/stdout, so we
might have to use a temporary file. I'll look into it and send a v2.


Vegard
kernel test robot Aug. 29, 2024, 2:58 p.m. UTC | #2
Hi Vegard,

kernel test robot noticed the following build errors:

[auto build test ERROR on masahiroy-kbuild/for-next]
[also build test ERROR on masahiroy-kbuild/fixes soc/for-next kvmarm/next kvm/queue uml/next krzk-mem-ctrl/for-next bpf-next/master bpf/master linus/master v6.11-rc5 next-20240829]
[cannot apply to tmlind-omap/for-next kvm/linux-next uml/fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Vegard-Nossum/kbuild-use-objcopy-to-generate-asm-offsets/20240828-163854
base:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
patch link:    https://lore.kernel.org/r/20240828083605.3093701-1-vegard.nossum%40oracle.com
patch subject: [PATCH] kbuild: use objcopy to generate asm-offsets
config: sh-randconfig-r072-20240829 (https://download.01.org/0day-ci/archive/20240829/202408292215.pEJKHLfT-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240829/202408292215.pEJKHLfT-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408292215.pEJKHLfT-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from scripts/mod/file2alias.c:13:
   scripts/mod/file2alias.c: In function 'do_usb_entry':
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:66:55: note: in definition of macro 'TO_NATIVE'
      66 |         (target_is_big_endian == host_is_big_endian ? x : bswap(x))
         |                                                       ^
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:175:9: note: in expansion of macro 'DEF_FIELD'
     175 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:57:31: note: in definition of macro 'bswap'
      57 |         _Static_assert(sizeof(x) == 1 || sizeof(x) == 2 || \
         |                               ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:175:9: note: in expansion of macro 'DEF_FIELD'
     175 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:57:49: note: in definition of macro 'bswap'
      57 |         _Static_assert(sizeof(x) == 1 || sizeof(x) == 2 || \
         |                                                 ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:175:9: note: in expansion of macro 'DEF_FIELD'
     175 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:58:31: note: in definition of macro 'bswap'
      58 |                        sizeof(x) == 4 || sizeof(x) == 8, "bug"); \
         |                               ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:175:9: note: in expansion of macro 'DEF_FIELD'
     175 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:58:49: note: in definition of macro 'bswap'
      58 |                        sizeof(x) == 4 || sizeof(x) == 8, "bug"); \
         |                                                 ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:175:9: note: in expansion of macro 'DEF_FIELD'
     175 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:59:17: note: in definition of macro 'bswap'
      59 |         (typeof(x))(sizeof(x) == 2 ? bswap_16(x) : \
         |                 ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:175:9: note: in expansion of macro 'DEF_FIELD'
     175 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:59:28: note: in definition of macro 'bswap'
      59 |         (typeof(x))(sizeof(x) == 2 ? bswap_16(x) : \
         |                            ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:175:9: note: in expansion of macro 'DEF_FIELD'
     175 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
   In file included from scripts/mod/modpost.h:2:
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:66:59: note: in expansion of macro 'bswap'
      66 |         (target_is_big_endian == host_is_big_endian ? x : bswap(x))
         |                                                           ^~~~~
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:175:9: note: in expansion of macro 'DEF_FIELD'
     175 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:60:28: note: in definition of macro 'bswap'
      60 |                     sizeof(x) == 4 ? bswap_32(x) : \
         |                            ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:175:9: note: in expansion of macro 'DEF_FIELD'
     175 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:66:59: note: in expansion of macro 'bswap'
      66 |         (target_is_big_endian == host_is_big_endian ? x : bswap(x))
         |                                                           ^~~~~
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:175:9: note: in expansion of macro 'DEF_FIELD'
     175 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:61:28: note: in definition of macro 'bswap'
      61 |                     sizeof(x) == 8 ? bswap_64(x) : \
         |                            ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:175:9: note: in expansion of macro 'DEF_FIELD'
     175 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:66:59: note: in expansion of macro 'bswap'
      66 |         (target_is_big_endian == host_is_big_endian ? x : bswap(x))
         |                                                           ^~~~~
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:175:9: note: in expansion of macro 'DEF_FIELD'
     175 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:62:21: note: in definition of macro 'bswap'
      62 |                     x); \
         |                     ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:175:9: note: in expansion of macro 'DEF_FIELD'
     175 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:11:36: error: stray '#' in program
      11 | #define OFF_usb_device_id_idVendor #2 /* offsetof(struct usb_device_id, idVendor) */
         |                                    ^
   scripts/mod/modpost.h:66:55: note: in definition of macro 'TO_NATIVE'
      66 |         (target_is_big_endian == host_is_big_endian ? x : bswap(x))
         |                                                       ^
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_idVendor'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:176:9: note: in expansion of macro 'DEF_FIELD'
     176 |         DEF_FIELD(symval, usb_device_id, idVendor);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:11:36: error: stray '#' in program
      11 | #define OFF_usb_device_id_idVendor #2 /* offsetof(struct usb_device_id, idVendor) */
         |                                    ^
   scripts/mod/modpost.h:57:31: note: in definition of macro 'bswap'
      57 |         _Static_assert(sizeof(x) == 1 || sizeof(x) == 2 || \
         |                               ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_idVendor'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:176:9: note: in expansion of macro 'DEF_FIELD'
     176 |         DEF_FIELD(symval, usb_device_id, idVendor);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:11:36: error: stray '#' in program
      11 | #define OFF_usb_device_id_idVendor #2 /* offsetof(struct usb_device_id, idVendor) */
         |                                    ^
   scripts/mod/modpost.h:57:49: note: in definition of macro 'bswap'
      57 |         _Static_assert(sizeof(x) == 1 || sizeof(x) == 2 || \
         |                                                 ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_idVendor'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:176:9: note: in expansion of macro 'DEF_FIELD'
     176 |         DEF_FIELD(symval, usb_device_id, idVendor);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:11:36: error: stray '#' in program
      11 | #define OFF_usb_device_id_idVendor #2 /* offsetof(struct usb_device_id, idVendor) */
         |                                    ^
   scripts/mod/modpost.h:58:31: note: in definition of macro 'bswap'
      58 |                        sizeof(x) == 4 || sizeof(x) == 8, "bug"); \
         |                               ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_idVendor'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:176:9: note: in expansion of macro 'DEF_FIELD'
     176 |         DEF_FIELD(symval, usb_device_id, idVendor);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:11:36: error: stray '#' in program
      11 | #define OFF_usb_device_id_idVendor #2 /* offsetof(struct usb_device_id, idVendor) */
         |                                    ^
   scripts/mod/modpost.h:58:49: note: in definition of macro 'bswap'
      58 |                        sizeof(x) == 4 || sizeof(x) == 8, "bug"); \
         |                                                 ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_idVendor'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:176:9: note: in expansion of macro 'DEF_FIELD'
     176 |         DEF_FIELD(symval, usb_device_id, idVendor);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:11:36: error: stray '#' in program
      11 | #define OFF_usb_device_id_idVendor #2 /* offsetof(struct usb_device_id, idVendor) */
         |                                    ^
   scripts/mod/modpost.h:59:17: note: in definition of macro 'bswap'
      59 |         (typeof(x))(sizeof(x) == 2 ? bswap_16(x) : \
         |                 ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_idVendor'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:176:9: note: in expansion of macro 'DEF_FIELD'
     176 |         DEF_FIELD(symval, usb_device_id, idVendor);
--
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_bInterfaceNumber'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:185:9: note: in expansion of macro 'DEF_FIELD'
     185 |         DEF_FIELD(symval, usb_device_id, bInterfaceNumber);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:21:44: error: stray '#' in program
      21 | #define OFF_usb_device_id_bInterfaceNumber #16 /* offsetof(struct usb_device_id, bInterfaceNumber) */
         |                                            ^
   scripts/mod/modpost.h:66:59: note: in expansion of macro 'bswap'
      66 |         (target_is_big_endian == host_is_big_endian ? x : bswap(x))
         |                                                           ^~~~~
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_bInterfaceNumber'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:185:9: note: in expansion of macro 'DEF_FIELD'
     185 |         DEF_FIELD(symval, usb_device_id, bInterfaceNumber);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:21:44: error: stray '#' in program
      21 | #define OFF_usb_device_id_bInterfaceNumber #16 /* offsetof(struct usb_device_id, bInterfaceNumber) */
         |                                            ^
   scripts/mod/modpost.h:60:28: note: in definition of macro 'bswap'
      60 |                     sizeof(x) == 4 ? bswap_32(x) : \
         |                            ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_bInterfaceNumber'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:185:9: note: in expansion of macro 'DEF_FIELD'
     185 |         DEF_FIELD(symval, usb_device_id, bInterfaceNumber);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:21:44: error: stray '#' in program
      21 | #define OFF_usb_device_id_bInterfaceNumber #16 /* offsetof(struct usb_device_id, bInterfaceNumber) */
         |                                            ^
   scripts/mod/modpost.h:66:59: note: in expansion of macro 'bswap'
      66 |         (target_is_big_endian == host_is_big_endian ? x : bswap(x))
         |                                                           ^~~~~
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_bInterfaceNumber'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:185:9: note: in expansion of macro 'DEF_FIELD'
     185 |         DEF_FIELD(symval, usb_device_id, bInterfaceNumber);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:21:44: error: stray '#' in program
      21 | #define OFF_usb_device_id_bInterfaceNumber #16 /* offsetof(struct usb_device_id, bInterfaceNumber) */
         |                                            ^
   scripts/mod/modpost.h:61:28: note: in definition of macro 'bswap'
      61 |                     sizeof(x) == 8 ? bswap_64(x) : \
         |                            ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_bInterfaceNumber'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:185:9: note: in expansion of macro 'DEF_FIELD'
     185 |         DEF_FIELD(symval, usb_device_id, bInterfaceNumber);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:21:44: error: stray '#' in program
      21 | #define OFF_usb_device_id_bInterfaceNumber #16 /* offsetof(struct usb_device_id, bInterfaceNumber) */
         |                                            ^
   scripts/mod/modpost.h:66:59: note: in expansion of macro 'bswap'
      66 |         (target_is_big_endian == host_is_big_endian ? x : bswap(x))
         |                                                           ^~~~~
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_bInterfaceNumber'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:185:9: note: in expansion of macro 'DEF_FIELD'
     185 |         DEF_FIELD(symval, usb_device_id, bInterfaceNumber);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:21:44: error: stray '#' in program
      21 | #define OFF_usb_device_id_bInterfaceNumber #16 /* offsetof(struct usb_device_id, bInterfaceNumber) */
         |                                            ^
   scripts/mod/modpost.h:62:21: note: in definition of macro 'bswap'
      62 |                     x); \
         |                     ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_bInterfaceNumber'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:185:9: note: in expansion of macro 'DEF_FIELD'
     185 |         DEF_FIELD(symval, usb_device_id, bInterfaceNumber);
         |         ^~~~~~~~~
   scripts/mod/file2alias.c: In function 'do_usb_entry_multi':
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:66:55: note: in definition of macro 'TO_NATIVE'
      66 |         (target_is_big_endian == host_is_big_endian ? x : bswap(x))
         |                                                       ^
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:282:9: note: in expansion of macro 'DEF_FIELD'
     282 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:57:31: note: in definition of macro 'bswap'
      57 |         _Static_assert(sizeof(x) == 1 || sizeof(x) == 2 || \
         |                               ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:282:9: note: in expansion of macro 'DEF_FIELD'
     282 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:57:49: note: in definition of macro 'bswap'
      57 |         _Static_assert(sizeof(x) == 1 || sizeof(x) == 2 || \
         |                                                 ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:282:9: note: in expansion of macro 'DEF_FIELD'
     282 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:58:31: note: in definition of macro 'bswap'
      58 |                        sizeof(x) == 4 || sizeof(x) == 8, "bug"); \
         |                               ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:282:9: note: in expansion of macro 'DEF_FIELD'
     282 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:58:49: note: in definition of macro 'bswap'
      58 |                        sizeof(x) == 4 || sizeof(x) == 8, "bug"); \
         |                                                 ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:282:9: note: in expansion of macro 'DEF_FIELD'
     282 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:59:17: note: in definition of macro 'bswap'
      59 |         (typeof(x))(sizeof(x) == 2 ? bswap_16(x) : \
         |                 ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:282:9: note: in expansion of macro 'DEF_FIELD'
     282 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
>> ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:59:28: note: in definition of macro 'bswap'
      59 |         (typeof(x))(sizeof(x) == 2 ? bswap_16(x) : \
         |                            ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:282:9: note: in expansion of macro 'DEF_FIELD'
     282 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:66:59: note: in expansion of macro 'bswap'
      66 |         (target_is_big_endian == host_is_big_endian ? x : bswap(x))
         |                                                           ^~~~~
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:282:9: note: in expansion of macro 'DEF_FIELD'
     282 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:60:28: note: in definition of macro 'bswap'
      60 |                     sizeof(x) == 4 ? bswap_32(x) : \
         |                            ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:282:9: note: in expansion of macro 'DEF_FIELD'
     282 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:66:59: note: in expansion of macro 'bswap'
      66 |         (target_is_big_endian == host_is_big_endian ? x : bswap(x))
         |                                                           ^~~~~
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:282:9: note: in expansion of macro 'DEF_FIELD'
     282 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:61:28: note: in definition of macro 'bswap'
      61 |                     sizeof(x) == 8 ? bswap_64(x) : \
         |                            ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:282:9: note: in expansion of macro 'DEF_FIELD'
     282 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:66:59: note: in expansion of macro 'bswap'
      66 |         (target_is_big_endian == host_is_big_endian ? x : bswap(x))
         |                                                           ^~~~~
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                                                           ^~~~
   scripts/mod/file2alias.c:282:9: note: in expansion of macro 'DEF_FIELD'
     282 |         DEF_FIELD(symval, usb_device_id, match_flags);
         |         ^~~~~~~~~
   ./scripts/mod/devicetable-offsets.h:10:39: error: stray '#' in program
      10 | #define OFF_usb_device_id_match_flags #0 /* offsetof(struct usb_device_id, match_flags) */
         |                                       ^
   scripts/mod/modpost.h:62:21: note: in definition of macro 'bswap'
      62 |                     x); \
         |                     ^
   scripts/mod/file2alias.c:73:44: note: in expansion of macro 'TO_NATIVE'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
         |                                            ^~~~~~~~~
   scripts/mod/file2alias.c:73:75: note: in expansion of macro 'OFF_usb_device_id_match_flags'
      73 |         typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f))
kernel test robot Aug. 29, 2024, 3:50 p.m. UTC | #3
Hi Vegard,

kernel test robot noticed the following build errors:

[auto build test ERROR on masahiroy-kbuild/for-next]
[also build test ERROR on masahiroy-kbuild/fixes soc/for-next kvmarm/next kvm/queue uml/next krzk-mem-ctrl/for-next bpf-next/master bpf/master linus/master v6.11-rc5 next-20240829]
[cannot apply to tmlind-omap/for-next kvm/linux-next uml/fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Vegard-Nossum/kbuild-use-objcopy-to-generate-asm-offsets/20240828-163854
base:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
patch link:    https://lore.kernel.org/r/20240828083605.3093701-1-vegard.nossum%40oracle.com
patch subject: [PATCH] kbuild: use objcopy to generate asm-offsets
config: arc-allnoconfig (https://download.01.org/0day-ci/archive/20240829/202408292301.KMuvybe3-lkp@intel.com/config)
compiler: arc-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240829/202408292301.KMuvybe3-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408292301.KMuvybe3-lkp@intel.com/

All errors (new ones prefixed by >>):

   {standard input}: Assembler messages:
>> {standard input}: Error: .size expression for main does not evaluate to a constant
   make[3]: *** [scripts/Makefile.build:244: scripts/mod/devicetable-offsets.o] Error 1
   make[3]: Target 'scripts/mod/' not remade because of errors.
   make[2]: *** [Makefile:1192: prepare0] Error 2
   make[2]: Target 'prepare' not remade because of errors.
   make[1]: *** [Makefile:224: __sub-make] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [Makefile:224: __sub-make] Error 2
   make: Target 'prepare' not remade because of errors.
kernel test robot Aug. 29, 2024, 8:37 p.m. UTC | #4
Hi Vegard,

kernel test robot noticed the following build warnings:

[auto build test WARNING on masahiroy-kbuild/for-next]
[also build test WARNING on masahiroy-kbuild/fixes soc/for-next kvmarm/next kvm/queue uml/next krzk-mem-ctrl/for-next bpf-next/master bpf/master linus/master v6.11-rc5 next-20240829]
[cannot apply to tmlind-omap/for-next kvm/linux-next uml/fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Vegard-Nossum/kbuild-use-objcopy-to-generate-asm-offsets/20240828-163854
base:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
patch link:    https://lore.kernel.org/r/20240828083605.3093701-1-vegard.nossum%40oracle.com
patch subject: [PATCH] kbuild: use objcopy to generate asm-offsets
config: mips-loongson3_defconfig (https://download.01.org/0day-ci/archive/20240830/202408300438.xObK98m5-lkp@intel.com/config)
compiler: mips64el-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240830/202408300438.xObK98m5-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408300438.xObK98m5-lkp@intel.com/

All warnings (new ones prefixed by >>):

   mips64el-linux-objcopy: /dev/stdout[.data.kbuild]: Illegal seek
   In file included from include/linux/mm_types.h:18,
                    from include/linux/uio.h:10,
                    from include/linux/socket.h:8,
                    from include/linux/compat.h:15,
                    from arch/mips/kernel/asm-offsets.c:12:
   include/linux/page-flags-layout.h:15:5: warning: "MAX_NR_ZONES" is not defined, evaluates to 0 [-Wundef]
      15 | #if MAX_NR_ZONES < 2
         |     ^~~~~~~~~~~~
   include/linux/page-flags-layout.h:58:19: warning: "LRU_GEN_WIDTH" is not defined, evaluates to 0 [-Wundef]
      58 | #if ZONES_WIDTH + LRU_GEN_WIDTH + SECTIONS_WIDTH + NODES_SHIFT \
         |                   ^~~~~~~~~~~~~
   include/linux/page-flags-layout.h:59:28: warning: "NR_PAGEFLAGS" is not defined, evaluates to 0 [-Wundef]
      59 |         <= BITS_PER_LONG - NR_PAGEFLAGS
         |                            ^~~~~~~~~~~~
   include/linux/page-flags-layout.h:93:19: warning: "LRU_GEN_WIDTH" is not defined, evaluates to 0 [-Wundef]
      93 | #if ZONES_WIDTH + LRU_GEN_WIDTH + SECTIONS_WIDTH + NODES_WIDTH + \
         |                   ^~~~~~~~~~~~~
   include/linux/page-flags-layout.h:94:64: warning: "NR_PAGEFLAGS" is not defined, evaluates to 0 [-Wundef]
      94 |         KASAN_TAG_WIDTH + LAST_CPUPID_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS
         |                                                                ^~~~~~~~~~~~
   include/linux/page-flags-layout.h:104:19: warning: "LRU_GEN_WIDTH" is not defined, evaluates to 0 [-Wundef]
     104 | #if ZONES_WIDTH + LRU_GEN_WIDTH + SECTIONS_WIDTH + NODES_WIDTH + \
         |                   ^~~~~~~~~~~~~
   include/linux/page-flags-layout.h:105:63: warning: "NR_PAGEFLAGS" is not defined, evaluates to 0 [-Wundef]
     105 |         KASAN_TAG_WIDTH + LAST_CPUPID_WIDTH > BITS_PER_LONG - NR_PAGEFLAGS
         |                                                               ^~~~~~~~~~~~
   In file included from include/linux/mm_types.h:5:
   include/linux/mm_types_task.h:22:34: warning: "SPINLOCK_SIZE" is not defined, evaluates to 0 [-Wundef]
      22 | #define ALLOC_SPLIT_PTLOCKS     (SPINLOCK_SIZE > BITS_PER_LONG/8)
         |                                  ^~~~~~~~~~~~~
   include/linux/mm_types.h:478:5: note: in expansion of macro 'ALLOC_SPLIT_PTLOCKS'
     478 | #if ALLOC_SPLIT_PTLOCKS
         |     ^~~~~~~~~~~~~~~~~~~
   In file included from include/linux/dcache.h:14,
                    from include/linux/fs.h:8,
                    from include/linux/compat.h:17:
>> include/linux/lockref.h:23:36: warning: "SPINLOCK_SIZE" is not defined, evaluates to 0 [-Wundef]
      23 |          IS_ENABLED(CONFIG_SMP) && SPINLOCK_SIZE <= 4)
         |                                    ^~~~~~~~~~~~~
   include/linux/lockref.h:27:5: note: in expansion of macro 'USE_CMPXCHG_LOCKREF'
      27 | #if USE_CMPXCHG_LOCKREF
         |     ^~~~~~~~~~~~~~~~~~~
   In file included from include/linux/gfp.h:7,
                    from include/linux/xarray.h:16,
                    from include/linux/list_lru.h:14,
                    from include/linux/fs.h:13:
   include/linux/mmzone.h:842:29: error: 'MAX_NR_ZONES' undeclared here (not in a function); did you mean 'MAX_NR_GENS'?
     842 |         long lowmem_reserve[MAX_NR_ZONES];
         |                             ^~~~~~~~~~~~
         |                             MAX_NR_GENS
   include/linux/mm_types_task.h:22:34: warning: "SPINLOCK_SIZE" is not defined, evaluates to 0 [-Wundef]
      22 | #define ALLOC_SPLIT_PTLOCKS     (SPINLOCK_SIZE > BITS_PER_LONG/8)
         |                                  ^~~~~~~~~~~~~
   include/linux/mm.h:2889:5: note: in expansion of macro 'ALLOC_SPLIT_PTLOCKS'
    2889 | #if ALLOC_SPLIT_PTLOCKS
         |     ^~~~~~~~~~~~~~~~~~~
   In file included from include/linux/swap.h:9,
                    from include/linux/suspend.h:5,
                    from arch/mips/kernel/asm-offsets.c:17:
   include/linux/memcontrol.h: In function 'mem_cgroup_get_zone_lru_size':
>> include/linux/memcontrol.h:914:31: warning: parameter 'lru' set but not used [-Wunused-but-set-parameter]
     914 |                 enum lru_list lru, int zone_idx)
         |                 ~~~~~~~~~~~~~~^~~
>> include/linux/memcontrol.h:914:40: warning: parameter 'zone_idx' set but not used [-Wunused-but-set-parameter]
     914 |                 enum lru_list lru, int zone_idx)
         |                                    ~~~~^~~~~~~~
   make[3]: *** [scripts/Makefile.build:244: arch/mips/kernel/asm-offsets.o] Error 1
   make[3]: Target 'missing-syscalls' not remade because of errors.
   make[2]: *** [arch/mips/Makefile:432: archprepare] Error 2
   make[2]: Target 'prepare' not remade because of errors.
   make[1]: *** [Makefile:224: __sub-make] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [Makefile:224: __sub-make] Error 2
   make: Target 'prepare' not remade because of errors.


vim +/SPINLOCK_SIZE +23 include/linux/lockref.h

57f4257eae33e0 Peter Zijlstra     2013-11-14  20  
57f4257eae33e0 Peter Zijlstra     2013-11-14  21  #define USE_CMPXCHG_LOCKREF \
57f4257eae33e0 Peter Zijlstra     2013-11-14  22  	(IS_ENABLED(CONFIG_ARCH_USE_CMPXCHG_LOCKREF) && \
597d795a2a786d Kirill A. Shutemov 2013-12-20 @23  	 IS_ENABLED(CONFIG_SMP) && SPINLOCK_SIZE <= 4)
0f8f2aaaab0b0f Waiman Long        2013-08-28  24
Michael Ellerman Sept. 2, 2024, 11:45 p.m. UTC | #5
Vegard Nossum <vegard.nossum@oracle.com> writes:
> In order to give assembly code access to C structs without having to
> hardcore member offsets, the kernel compiles a C source file listing all
> the structs and offsets that are needed in assembly code. Using some
> C preprocessor trickery and a sed script, the compiled assembly code is
> turned back into C preprocessor code that in turn can be used by the
> asssembly code.
>
> This sed script is very hard to read and understand.
>
> Remove the sed script and compile the C source listing structs and
> offsets to an object file (instead of assembly code) that embeds C source
> directly. Then extract the C source using objcopy.
>

I threw some builders at this and hit a few errors:

parisc:
  # make -s -j 160 ARCH=parisc64 O=/kisskb/build/mpe_generic-64bit_defconfig_parisc64-gcc13 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-13.1.0-nolibc/hppa-linux/bin/hppa64-linux-  
  {standard input}: Assembler messages:
  {standard input}: Error: .size expression for main does not evaluate to a constant
  make[3]: *** [/kisskb/src/scripts/Makefile.build:244: scripts/mod/devicetable-offsets.o] Error 1

s390:
  # make -s -j 32 ARCH=s390 O=/kisskb/build/mpe_defconfig_s390x-gcc13 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-13.1.0-nolibc/s390-linux/bin/s390-linux-  
  In file included from /kisskb/src/arch/s390/include/asm/ptrace.h:11,
                   from /kisskb/src/arch/s390/kernel/vdso64/vdso_user_wrapper.S:7:
  /kisskb/src/arch/s390/include/uapi/asm/ptrace.h:167: warning: "STACK_FRAME_OVERHEAD" redefined
    167 | #define STACK_FRAME_OVERHEAD    160      /* size of minimum stack frame */
        | 
  In file included from /kisskb/src/include/asm-generic/asm-offsets.h:1,
                   from ./arch/s390/include/generated/asm/asm-offsets.h:1,
                   from /kisskb/src/arch/s390/kernel/vdso64/vdso_user_wrapper.S:5:
  ./include/generated/asm-offsets.h:51: note: this is the location of the previous definition
     51 | #define STACK_FRAME_OVERHEAD -96 /* sizeof(struct stack_frame) */

mips:
  # make -s -j 32 ARCH=mips O=/kisskb/build/mpe_defconfig_mips-gcc13 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-13.1.0-nolibc/mips-linux/bin/mips-linux-  
  {standard input}: Assembler messages:
  {standard input}:27: Error: junk at end of line, first unrecognized character is `M'
  {standard input}:212: Error: junk at end of line, first unrecognized character is `M'
  {standard input}:265: Error: junk at end of line, first unrecognized character is `M'
  {standard input}:338: Error: junk at end of line, first unrecognized character is `M'
  {standard input}:596: Error: junk at end of line, first unrecognized character is `S'
  {standard input}:608: Error: junk at end of line, first unrecognized character is `L'
  {standard input}:721: Error: junk at end of line, first unrecognized character is `L'
  {standard input}:806: Error: junk at end of line, first unrecognized character is `L'
  {standard input}:963: Error: junk at end of line, first unrecognized character is `P'
  {standard input}:996: Error: junk at end of line, first unrecognized character is `K'
  {standard input}:1161: Error: junk at end of line, first unrecognized character is `M'
  make[3]: *** [/kisskb/src/scripts/Makefile.build:244: arch/mips/kernel/asm-offsets.o] Error 1

riscv:
  # make -s -j 160 ARCH=riscv O=/kisskb/build/mpe_defconfig_riscv-gcc13 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-13.1.0-nolibc/riscv64-linux/bin/riscv64-linux-  
  In file included from /kisskb/src/arch/riscv/kernel/asm-offsets.c:9:
  /kisskb/src/arch/riscv/kernel/asm-offsets.c: In function 'asm_offsets':
  /kisskb/src/include/linux/kbuild.h:6:9: error: invalid 'asm': invalid use of '%c'
      6 |         asm volatile( \
        |         ^~~
  /kisskb/src/include/linux/kbuild.h:12:9: note: in expansion of macro '_LINE'
     12 |         _LINE("#define " #sym " %c0 /* " #val " */", "i" (val))
        |         ^~~~~
  /kisskb/src/include/linux/kbuild.h:15:9: note: in expansion of macro 'DEFINE'
     15 |         DEFINE(sym, offsetof(struct str, mem))
        |         ^~~~~~
  /kisskb/src/arch/riscv/kernel/asm-offsets.c:25:9: note: in expansion of macro 'OFFSET'
     25 |         OFFSET(TASK_THREAD_RA, task_struct, thread.ra);
        |         ^~~~~~
  /kisskb/src/include/linux/kbuild.h:6:9: error: invalid 'asm': invalid use of '%c'
      6 |         asm volatile( \
        |         ^~~


Full list here, but note there are some unrelated pre-existing failures:
  http://kisskb.ellerman.id.au/kisskb/head/259bba3447faaf5e5b12ae41a26a62978d4c1965/


cheers
Vegard Nossum Sept. 3, 2024, 7:20 a.m. UTC | #6
On 03/09/2024 01:45, Michael Ellerman wrote:
> Vegard Nossum <vegard.nossum@oracle.com> writes:
>> Remove the sed script and compile the C source listing structs and
>> offsets to an object file (instead of assembly code) that embeds C source
>> directly. Then extract the C source using objcopy.
>>
> 
> I threw some builders at this and hit a few errors:

Thanks, I also got the ones from kernel test robot and figured something
was going a bit wrong.

There are several issues: clang wants - instead of /dev/stdout as an
argument to objcopy, and then gcc has some bugs that prevent the numbers
from appearing correctly on some architectures, also I had an extra # in
the COMMENT() macro which only resulted in an error on some
architectures. I've attached a tentative v2 that fixes these issues, but
I'm still trying to figure out why m68k is giving me slightly different
output for include/generated/asm-offsets.h and why the arc assembler
fails.

In the end I'm wondering if this patch is really worth it, given all the
failures and little workarounds :-| If I can sort out the last few
failures I'll submit it as an RFC.

> Full list here, but note there are some unrelated pre-existing failures:
>    http://kisskb.ellerman.id.au/kisskb/head/259bba3447faaf5e5b12ae41a26a62978d4c1965/

Thanks again,


Vegard
Masahiro Yamada Sept. 3, 2024, 9:28 a.m. UTC | #7
On Tue, Sep 3, 2024 at 4:21 PM Vegard Nossum <vegard.nossum@oracle.com> wrote:
>
>
> On 03/09/2024 01:45, Michael Ellerman wrote:
> > Vegard Nossum <vegard.nossum@oracle.com> writes:
> >> Remove the sed script and compile the C source listing structs and
> >> offsets to an object file (instead of assembly code) that embeds C source
> >> directly. Then extract the C source using objcopy.
> >>
> >
> > I threw some builders at this and hit a few errors:
>
> Thanks, I also got the ones from kernel test robot and figured something
> was going a bit wrong.
>
> There are several issues: clang wants - instead of /dev/stdout as an
> argument to objcopy, and then gcc has some bugs that prevent the numbers
> from appearing correctly on some architectures, also I had an extra # in
> the COMMENT() macro which only resulted in an error on some
> architectures. I've attached a tentative v2 that fixes these issues, but
> I'm still trying to figure out why m68k is giving me slightly different
> output for include/generated/asm-offsets.h and why the arc assembler
> fails.
>
> In the end I'm wondering if this patch is really worth it, given all the
> failures and little workarounds :-| If I can sort out the last few
> failures I'll submit it as an RFC.

This patch has zero benefit.

The current way (preprocess + sed) is faster than
your way (preprocess + compile + objcopy) and works
independently of tool quirks.








--
Best Regards
Masahiro Yamada
diff mbox series

Patch

diff --git a/Kbuild b/Kbuild
index 464b34a08f51e..412b77007deb1 100644
--- a/Kbuild
+++ b/Kbuild
@@ -9,9 +9,9 @@ 
 
 bounds-file := include/generated/bounds.h
 
-targets := kernel/bounds.s
+targets := kernel/bounds.o
 
-$(bounds-file): kernel/bounds.s FORCE
+$(bounds-file): kernel/bounds.o FORCE
 	$(call filechk,offsets,__LINUX_BOUNDS_H__)
 
 # Generate timeconst.h
@@ -27,11 +27,11 @@  $(timeconst-file): kernel/time/timeconst.bc FORCE
 
 offsets-file := include/generated/asm-offsets.h
 
-targets += arch/$(SRCARCH)/kernel/asm-offsets.s
+targets += arch/$(SRCARCH)/kernel/asm-offsets.o
 
-arch/$(SRCARCH)/kernel/asm-offsets.s: $(timeconst-file) $(bounds-file)
+arch/$(SRCARCH)/kernel/asm-offsets.o: $(timeconst-file) $(bounds-file)
 
-$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
+$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.o FORCE
 	$(call filechk,offsets,__ASM_OFFSETS_H__)
 
 # Check for missing system calls
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 794bd12ab0a8e..4d4be0000fd98 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -18,10 +18,10 @@  ifeq ($(CONFIG_PM_DEBUG),y)
 CFLAGS_pm.o += -DDEBUG
 endif
 
-$(obj)/pm_data-offsets.h: $(obj)/pm_data-offsets.s FORCE
+$(obj)/pm_data-offsets.h: $(obj)/pm_data-offsets.o FORCE
 	$(call filechk,offsets,__PM_DATA_OFFSETS_H__)
 
 $(obj)/pm_suspend.o: $(obj)/pm_data-offsets.h
 
-targets += pm_data-offsets.s
+targets += pm_data-offsets.o
 clean-files += pm_data-offsets.h
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index daf21127c82f1..991ffe6871d1d 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -217,12 +217,12 @@  obj-y					+= omap_phy_internal.o
 
 obj-$(CONFIG_MACH_OMAP2_TUSB6010)	+= usb-tusb6010.o
 
-$(obj)/pm-asm-offsets.h: $(obj)/pm-asm-offsets.s FORCE
+$(obj)/pm-asm-offsets.h: $(obj)/pm-asm-offsets.o FORCE
 	$(call filechk,offsets,__TI_PM_ASM_OFFSETS_H__)
 
 $(obj)/sleep33xx.o $(obj)/sleep43xx.o: $(obj)/pm-asm-offsets.h
 
-targets += pm-asm-offsets.s
+targets += pm-asm-offsets.o
 clean-files += pm-asm-offsets.h
 
 obj-$(CONFIG_OMAP_IOMMU)		+= omap-iommu.o
diff --git a/arch/arm64/kvm/Makefile b/arch/arm64/kvm/Makefile
index 86a629aaf0a13..ee699a683d82c 100644
--- a/arch/arm64/kvm/Makefile
+++ b/arch/arm64/kvm/Makefile
@@ -28,17 +28,18 @@  kvm-y += arm.o mmu.o mmio.o psci.o hypercalls.o pvtime.o \
 kvm-$(CONFIG_HW_PERF_EVENTS)  += pmu-emul.o pmu.o
 kvm-$(CONFIG_ARM64_PTR_AUTH)  += pauth.o
 
-always-y := hyp_constants.h hyp-constants.s
+always-y := hyp_constants.h hyp-constants.o
 
 define rule_gen_hyp_constants
 	$(call filechk,offsets,__HYP_CONSTANTS_H__)
 endef
 
 CFLAGS_hyp-constants.o = -I $(src)/hyp/include
-$(obj)/hyp-constants.s: $(src)/hyp/hyp-constants.c FORCE
-	$(call if_changed_dep,cc_s_c)
 
-$(obj)/hyp_constants.h: $(obj)/hyp-constants.s FORCE
+$(obj)/hyp-constants.o: $(src)/hyp/hyp-constants.c FORCE
+	$(call if_changed_dep,cc_o_c)
+
+$(obj)/hyp_constants.h: $(obj)/hyp-constants.o FORCE
 	$(call if_changed_rule,gen_hyp_constants)
 
 obj-kvm := $(addprefix $(obj)/, $(kvm-y))
diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile
index 5494669a055a6..3b561c7e7c4f9 100644
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -42,8 +42,8 @@  $(obj)/svm/vmenter.o: $(obj)/kvm-asm-offsets.h
 AFLAGS_vmx/vmenter.o    := -iquote $(obj)
 $(obj)/vmx/vmenter.o: $(obj)/kvm-asm-offsets.h
 
-$(obj)/kvm-asm-offsets.h: $(obj)/kvm-asm-offsets.s FORCE
+$(obj)/kvm-asm-offsets.h: $(obj)/kvm-asm-offsets.o FORCE
 	$(call filechk,offsets,__KVM_ASM_OFFSETS_H__)
 
-targets += kvm-asm-offsets.s
+targets += kvm-asm-offsets.o
 clean-files += kvm-asm-offsets.h
diff --git a/arch/x86/um/Makefile b/arch/x86/um/Makefile
index 36e67fc97c22f..6563503d4b25d 100644
--- a/arch/x86/um/Makefile
+++ b/arch/x86/um/Makefile
@@ -38,11 +38,11 @@  subarch-$(CONFIG_MODULES) += ../kernel/module.o
 
 USER_OBJS := bugs_$(BITS).o ptrace_user.o fault.o
 
-$(obj)/user-offsets.s: c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \
+$(obj)/user-offsets.o: c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \
 	-Iarch/x86/include/generated
-targets += user-offsets.s
+targets += user-offsets.o
 
-include/generated/user_constants.h: $(obj)/user-offsets.s FORCE
+include/generated/user_constants.h: $(obj)/user-offsets.o FORCE
 	$(call filechk,offsets,__USER_CONSTANT_H__)
 
 UNPROFILE_OBJS := stub_segv.o
diff --git a/drivers/memory/Makefile b/drivers/memory/Makefile
index d2e6ca9abbe02..efae95f315a12 100644
--- a/drivers/memory/Makefile
+++ b/drivers/memory/Makefile
@@ -34,8 +34,8 @@  ti-emif-sram-objs		:= ti-emif-pm.o ti-emif-sram-pm.o
 
 $(obj)/ti-emif-sram-pm.o: $(obj)/ti-emif-asm-offsets.h
 
-$(obj)/ti-emif-asm-offsets.h: $(obj)/emif-asm-offsets.s FORCE
+$(obj)/ti-emif-asm-offsets.h: $(obj)/emif-asm-offsets.o FORCE
 	$(call filechk,offsets,__TI_EMIF_ASM_OFFSETS_H__)
 
-targets += emif-asm-offsets.s
+targets += emif-asm-offsets.o
 clean-files += ti-emif-asm-offsets.h
diff --git a/include/linux/kbuild.h b/include/linux/kbuild.h
index e7be517aaaf68..d253ae4dfd1c1 100644
--- a/include/linux/kbuild.h
+++ b/include/linux/kbuild.h
@@ -2,15 +2,22 @@ 
 #ifndef __LINUX_KBUILD_H
 #define __LINUX_KBUILD_H
 
-#define DEFINE(sym, val) \
-	asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
+#define _LINE(x, ...) \
+	asm volatile( \
+		".pushsection \".data.kbuild\"; "\
+		".ascii \"" x "\\n\"; "\
+		".popsection" : : __VA_ARGS__)
 
-#define BLANK() asm volatile("\n.ascii \"->\"" : : )
+#define DEFINE(sym, val) \
+	_LINE("#define " #sym " %c0 /* " #val " */", "i" (val))
 
 #define OFFSET(sym, str, mem) \
 	DEFINE(sym, offsetof(struct str, mem))
 
+#define BLANK() \
+	_LINE("")
+
 #define COMMENT(x) \
-	asm volatile("\n.ascii \"->#" x "\"")
+	_LINE("/* " #x " */")
 
 #endif
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 3e003dd6bea09..a5d86ac8f5f57 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -270,10 +270,10 @@  $(LIBBPF_OUTPUT) $(BPFTOOL_OUTPUT):
 	$(call msg,MKDIR,$@)
 	$(Q)mkdir -p $@
 
-$(obj)/syscall_nrs.h:	$(obj)/syscall_nrs.s FORCE
+$(obj)/syscall_nrs.h:	$(obj)/syscall_nrs.o FORCE
 	$(call filechk,offsets,__SYSCALL_NRS_H__)
 
-targets += syscall_nrs.s
+targets += syscall_nrs.o
 clean-files += syscall_nrs.h
 
 FORCE:
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 207325eaf1d1c..f78b0b12ace26 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -583,17 +583,6 @@  quiet_cmd_zstd22_with_size = ZSTD22  $@
 # ASM offsets
 # ---------------------------------------------------------------------------
 
-# Default sed regexp - multiline due to syntax constraints
-#
-# Use [:space:] because LLVM's integrated assembler inserts <tab> around
-# the .ascii directive whereas GCC keeps the <space> as-is.
-define sed-offsets
-	's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
-	/^->/{s:->#\(.*\):/* \1 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
-	s:->::; p;}'
-endef
-
 # Use filechk to avoid rebuilds when a header changes, but the resulting file
 # does not
 define filechk_offsets
@@ -605,7 +594,7 @@  define filechk_offsets
 	 echo " * This file was generated by Kbuild"; \
 	 echo " */"; \
 	 echo ""; \
-	 sed -ne $(sed-offsets) < $<; \
+	 $(OBJCOPY) -j .data.kbuild -O binary $< /dev/stdout | cat; \
 	 echo ""; \
 	 echo "#endif"
 endef
diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile
index c729bc936bae1..3c3f5e16a30a2 100644
--- a/scripts/mod/Makefile
+++ b/scripts/mod/Makefile
@@ -8,10 +8,10 @@  modpost-objs	:= modpost.o file2alias.o sumversion.o symsearch.o
 
 devicetable-offsets-file := devicetable-offsets.h
 
-$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s FORCE
+$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.o FORCE
 	$(call filechk,offsets,__DEVICETABLE_OFFSETS_H__)
 
-targets += $(devicetable-offsets-file) devicetable-offsets.s
+targets += $(devicetable-offsets-file) devicetable-offsets.o
 
 # dependencies on generated files need to be listed explicitly