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

[Docker] Add script to build llvm from source #13823

Merged
merged 4 commits into from
Mar 7, 2023

Conversation

neildhickey
Copy link
Contributor

This allows us to use the latest llvm and make sure it builds with the same configuration as the rest of tvm

Change-Id: I004ec89700498167c632d25f4fdf667922ba4943

@tvm-bot
Copy link
Collaborator

tvm-bot commented Jan 23, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

  • No users to tag found in teams: docker See #10317 for details

Generated by tvm-bot

@ekalda
Copy link
Contributor

ekalda commented Jan 24, 2023

@tvm-bot rerun

@mehrdadh
Copy link
Member

@neildhickey what is the benefit of building from source if we are using the released version anyway?

@neildhickey
Copy link
Contributor Author

neildhickey commented Jan 25, 2023

@mehrdadh Newer versions of gcc and clang introduce an option to outline atomic calls which means it will look for these atomic functions calls in glibc. The atomic calls are of the form __aarch64_ldadd4_acq_rel and others.

With the version of gcc and glibc we use to build tvm, these functions aren't available, and the build fails when trying to link against prebuilt libraries which use these options.

The released llvm packages for llvm-15 are built with these options enabled, so a workaround is to build llvm from source using the same version of the compiler we use to build tvm, thus alleviating the issue of the undefined function references.

@neildhickey neildhickey force-pushed the llvm_15_upgrade branch 2 times, most recently from 90c83e5 to 5033f5d Compare February 6, 2023 13:54
LLVM_VERSION_MAJOR=$1

detect_llvm_version() {
curl -sL "https://api.github.com/repos/llvm/llvm-project/releases?per_page=100" | \
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to follow redirects here?


set -e

LLVM_VERSION_MAJOR=$1
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this introduce ambiguity as to which version of LLVM we've built with and make it harder to debug issues (we have to figure out which version of LLVM was live at the time of the build of the container)? Wouldn't it be better to fix it to a full version?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, and if we remove the $1 parameter, then should we also cleanup the detect_llvm_version function? What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

We could still use the parameter if we wanted to, similar to:

RUN bash /install/ubuntu_install_androidsdk.sh 25.2.9519653 3.22.1 33.0.2 33

Otherwise, yes, detect_llvm_version should be removed.

Comment on lines 41 to 42
unxz llvm-project-${LLVM_VERSION}.src.tar.xz
tar xf llvm-project-${LLVM_VERSION}.src.tar
Copy link
Member

Choose a reason for hiding this comment

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

Does this not work? Surprised tar doesn't sniff the format.

Suggested change
unxz llvm-project-${LLVM_VERSION}.src.tar.xz
tar xf llvm-project-${LLVM_VERSION}.src.tar
tar xf llvm-project-${LLVM_VERSION}.src.tar.xz

ninja install
popd
popd
rm -rf llvm-${LLVM_VERSION}.src.tar.xz llvm-${LLVM_VERSION}.src.tar llvm-${LLVM_VERSION}.src
Copy link
Member

Choose a reason for hiding this comment

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

Can you use this cleanup pattern that should auto clean up these things on script failure?
https://github.com/apache/tvm/blob/main/docker/install/ubuntu_download_arm_compute_lib_binaries.sh#L46-L53

COPY install/ubuntu_install_llvm.sh /install/ubuntu_install_llvm.sh
RUN bash /install/ubuntu_install_llvm.sh
COPY install/ubuntu_install_llvm_from_source.sh /install/ubuntu_install_llvm_from_source.sh
RUN bash /install/ubuntu_install_llvm_from_source.sh 15.0.7
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a hash parameter in here to verify the source tarball? Similar to:
https://github.com/apache/tvm/blob/main/docker/install/ubuntu_install_zephyr_sdk.sh#L45-L48

Neil Hickey added 4 commits March 7, 2023 13:34
This allows us to use the latest llvm and make sure it builds with the same configuration as the rest of tvm

Change-Id: I004ec89700498167c632d25f4fdf667922ba4943
Note: This will be undone once the docker images have been updated
@Mousius Mousius merged commit ca48caf into apache:main Mar 7, 2023
@neildhickey neildhickey deleted the llvm_15_upgrade branch March 8, 2023 09:06
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.

6 participants