Skip to content

Comments

Add default value when FeatureDynamicCodeCompiled is undefined#124476

Merged
BrzVlad merged 1 commit intodotnet:mainfrom
BrzVlad:fix-vs-build
Feb 17, 2026
Merged

Add default value when FeatureDynamicCodeCompiled is undefined#124476
BrzVlad merged 1 commit intodotnet:mainfrom
BrzVlad:fix-vs-build

Conversation

@BrzVlad
Copy link
Member

@BrzVlad BrzVlad commented Feb 16, 2026

This property is normally passed to msbuild when building runtime.proj, with a true or false value. An exception happens when building from vs, with ./build.cmd -vs coreclr.slnx. Feature defines need to have a default value for this scenario. Rather than adding a default in clrfeatures.cmake, which would require duplicating target os logic from the build scripts, this commit handles the default at a higher level in runtime.proj.

This property is normally passed to msbuild when building runtime.proj, with a true or false value. An exception happens when building from vs, with `./build.cmd -vs coreclr.slnx`. Feature defines need to have a default value for this scenario. Rather than adding a default in clrfeatures.cmake, which would require duplicating target os logic from the build scripts, this commit handles the default at a higher level in runtime.proj.
@BrzVlad
Copy link
Member Author

BrzVlad commented Feb 16, 2026

Issue hit by @jakobbotsch in #124168 (comment)

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a build issue when opening CoreCLR in Visual Studio using ./build.cmd -vs coreclr.slnx. When building through this path, the FeatureDynamicCodeCompiled MSBuild property is undefined, causing CMake configuration to fail. The fix adds a default value by treating an empty string as true, which aligns with the default behavior in build scripts for Windows platforms.

Changes:

  • Modified the conditional check for FeatureDynamicCodeCompiled in runtime.proj to default to enabled when the property is undefined

Copy link
Member

@jakobbotsch jakobbotsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@BrzVlad BrzVlad merged commit 9268ae6 into dotnet:main Feb 17, 2026
110 checks passed
@akoeplinger
Copy link
Member

This seems like the wrong fix to me. The flag should probably be initialized in msbuild rather than the build.sh/cmd scripts so the logic is handled there. E.g. ILCompiler.ReadyToRun.csproj and clr.featuredefines.props are also using it.

@BrzVlad
Copy link
Member Author

BrzVlad commented Feb 17, 2026

@akoeplinger Hmm, if I'm understanding correctly, then it is not necessarily this fix that is wrong, but the original implementation. So you would recommend the arch handling to be removed from here: https://github.com/dotnet/runtime/blob/main/eng/build.ps1#L357 and here: https://github.com/dotnet/runtime/blob/main/eng/build.sh#L597, pass the FeatureDynamicCodeCompiled property to msbuild only if it is explicitly set via --dynamiccodecompiled and in clr.featuredefines.props have the default value of the property, if it is not set, depending on the target ?

edit: I'm not sure if runtime.proj would see properties from clr.featuredefines.props

@akoeplinger
Copy link
Member

Yeah though it looks like clr.featuredefines.props is not imported in runtime.proj. I think this might be the first "enabled-by-default" feature.

e.g. if you look at FeatureXplatEventSource we set it to true based on some conditions in

<PropertyGroup Condition="'$(TargetsUnix)' == 'true'">
<FeatureXplatEventSource Condition="'$(FeatureXplatEventSource)' == '' AND '$(TargetOS)' == 'linux'">true</FeatureXplatEventSource>
but only pass it to the runtime build when it's false (which happens to work):

<_CoreClrBuildArg Condition="'$(FeatureXplatEventSource)' == 'false'" Include="-cmakeargs &quot;-DFEATURE_EVENTSOURCE_XPLAT=0&quot;" />

@BrzVlad
Copy link
Member Author

BrzVlad commented Feb 17, 2026

A problem with dynamic code compiled option is that, even if you don't pass it explicitly to the build it needs to have a platform dependent value, both for runtime/crossgen2 and SPC. So it seems clr.featuredefines.props is not the unified solution to this problem and we would still need to have defaults in other places, for runtime.proj and crossgen2.

I believe we have 2 options:

  • Adding the pattern from this PR to clr.featuredefines.props and ILCompiler.ReadyToRun.csproj, by adding the default as true if it was not set.
  • what I believe you might be suggesting:
    • we remove the target checks from build.sh and build.ps1
    • in runtime.proj, clr.featuredefines.props and ILCompiler.ReadyToRun.csproj, if FeatureDynamicCodeCompiled is undefined (meaning the build scripts didn't set an explicit value), we will do the target platform checks to produce the value of this property.

@jkotas
Copy link
Member

jkotas commented Feb 17, 2026

I see the top-level build option as a non-production quality testing hook. I think the current implementation is good enough for that.

A production quality option would be much more complicated. For example, we would not want to have the ifdef in ILCompiler.ReadyToRun.csproj at all. Instead, we would want it to be a crossgen2 switch, or have crossgen2 auto-detect the setting from the CoreLib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants