Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
Milestone
Description
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
dotnet new console -n frog && cd frogdotnet 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
- 7.0.100
- debian 12 sid bookworm
- x86 64-bit
- gcc (Debian 12.2.0-9) 12.2.0
- aarch64-linux-gnu-gcc (Debian 12.2.0-9) 12.2.0
- No clang installed
Other information
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
am11 commentedon Nov 18, 2022
We haven't tested cross-compilation with gcc, so this is unsupported. We can add support for it. However, there are few things to consider:
-target/--targetoptions are supported), but gcc only has one main target for which it was built for. We don't check the compiler flavor when setting this option (which is a bug).You can install clang (or use a docker image) for the cross-compilation in the meantime.
jkotas commentedon Nov 18, 2022
Cross-compilation instructions are at https://github.com/dotnet/runtime/blob/main/src/coreclr/nativeaot/docs/compiling.md#cross-architecture-compilation . Cross-compilation on Linux requires rootfs and target architecture native toolchain to be present.
am11 commentedon Nov 18, 2022
Yup, those instructions apply only to clang, because this argument is not supported on gcc:
runtime/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
Line 91 in 0eabf7f
WhiteBlackGoose commentedon Nov 18, 2022
I see.
While we're at it, is there anything for OS X that has to be referenced? (I see only windows and linux mentioned in the instruction)
am11 commentedon Nov 18, 2022
macOS is not supported in .NET 7. It is only available in the daily builds of .NET 8. We can update the document. Basically only cross-architecture is supported on OSX (not linux to osx). For example on M1 machine (osx-arm64), we can use:
to cross-compile x64 binary.
WhiteBlackGoose commentedon Nov 18, 2022
Without cross-compilation it works though 🤔
am11 commentedon Nov 18, 2022
Yes, for osx-x64 but osx-arm64 is only supported in .NET 8.
WhiteBlackGoose commentedon Nov 18, 2022
Got it. Any reason why btw? It requires additional work or something else?
WhiteBlackGoose commentedon Nov 18, 2022
Also, is arch-cross-compilation only available in .NET 8?
am11 commentedon Nov 18, 2022
osx-arm64 support was implemented in #75264 (merged three days before the 7.0 RC1 release), and number of fixes went in main branch after that. Normally new platform support PRs are not backported, when there was no time spent on testing during the development cycle.
Yes, because for OSX we only support cross-architecture compilation (and not cross-OS compilation), so it was not necessary when only one architecture was supported.
WhiteBlackGoose commentedon Nov 18, 2022
I mean, what about other OS? Is there arch-cross-compilation for linux on .NET 7?
am11 commentedon Nov 18, 2022
Yes. On linux, cross-compilation is supported with clang only. Normal compilation is supported with both clang and gcc.
WhiteBlackGoose commentedon Nov 18, 2022
Thanks, is there any specific instruction or should work out of the box? (trying to get through an issue issue right now with it)
agocke commentedon Nov 18, 2022
Instructions are here https://github.com/dotnet/runtime/blob/main/src/coreclr/nativeaot/docs/compiling.md#cross-architecture-compilation. They do require a "sysroot" that contains the arm64 toolchain, esp. glibc. I did have some success getting this to work on Ubuntu by pulling in arm64 packages, but I haven't written anything up yet.
agocke commentedon Jun 21, 2023
Closing as answered