llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.78k stars 10.97k forks source link

error: invalid instruction mnemonic 'hvc' #88342

Open zhangxin6483 opened 2 months ago

zhangxin6483 commented 2 months ago

while compile Jailhouse by clang(Compilers ported from gcc to clang), have point target -march parameter Prompt for this error,

======--target=aarch64-linux-gnu --target=arm64 --prefix=aarch64-linux-gnu- -march=armv8-a ==== aarch64-linux-gnu- ===

  CC      /home/src/jailhouse/inmates/lib/arm64/../arm-common/../printk.o
In file included from /home/src/jailhouse/inmates/lib/arm64/../arm-common/../printk.c:44:
In file included from /home/src/jailhouse/inmates/lib/arm64/../arm-common/include/inmate.h:108:
In file included from /home/src/jailhouse/inmates/lib/include/inmate_common.h:89:
In file included from /home/src/jailhouse/inmates/../include/jailhouse/hypercall.h:126:
In file included from /homesrc/jailhouse/inmates/../include/arch/arm64/asm/jailhouse_hypercall.h:52:
/home/zhangshizong/kylin_jailhouse/src/jailhouse/inmates/../include/arch/arm64/../arm-common/asm/jailhouse_hypercall.h:89:25: error: invalid instruction mnemonic 'hvc'
                        JAILHOUSE_CALL_INS
                        ^
/home/src/jailhouse/inmates/../include/arch/arm64/asm/jailhouse_hypercall.h:39:29: note: expanded from macro 'JAILHOUSE_CALL_INS'
#define JAILHOUSE_CALL_INS              "hvc #0x4a48"
                                        ^
<inline asm>:1:2: note: instantiated into assembly here
        hvc #0x4a48
        ^~~
1 error generated.

below is my configuration,

ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
 ifneq ($(CROSS_COMPILE),)
 CLANG_FLAGS     += --target=$(notdir $(CROSS_COMPILE:%-=%))
 CLANG_FLAGS    += --target=arm64
 GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
CLANG_FLAGS     += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
 CLANG_FLAGS     += -march=armv8-a
 GCC_TOOLCHAIN   := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
$(info ====== $(CLANG_FLAGS) ==== $(CROSS_COMPILE) ===$(GCC_TOOLCHAIN_DIR) )
 endif
 ifneq ($(GCC_TOOLCHAIN),)
 CLANG_FLAGS     += --gcc-toolchain=$(GCC_TOOLCHAIN)
 $(info ====== $(CLANG_FLAGS) == $(GCC_TOOLCHAIN) =====)
 endif
  ifneq ($(LLVM_IAS),1)
  CLANG_FLAGS     += -no-integrated-as
 endif
 CLANG_FLAGS     += -Werror=unknown-warning-option \
         -std=gnu99
 KBUILD_CFLAGS   += $(CLANG_FLAGS)
 KBUILD_AFLAGS   += $(CLANG_FLAGS)
 export CLANG_FLAGS
 endif

what should I do next?

thanks.

llvmbot commented 2 months ago

@llvm/issue-subscribers-backend-aarch64

Author: None (zhangxin6483)

**while compile Jailhouse by clang(Compilers ported from gcc to clang), have point target -march parameter Prompt for this error,** ======--target=aarch64-linux-gnu --target=arm64 --prefix=aarch64-linux-gnu- -march=armv8-a ==== aarch64-linux-gnu- === CC /home/src/jailhouse/inmates/lib/arm64/../arm-common/../printk.o In file included from /home/src/jailhouse/inmates/lib/arm64/../arm-common/../printk.c:44: In file included from /home/src/jailhouse/inmates/lib/arm64/../arm-common/include/inmate.h:108: In file included from /home/src/jailhouse/inmates/lib/include/inmate_common.h:89: In file included from /home/src/jailhouse/inmates/../include/jailhouse/hypercall.h:126: In file included from /homesrc/jailhouse/inmates/../include/arch/arm64/asm/jailhouse_hypercall.h:52: /home/zhangshizong/kylin_jailhouse/src/jailhouse/inmates/../include/arch/arm64/../arm-common/asm/jailhouse_hypercall.h:89:25: error: invalid instruction mnemonic 'hvc' JAILHOUSE_CALL_INS ^ /home/src/jailhouse/inmates/../include/arch/arm64/asm/jailhouse_hypercall.h:39:29: note: expanded from macro 'JAILHOUSE_CALL_INS' #define JAILHOUSE_CALL_INS "hvc #0x4a48" ^ <inline asm>:1:2: note: instantiated into assembly here hvc #0x4a48 ^~~ 1 error generated. **below is my configuration,** ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) ifneq ($(CROSS_COMPILE),) CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) CLANG_FLAGS += --target=arm64 GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) CLANG_FLAGS += -march=armv8-a GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) $(info ====== $(CLANG_FLAGS) ==== $(CROSS_COMPILE) ===$(GCC_TOOLCHAIN_DIR) ) endif ifneq ($(GCC_TOOLCHAIN),) CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) $(info ====== $(CLANG_FLAGS) == $(GCC_TOOLCHAIN) =====) endif ifneq ($(LLVM_IAS),1) CLANG_FLAGS += -no-integrated-as endif CLANG_FLAGS += -Werror=unknown-warning-option \ -std=gnu99 KBUILD_CFLAGS += $(CLANG_FLAGS) KBUILD_AFLAGS += $(CLANG_FLAGS) export CLANG_FLAGS endif what should I do next? thanks.
davemgreen commented 2 months ago

Hi. It appears to be OK in https://godbolt.org/z/h7fq1G3x1.

It looks like the error message might imply that it is still not compiling for an aarch64 target correctly. Can you extract the full compile command that it is running and pre-processed (-E) sources?