-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make PublishAot an optional feature because Mono does not support it. #28674
Conversation
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -875,4 +875,8 @@ You may need to build the project on another operating system or architecture, o | |||
<value>NETSDK1192: Targeting .NET 7.0 or higher in Visual Studio 2022 17.3 is not supported.</value> | |||
<comment>{StrBegin="NETSDK1192: "}</comment> | |||
</data> | |||
<data name="AotNotSupported" xml:space="preserve"> | |||
<value>NETSDK1193: The SDK does not support Ahead of time compilation. Set the PublishAot property to false.</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Why is the initial A
in Ahead
capitalized? It is usually spelled "ahead-of-time compilation", (e.g., in Wikipedia).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the spelling from
sdk/src/Tasks/Common/Resources/Strings.resx
Line 839 in 1624c6a
<value>NETSDK1183: Unable to optimize assemblies for Ahead of time compilation: a valid runtime package was not found. Either set the PublishAot property to false, or use a supported runtime identifier when publishing and make sure to restore packages with the PublishAot property set to true.</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AntonLapounov should I update both values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, missed the question. I would update both values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've replaced it everywhere where the language is English. I left the other ones untouched.
Strings.es.xlf: <target state="translated">NETSDK1183: No se pueden optimizar los ensamblados para la compilación Ahead of time: no se ha encontrado un paquete en tiempo de ejecución válido. Establezca la propiedad PublishAot en false o use un identificador de tiempo de ejecución compatible al publicar. Cuando el destino sea .NET 7 o una versión posterior, asegúrese de restaurar los paquetes con la propiedad PublishAot establecida en true.</target>
Strings.fr.xlf: <target state="translated">NETSDK1183: Impossible d'optimiser les assemblys pour la compilation Ahead of time : un package d'exécution valide n'a pas été trouvé. Définissez la propriété PublishAot sur false ou utilisez un identificateur d'exécution pris en charge lors de la publication. Lorsque vous ciblez .NET 7 ou supérieur, assurez-vous de restaurer les packages avec la propriété PublishAot définie sur true.</target>
Strings.it.xlf: <target state="translated">NETSDK1183: non è possibile ottimizzare gli assembly per la compilazione Ahead Of Time perché non è stato trovato alcun pacchetto di runtime valido. Impostare la proprietà PublishAot su false oppure usare un identificatore di runtime supportato durante la pubblicazione. Quando si usa .NET 7 o versioni successive, assicurarsi di ripristinare i pacchetti con la proprietà PublishAot impostata su true.</target>
Strings.ja.xlf: <target state="translated">NETSDK1183: Ahead Of Time コンパイル用にアセンブリを最適化できません: 有効なランタイム パッケージが見つかりませんでした。PublishAot プロパティを false に設定するか、公開時に、サポートされているランタイム識別子を使用してください。.NET 7 以降を対象とする場合は、必ず PublishAot プロパティを true に設定してパッケージを復元してください。</target>
Strings.ko.xlf: <target state="translated">NETSDK1183: Ahead of Time 컴파일을 위해 어셈블리를 최적화할 수 없습니다. 유효한 런타임 패키지를 찾을 수 없습니다. PublishAot 속성을 false로 설정하거나 게시할 때 지원되는 런타임 식별자를 사용하세요. .NET 7 이상을 대상으로 하는 경우 PublishAot 속성이 true로 설정된 패키지를 복원해야 합니다.</target>
Strings.ru.xlf: <target state="translated">NETSDK1183: не удалось оптимизировать сборки для компиляции Ahead Of Time: не найден допустимый пакет среды выполнения. Задайте для свойства PublishAot значение false либо используйте поддерживаемый идентификатор среды выполнения при публикации. При выборе .NET 7 или более поздней версии в качестве цели восстановите пакеты со свойством PublishAot со значением true.</target>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM from the source-build perspective.
What branch should I target? 7.0.1xx? Will that get merged to 7.0.2xx? For the |
I would say 7.0.1xx. Changes to 7.0.1xx will get auto merged (via PR) to the higher feature bands (e.g. 7.0.2xx) |
I've changed this to target 7.0.1xx. @agocke when CI is green, can you merge this? For |
@tmds This will need to go through servicing approval for 7.0. Have you already done that? |
Is this good to merge? |
Unfortunately couldn't get to it in Tactics today. I'll try to do this over email. |
@tmds Have you encountered any errors building SDK with this patch. Our Alpine build on
ILCompiler nupkg doesn't get added in the artifacts tarball for some reason. |
Is this using mono runtime? I verified this patch works in builds with coreclr runtime and with mono runtime With mono runtime, the |
Debugging further has confirmed that this patch isn't the cause. Coreclr-flavored runtime build on |
@@ -8,6 +8,7 @@ | |||
<PropertyGroup> | |||
<InnerBuildArgs>$(InnerBuildArgs) /p:Projects="$(InnerSourceBuildRepoRoot)\source-build.slnf"</InnerBuildArgs> | |||
<InnerBuildArgs>$(InnerBuildArgs) /p:UseSharedCompilation=false</InnerBuildArgs> | |||
<InnerBuildArgs Condition="'$(SourceBuildUseMonoRuntime)' == 'true'">$(InnerBuildArgs) /p:NativeAotSupported=false</InnerBuildArgs> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some coreclr-supported platforms do not support NativeAot as well (arm
). Does SDK have a platform variable? I couldn't find any thus I had to find another way to set NativeAotSupported
when arch is arm
. On Alpine, I removed this part of the modification, and moved the check to repos/sdk.proj
as $(BuildArchitecture)
does not reach eng/SourceBuild.props
.
Of course, you can keep this check and source-build can set NativeAotSupported=false
when $(BuildArchitecture) == arm
.
Thus, in dotnet/installer#14792:
diff --git a/src/SourceBuild/tarball/content/repos/sdk.proj b/src/SourceBuild/tarball/content/repos/sdk.proj
index c18e00dd61..6567b41983 100644
--- a/src/SourceBuild/tarball/content/repos/sdk.proj
+++ b/src/SourceBuild/tarball/content/repos/sdk.proj
@@ -6,6 +6,7 @@
<BuildCommandArgs>$(BuildCommandArgs) $(FlagParameterPrefix)nodereuse $(ArcadeFalseBoolBuildArg)</BuildCommandArgs>
<BuildCommandArgs>$(BuildCommandArgs) /p:PackageProjectUrl=https://github.com/dotnet/sdk</BuildCommandArgs>
<BuildCommandArgs>$(BuildCommandArgs) /p:PublishCompressedFilesPathPrefix=$(SourceBuiltToolsetDir)</BuildCommandArgs>
+ <BuildCommandArgs Condition="'$(SourceBuildUseMonoRuntime)' == 'true' OR '$(BuildArchitecture)' == 'arm'">$(BuildCommandArgs) /p:NativeAotSupported=false</BuildCommandArgs>
<LogVerbosityOptOut>true</LogVerbosityOptOut>
<BuildCommandArgs>$(BuildCommandArgs) -v $(LogVerbosity)</BuildCommandArgs>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does SDK have a platform variable?
I don't think so. This approach looks fine to me.
@@ -8,6 +8,7 @@ | |||
<PropertyGroup> | |||
<InnerBuildArgs>$(InnerBuildArgs) /p:Projects="$(InnerSourceBuildRepoRoot)\source-build.slnf"</InnerBuildArgs> | |||
<InnerBuildArgs>$(InnerBuildArgs) /p:UseSharedCompilation=false</InnerBuildArgs> | |||
<InnerBuildArgs Condition="'$(SourceBuildUseMonoRuntime)' == 'true'">$(InnerBuildArgs) /p:NativeAotSupported=false</InnerBuildArgs> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does SDK have a platform variable?
I don't think so. This approach looks fine to me.
Customer impact
The sdk assumes native aot is always available. This is not the case when .NET 7 is source-built with mono runtime for architectures like s390x and ppc64le.
Testing
The builds for RHEL and Fedora already include this patch.
Risk
Low, as it is already used.