llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

error: invalid instruction mnemonic 'hvc'

Open zhangxin6483 opened this issue 2 years ago • 3 comments

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.

zhangxin6483 avatar Apr 11 '24 02:04 zhangxin6483

@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.

llvmbot avatar Apr 11 '24 05:04 llvmbot

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?

davemgreen avatar Apr 12 '24 06:04 davemgreen

not much we can do about this one without a reproducer, please reopen if you have one.

c-rhodes avatar Jul 24 '25 09:07 c-rhodes