mailing list of musl libc
 help / color / mirror / code / Atom feed
* Clang warning silencing patch
@ 2017-01-10  9:58 Dmitry Golovin
  2017-01-10 10:34 ` Dmitry Golovin
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Golovin @ 2017-01-10  9:58 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 535 bytes --]

The attached patch will reduce the amount of warnings produced when using clang compiler.

It does two things:

  1. Tests for excess-precision=standard and rounding-math are disabled for clang. The problem is that those tests pass, but do no good: every compilation commands produce two warnings about unsupported optimization flags.

  2. LDFLAGS (added to --help) variable is only used for linking, CFLAGS is only used for compiling, none of them are used for assembly. This suppresses all unused argument warnings.

Regards,
Dmitry

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ldflags-musl.patch --]
[-- Type: text/x-diff; name="ldflags-musl.patch", Size: 1976 bytes --]

With this patch CFLAGS and LDFLAGS are separated, so CFLAGS only used when compiling and LDFLAGS only used when linking.
This would silence many clang's warnings about unused arguments.

diff --git a/Makefile b/Makefile
index 8246b78..508878c 100644
--- a/Makefile
+++ b/Makefile
@@ -142,7 +142,7 @@ CC_CMD = $(CC) $(CFLAGS_ALL) -c -o $@ $<
 ifeq ($(ADD_CFI),yes)
 	AS_CMD = LC_ALL=C awk -f $(srcdir)/tools/add-cfi.common.awk -f $(srcdir)/tools/add-cfi.$(ARCH).awk $< | $(CC) $(CFLAGS_ALL) -x assembler -c -o $@ -
 else
-	AS_CMD = $(CC_CMD)
+	AS_CMD = $(CC) -c -o $@ $<
 endif
 
 obj/%.o: $(srcdir)/%.s
@@ -164,7 +164,7 @@ obj/%.lo: $(srcdir)/%.c $(GENH) $(IMPH)
 	$(CC_CMD)
 
 lib/libc.so: $(LOBJS) $(LDSO_OBJS)
-	$(CC) $(CFLAGS_ALL) $(LDFLAGS_ALL) -nostdlib -shared \
+	$(CC) $(LDFLAGS_ALL) -nostdlib -shared \
 	-Wl,-e,_dlstart -o $@ $(LOBJS) $(LDSO_OBJS) $(LIBCC)
 
 lib/libc.a: $(AOBJS)
diff --git a/configure b/configure
index c2db298..9f01ae5 100755
--- a/configure
+++ b/configure
@@ -39,6 +39,7 @@ Optional features:
 Some influential environment variables:
   CC                      C compiler command [detected]
   CFLAGS                  C compiler flags [-Os -pipe ...]
+  LDFLAGS                 linker flags [none]
   CROSS_COMPILE           prefix for cross compiler and tools [none]
   LIBCC                   compiler runtime library [detected]
 
@@ -337,9 +338,17 @@ tryflag CFLAGS_C99FSE -std=c99
 tryflag CFLAGS_C99FSE -nostdinc
 tryflag CFLAGS_C99FSE -ffreestanding \
 || tryflag CFLAGS_C99FSE -fno-builtin
+
+#
+# Do not check for excess-precision=standard and rounding-math on clang
+# because the test doesn't fail, but clang shows them as
+# unsupported optimization flags
+#
+if test "$cc_family" != clang ; then
 tryflag CFLAGS_C99FSE -fexcess-precision=standard \
 || { test "$ARCH" = i386 && tryflag CFLAGS_C99FSE -ffloat-store ; }
 tryflag CFLAGS_C99FSE -frounding-math
+fi
 
 #
 # We may use the may_alias attribute if __GNUC__ is defined, so

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-01-12 11:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-10  9:58 Clang warning silencing patch Dmitry Golovin
2017-01-10 10:34 ` Dmitry Golovin
2017-01-12  4:23   ` Rich Felker
2017-01-12 11:29     ` Dmitry Golovin

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).