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

build fails on relocate phase for xdna2 for Unknown AIE version in EFLAGS" #258

Open
lamikr opened this issue Jan 13, 2025 · 0 comments
Open

Comments

@lamikr
Copy link

lamikr commented Jan 13, 2025

I tested the new xdna2 integration that landed couple of days ago by updating the example application
that is on WIKI so that it is build and installed also for the XDNA2 by using the
triplet aie2p-none-unknown-elf and noticed that there is error on llvm's relocate function.

I however got error on relocate function in lld/ELF/Arch/AIE.cpp throwing error "Unknown AIE version in EFLAGS"
I checked that the Arch in EFLAGS for the produced binary I had was 2 for xdna1 target and 3 for xdna2 target.

Following patch seems to fix the problem and I was able to test the application.

diff --git a/lld/ELF/Arch/AIE.cpp b/lld/ELF/Arch/AIE.cpp
index 378be130ce56..4002d8877551 100644
--- a/lld/ELF/Arch/AIE.cpp
+++ b/lld/ELF/Arch/AIE.cpp
@@ -370,6 +370,7 @@ void AIE::relocate(uint8_t *Loc, const Relocation &rel, uint64_t Val) const {
     relocateAIE1(Loc, rel, Val);
     break;
   case 2:
+  case 3:
     relocateAIE2(Loc, rel, Val);
     break;
   default:

Below is the Makefile I used to build it and full example which includes also the linker-scripts, etc. can be found from
https://github.com/lamikr/rocm_sdk_builder/tree/master/docs/examples/aie/store_pii

PEANO_INSTALL_DIR=${ROCM_HOME}/apps/aie
CC = ${PEANO_INSTALL_DIR}/bin/clang
TARGET_TRIPLE_XDNA1=aie2-none-unknown-elf
TARGET_TRIPLE_XDNA2=aie2p-none-unknown-elf
APP_NAME_SUFFIX_XDNA1=xdna1
APP_NAME_SUFFIX_XDNA2=xdna2
APP_NAME_FULL_XDNA1=fivepi_${APP_NAME_SUFFIX_XDNA1}
APP_NAME_FULL_XDNA2=fivepi_${APP_NAME_SUFFIX_XDNA2}

generate_ll:
	${CC} -O2 --target=${TARGET_TRIPLE} -I${PEANO_INSTALL_DIR}/lib/clang/18/include -S main.cpp -emit-llvm -o main_${APP_NAME_SUFFIX}.ll
	
generate_elf:
	${CC} -O2 --target=${TARGET_TRIPLE} main_${APP_NAME_SUFFIX}.ll -ccc-install-dir ${PEANO_INSTALL_DIR}/bin -Wl,-T main.ld.script -o ${APP_NAME_FULL}.elf
	
main_${APP_NAME_SUFFIX_XDNA1}.ll:
	APP_NAME_SUFFIX=${APP_NAME_SUFFIX_XDNA1} TARGET_TRIPLE=${TARGET_TRIPLE_XDNA1} make generate_ll

main_${APP_NAME_SUFFIX_XDNA2}.ll:
	APP_NAME_SUFFIX=${APP_NAME_SUFFIX_XDNA2} TARGET_TRIPLE=${TARGET_TRIPLE_XDNA2} make generate_ll

${APP_NAME_FULL_XDNA1}.elf: main_${APP_NAME_SUFFIX_XDNA1}.ll
	APP_NAME_SUFFIX=${APP_NAME_SUFFIX_XDNA1} TARGET_TRIPLE=${TARGET_TRIPLE_XDNA1} APP_NAME_FULL=${APP_NAME_FULL_XDNA1} make generate_elf

${APP_NAME_FULL_XDNA2}.elf: main_${APP_NAME_SUFFIX_XDNA2}.ll
	APP_NAME_SUFFIX=${APP_NAME_SUFFIX_XDNA2} TARGET_TRIPLE=${TARGET_TRIPLE_XDNA2} APP_NAME_FULL=${APP_NAME_FULL_XDNA2} make generate_elf

clean:
	rm -f *.ll
	rm -f *.elf
	rm -f *.json
	rm -f *.bif
	rm -f *.xclbin
	rm -f *.pdi
	rm -f *.bin

all: clean ${APP_NAME_FULL_XDNA1}.elf ${APP_NAME_FULL_XDNA2}.elf

.DEFAULT_GOAL := all
lamikr added a commit to lamikr/llvm-aie that referenced this issue Jan 13, 2025
This solves "Unknown AIE version in EFLAGS"
error when test application is build for the
triplet aie2p-none-unknown-elf target.
For this target the EFLAGS is 3.

fixes: Xilinx#258

Signed-off-by: Mika Laitio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant