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

[M68k] error: unknown register name 'sp' in asm when trying to build Linux kernel #78620

Closed
glaubitz opened this issue Jan 18, 2024 · 1 comment · Fixed by #87095
Closed

[M68k] error: unknown register name 'sp' in asm when trying to build Linux kernel #78620

glaubitz opened this issue Jan 18, 2024 · 1 comment · Fixed by #87095

Comments

@glaubitz
Copy link
Contributor

Trying to build the Linux/m68k kernel with clang has improved quite a bit, but unfortunately still fails early:

glaubitz@node54:/data/home/glaubitz/linux> make CC=clang -j32
  SYNC    include/config/auto.conf.cmd
*
* Restart config...
*
*
* Memory initialization
*
Initialize kernel stack variables at function entry
> 1. no automatic stack variable initialization (weakest) (INIT_STACK_NONE)
  2. pattern-init everything (strongest) (INIT_STACK_ALL_PATTERN) (NEW)
  3. zero-init everything (strongest and safest) (INIT_STACK_ALL_ZERO) (NEW)
choice[1-3?]: 
Enable heap memory zeroing on allocation by default (INIT_ON_ALLOC_DEFAULT_ON) [N/y/?] n
Enable heap memory zeroing on free by default (INIT_ON_FREE_DEFAULT_ON) [N/y/?] n
*
* Kernel hardening options
*
Randomize layout of sensitive kernel structures
> 1. Disable structure layout randomization (RANDSTRUCT_NONE)
  2. Fully randomize structure layout (RANDSTRUCT_FULL) (NEW)
choice[1-2?]: 
  SYSHDR  arch/m68k/include/generated/uapi/asm/unistd_32.h
  SYSTBL  arch/m68k/include/generated/asm/syscall_table.h
  UPD     include/generated/compile.h
  HOSTCC  scripts/asn1_compiler
  HOSTCC  scripts/kallsyms
  UPD     include/config/kernel.release
  UPD     include/generated/utsrelease.h
  HOSTCC  scripts/mod/mk_elfconfig
  CC      scripts/mod/empty.o
  CC      scripts/mod/devicetable-offsets.s
  MKELF   scripts/mod/elfconfig.h
  HOSTCC  scripts/mod/modpost.o
  HOSTCC  scripts/mod/file2alias.o
  HOSTCC  scripts/mod/sumversion.o
  HOSTLD  scripts/mod/modpost
  CC      kernel/bounds.s
  CHKSHA1 include/linux/atomic/atomic-arch-fallback.h
  CHKSHA1 include/linux/atomic/atomic-long.h
  CHKSHA1 include/linux/atomic/atomic-instrumented.h
  CC      arch/m68k/kernel/asm-offsets.s
In file included from arch/m68k/kernel/asm-offsets.c:15:
In file included from ./include/linux/sched.h:12:
./arch/m68k/include/asm/current.h:29:54: error: unknown register name 'sp' in asm
   29 | register unsigned long current_stack_pointer __asm__("sp");
      |                                                      ^
1 error generated.
make[2]: *** [scripts/Makefile.build:116: arch/m68k/kernel/asm-offsets.s] Error 1
make[1]: *** [/data/home/glaubitz/linux/Makefile:1287: prepare0] Error 2
make: *** [Makefile:234: __sub-make] Error 2
glaubitz@node54:/data/home/glaubitz/linux>

It seems that that the m68k backend needs to learn about register names or at least the SP register.

CC @mshockwave @0x59616e

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 18, 2024

@llvm/issue-subscribers-backend-m68k

Author: John Paul Adrian Glaubitz (glaubitz)

Trying to build the Linux/m68k kernel with clang has improved quite a bit, but unfortunately still fails early:
glaubitz@<!-- -->node54:/data/home/glaubitz/linux&gt; make CC=clang -j32
  SYNC    include/config/auto.conf.cmd
*
* Restart config...
*
*
* Memory initialization
*
Initialize kernel stack variables at function entry
&gt; 1. no automatic stack variable initialization (weakest) (INIT_STACK_NONE)
  2. pattern-init everything (strongest) (INIT_STACK_ALL_PATTERN) (NEW)
  3. zero-init everything (strongest and safest) (INIT_STACK_ALL_ZERO) (NEW)
choice[1-3?]: 
Enable heap memory zeroing on allocation by default (INIT_ON_ALLOC_DEFAULT_ON) [N/y/?] n
Enable heap memory zeroing on free by default (INIT_ON_FREE_DEFAULT_ON) [N/y/?] n
*
* Kernel hardening options
*
Randomize layout of sensitive kernel structures
&gt; 1. Disable structure layout randomization (RANDSTRUCT_NONE)
  2. Fully randomize structure layout (RANDSTRUCT_FULL) (NEW)
choice[1-2?]: 
  SYSHDR  arch/m68k/include/generated/uapi/asm/unistd_32.h
  SYSTBL  arch/m68k/include/generated/asm/syscall_table.h
  UPD     include/generated/compile.h
  HOSTCC  scripts/asn1_compiler
  HOSTCC  scripts/kallsyms
  UPD     include/config/kernel.release
  UPD     include/generated/utsrelease.h
  HOSTCC  scripts/mod/mk_elfconfig
  CC      scripts/mod/empty.o
  CC      scripts/mod/devicetable-offsets.s
  MKELF   scripts/mod/elfconfig.h
  HOSTCC  scripts/mod/modpost.o
  HOSTCC  scripts/mod/file2alias.o
  HOSTCC  scripts/mod/sumversion.o
  HOSTLD  scripts/mod/modpost
  CC      kernel/bounds.s
  CHKSHA1 include/linux/atomic/atomic-arch-fallback.h
  CHKSHA1 include/linux/atomic/atomic-long.h
  CHKSHA1 include/linux/atomic/atomic-instrumented.h
  CC      arch/m68k/kernel/asm-offsets.s
In file included from arch/m68k/kernel/asm-offsets.c:15:
In file included from ./include/linux/sched.h:12:
./arch/m68k/include/asm/current.h:29:54: error: unknown register name 'sp' in asm
   29 | register unsigned long current_stack_pointer __asm__("sp");
      |                                                      ^
1 error generated.
make[2]: *** [scripts/Makefile.build:116: arch/m68k/kernel/asm-offsets.s] Error 1
make[1]: *** [/data/home/glaubitz/linux/Makefile:1287: prepare0] Error 2
make: *** [Makefile:234: __sub-make] Error 2
glaubitz@<!-- -->node54:/data/home/glaubitz/linux&gt;

It seems that that the m68k backend needs to learn about register names or at least the SP register.

CC @mshockwave @0x59616e

tclin914 added a commit that referenced this issue Apr 2, 2024
In M68kRegisterInfo.td, register SP is defined with name sp and
alternate name a7.

Fixes: #78620
qihangkong pushed a commit to rvgpu/llvm that referenced this issue Apr 18, 2024
In M68kRegisterInfo.td, register SP is defined with name x7 and alternate name a7.

Fixes: llvm/llvm-project#78620
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants