Skip to content

source-built NativeAOT doesn't work with system brotli #107020

@tmds

Description

@tmds

When source-building .NET with the brotli system lib, the source-built NativeAOT fails to compile an application that uses brotli.

The compilation failure is due to missing flags for brotli.

  console failed with 2 error(s) (12.2s) → bin/Release/net9.0/fedora.40-x64/console.dll
    clang : error : linker command failed with exit code 1 (use -v to see invocation)
    /var/home/tmds/.nuget/packages/microsoft.dotnet.ilcompiler/9.0.0-rc.2.24423.10/build/Microsoft.NETCore.Native.targets(376,5): error MSB3073: The command ""clang" "obj/Release/net9.0/fedora.40-x64/native/console.o" -o "bin/Release/net9.0/fedora.40-x64/native/console" -Wl,--version-script=obj/Release/net9.0/fedora.40-x64/native/console.exports -Wl,--export-dynamic -gz=zlib -fuse-ld=bfd /tmp/dotnet/packs/runtime.fedora.40-x64.Microsoft.DotNet.ILCompiler/9.0.0-rc.2.24423.10/sdk/libbootstrapper.o /tmp/dotnet/packs/runtime.fedora.40-x64.Microsoft.DotNet.ILCompiler/9.0.0-rc.2.24423.10/sdk/libRuntime.WorkstationGC.a /tmp/dotnet/packs/runtime.fedora.40-x64.Microsoft.DotNet.ILCompiler/9.0.0-rc.2.24423.10/sdk/libeventpipe-disabled.a /tmp/dotnet/packs/runtime.fedora.40-x64.Microsoft.DotNet.ILCompiler/9.0.0-rc.2.24423.10/sdk/libRuntime.VxsortEnabled.a /tmp/dotnet/packs/runtime.fedora.40-x64.Microsoft.DotNet.ILCompiler/9.0.0-rc.2.24423.10/sdk/libstandalonegc-disabled.a /tmp/dotnet/packs/runtime.fedora.40-x64.Microsoft.DotNet.ILCompiler/9.0.0-rc.2.24423.10/sdk/libstdc++compat.a /tmp/dotnet/packs/runtime.fedora.40-x64.Microsoft.DotNet.ILCompiler/9.0.0-rc.2.24423.10/framework/libSystem.Native.a /tmp/dotnet/packs/runtime.fedora.40-x64.Microsoft.DotNet.ILCompiler/9.0.0-rc.2.24423.10/framework/libSystem.Globalization.Native.a /tmp/dotnet/packs/runtime.fedora.40-x64.Microsoft.DotNet.ILCompiler/9.0.0-rc.2.24423.10/framework/libSystem.IO.Compression.Native.a /tmp/dotnet/packs/runtime.fedora.40-x64.Microsoft.DotNet.ILCompiler/9.0.0-rc.2.24423.10/framework/libSystem.Net.Security.Native.a /tmp/dotnet/packs/runtime.fedora.40-x64.Microsoft.DotNet.ILCompiler/9.0.0-rc.2.24423.10/framework/libSystem.Security.Cryptography.Native.OpenSsl.a -g -Wl,-rpath,'$ORIGIN' -Wl,--build-id=sha1 -Wl,--as-needed -pthread -lssl -lcrypto -ldl -lz -lrt -lm -pie -Wl,-pie -Wl,-z,relro -Wl,-z,now -Wl,--eh-frame-hdr -Wl,--discard-all -Wl,--gc-sections" exited with code 1.

In #97536, we've added such flags for OpenSSL:

<ItemGroup Condition="'$(StaticOpenSslLinking)' != 'true' and Exists('$(IlcSdkPath)nonportable.txt')">
<NativeSystemLibrary Include="ssl" />
<NativeSystemLibrary Include="crypto" />
</ItemGroup>

We need to additionally have:

      <NativeSystemLibrary Include="brotlienc" />
      <NativeSystemLibrary Include="brotlidec" />

.NET can be either built with system brotli or the bundled broti. The above is only needed when built with system brotli.

Microsoft.NETCore.Native.Unix.targets is in the Microsoft.DotNet.ILCompiler package, which means it may come from nuget.org, so we can't just patch it as part of source-building .NET.

For the OpenSSL flags, #97536 introduced a nonportable.txt breadcrumb that is stored in the source-built .NET so Microsoft.DotNet.ILCompiler knows when to include the OpenSSL flags.

For brotli, we need something similar.

If we can consider brotli an acceptable system dependency for source-build platforms, we may consider to have non-portable builds always use brotli and use the nonportable.txt breadcrumb.

cc @jkotas @omajid @MichaelSimons

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-NativeAOT-coreclrin-prThere is an active PR which will close this issue when it is mergedsource-buildIssues relating to dotnet/source-build

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions