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

Fix name of zlib that the linker needs #104904

Merged
merged 3 commits into from
Jul 16, 2024

Conversation

omajid
Copy link
Member

@omajid omajid commented Jul 15, 2024

It needs to be z so the linker argument becomes -lz. Otherwise the linker sees -lzlib which fails on Linux.

To reproduce the error, I used:

$ ./build.sh --cmakeargs -DCLR_CMAKE_USE_SYSTEM_ZLIB=true

It needs to be `z` so the linker argument becomes `-lz`. Otherwise the
linker sees `-lzlib` which fails on Linux.

To reproduce the error, I used:

    $ ./build.sh --cmakeargs -DCLR_CMAKE_USE_SYSTEM_ZLIB=true
@omajid
Copy link
Member Author

omajid commented Jul 15, 2024

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jul 15, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-io-compression
See info in area-owners.md if you want to be subscribed.

@ViktorHofer ViktorHofer requested a review from carlossanlop July 15, 2024 16:27
@omajid
Copy link
Member Author

omajid commented Jul 15, 2024

cc @carlossanlop

Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
@carlossanlop
Copy link
Member

/azp run runtime-native-aot

This comment was marked as outdated.

@carlossanlop
Copy link
Member

/azp runtime-nativeaot-outerloop

This comment was marked as resolved.

@carlossanlop
Copy link
Member

/azp run runtime-community

This comment was marked as outdated.

@carlossanlop
Copy link
Member

/azp run runtime-nativeaot-outerloop

This comment was marked as outdated.

@carlossanlop
Copy link
Member

/azp run runtime-extra-platforms

This comment was marked as outdated.

Copy link
Member

@carlossanlop carlossanlop left a comment

Choose a reason for hiding this comment

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

Approving after confirming the CI looks good.

@@ -13,7 +13,7 @@ macro(append_extra_compression_libs NativeLibsExtra)
find_package(ZLIB REQUIRED)
list(APPEND ZLIB_LIBRARIES m)
else()
list(APPEND ZLIB_LIBRARIES zlib)
list(APPEND ZLIB_LIBRARIES $<IF:$<BOOL:CLR_CMAKE_USE_SYSTEM_ZLIB>,z,zlib>)
Copy link
Member

Choose a reason for hiding this comment

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

We should be able to delete the ANDROID special-case above since it should be handled by this condition just fine now.

Copy link
Member

Choose a reason for hiding this comment

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

Good point. Done. I also added a comment.

@carlossanlop
Copy link
Member

/ba-g Failure is an unrelated timeout to download infra resources in a wasm leg. Other wasm legs passed:

src/mono/nuget/Microsoft.NET.Runtime.WorkloadTesting.Internal/Sdk/WorkloadTesting.Core.targets(82,5): error MSB3923: Failed to download file "https://dot.net/v1/dotnet-install.sh". The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing. ---> A task was canceled. ---> A task was canceled.

@carlossanlop
Copy link
Member

carlossanlop commented Jul 23, 2024

@LoopedBard3 what this change did was make sure that when building, the CLR_CMAKE_USE_SYSTEM_ZLIB cmake property can be set from the command line. Are we passing that variable to the command for perf runs on Linux?

Edit: Context is #105331 (comment)

@LoopedBard3
Copy link
Member

LoopedBard3 commented Jul 23, 2024

@carlossanlop We should be using the same build steps as the runtime runs unless something has updated for in the steps that we have not gotten. The current command line for building linux x64 ends up being build.sh -ci -arch x64 -os linux -cross -s clr+libs+host+packs -c Release with the top level build.sh in the runtime repo (https://dev.azure.com/dnceng/internal/_build/results?buildId=2500691&view=results). This is the specific yml we use to build the runtime: https://github.com/dotnet/runtime/blob/main/eng/pipelines/coreclr/perf-non-wasm-jobs.yml#L5-L28.

@omajid
Copy link
Member Author

omajid commented Jul 23, 2024

I did some quick testing:

$ ./build.sh
$ find -iname '*Compression*so'
...
./artifacts/bin/coreclr/linux.x64.Debug/ilc/libSystem.IO.Compression.Native.so
...
$  ldd ./artifacts/bin/coreclr/linux.x64.Debug/ilc/libSystem.IO.Compression.Native.so
        linux-vdso.so.1 (0x00007f23b178d000)
        libz.so.1 => /lib64/libz.so.1 (0x00007f23b1680000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f23b159c000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f23b13ab000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f23b178f000)

Looks like we still link to libz in a default build configuration?

@mtl1979
Copy link

mtl1979 commented Jul 23, 2024

Could be that BOOL:CLR_CMAKE_USE_SYSTEM_ZLIB here always returns true... Easy test would be to try changing the generator expression to normal if block.

@carlossanlop
Copy link
Member

Good find @omajid.
Checking your suggestion now, @mtl1979.

@am11
Copy link
Member

am11 commented Jul 23, 2024

We are using generator pattern in many places in the repo, I don't think it's due to that.

According to artifacts/obj/native/linux-x64-Debug/CMakeFiles/CMakeConfigureLog.yaml, it's coming from the first one here:

% git grep relro
eng/native/configurecompiler.cmake:  add_linker_flag(-Wl,-z,relro,-z,now)
src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets:      <LinkerArg Include="-Wl,-z,relro" Condition="'$(_IsApplePlatform)' != 'true'" />
src/mono/CMakeLists.txt:  add_link_options(-Wl,-z,relro)
src/mono/CMakeLists.txt:  add_compile_options(-Wl,-z,relro)

@jkoritzinsky
Copy link
Member

@am11 can you share your configure log?

@am11
Copy link
Member

am11 commented Jul 23, 2024

Sorry, my bad. It was actually a syntax error. :(
This is the fix: #105352.

@carlossanlop
Copy link
Member

Sorry, my bad. It was actually a syntax error. :(

No worries, we found it on time :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.IO.Compression community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants