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 with zlib on Unix #456

Merged
merged 13 commits into from
Aug 1, 2023
Merged

Build with zlib on Unix #456

merged 13 commits into from
Aug 1, 2023

Conversation

am11
Copy link
Member

@am11 am11 commented Jul 26, 2023

llvm-dwarfdump requires zlib support in dotnet/runtime#85192 (comment). It doesn't hurt having it enabled in the other tools (distro, such as Ubuntu, have it enabled for llvm-*).

@am11
Copy link
Member Author

am11 commented Jul 26, 2023

cc @jkotas, @agocke, @MichalStrehovsky

llvm.proj Outdated Show resolved Hide resolved
Copy link
Member

@MichalStrehovsky MichalStrehovsky left a comment

Choose a reason for hiding this comment

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

This likely brings a dependency on zlib to objwriter as well (i.e. this is also a product change). The pre-existing -DLLVM_ENABLE_ZLIB=OFF on Windows is there because LLVM will bring in something that depends on zlib if left unchecked, at least on Windows.

I don't have big concerns around it since ilc already seems to depend on zlib on Linux anyway, but calling it out.

I assume mac is fine and ships with a zlib?

llvm.proj Outdated Show resolved Hide resolved
@am11 am11 closed this Jul 27, 2023
@am11 am11 reopened this Jul 27, 2023
Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@am11
Copy link
Member Author

am11 commented Jul 27, 2023

From the docs: https://llvm.org/docs/HowToCrossCompileLLVM.html

  1. The ARM libraries won’t be installed in your system. But the CMake prepare step, which checks for dependencies, will check the host libraries, not the target ones. Below there’s a list of some dependencies, but your project could have more, or this document could be outdated. You’ll see the errors while linking as an indication of that.

Debian based distros have a way to add multiarch, which adds a new architecture and allows you to install packages for those systems. See https://wiki.debian.org/Multiarch/HOWTO for more info.

But not all distros will have that, and possibly not an easy way to install them in any anyway, so you’ll have to build/download them separately.

which (after trying out different ways to satisfy cmake's "find_package() config-mode" on CBL-mariner without modifying the LLVM source files) translates to my second commit. Lets see how it goes. 🤞😅

@akoeplinger
Copy link
Member

akoeplinger commented Jul 27, 2023

@am11

/__w/_temp/13f0d39e-dcfc-4f55-8b65-a14369a4d938.sh: line 1: ROOTFS_DIR: command not found
ln: failed to create symbolic link '/usr/lib/aarch64-alpine-linux-musl': Permission denied

should be $ROOTFS_DIR since it is an env var (or use $(rootfs)), and you'll need sudo

@am11
Copy link
Member Author

am11 commented Jul 28, 2023

Switching images with rootfs to use include(FindZLIB) makes all platform happy simultaneously. It is supported since cmake v3.1. This approach does not require symlinks.

llvm.proj Outdated Show resolved Hide resolved
Comment on lines 120 to 124
if("${ZLIB_ROOT}" STREQUAL "")
find_package(ZLIB REQUIRED)
else()
include(FindZLIB)
endif()
Copy link
Member

Choose a reason for hiding this comment

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

So in https://reviews.llvm.org/D70519 there was an attempt to use FindZLIB and it was noted it changes the value in llvm-config --system-libs, is that still the case?

Copy link
Member Author

Choose a reason for hiding this comment

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

It will select $ZLIB_ROOT/libz.so which is enough for our purposes. As long as RPATH is correct (which I haven't checked as full cross-build was taking ages on my machine), it will load on any system with libz. On NativeAOT, libz is a system prerequisite on build machine, so ilc will be ok.

Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
@am11
Copy link
Member Author

am11 commented Jul 31, 2023

Good to merge?

@MichalStrehovsky
Copy link
Member

Good to merge?

@directhex @akoeplinger any concerns from Mono side? This is changing build configuration everywhere. It looks good from CoreCLR test tools/objwriter perspective.

@akoeplinger akoeplinger enabled auto-merge (squash) August 1, 2023 10:59
@am11
Copy link
Member Author

am11 commented Aug 1, 2023

Don't use FindZLIB, just setting ZLIB_ROOT is enough

Cool 👍 (assuming it works 😅)

@akoeplinger akoeplinger merged commit cbc7a23 into dotnet:dotnet/main-16.x Aug 1, 2023
13 checks passed
@akoeplinger
Copy link
Member

Thank you!

@am11 am11 deleted the patch-2 branch August 1, 2023 14:36
sbomer added a commit to dotnet/dotnet-buildtools-prereqs-docker that referenced this pull request Apr 4, 2024
Per #990 we would like to avoid installing `sudo` onto our build images if possible.

This was added for dotnet/llvm-project#456, which I believe didn't end up using `sudo`.
radekdoulik pushed a commit to radekdoulik/llvm-project that referenced this pull request May 9, 2024
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
akoeplinger added a commit that referenced this pull request May 17, 2024
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
radekdoulik pushed a commit that referenced this pull request Aug 16, 2024
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
radekdoulik pushed a commit that referenced this pull request Sep 2, 2024
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
radekdoulik pushed a commit that referenced this pull request Sep 12, 2024
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
radekdoulik pushed a commit that referenced this pull request Sep 19, 2024
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
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.

4 participants