Skip to content

Conversation

@yuqisun
Copy link
Collaborator

@yuqisun yuqisun commented May 22, 2025

Test to print LLVM version of Github Actions.

@tancheng
Copy link
Contributor

Hi @yuqisun, so the apt-installed method works on your local machine/docker?

@yuqisun
Copy link
Collaborator Author

yuqisun commented May 23, 2025

Hi @yuqisun, so the apt-installed method works on your local machine/docker?

Nope :(, revert just now, looks MLIR is not included in apt-install. Have to build by source code.

@tancheng
Copy link
Contributor

tancheng commented May 23, 2025

Hi @yuqisun, so the apt-installed method works on your local machine/docker?

Nope :(, revert just now, looks MLIR is not included in apt-install. Have to build by source code.

What about sudo apt install llvm-14 clang-14 libclang-14-dev libmlir-14-dev mlir-14-tools? Can try on your local first? (we prefer llvm-19 though)

@yuqisun
Copy link
Collaborator Author

yuqisun commented May 23, 2025

Hi @yuqisun, so the apt-installed method works on your local machine/docker?

Nope :(, revert just now, looks MLIR is not included in apt-install. Have to build by source code.

What about sudo apt install llvm-14 clang-14 libclang-14-dev libmlir-14-dev mlir-14-tools? Can try on your local first? (we prefer llvm-19 though)

Still doesn't work. We are depending on MLIRArithDialect, MLIRFuncDialect target which are not installed by apt.
Your original manual step is also the recommendation of deepseek/copilot, compile and install from source code.

CMake Error at /usr/lib/llvm-14/lib/cmake/llvm/AddLLVM.cmake:518 (add_dependencies):
  The dependency target "MLIRArithDialect" of target "obj.NeuraArithToNeura"
  does not exist.
Call Stack (most recent call first):
  /usr/lib/llvm-14/lib/cmake/mlir/AddMLIR.cmake:148 (llvm_add_library)
  lib/Conversion/ArithToNeura/CMakeLists.txt:14 (add_mlir_library)


CMake Error at /usr/lib/llvm-14/lib/cmake/llvm/AddLLVM.cmake:518 (add_dependencies):
  The dependency target "MLIRFuncDialect" of target "obj.NeuraArithToNeura"
  does not exist.
Call Stack (most recent call first):
  /usr/lib/llvm-14/lib/cmake/mlir/AddMLIR.cmake:148 (llvm_add_library)
  lib/Conversion/ArithToNeura/CMakeLists.txt:14 (add_mlir_library)

image

@yuqisun
Copy link
Collaborator Author

yuqisun commented May 23, 2025

Hi @tancheng ,

  1. Looks MLIR has to be installed by source code
  2. Upgraded to build from LLVM-19 branch
  3. Added Dockerfile for container environment setup

Thanks,

-DLLVM_ENABLE_LLD=ON \
-DMLIR_INSTALL_AGGREGATE_OBJECTS=ON \
-DLLVM_ENABLE_RTTI=ON \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this because Ninja cannot auto fix RPATH:

CMake Error at cmake/modules/AddLLVM.cmake:1029 (add_executable):
The install of the llvm-tblgen target requires changing an RPATH from the
build tree, but this is not supported with the Ninja generator unless on an
ELF-based or XCOFF-based platform. The CMAKE_BUILD_WITH_INSTALL_RPATH
variable may be set to avoid this relinking step.
Call Stack (most recent call first):
cmake/modules/TableGen.cmake:181 (add_llvm_executable)
utils/TableGen/CMakeLists.txt:32 (add_tablegen)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also have DCMAKE_EXPORT_COMPILE_COMMANDS=ON for VS Code users (to avoid warning in the IDE for include paths), I just set it up with copilot.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also mention we prefer the clang is also in llvm-19 version?

I am wondering, when we build LLVM-19.x from source, it is compiled using the built-in clang, which may not be llvm-19, right? Then if user install clang in llvm-19, should we update this

// RUN: clang++ -S -emit-llvm -o %t-kernel.ll kernel.cpp
to distinguish the system clang and the user-installed clang?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about now: Compile both clang and mlir and add note at the beginning of test.mlir to recommend user to add llvm-19 clang to PATH.

-DLLVM_ENABLE_PROJECTS="clang;mlir" --- To compile clang in llvm-19 but take more time.

# install clang for LLVM build
- name: install clang
run: sudo apt-get install -y clang
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may already ask, but what is this clang version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default install version is 14.


You can directly pull and use the pre-built Docker image:
```sh
$ docker pull cgra/neura:v1
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image is pushing in progress:

The push refers to repository [docker.io/cgra/neura]
3b5d14681ffd: Pushing [==================================================>]  12.92GB
346f14bf17b9: Layer already exists

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uploaded to cgra/neura:v1.

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 this pull request may close these issues.

2 participants