From: Nadav Har'El <n...@scylladb.com>
Committer: Waldemar Kozaczuk <wkozac...@waldemars-air.attlocal.net>
Branch: master
libc: avoid weak_alias() warnings from gcc 9.
gcc 9 started to warn about alias created with different "attributes"
(__attribute__(...)) from the source symbol. Unfortunately, in a couple
of cases gcc also started to add a gratuituous "nothrow" attribute to
our C code (which can never throw in any case...) and as a result,
weak_alias throws.
I tried to fix this in a number of ways, but none of them worked
satisfactorily. This patch does something ugly, that works - add
the nothrow attribute manually in the two places which had this
problem. Unfortunately it means we edited yet another Musl source
file (stdio/sscanf.c).
Signed-off-by: Nadav Har'El <n...@scylladb.com>
Message-Id: <20190519122628.6226-3-...@scylladb.com>
---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1515,7 +1515,7 @@ musl += stdio/setlinebuf.o
musl += stdio/setvbuf.o
musl += stdio/snprintf.o
musl += stdio/sprintf.o
-musl += stdio/sscanf.o
+libc += stdio/sscanf.o
libc += stdio/stderr.o
libc += stdio/stdin.o
libc += stdio/stdout.o
diff --git a/libc/stdio/sscanf.c b/libc/stdio/sscanf.c
--- a/libc/stdio/sscanf.c
+++ b/libc/stdio/sscanf.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include "libc.h"
+
+int sscanf(const char *restrict s, const char *restrict fmt, ...)
+{
+ int ret;
+ va_list ap;
+ va_start(ap, fmt);
+ ret = vsscanf(s, fmt, ap);
+ va_end(ap);
+ return ret;
+}
+
+#if __GNUC__ >= 9
+weak_alias(sscanf,__isoc99_sscanf) __attribute__((nothrow));
+#else
+weak_alias(sscanf,__isoc99_sscanf);
+#endif
diff --git a/libc/stdio/vsscanf.c b/libc/stdio/vsscanf.c
--- a/libc/stdio/vsscanf.c
+++ b/libc/stdio/vsscanf.c
@@ -15,4 +15,8 @@ int vsscanf(const char *restrict s, const char *restrict
fmt, va_list ap)
return vfscanf(&f, fmt, ap);
}
+#if __GNUC__ >= 9
+weak_alias(vsscanf,__isoc99_vsscanf) __attribute__((nothrow));
+#else
weak_alias(vsscanf,__isoc99_vsscanf);
+#endif
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/osv-dev/00000000000073bd64058942c6ec%40google.com.
For more options, visit https://groups.google.com/d/optout.