Skip to content

Commit 4fd9470

Browse files
Fail tests if LTCG is used (#111651)
#111566 is not the first time we accidentally shipped something built with LTCG. We should ideally not allow merging such code into `main`.
1 parent e424e05 commit 4fd9470

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

eng/testing/tests.singlefile.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<IlcSdkPath>$(CoreCLRAotSdkDir)</IlcSdkPath>
2929
<IlcFrameworkPath>$(NetCoreAppCurrentTestHostSharedFrameworkPath)</IlcFrameworkPath>
3030
<IlcFrameworkNativePath>$(NetCoreAppCurrentTestHostSharedFrameworkPath)</IlcFrameworkNativePath>
31+
<IlcCppLinkerCustomWarningRegularExpression>module compiled with /GL found</IlcCppLinkerCustomWarningRegularExpression>
3132
<NoWarn>$(NoWarn);IL1005;IL2122;IL3000;IL3001;IL3002;IL3003;IL3050;IL3051;IL3052;IL3053</NoWarn>
3233
<TrimMode>partial</TrimMode>
3334
<SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings>

src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,16 @@ The .NET Foundation licenses this file to you under the MIT license.
372372
<!-- write linker script for lld (13+) to retain the __modules section -->
373373
<WriteLinesToFile File="$(NativeIntermediateOutputPath)sections.ld" Lines="OVERWRITE_SECTIONS { __modules : { KEEP(*(__modules)) } }" Overwrite="true" Condition="'$(LinkerFlavor)' == 'lld' and '$(_LinkerVersion)' &gt; '12'" />
374374

375-
<Exec Command="&quot;$(CppLinker)&quot; @(CustomLinkerArg, ' ')" Condition="'$(_targetOS)' != 'win' and '$(NativeLib)' != 'Static'" IgnoreStandardErrorWarningFormat="$(_IgnoreLinkerWarnings)" />
375+
<Exec Command="&quot;$(CppLinker)&quot; @(CustomLinkerArg, ' ')"
376+
Condition="'$(_targetOS)' != 'win' and '$(NativeLib)' != 'Static'"
377+
IgnoreStandardErrorWarningFormat="$(_IgnoreLinkerWarnings)"
378+
CustomWarningRegularExpression="$(IlcCppLinkerCustomWarningRegularExpression)" />
376379
<Exec Command="&quot;$(CppLibCreator)&quot; @(CustomLibArg, ' ')" Condition="'$(_targetOS)' != 'win' and '$(NativeLib)' == 'Static'" />
377380

378381
<WriteLinesToFile File="$(NativeIntermediateOutputPath)link.rsp" Lines="@(CustomLinkerArg)" Overwrite="true" Encoding="utf-8" Condition="'$(_targetOS)' == 'win' and '$(NativeLib)' != 'Static'" />
379-
<Exec Command="&quot;$(CppLinker)&quot; @&quot;$(NativeIntermediateOutputPath)link.rsp&quot;" Condition="'$(_targetOS)' == 'win' and '$(NativeLib)' != 'Static'" />
382+
<Exec Command="&quot;$(CppLinker)&quot; @&quot;$(NativeIntermediateOutputPath)link.rsp&quot;"
383+
Condition="'$(_targetOS)' == 'win' and '$(NativeLib)' != 'Static'"
384+
CustomWarningRegularExpression="$(IlcCppLinkerCustomWarningRegularExpression)" />
380385
<WriteLinesToFile File="$(NativeIntermediateOutputPath)lib.rsp" Lines="@(CustomLibArg)" Overwrite="true" Encoding="utf-8" Condition="'$(_targetOS)' == 'win' and '$(NativeLib)' == 'Static'" />
381386
<Exec Command="&quot;$(CppLibCreator)&quot; @&quot;$(NativeIntermediateOutputPath)lib.rsp&quot;" Condition="'$(_targetOS)' == 'win' and '$(NativeLib)' == 'Static'" />
382387

0 commit comments

Comments
 (0)