Issue 142780
Summary -fno-builtin wont works if -O0
Labels new issue
Assignees
Reporter Duiccni
    The code I tried to compile is given in the bottom used clang version 20.1.5 Target: x86_64-pc-windows-msvc
without -O flag it gives error:

test-0bfdf5.o : error LNK2019: unresolved external symbol memset referenced in function _entry
CCC\test.exe : fatal error LNK1120: 1 unresolved externals
clang: error: linker command failed with exit code 1120 (use -v to see invocation)

which i believe it shoudnt becouse of -fno-builtin flag i used
with -O flag it works just fine

```// C:\"Program Files"\LLVM\bin\clang.exe CCC\test.c -o CCC\test.exe -lkernel32 -luser32 -nostdlib -nostartfiles -fno-builtin -O "-Wl,/subsystem:windows" "-Wl,/entry:_entry"

#undef UNICODE

#include <Windows.h>

HWND hwnd;
HINSTANCE hInstance;
char* className = "MyWindowClass";

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
   if (uMsg == WM_CLOSE) {
 return -1;
   }
   return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

void _entry() {
   hInstance = GetModuleHandle(NULL);

 WNDCLASS wc = {0};
   wc.lpfnWndProc = WindowProc;
   wc.hInstance = hInstance;
   wc.lpszClassName = className;
   RegisterClassA(&wc);
 hwnd = CreateWindowExA(0, className, "My Window", WS_VISIBLE | WS_SYSMENU | WS_CAPTION, 0, 0, 320, 320, NULL, NULL, hInstance, NULL);

   MSG msg;
loop:
   while (PeekMessageA(&msg, hwnd /*NULL*/, 0, 0, PM_REMOVE)) {
      DWORD r = DispatchMessageA(&msg);
      if (r == -1) {
 MessageBoxA(NULL, "WM_CLOSE", "Info", 0); // I expect it not to be work because hwnd set to hwnd not null
         goto end;
      }
   }

 Sleep(500);
   goto loop;
end:

   DestroyWindow(hwnd);
 UnregisterClassA(className, hInstance);

   ExitProcess(0);
}```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to