Skip to content

NativeAOT produces very large __LINKEDIT segment on macOS #86707

@nxtn-staged

Description

@nxtn-staged

Description

NativeAOT on macOS typically produces binaries about twice the size with large, almost zero-filled __LINKEDIT segments. Is this expected?

Reproduction Steps

dotnet new console --aot --output Test.Console
cat > ./Test.Console/Program.cs << EOF
using var client = new HttpClient();
Console.WriteLine(await client.GetStringAsync("https://example.com"));
EOF
dotnet publish ./Test.Console/Test.Console.csproj
ls -lh ./artifacts/publish/Test.Console/release

Expected behavior

win-x64

5.0M Test.Console.exe
 22M Test.Console.pdb

linux-x64

6.6M Test.Console
 19M Test.Console.dbg

Actual behavior

osx-x64

 11M Test.Console
 24M Test.Console.dwarf
% bloaty ./artifacts/publish/Test.Console/release/Test.Console
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  37.9%  4.11Mi  34.1%  4.11Mi    [__LINKEDIT]
  26.4%  2.87Mi  23.8%  2.87Mi    __TEXT,__managedcode
  13.3%  1.45Mi  12.0%  1.45Mi    __TEXT,__const
   0.0%       0   9.2%  1.11Mi    __DATA,hydrated
   8.5%   938Ki   7.6%   938Ki    __TEXT,__eh_frame
   5.1%   563Ki   4.6%   563Ki    __TEXT,__text
   4.1%   459Ki   3.7%   459Ki    __DATA,.dotnet_eh_table
   2.7%   297Ki   2.4%   297Ki    __TEXT,__unwind_info
   0.8%  88.5Ki   0.7%  88.5Ki    __DATA,__data
   0.0%       0   0.5%  61.2Ki    __DATA,__bss
   0.4%  39.5Ki   0.3%  39.5Ki    __TEXT,__cstring
   0.3%  30.1Ki   0.2%  30.1Ki    Function Start Addresses
   0.0%       0   0.2%  29.4Ki    __DATA,__common
   0.1%  11.9Ki   0.1%  14.0Ki    [__DATA]
   0.1%  10.3Ki   0.1%  10.7Ki    [14 Others]
   0.1%  10.3Ki   0.1%  10.3Ki    __TEXT,__unbox
   0.1%  9.00Ki   0.1%  9.00Ki    [__DATA_CONST]
   0.1%  6.76Ki   0.1%  6.76Ki    String Table
   0.1%  6.62Ki   0.1%  6.62Ki    Symbol Table
   0.0%  3.39Ki   0.0%  3.39Ki    __DATA_CONST,__got
   0.0%  3.38Ki   0.0%  3.27Ki    [Mach-O Headers]
 100.0%  10.8Mi 100.0%  12.0Mi    TOTAL

osx-arm64

 11M Test.Console
 24M Test.Console.dwarf
% bloaty ./artifacts/publish/Test.Console/release/Test.Console
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  36.5%  4.06Mi  33.0%  4.07Mi    [__LINKEDIT]
  28.6%  3.19Mi  25.8%  3.19Mi    __TEXT,__managedcode
  12.8%  1.42Mi  11.5%  1.42Mi    __TEXT,__const
   0.0%       0   9.0%  1.11Mi    __DATA,hydrated
   8.3%   941Ki   7.4%   941Ki    __TEXT,__eh_frame
   4.6%   520Ki   4.1%   520Ki    __TEXT,__text
   4.0%   451Ki   3.6%   451Ki    __DATA,.dotnet_eh_table
   2.6%   293Ki   2.3%   293Ki    __TEXT,__unwind_info
   0.8%  88.5Ki   0.7%  88.5Ki    Code Signature
   0.8%  88.5Ki   0.7%  88.5Ki    __DATA,__data
   0.0%       0   0.5%  61.1Ki    __DATA,__bss
   0.3%  39.7Ki   0.3%  39.7Ki    __TEXT,__cstring
   0.3%  31.5Ki   0.2%  31.5Ki    Function Start Addresses
   0.0%       0   0.2%  29.2Ki    __DATA,__common
   0.2%  19.0Ki   0.2%  19.1Ki    [14 Others]
   0.1%  9.29Ki   0.1%  9.39Ki    [__TEXT]
   0.1%  8.19Ki   0.1%  8.19Ki    [__DATA_CONST]
   0.0%  4.08Ki   0.1%  7.05Ki    [__DATA]
   0.1%  6.88Ki   0.1%  6.88Ki    __TEXT,__unbox
   0.1%  6.71Ki   0.1%  6.71Ki    String Table
   0.1%  6.58Ki   0.1%  6.58Ki    Symbol Table
 100.0%  11.1Mi 100.0%  12.3Mi    TOTAL

Regression?

No response

Known Workarounds

No response

Configuration

win-x64

> dotnet --info
.NET SDK:
 Version:   8.0.100-preview.4.23260.5
 Commit:    2268e7b15c

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win10-x64

linux-x64

$ dotnet --info
.NET SDK:
 Version:   8.0.100-preview.4.23260.5
 Commit:    2268e7b15c

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64

osx-x64

% dotnet --info
.NET SDK:
 Version:   8.0.100-preview.4.23260.5
 Commit:    2268e7b15c

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  13.4
 OS Platform: Darwin
 RID:         osx.13-x64

osx-arm64

% dotnet --info
.NET SDK:
 Version:   8.0.100-preview.4.23260.5
 Commit:    2268e7b15c

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  13.4
 OS Platform: Darwin
 RID:         osx.13-arm64

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions