Skip to content

Commit cc05fde

Browse files
Remove the property disabling optimization (PowerShell#19701)
1 parent b77d510 commit cc05fde

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

PowerShell.Common.props

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,6 @@
185185
<DebugType>full</DebugType>
186186
</PropertyGroup>
187187

188-
<!-- Define non-windows, release configuration properties -->
189-
<PropertyGroup Condition=" '$(Configuration)' == 'Release' And '$(IsWindows)' != 'true' ">
190-
<!-- Set-Date fails with optimize enabled in NonWindowsSetDate
191-
Debugging the issues resolves the problem
192-
-->
193-
<Optimize>false</Optimize>
194-
</PropertyGroup>
195-
196188
<PropertyGroup>
197189
<Features>strict</Features>
198190
</PropertyGroup>

src/System.Management.Automation/CoreCLR/CorePsPlatform.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,10 @@ internal static partial class NativeMethods
932932
[LibraryImport(psLib)]
933933
internal static partial int WaitPid(int pid, [MarshalAs(UnmanagedType.Bool)] bool nohang);
934934

935-
// This is a struct tm from <time.h>.
936-
[StructLayout(LayoutKind.Sequential)]
935+
// This is the struct `private_tm` from setdate.h in libpsl-native.
936+
// Packing is set to 4 to match the unmanaged declaration.
937+
// https://github.com/PowerShell/PowerShell-Native/blob/c5575ceb064e60355b9fee33eabae6c6d2708d14/src/libpsl-native/src/setdate.h#L23
938+
[StructLayout(LayoutKind.Sequential, Pack = 4)]
937939
internal unsafe struct UnixTm
938940
{
939941
/// <summary>Seconds (0-60).</summary>
@@ -980,7 +982,7 @@ internal static UnixTm DateTimeToUnixTm(DateTime date)
980982
return tm;
981983
}
982984

983-
[LibraryImport(psLib)]
985+
[LibraryImport(psLib, SetLastError = true)]
984986
internal static unsafe partial int SetDate(UnixTm* tm);
985987

986988
[LibraryImport(psLib, StringMarshalling = StringMarshalling.Utf8)]

0 commit comments

Comments
 (0)