dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.37k stars 4.75k forks source link

[NativeAOT] ILC: AOT analysis error IL1005 Vararg call not supported #67804

Closed AhmedZero closed 2 years ago

AhmedZero commented 2 years ago

Description

there is an error when building the driver

Reproduction Steps

        [MethodImpl(MethodImplOptions.InternalCall)]
        [RuntimeImport("ntoskrnl.exe", "DbgPrint")]
        public static extern ulong _DbgPrint(byte* Format, __arglist);

        static NTSTATUS DriverEntry()
        {
            _DbgPrint("%d".asstr(), __arglist(2));
            return NTSTATUS.Success;
        }
        public static byte* asstr(this string str)
        {
            fixed (char* wc = str)
            {
                var buf = ExAllocatePool(PoolType.NonPagedPool, (ulong)str.Length + 20);
                for (int i = 0; i < str.Length; i++)
                    buf[i] = (byte)wc[i];
                buf[str.Length] = (byte)0;
                return buf;
            }
        }

Expected behavior

build without any problems

Actual behavior

ILC: AOT analysis error IL1005: testdriver.Program.DriverEntry(): Method will always throw because: Vararg call to 'UInt64 testdriver.WDK._DbgPrint(Char*)' not supported

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

dotnet-issue-labeler[bot] commented 2 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

jkotas commented 2 years ago

varargs are supported only on Windows for C++/CLI compatibility. C++/CLI is not supported by NativeAOT.

More general support for varargs is tracked by #48796.

jkotas commented 2 years ago

Listed in https://github.com/dotnet/runtime/issues/69919

AhmedZero commented 2 years ago

I hope to support it soon. thanks.