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

Build Failure - implicit declaration of function ‘strlcpy’ #324

Closed
orbea opened this issue Jun 4, 2022 · 2 comments
Closed

Build Failure - implicit declaration of function ‘strlcpy’ #324

orbea opened this issue Jun 4, 2022 · 2 comments

Comments

@orbea
Copy link

orbea commented Jun 4, 2022

OS: Gentoo
rsync: 6f35553

Starting with version 3.2.4 the build fails.

x86_64-pc-linux-gnu-gcc -I. -I. -I./zlib -g -O2 -DHAVE_CONFIG_H -Wall -W -pedantic-errors  -c flist.c -o flist.o
flist.c: In function ‘send_file_entry’:
flist.c:674:9: error: implicit declaration of function ‘strlcpy’; did you mean ‘strncpy’? [-Wimplicit-function-declaration]
  674 |         strlcpy(lastname, fname, MAXPATHLEN);
      |         ^~~~~~~
      |         strncpy

In version 3.2.3 this was only a warning and was not a hard failure.

Since strlcpy is a non-standard function the fix is to use bsd/string.h instead of the regular string.h.

diff --git a/rsync.h b/rsync.h
index e5aacd25..05c9d2c5 100644
--- a/rsync.h
+++ b/rsync.h
@@ -336,7 +336,7 @@ enum delret {
 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
 #  include <memory.h>
 # endif
-# include <string.h>
+# include <bsd/string.h>
 #endif
 #ifdef HAVE_STRINGS_H
 # include <strings.h>

Also linking with -lbsd might be needed?

The configure strlcpy check probably passes because it lacks -Werror and thus only emits a warning. Maybe its more obvious to someone familiar with rsync how to modify the build system more cleanly?

Full build log: rsync.log

@WayneD
Copy link
Member

WayneD commented Jun 19, 2022

That's pretty weird to segment the declaration into a bsd .h file without segmenting the function itself into a separate library. If configure had not found that strlcpy() existed, rsync would have supplied its own code with its own declaration.

I've made configure look for bsd/strings.h and have rsync.h optionally include it. Please test that the latest code in git works for you.

@orbea
Copy link
Author

orbea commented Jun 19, 2022

Yes, I tested the latest commit (b38780f) and it compiles without warnings, thanks!

Edit: The commit with the fix for future reference. 3592ac3

@orbea orbea closed this as completed Jun 19, 2022
orbea added a commit to orbea/gentoo that referenced this issue Jun 19, 2022
Upstream-issue: RsyncProject/rsync#324
Upstream-commit: 3592ac3c025d ("Include bsd/strings.h if it exists")
Signed-off-by: orbea <orbea@riseup.net>
gentoo-bot pushed a commit to gentoo/gentoo that referenced this issue Jun 20, 2022
Upstream-issue: RsyncProject/rsync#324
Upstream-commit: 3592ac3c025d ("Include bsd/strings.h if it exists")
Signed-off-by: orbea <orbea@riseup.net>
Closes: #25982
Signed-off-by: Sam James <sam@gentoo.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants