Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to build on Windows with recent clang #1940

Open
lazka opened this issue Jan 12, 2025 · 3 comments · May be fixed by #1941
Open

Fails to build on Windows with recent clang #1940

lazka opened this issue Jan 12, 2025 · 3 comments · May be fixed by #1941
Labels
bug Something isn't working

Comments

@lazka
Copy link

lazka commented Jan 12, 2025

FAILED: src/CMakeFiles/libavrdude.dir/serbb_win32.c.obj 
C:\msys64\clangarm64\bin\clang.exe -DCONFIG_DIR=\"/clangarm64/etc\" -IC:/M/B/src/build-CLANGARM64/src -IC:/M/B/src/avrdude-8.0 -IC:/M/B/src/build-CLANGARM64 -IC:/M/B/src/avrdude-8.0/src -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong -Wp,-D__USE_MINGW_ANSI_STDIO=1 -IC:/msys64/clangarm64/include/libusb-compat -O3 -DNDEBUG -std=gnu11 -Wall -Wextra -Wno-unused-parameter -Wno-format-zero-length -MD -MT src/CMakeFiles/libavrdude.dir/serbb_win32.c.obj -MF src\CMakeFiles\libavrdude.dir\serbb_win32.c.obj.d -o src/CMakeFiles/libavrdude.dir/serbb_win32.c.obj -c C:/M/B/src/avrdude-8.0/src/serbb_win32.c
C:/M/B/src/avrdude-8.0/src/serbb_win32.c:294:3: error: call to undeclared library function 'free' with type 'void (void *)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  294 |   mmt_free(pgm->cookie);
      |   ^
C:/M/B/src/avrdude-8.0/src/avrdude.h:46:21: note: expanded from macro 'mmt_free'
   46 | #define mmt_free(p) free(p)
      |                     ^
C:/M/B/src/avrdude-8.0/src/serbb_win32.c:294:3: note: include the header <stdlib.h> or explicitly provide a declaration for 'free'
C:/M/B/src/avrdude-8.0/src/avrdude.h:46:21: note: expanded from macro 'mmt_free'
   46 | #define mmt_free(p) free(p)

I've fixed it via this for now:

--- avrdude-8.0/src/avrdude.h.orig	2025-01-12 15:51:31.535158800 +0100
+++ avrdude-8.0/src/avrdude.h	2025-01-12 15:51:34.737728900 +0100
@@ -20,6 +20,7 @@
 #define avrdude_h
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #define SYSTEM_CONF_FILE "avrdude.conf"
@stefanrueger
Copy link
Collaborator

@lazka Thanks for reporting.

I've fixed it [...]

Good fix, I'd have suggested the same. Do you want to issue a PR?

@lazka
Copy link
Author

lazka commented Jan 14, 2025

Sure, I'll have a look later, thanks.

@stefanrueger
Copy link
Collaborator

Good, that way you get credit for your discovery

lazka added a commit to lazka/avrdude that referenced this issue Jan 14, 2025
Building avrdude with current clang+mingw-w64 for arm64 on Windows
leads to the following error:
serbb_win32.c:294:3: error: call to undeclared library function 'free' with type 'void (void *)'

Explicitely import stdlib.h for free() in avrdude.h
where mmt_free() is defind to free() to fix this.

Fixes avrdudes#1940
@lazka lazka linked a pull request Jan 14, 2025 that will close this issue
@stefanrueger stefanrueger added the bug Something isn't working label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants