Skip to content

gcc fails to arch-cross-compile on GNU/Linux in NativeAOT .NET 7 #78559

@WhiteBlackGoose

Description

@WhiteBlackGoose

Description

Getting an error

gcc : error : unrecognized command-line option '--target=aarch64-linux-gnu'

When trying to compile my app for ARM64 while being on x86 64bit laptop

Reproduction Steps

  1. dotnet new console -n frog && cd frog
  2. dotnet publish -p:PublishAot=true -p:SelfContained=true -r linux-arm64

Expected behavior

Compiles

Actual behavior

Doesn't compile:

$ dotnet publish -p:PublishAot=true -p:SelfContained=true -r linux-arm64
MSBuild version 17.4.0+18d5aef85 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
  frog -> /home/goose/sandbox-1668781319/frog/bin/Debug/net7.0/linux-arm64/frog.dll
  Generating native code
gcc : error : unrecognized command-line option '--target=aarch64-linux-gnu' [/home/goose/sandbox-1668781319/frog/frog.csproj]
/home/goose/programs/dotnet-folder/sdk/7.0.100/Sdks/Microsoft.DotNet.ILCompiler/build/Microsoft.NETCore.Native.targets(346,5): error MSB3073: The command ""gcc" "obj/Debug/net7.0/linux-arm64/native/frog.o" -o "bin/Debug/net7.0/linux-arm64/native/frog" /home/goose/.nuget/packages/runtime.linux-arm64.microsoft.dotnet.ilcompiler/7.0.0/sdk/libbootstrapper.a /home/goose/.nuget/packages/runtime.linux-arm64.microsoft.dotnet.ilcompiler/7.0.0/sdk/libRuntime.WorkstationGC.a /home/goose/.nuget/packages/runtime.linux-arm64.microsoft.dotnet.ilcompiler/7.0.0/framework/libSystem.Native.a /home/goose/.nuget/packages/runtime.linux-arm64.microsoft.dotnet.ilcompiler/7.0.0/framework/libSystem.Globalization.Native.a /home/goose/.nuget/packages/runtime.linux-arm64.microsoft.dotnet.ilcompiler/7.0.0/framework/libSystem.IO.Compression.Native.a /home/goose/.nuget/packages/runtime.linux-arm64.microsoft.dotnet.ilcompiler/7.0.0/framework/libSystem.Net.Security.Native.a /home/goose/.nuget/packages/runtime.linux-arm64.microsoft.dotnet.ilcompiler/7.0.0/framework/libSystem.Security.Cryptography.Native.OpenSsl.a --target=aarch64-linux-gnu -g -Wl,-rpath,'$ORIGIN' -Wl,--build-id=sha1 -Wl,--as-needed -pthread -lstdc++ -ldl -lm -lz -lrt -pie -Wl,-z,relro -Wl,-z,now -Wl,--discard-all -Wl,--gc-sections" exited with code 1. [/home/goose/sandbox-1668781319/frog/frog.csproj]

Regression?

No response

Known Workarounds

No response

Configuration

  1. 7.0.100
  2. debian 12 sid bookworm
  3. x86 64-bit
  4. gcc (Debian 12.2.0-9) 12.2.0
  5. aarch64-linux-gnu-gcc (Debian 12.2.0-9) 12.2.0
  6. No clang installed

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions