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

[installation] fix llvm config #61

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

gfengTT
Copy link
Contributor

@gfengTT gfengTT commented Feb 5, 2025

(copied from tenstorrent/tt-forge-fe#1185)

Problem description

  1. Each tvm installation downloads llvm 13.0.0 and extracts the package, but only uses the llvm-config binary;
  2. The downloaded version is old (released Sept. 2021), and was only for ubuntu 20.04, while forge by default works on ubuntu 22.04.

What's changed

Our forge docker image includes llvm-config-17. We only need to pick up a fix in apache-tvm, and to add the necessary packages in our docker image.

I've also added the option to specify a custom llvm-config in case we want to use another version, but so far I haven't run into any issue with llvm-config-17.

lhutton1 and others added 2 commits February 5, 2025 16:54
* [CMake] Fallback for finding static zstd library from the system

LLVM17 now depends on `-lzstd` when the `--link-static` option is used.
I.e:
```
$ llvm-config-16 --link-static --system-libs
-lrt -ldl -lm -lz -ltinfo -lxml2

$ llvm-config-17 --link-static --system-libs
-lrt -ldl -lm -lz -lzstd -ltinfo -lxml2
```

The current cmake rules try to find a "Findzstd.cmake" file located
within the project, although this doesn't seem to exist, resulting in a
compilation error. This commit adds a fallback to search the system for
libzstd.a incase a "Findzstd.cmake" is not found. The zstd library is
already installed as part of: https://github.com/apache/tvm/pull/15799/files#diff-c2c0605a8fdd4f5600690a8c7b1ec769882426af1b0ed01e8aaa0814e3a8f5dbR48

Change-Id: I19ab168f92d23e98809851f948e2122345ed01f1

* Use llvm-config to locate Findzstd.cmake

Use llvm-config to find the location of the "Find*.cmake" files
and add this location to the cmake `CMAKE_MODULE_PATH` variable.
This allows the build to discover "Findzstd.cmake".

Change-Id: I3d25074fad3b2b8fa4c3d47e0e4c0b27d8739c65
llvm-config is now found by the following order:

1. the value of env var LLVM_CONFIG_CMD
2. the installed llvm-config-17 in the Ubuntu 22.04 images
3. download clang+llvm 13 and use the downloaded binary
@@ -111,6 +111,14 @@ macro(find_llvm use_llvm)
message(FATAL_ERROR "Fatal error executing: ${LLVM_CONFIG} --libdir")
endif()
message(STATUS "LLVM libdir: ${__llvm_libdir}")
execute_process(COMMAND ${LLVM_CONFIG} --cmakedir
Copy link
Contributor

Choose a reason for hiding this comment

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

We're planning to uplift tt-tvm to the latest version in the next period. Therefore, we're trying to avoid adding custom changes to their build and core engine just to make our life a bit easier during the next and future uplifts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To the latest apache-tvm? That would be awesome. It shouldn't be an issue because I'm cherry-picking one commit in that repo.

Copy link
Contributor

@nvukobratTT nvukobratTT left a comment

Choose a reason for hiding this comment

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

@gfengTT can you share more details about the purpose of the change? Are we blocked on something due to that older version of LLVM linked to TVM?

@gfengTT
Copy link
Contributor Author

gfengTT commented Feb 6, 2025

@nvukobratTT the main purpose is to skip the downloading of llvm 13. The package is ~520M and after extraction takes 3.5G of disk space. As far as I can tell, all we need is the llvm-config binary, and we can simply use llvm-config-17 which already exists in the docker image.

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.

3 participants