Skip to content

Instantly share code, notes, and snippets.

@basedjakfan2
Created February 5, 2022 15:42
Show Gist options
  • Save basedjakfan2/349a78f190d61b74e2a33c15ca265edf to your computer and use it in GitHub Desktop.
Save basedjakfan2/349a78f190d61b74e2a33c15ca265edf to your computer and use it in GitHub Desktop.
you will never be a real woman
From f0068c8695ecc519e9009e4adca74100e9fdf34b Mon Sep 17 00:00:00 2001
From: Taylor Berlioz <[email protected]>
Date: Sat, 5 Feb 2022 07:39:10 -0800
Subject: [PATCH] clang!
Signed-off-by: Taylor Berlioz <[email protected]>
---
Makeconfig | 12 ++
Makerules | 4 +-
benchtests/Makefile | 2 +
config.h.in | 3 +
config.make.in | 1 +
configure | 57 ++++++---
configure.ac | 31 ++++-
elf/Makefile | 11 ++
elf/dl-profile.c | 2 +
gmon/Makefile | 4 +
include/libc-symbols.h | 10 ++
inet/Makefile | 8 ++
io/Makefile | 4 +
math/Makefile | 10 +-
misc/Makefile | 4 +
nptl/Makefile | 5 +
nptl/pthread_create.c | 2 +
nss/Makefile | 4 +
posix/Makefile | 8 ++
resolv/Makefile | 5 +
rt/Makefile | 4 +
stdio-common/Makefile | 5 +
stdio-common/vfscanf-internal.c | 2 +
stdlib/Makefile | 5 +
stdlib/longlong.h | 186 ++++++++++++++--------------
sunrpc/Makefile | 6 +
sysdeps/generic/ldsodefs.h | 15 +++
sysdeps/i386/i686/Makefile | 2 +
sysdeps/ieee754/float128/Makeconfig | 2 +-
sysdeps/ieee754/float128/Makefile | 2 +
sysdeps/ieee754/ldbl-96/Makefile | 6 +
sysdeps/nptl/Makefile | 4 +
sysdeps/wordsize-64/Makefile | 5 +
sysdeps/x86/Makefile | 8 ++
sysdeps/x86/bits/floatn.h | 24 ++++
sysdeps/x86/fpu/math-barriers.h | 2 +-
sysdeps/x86_64/multiarch/Makefile | 57 +++++++++
time/Makefile | 6 +
wcsmbs/Makefile | 6 +
39 files changed, 416 insertions(+), 118 deletions(-)
diff --git a/Makeconfig b/Makeconfig
index 47db08d6..a028fbcf 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -940,6 +940,18 @@ ifeq "$(strip $(+cflags))" ""
+cflags := $(default_cflags)
endif # $(+cflags) == ""
+# For now, manually add known-needed clang flags here.
+ifeq ($(with-clang),yes)
+# Don't complain about __sigsetjmp.
++cflags += -Wno-builtin-requires-header
+# clang takes gnu89 as requiring a warning about duplicates, gcc does not
++cflags += -Wno-duplicate-decl-specifier
+# Non-string format arguments come from debugging prints in ld.so.
++cflags += -Wno-format-security
+# Don't complain about ignored attributes
++cflags += -Wno-ignored-attributes
+endif # with-clang == yes
+
# Force building with -fno-common because hidden_def, compat_symbol
# and other constructs do not work for common symbols (and would
# otherwise require specifying __attribute__ ((nocommon)) on a
diff --git a/Makerules b/Makerules
index 5de2cec6..b98985dc 100644
--- a/Makerules
+++ b/Makerules
@@ -584,7 +584,7 @@ $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
common-generated += shlib.lds
shlib-lds = $(common-objpfx)shlib.lds
-shlib-lds-flags = -T $(shlib-lds)
+shlib-lds-flags = -Wl,-T,$(shlib-lds)
endif
define build-shlib
@@ -637,7 +637,7 @@ LDFLAGS-c.so = -nostdlib -nostartfiles
# But we still want to link libc.so against $(libc.so-gnulib).
LDLIBS-c.so += $(libc.so-gnulib)
# Give libc.so an entry point and make it directly runnable itself.
-LDFLAGS-c.so += -e __libc_main
+LDFLAGS-c.so += -Wl,-e,__libc_main
# Pre-link the objects of libc_pic.a so that we can locally resolve
# COMMON symbols before we link against ld.so. This is because ld.so
# contains some of libc_pic.a already, which will prevent the COMMONs
diff --git a/benchtests/Makefile b/benchtests/Makefile
index 4c6af01c..9ff450bb 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -157,9 +157,11 @@ CFLAGS-bench-trunc.c += -fno-builtin
CFLAGS-bench-truncf.c += -fno-builtin
CFLAGS-bench-roundeven.c += -fno-builtin
CFLAGS-bench-roundevenf.c += -fno-builtin
+ifeq ($(with-clang),no)
CFLAGS-bench-isnan.c += -fsignaling-nans
CFLAGS-bench-isinf.c += -fsignaling-nans
CFLAGS-bench-isfinite.c += -fsignaling-nans
+endif
ifeq (${BENCHSET},)
bench-malloc := malloc-thread malloc-simple
diff --git a/config.h.in b/config.h.in
index ff859741..67d2cbf6 100644
--- a/config.h.in
+++ b/config.h.in
@@ -189,6 +189,9 @@
/* Define if CC supports attribute retain. */
#undef HAVE_GNU_RETAIN
+/* Define if our CC support __int128. */
+#define WANT_FLOAT128 0
+
/* Define to 1 if the assembler needs intermediate aliases to define
multiple symbol versions for one symbol. */
#define SYMVER_NEEDS_ALIAS 0
diff --git a/config.make.in b/config.make.in
index 6d43e691..ac60f6da 100644
--- a/config.make.in
+++ b/config.make.in
@@ -100,6 +100,7 @@ use-nscd = @use_nscd@
build-hardcoded-path-in-tests= @hardcoded_path_in_tests@
build-pt-chown = @build_pt_chown@
have-tunables = @have_tunables@
+enable-float128 = @enable_float128@
pthread-in-libc = @pthread_in_libc@
# Build tools.
diff --git a/configure b/configure
index 00dc6383..cb02ee45 100755
--- a/configure
+++ b/configure
@@ -667,6 +667,7 @@ stack_protector
libc_cv_ssp
libc_cv_with_fp
base_machine
+enable_float128
have_tunables
build_pt_chown
build_nscd
@@ -730,7 +731,6 @@ infodir
docdir
oldincludedir
includedir
-runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -760,6 +760,7 @@ with_gd_include
with_gd_lib
with_binutils
with_selinux
+with_clang
with_headers
with_default_link
with_nonshared_cflags
@@ -790,6 +791,7 @@ enable_build_nscd
enable_nscd
enable_pt_chown
enable_tunables
+enable_float128
enable_mathvec
enable_cet
enable_scv
@@ -845,7 +847,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1098,15 +1099,6 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
- -runstatedir | --runstatedir | --runstatedi | --runstated \
- | --runstate | --runstat | --runsta | --runst | --runs \
- | --run | --ru | --r)
- ac_prev=runstatedir ;;
- -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
- | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
- | --run=* | --ru=* | --r=*)
- runstatedir=$ac_optarg ;;
-
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1244,7 +1236,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir runstatedir
+ libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1397,7 +1389,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -1472,6 +1463,7 @@ Optional Features:
--enable-pt_chown Enable building and installing pt_chown
--enable-tunables Enable tunables support. Known values are 'yes',
'no' and 'valstring'
+ --disable-float128 disable float128 support
--enable-mathvec Enable building and installing mathvec [default
depends on architecture]
--enable-cet enable Intel Control-flow Enforcement Technology
@@ -1489,6 +1481,7 @@ Optional Packages:
--with-gd-lib=DIR find libgd library files in DIR
--with-binutils=PATH specify location of binutils (as and ld)
--with-selinux if building with SELinux support
+ --with-clang if building with clang (temporary)
--with-headers=PATH location of system headers to use (for example
/usr/src/linux/include) [default=compiler default]
--with-default-link do not use explicit linker scripts
@@ -3372,6 +3365,16 @@ else
fi
+# Check whether --with-clang was given.
+if test "${with_clang+set}" = set; then :
+ withval=$with_clang; with_clang=$withval
+else
+ with_clang=no
+fi
+
+config_vars="$config_vars
+with-clang = $with_clang"
+
# Check whether --with-headers was given.
if test "${with_headers+set}" = set; then :
@@ -3805,6 +3808,19 @@ if test "$have_tunables" = yes; then
fi
+# Check whether --enable-float128 was given.
+if test "${enable_float128+set}" = set; then :
+ enableval=$enable_float128; enable_float128=$enableval
+else
+ enable_float128=yes
+fi
+
+
+if test "$enable_float128" = yes; then
+ $as_echo "#define WANT_FLOAT128 1" >>confdefs.h
+
+fi
+
# The abi-tags file uses a fairly simplistic model for name recognition that
# can't distinguish i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a
# $host_os of `gnu*' here to be `gnu-gnu*' just so that it can tell.
@@ -5305,7 +5321,9 @@ main ()
{
#if !defined __GNUC__ || __GNUC__ < 6 || (__GNUC__ == 6 && __GNUC_MINOR__ < 2)
+#if !defined __clang__
#error insufficient compiler
+#endif
#endif
;
return 0;
@@ -6358,7 +6376,11 @@ $as_echo "$libc_cv_fno_toplevel_reorder" >&6; }
if test $libc_cv_fno_toplevel_reorder = yes; then
fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
else
- fno_unit_at_a_time=-fno-unit-at-a-time
+ if test "$with_clang" = no; then
+ fno_unit_at_a_time=-fno-unit-at-a-time
+ else
+ fno_unit_at_a_time=
+ fi
fi
@@ -6480,7 +6502,7 @@ rm -f conftest*
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_gcc_builtin_redirection" >&5
$as_echo "$libc_cv_gcc_builtin_redirection" >&6; }
-if test "$libc_cv_gcc_builtin_redirection" = no; then
+if test "$libc_cv_gcc_builtin_redirection" = no && test "$with_clang" = no; then
as_fn_error $? "support for the symbol redirection needed" "$LINENO" 5
fi
@@ -6546,7 +6568,7 @@ __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
foo (void) {}
EOF
libc_cv_cc_loop_to_function=no
-if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c'
+if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
(eval $ac_try) 2>&5
ac_status=$?
@@ -7108,8 +7130,11 @@ enable-static-pie = $libc_cv_static_pie"
# Set the `multidir' variable by grabbing the variable from the compiler.
# We do it once and save the result in a generated makefile.
+libc_cv_multidir=.
+if test "$with_clang" = no; then
libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
+fi
diff --git a/configure.ac b/configure.ac
index 87f67d25..d1b78a65 100644
--- a/configure.ac
+++ b/configure.ac
@@ -138,6 +138,12 @@ AC_ARG_WITH([selinux],
[if building with SELinux support]),
[with_selinux=$withval],
[with_selinux=auto])
+AC_ARG_WITH([clang],
+ AC_HELP_STRING([--with-clang],
+ [if building with clang (temporary)]),
+ [with_clang=$withval],
+ [with_clang=no])
+LIBC_CONFIG_VAR([with-clang], [$with_clang])
AC_ARG_WITH([headers],
AS_HELP_STRING([--with-headers=PATH],
@@ -452,6 +458,16 @@ if test "$have_tunables" = yes; then
AC_DEFINE(HAVE_TUNABLES)
fi
+AC_ARG_ENABLE([float128],
+ AC_HELP_STRING([--disable-float128],
+ [disable float128 support]),
+ [enable_float128=$enableval],
+ [enable_float128=yes])
+AC_SUBST(enable_float128)
+if test "$enable_float128" = yes; then
+ AC_DEFINE(WANT_FLOAT128)
+fi
+
# The abi-tags file uses a fairly simplistic model for name recognition that
# can't distinguish i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a
# $host_os of `gnu*' here to be `gnu-gnu*' just so that it can tell.
@@ -1061,7 +1077,9 @@ AC_CHECK_PROG_VER(BISON, bison, --version,
AC_CACHE_CHECK([if $CC is sufficient to build libc], libc_cv_compiler_ok, [
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
#if !defined __GNUC__ || __GNUC__ < 6 || (__GNUC__ == 6 && __GNUC_MINOR__ < 2)
+#if !defined __clang__
#error insufficient compiler
+#endif
#endif]])],
[libc_cv_compiler_ok=yes],
[libc_cv_compiler_ok=no])])
@@ -1493,7 +1511,11 @@ rm -f conftest*])
if test $libc_cv_fno_toplevel_reorder = yes; then
fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
else
- fno_unit_at_a_time=-fno-unit-at-a-time
+ if test "$with_clang" = no; then
+ fno_unit_at_a_time=-fno-unit-at-a-time
+ else
+ fno_unit_at_a_time=
+ fi
fi
AC_SUBST(fno_unit_at_a_time)
@@ -1573,7 +1595,7 @@ else
libc_cv_gcc_builtin_redirection=no
fi
rm -f conftest* ])
-if test "$libc_cv_gcc_builtin_redirection" = no; then
+if test "$libc_cv_gcc_builtin_redirection" = no && test "$with_clang" = no; then
AC_MSG_ERROR([support for the symbol redirection needed])
fi
@@ -1609,7 +1631,7 @@ __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
foo (void) {}
EOF
libc_cv_cc_loop_to_function=no
-if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c])
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
then
libc_cv_cc_loop_to_function=yes
fi
@@ -1906,8 +1928,11 @@ LIBC_CONFIG_VAR([enable-static-pie], [$libc_cv_static_pie])
# Set the `multidir' variable by grabbing the variable from the compiler.
# We do it once and save the result in a generated makefile.
+libc_cv_multidir=.
+if test "$with_clang" = no; then
libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
AC_SUBST(libc_cv_multidir)
+fi
AC_SUBST(profile)
AC_SUBST(static_nss)
diff --git a/elf/Makefile b/elf/Makefile
index 5bdf0a38..9b30d041 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -183,6 +183,17 @@ routines += unwind-dw2-fde-glibc
shared-only-routines += unwind-dw2-fde-glibc
endif
+ifeq ($(with-clang),yes)
+CFLAGS-dl-debug.c += -Wno-sometimes-uninitialized
+CFLAGS-dl-load.c += -Wno-format
+CFLAGS-dl-tunables.c += -Wno-format-invalid-specifier -Wno-format-extra-args
+CFLAGS-dl-lookup.c += -Wno-format-invalid-specifier -Wno-format-extra-args
+CFLAGS-rtld.c += -\
+ -Wno-string-plus-int \
+ -Wno-format-invalid-specifier \
+ -Wno-format-extra-args
+endif
+
before-compile += $(objpfx)trusted-dirs.h
generated += trusted-dirs.h trusted-dirs.st for-renamed/renamed.so
generated-dirs += for-renamed
diff --git a/elf/dl-profile.c b/elf/dl-profile.c
index 9359be7c..016eab7f 100644
--- a/elf/dl-profile.c
+++ b/elf/dl-profile.c
@@ -488,6 +488,7 @@ _dl_start_profile (void)
void
_dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc)
{
+#ifndef __clang__
volatile uint16_t *topcindex;
size_t i, fromindex;
struct here_fromstruct *fromp;
@@ -590,5 +591,6 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc)
done:
;
+#endif
}
rtld_hidden_def (_dl_mcount)
diff --git a/gmon/Makefile b/gmon/Makefile
index 552b7d77..7943b8ca 100644
--- a/gmon/Makefile
+++ b/gmon/Makefile
@@ -48,6 +48,10 @@ endif
# The mcount code won't work without a frame pointer.
CFLAGS-mcount.c := -fno-omit-frame-pointer
+ifeq ($(with-clang),yes)
+CFLAGS-sprofil.c += -Wno-unused-function
+endif
+
CFLAGS-tst-gmon.c := -fno-omit-frame-pointer -pg
tst-gmon-no-pie = yes
CRT-tst-gmon := $(csu-objpfx)g$(start-installed-name)
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index 662bd118..aaca0593 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -534,9 +534,19 @@ for linking")
__hidden_proto (name, , __GI_##name, ##attrs)
# define hidden_tls_proto(name, attrs...) \
__hidden_proto (name, __thread, __GI_##name, ##attrs)
+#ifndef __clang__
# define __hidden_proto(name, thread, internal, attrs...) \
extern thread __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
__hidden_proto_hiddenattr (attrs);
+#else
+# define __hidden_proto(name, thread, internal, attrs...) \
+ extern thread __typeof (name) name \
+ __hidden_proto_hiddenattr (attrs); \
+ _Pragma (__redefine(name, internal))
+/* Note that this macro does not use __hidden_asmname, since it produces a string. */
+# define __redefine(name, internal) __stringize(redefine_extname name internal)
+# define __stringize(X) #X
+#endif
# define __hidden_asmname(name) \
__hidden_asmname1 (__USER_LABEL_PREFIX__, name)
# define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
diff --git a/inet/Makefile b/inet/Makefile
index 9b96e57c..47773bd2 100644
--- a/inet/Makefile
+++ b/inet/Makefile
@@ -107,6 +107,14 @@ CFLAGS-either_hton.c += -fexceptions
CFLAGS-getnetgrent.c += -fexceptions
CFLAGS-getnetgrent_r.c += -fexceptions
+ifeq ($(with-clang),yes)
+CFLAGS-getnameinfo.c += -Wno-unknown-warning-option
+CFLAGS-inet6_scopeid_pton.c += -Wno-unknown-warning-option
+CFLAGS-idna_name_classify.c += -Wno-unknown-warning-option
+CFLAGS-idna.c += -Wno-unknown-warning-option
+CFLAGS-deadline.c += -Wno-unknown-warning-option
+endif
+
CFLAGS-tst-checks-posix.c += -std=c99
CFLAGS-tst-sockaddr.c += -fno-strict-aliasing
diff --git a/io/Makefile b/io/Makefile
index cf265dc9..a4ab023f 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -134,6 +134,10 @@ CFLAGS-read.c += -fexceptions -fasynchronous-unwind-tables
CFLAGS-write.c += -fexceptions -fasynchronous-unwind-tables
CFLAGS-close.c += -fexceptions -fasynchronous-unwind-tables
+ifeq ($(with-clang),yes)
+CFLAGS-fstatat64.c += -Wno-unused-function
+endif
+
CFLAGS-test-stat.c += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
CFLAGS-test-lfs.c += -D_LARGEFILE64_SOURCE
diff --git a/math/Makefile b/math/Makefile
index 7dae2313..8949ca62 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -420,8 +420,10 @@ CFLAGS-test-float-vlen16-wrappers.c += $(float-vlen16-arch-ext-cflags)
# raise spurious exceptions for sNaNs, but also do not test for
# exceptions. Thus both versions of the classification macros are
# validated.
-libm-test-no-inline-cflags = -fno-inline -ffloat-store -fno-builtin \
- -fsignaling-nans
+libm-test-no-inline-cflags = -fno-inline -ffloat-store -fno-builtin
+ifeq ($(with-clang),no)
+libm-test-no-inline-cflags += -fsignaling-nans
+endif
CFLAGS-test-tgmath.c += -fno-builtin
# The following testcase uses very long lines (>3 million), so it may take a
# while to compile it. See: http://llvm.org/bugs/show_bug.cgi?id=14106 and
@@ -430,7 +432,9 @@ CFLAGS-test-tgmath2.c += -fno-builtin
CFLAGS-test-tgmath-ret.c += -fno-builtin
CFLAGS-test-powl.c += -fno-builtin
+ifeq ($(with-clang),no)
CFLAGS-test-snan.c += -fsignaling-nans
+endif
CFLAGS-test-signgam-uchar.c += -std=c99
CFLAGS-test-signgam-uchar-init.c += -std=c99
@@ -766,12 +770,14 @@ CFLAGS-s_y1.c += -fno-builtin-y1l
CFLAGS-s_yn.c += -fno-builtin-ynl
endif
+ifeq ($(with-clang),no)
# These files quiet sNaNs in a way that is optimized away without
# -fsignaling-nans.
CFLAGS-s_modf.c += -fsignaling-nans
CFLAGS-s_modff.c += -fsignaling-nans
CFLAGS-s_modfl.c += -fsignaling-nans
CFLAGS-s_modff128.c += -fsignaling-nans
+endif
$(addprefix $(objpfx),\
$(filter-out $(tests-static) $(libm-tests-vector),\
diff --git a/misc/Makefile b/misc/Makefile
index 3d8a569d..1c50d68a 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -154,6 +154,10 @@ CFLAGS-mmap.op = $(no-stack-protector)
CFLAGS-mmap64.o = $(no-stack-protector)
CFLAGS-mmap64.op = $(no-stack-protector)
+ifeq ($(with-clang),yes)
+CFLAGS-mmap64.c += -Wno-error
+endif
+
include ../Rules
$(objpfx)libg.a: $(dep-dummy-lib); $(make-dummy-lib)
diff --git a/nptl/Makefile b/nptl/Makefile
index b5856639..104502eb 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -263,6 +263,11 @@ CFLAGS-sem_clockwait.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-futex-internal.c += -fexceptions -fasynchronous-unwind-tables
+ifeq ($(with-clang),yes)
+CFLAGS-pthread_join_common.c += -Wno-incompatible-pointer-types
+CFLAGS-pthread_create.c += -Wno-uninitialized
+endif
+
LDLIBS-tst-once5 = -lstdc++
CFLAGS-tst-thread_local1.o = -std=gnu++11
LDLIBS-tst-thread_local1 = -lstdc++
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index e7a099ac..8c567982 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -47,7 +47,9 @@
/* Globally enabled events. */
td_thr_events_t __nptl_threads_events;
libc_hidden_proto (__nptl_threads_events)
+#ifndef __clang__
libc_hidden_data_def (__nptl_threads_events)
+#endif
/* Pointer to descriptor with the last event. */
struct pthread *__nptl_last_event;
diff --git a/nss/Makefile b/nss/Makefile
index 552e5d03..478f1f95 100644
--- a/nss/Makefile
+++ b/nss/Makefile
@@ -134,6 +134,10 @@ tests-static += tst-nss-static
endif
extra-test-objs += nss_test1.os nss_test2.os
+ifeq ($(with-clang),yes)
+CFLAGS-nss_module.c += -Wno-string-plus-int
+endif
+
include ../Rules
ifeq (yes,$(have-selinux))
diff --git a/posix/Makefile b/posix/Makefile
index 9b30b53a..ced133eb 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -281,6 +281,14 @@ CFLAGS-execlp.os = -fomit-frame-pointer
CFLAGS-nanosleep.c += -fexceptions -fasynchronous-unwind-tables
CFLAGS-fork.c = $(libio-mtsafe)
+ifeq ($(with-clang),yes)
+CFLAGS-sysconf.c += -Wno-expansion-to-defined
+CFLAGS-getaddrinfo.c += \
+ -Wno-sometimes-uninitialized \
+ -Wno-unused-but-set-variable \
+ -Wno-unknown-warning-option
+endif
+
tstgetopt-ARGS = -a -b -cfoobar --required foobar --optional=bazbug \
--none random --col --color --colour
diff --git a/resolv/Makefile b/resolv/Makefile
index c465479e..c4662e26 100644
--- a/resolv/Makefile
+++ b/resolv/Makefile
@@ -196,6 +196,11 @@ libnss_dns-inhibit-o = $(filter-out .os,$(object-suffixes))
install-lib-ldscripts = libnss_dns.so
$(inst_libdir)/libnss_dns.so:
+ifeq ($(with-clang),yes)
+CFLAGS-res_init.c += -Wno-unknown-warning-option
+CFLAGS-res_send.c += -Wno-unknown-warning-option
+endif
+
ifeq ($(run-built-tests),yes)
ifneq (no,$(PERL))
tests-special += $(objpfx)mtrace-tst-leaks.out $(objpfx)mtrace-tst-leaks2.out \
diff --git a/rt/Makefile b/rt/Makefile
index bf24ac4f..0d8acb6c 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -100,6 +100,10 @@ CFLAGS-aio_suspend.c += -fexceptions
CFLAGS-mq_timedreceive.c += -fexceptions -fasynchronous-unwind-tables
CFLAGS-mq_timedsend.c += -fexceptions -fasynchronous-unwind-tables
+ifeq ($(with-clang),yes)
+CFLAGS-timer_create.c += -Wno-shift-negative-value
+endif
+
LDFLAGS-rt.so = -Wl,--enable-new-dtags,-z,nodelete
$(objpfx)librt.so: $(shared-thread-library)
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index d8498bbd..fc636bcd 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -190,6 +190,11 @@ CFLAGS-siglist.c += $(fno-unit-at-a-time)
CFLAGS-scanf14a.c += -std=gnu89
CFLAGS-scanf16a.c += -std=gnu89
+ifeq ($(with-clang),yes)
+CFLAGS-printf_fp.c += -Wno-expansion-to-defined
+CFLAGS-vfprintf-internal.c += -Wno-unknown-warning-option -Wno-tautological-constant-out-of-range-compare
+endif
+
CFLAGS-bug3.c += -DOBJPFX=\"$(objpfx)\"
CFLAGS-bug4.c += -DOBJPFX=\"$(objpfx)\"
CFLAGS-bug5.c += -DOBJPFX=\"$(objpfx)\"
diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-internal.c
index 2ad34050..7ce8a528 100644
--- a/stdio-common/vfscanf-internal.c
+++ b/stdio-common/vfscanf-internal.c
@@ -1535,7 +1535,9 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
above, but the test for "map != NULL" is done
inside the loop here and outside the loop there. */
DIAG_PUSH_NEEDS_COMMENT;
+#ifndef __clang__
DIAG_IGNORE_NEEDS_COMMENT (4.7, "-Wmaybe-uninitialized");
+#endif
if (__glibc_unlikely (map != NULL))
wcdigits[n] = wcdigits_extended[n];
diff --git a/stdlib/Makefile b/stdlib/Makefile
index 82367419..228ae830 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -206,6 +206,11 @@ CFLAGS-fmtmsg.c += -fexceptions
CFLAGS-strfmon.c += $(libio-mtsafe)
CFLAGS-strfmon_l.c += $(libio-mtsafe)
+ifeq ($(with-clang),yes)
+CFLAGS-setenv.c += -Wno-unknown-warning-option
+CFLAGS-fpioconst.c += -Wno-expansion-to-defined
+endif
+
# The strfrom class of functions call __printf_fp in order to convert the
# floating-point value to characters. This requires the value of IO_MTSAFE_IO.
CFLAGS-strfromd.c += $(libio-mtsafe)
diff --git a/stdlib/longlong.h b/stdlib/longlong.h
index 9b89469a..5b1fc3f6 100644
--- a/stdlib/longlong.h
+++ b/stdlib/longlong.h
@@ -194,8 +194,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
#if defined (__arc__) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add.f %1, %4, %5\n\tadc %0, %2, %3" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "%r" ((USItype) (ah)), \
"rICal" ((USItype) (bh)), \
"%r" ((USItype) (al)), \
@@ -203,8 +203,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
: "cc")
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub.f %1, %4, %5\n\tsbc %0, %2, %3" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "r" ((USItype) (ah)), \
"rICal" ((USItype) (bh)), \
"r" ((USItype) (al)), \
@@ -230,16 +230,16 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
&& W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("adds %1, %4, %5\n\tadc %0, %2, %3" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "%r" ((USItype) (ah)), \
"rI" ((USItype) (bh)), \
"%r" ((USItype) (al)), \
"rI" ((USItype) (bl)) __CLOBBER_CC)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("subs %1, %4, %5\n\tsbc %0, %2, %3" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "r" ((USItype) (ah)), \
"rI" ((USItype) (bh)), \
"r" ((USItype) (al)), \
@@ -262,8 +262,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
" addcs %0, %0, #65536\n" \
" adds %1, %1, %3, lsl #16\n" \
" adc %0, %0, %3, lsr #16" \
- : "=&r" ((USItype) (xh)), \
- "=r" ((USItype) (xl)), \
+ : "=&r" (xh), \
+ "=r" (xl), \
"=&r" (__t0), "=&r" (__t1), "=r" (__t2) \
: "r" ((USItype) (a)), \
"r" ((USItype) (b)) __CLOBBER_CC ); \
@@ -348,16 +348,16 @@ extern UDItype __umulsidi3 (USItype, USItype);
#if defined (__hppa) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add %4,%5,%1\n\taddc %2,%3,%0" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "%rM" ((USItype) (ah)), \
"rM" ((USItype) (bh)), \
"%rM" ((USItype) (al)), \
"rM" ((USItype) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub %4,%5,%1\n\tsubb %2,%3,%0" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "rM" ((USItype) (ah)), \
"rM" ((USItype) (bh)), \
"rM" ((USItype) (al)), \
@@ -456,30 +456,30 @@ extern UDItype __umulsidi3 (USItype, USItype);
#if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add{l} {%5,%1|%1,%5}\n\tadc{l} {%3,%0|%0,%3}" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "%0" ((USItype) (ah)), \
"g" ((USItype) (bh)), \
"%1" ((USItype) (al)), \
"g" ((USItype) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub{l} {%5,%1|%1,%5}\n\tsbb{l} {%3,%0|%0,%3}" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "0" ((USItype) (ah)), \
"g" ((USItype) (bh)), \
"1" ((USItype) (al)), \
"g" ((USItype) (bl)))
#define umul_ppmm(w1, w0, u, v) \
__asm__ ("mul{l} %3" \
- : "=a" ((USItype) (w0)), \
- "=d" ((USItype) (w1)) \
+ : "=a" (w0), \
+ "=d" (w1) \
: "%0" ((USItype) (u)), \
"rm" ((USItype) (v)))
#define udiv_qrnnd(q, r, n1, n0, dv) \
__asm__ ("div{l} %4" \
- : "=a" ((USItype) (q)), \
- "=d" ((USItype) (r)) \
+ : "=a" (q), \
+ "=d" (r) \
: "0" ((USItype) (n0)), \
"1" ((USItype) (n1)), \
"rm" ((USItype) (dv)))
@@ -492,30 +492,30 @@ extern UDItype __umulsidi3 (USItype, USItype);
#if defined (__x86_64__) && W_TYPE_SIZE == 64
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add{q} {%5,%1|%1,%5}\n\tadc{q} {%3,%0|%0,%3}" \
- : "=r" ((UDItype) (sh)), \
- "=&r" ((UDItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "%0" ((UDItype) (ah)), \
"rme" ((UDItype) (bh)), \
"%1" ((UDItype) (al)), \
"rme" ((UDItype) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub{q} {%5,%1|%1,%5}\n\tsbb{q} {%3,%0|%0,%3}" \
- : "=r" ((UDItype) (sh)), \
- "=&r" ((UDItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "0" ((UDItype) (ah)), \
"rme" ((UDItype) (bh)), \
"1" ((UDItype) (al)), \
"rme" ((UDItype) (bl)))
#define umul_ppmm(w1, w0, u, v) \
__asm__ ("mul{q} %3" \
- : "=a" ((UDItype) (w0)), \
- "=d" ((UDItype) (w1)) \
+ : "=a" (w0), \
+ "=d" (w1) \
: "%0" ((UDItype) (u)), \
"rm" ((UDItype) (v)))
#define udiv_qrnnd(q, r, n1, n0, dv) \
__asm__ ("div{q} %4" \
- : "=a" ((UDItype) (q)), \
- "=d" ((UDItype) (r)) \
+ : "=a" (q), \
+ "=d" (r) \
: "0" ((UDItype) (n0)), \
"1" ((UDItype) (n1)), \
"rm" ((UDItype) (dv)))
@@ -597,8 +597,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
/* The cmp clears the condition bit. */ \
__asm__ ("cmp %0,%0\n\taddx %1,%5\n\taddx %0,%3" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "0" ((USItype) (ah)), \
"r" ((USItype) (bh)), \
"1" ((USItype) (al)), \
@@ -607,8 +607,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
/* The cmp clears the condition bit. */ \
__asm__ ("cmp %0,%0\n\tsubx %1,%5\n\tsubx %0,%3" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "0" ((USItype) (ah)), \
"r" ((USItype) (bh)), \
"1" ((USItype) (al)), \
@@ -619,16 +619,16 @@ extern UDItype __umulsidi3 (USItype, USItype);
#if defined (__mc68000__) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add%.l %5,%1\n\taddx%.l %3,%0" \
- : "=d" ((USItype) (sh)), \
- "=&d" ((USItype) (sl)) \
+ : "=d" (sh), \
+ "=&d" (sl) \
: "%0" ((USItype) (ah)), \
"d" ((USItype) (bh)), \
"%1" ((USItype) (al)), \
"g" ((USItype) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub%.l %5,%1\n\tsubx%.l %3,%0" \
- : "=d" ((USItype) (sh)), \
- "=&d" ((USItype) (sl)) \
+ : "=d" (sh), \
+ "=&d" (sl) \
: "0" ((USItype) (ah)), \
"d" ((USItype) (bh)), \
"1" ((USItype) (al)), \
@@ -638,23 +638,23 @@ extern UDItype __umulsidi3 (USItype, USItype);
#if (defined (__mc68020__) && !defined (__mc68060__))
#define umul_ppmm(w1, w0, u, v) \
__asm__ ("mulu%.l %3,%1:%0" \
- : "=d" ((USItype) (w0)), \
- "=d" ((USItype) (w1)) \
+ : "=d" (w0), \
+ "=d" (w1) \
: "%0" ((USItype) (u)), \
"dmi" ((USItype) (v)))
#define UMUL_TIME 45
#define udiv_qrnnd(q, r, n1, n0, d) \
__asm__ ("divu%.l %4,%1:%0" \
- : "=d" ((USItype) (q)), \
- "=d" ((USItype) (r)) \
+ : "=d" (q), \
+ "=d" (r) \
: "0" ((USItype) (n0)), \
"1" ((USItype) (n1)), \
"dmi" ((USItype) (d)))
#define UDIV_TIME 90
#define sdiv_qrnnd(q, r, n1, n0, d) \
__asm__ ("divs%.l %4,%1:%0" \
- : "=d" ((USItype) (q)), \
- "=d" ((USItype) (r)) \
+ : "=d" (q), \
+ "=d" (r) \
: "0" ((USItype) (n0)), \
"1" ((USItype) (n1)), \
"dmi" ((USItype) (d)))
@@ -688,8 +688,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
" move%.l %/d2,%1\n" \
" add%.l %/d1,%/d0\n" \
" move%.l %/d0,%0" \
- : "=g" ((USItype) (xh)), \
- "=g" ((USItype) (xl)) \
+ : "=g" (xh)), \
+ "=g" (xl) \
: "g" ((USItype) (a)), \
"g" ((USItype) (b)) \
: "d0", "d1", "d2", "d3", "d4")
@@ -724,8 +724,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
" move%.l %/d2,%1\n" \
" add%.l %/d1,%/d0\n" \
" move%.l %/d0,%0" \
- : "=g" ((USItype) (xh)), \
- "=g" ((USItype) (xl)) \
+ : "=g" (xh)), \
+ "=g" (xl) \
: "g" ((USItype) (a)), \
"g" ((USItype) (b)) \
: "d0", "d1", "d2", "d3", "d4")
@@ -739,7 +739,7 @@ extern UDItype __umulsidi3 (USItype, USItype);
#if defined (__mc68020__) && !defined (__mcpu32__)
#define count_leading_zeros(count, x) \
__asm__ ("bfffo %1{%b2:%b2},%0" \
- : "=d" ((USItype) (count)) \
+ : "=d" (count) \
: "od" ((USItype) (x)), "n" (0))
/* Some ColdFire architectures have a ff1 instruction supported via
__builtin_clz. */
@@ -752,16 +752,16 @@ extern UDItype __umulsidi3 (USItype, USItype);
#if defined (__m88000__) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("addu.co %1,%r4,%r5\n\taddu.ci %0,%r2,%r3" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "%rJ" ((USItype) (ah)), \
"rJ" ((USItype) (bh)), \
"%rJ" ((USItype) (al)), \
"rJ" ((USItype) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("subu.co %1,%r4,%r5\n\tsubu.ci %0,%r2,%r3" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "rJ" ((USItype) (ah)), \
"rJ" ((USItype) (bh)), \
"rJ" ((USItype) (al)), \
@@ -988,16 +988,16 @@ extern UDItype __umulsidi3 (USItype, USItype);
#if defined (__ibm032__) /* RT/ROMP */ && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("a %1,%5\n\tae %0,%3" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "%0" ((USItype) (ah)), \
"r" ((USItype) (bh)), \
"%1" ((USItype) (al)), \
"r" ((USItype) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("s %1,%5\n\tse %0,%3" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "0" ((USItype) (ah)), \
"r" ((USItype) (bh)), \
"1" ((USItype) (al)), \
@@ -1026,8 +1026,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
" m r2,%3\n" \
" cas %0,r2,r0\n" \
" mfs r10,%1" \
- : "=r" ((USItype) (ph)), \
- "=r" ((USItype) (pl)) \
+ : "=r" (ph), \
+ "=r" (pl) \
: "%r" (__m0), \
"r" (__m1) \
: "r2"); \
@@ -1040,12 +1040,12 @@ extern UDItype __umulsidi3 (USItype, USItype);
do { \
if ((x) >= 0x10000) \
__asm__ ("clz %0,%1" \
- : "=r" ((USItype) (count)) \
+ : "=r" (count) \
: "r" ((USItype) (x) >> 16)); \
else \
{ \
__asm__ ("clz %0,%1" \
- : "=r" ((USItype) (count)) \
+ : "=r" (count) \
: "r" ((USItype) (x))); \
(count) += 16; \
} \
@@ -1107,8 +1107,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
#define umul_ppmm(w1, w0, u, v) \
__asm__ ( \
"dmulu.l %2,%3\n\tsts%M1 macl,%1\n\tsts%M0 mach,%0" \
- : "=r<" ((USItype)(w1)), \
- "=r<" ((USItype)(w0)) \
+ : "=r<" (w1), \
+ "=r<" (w0) \
: "r" ((USItype)(u)), \
"r" ((USItype)(v)) \
: "macl", "mach")
@@ -1179,8 +1179,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
&& W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("addcc %r4,%5,%1\n\taddx %r2,%3,%0" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "%rJ" ((USItype) (ah)), \
"rI" ((USItype) (bh)), \
"%rJ" ((USItype) (al)), \
@@ -1188,8 +1188,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
__CLOBBER_CC)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("subcc %r4,%5,%1\n\tsubx %r2,%3,%0" \
- : "=r" ((USItype) (sh)), \
- "=&r" ((USItype) (sl)) \
+ : "=r" (sh), \
+ "=&r" (sl) \
: "rJ" ((USItype) (ah)), \
"rI" ((USItype) (bh)), \
"rJ" ((USItype) (al)), \
@@ -1201,7 +1201,7 @@ extern UDItype __umulsidi3 (USItype, USItype);
register USItype __g1 asm ("g1"); \
__asm__ ("umul\t%2,%3,%1\n\t" \
"srlx\t%1, 32, %0" \
- : "=r" ((USItype) (w1)), \
+ : "=r" (w1), \
"=r" (__g1) \
: "r" ((USItype) (u)), \
"r" ((USItype) (v))); \
@@ -1212,8 +1212,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
"udiv\t%3,%4,%0\n\t" \
"umul\t%0,%4,%1\n\t" \
"sub\t%3,%1,%1" \
- : "=&r" ((USItype) (__q)), \
- "=&r" ((USItype) (__r)) \
+ : "=&r" (__q), \
+ "=&r" (__r) \
: "r" ((USItype) (__n1)), \
"r" ((USItype) (__n0)), \
"r" ((USItype) (__d)))
@@ -1221,14 +1221,14 @@ extern UDItype __umulsidi3 (USItype, USItype);
#if defined (__sparc_v8__)
#define umul_ppmm(w1, w0, u, v) \
__asm__ ("umul %2,%3,%1;rd %%y,%0" \
- : "=r" ((USItype) (w1)), \
- "=r" ((USItype) (w0)) \
+ : "=r" (w1), \
+ "=r" (w0) \
: "r" ((USItype) (u)), \
"r" ((USItype) (v)))
#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \
__asm__ ("mov %2,%%y;nop;nop;nop;udiv %3,%4,%0;umul %0,%4,%1;sub %3,%1,%1"\
- : "=&r" ((USItype) (__q)), \
- "=&r" ((USItype) (__r)) \
+ : "=&r" (__q), \
+ "=&r" (__r) \
: "r" ((USItype) (__n1)), \
"r" ((USItype) (__n0)), \
"r" ((USItype) (__d)))
@@ -1238,8 +1238,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
instructions scan (ffs from high bit) and divscc. */
#define umul_ppmm(w1, w0, u, v) \
__asm__ ("umul %2,%3,%1;rd %%y,%0" \
- : "=r" ((USItype) (w1)), \
- "=r" ((USItype) (w0)) \
+ : "=r" (w1), \
+ "=r" (w0) \
: "r" ((USItype) (u)), \
"r" ((USItype) (v)))
#define udiv_qrnnd(q, r, n1, n0, d) \
@@ -1282,8 +1282,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
" bl,a 1f\n" \
" add %1,%4,%1\n" \
"1: ! End of inline udiv_qrnnd" \
- : "=r" ((USItype) (q)), \
- "=r" ((USItype) (r)) \
+ : "=r" (q), \
+ "=r" (r) \
: "r" ((USItype) (n1)), \
"r" ((USItype) (n0)), \
"rI" ((USItype) (d)) \
@@ -1292,7 +1292,7 @@ extern UDItype __umulsidi3 (USItype, USItype);
#define count_leading_zeros(count, x) \
do { \
__asm__ ("scan %1,1,%0" \
- : "=r" ((USItype) (count)) \
+ : "=r" (count) \
: "r" ((USItype) (x))); \
} while (0)
/* Early sparclites return 63 for an argument of 0, but they warn that future
@@ -1342,8 +1342,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
" mulscc %%g1,0,%%g1\n" \
" add %%g1,%%o5,%0\n" \
" rd %%y,%1" \
- : "=r" ((USItype) (w1)), \
- "=r" ((USItype) (w0)) \
+ : "=r" (w1), \
+ "=r" (w0) \
: "%rI" ((USItype) (u)), \
"r" ((USItype) (v)) \
: "g1", "o5" __AND_CLOBBER_CC)
@@ -1375,8 +1375,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
" sub %1,%2,%1\n" \
"3: xnor %0,0,%0\n" \
" ! End of inline udiv_qrnnd" \
- : "=&r" ((USItype) (__q)), \
- "=&r" ((USItype) (__r)) \
+ : "=&r" (__q), \
+ "=&r" (__r) \
: "r" ((USItype) (__d)), \
"1" ((USItype) (__n1)), \
"0" ((USItype) (__n0)) : "g1" __AND_CLOBBER_CC)
@@ -1395,8 +1395,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
"add\t%r3,%4,%0\n\t" \
"movcs\t%%xcc, 1, %2\n\t" \
"add\t%0, %2, %0" \
- : "=r" ((UDItype)(sh)), \
- "=&r" ((UDItype)(sl)), \
+ : "=r" (sh), \
+ "=&r" (sl), \
"+r" (__carry) \
: "%rJ" ((UDItype)(ah)), \
"rI" ((UDItype)(bh)), \
@@ -1412,8 +1412,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
"sub\t%r3,%4,%0\n\t" \
"movcs\t%%xcc, 1, %2\n\t" \
"sub\t%0, %2, %0" \
- : "=r" ((UDItype)(sh)), \
- "=&r" ((UDItype)(sl)), \
+ : "=r" (sh), \
+ "=&r" (sl), \
"+r" (__carry) \
: "%rJ" ((UDItype)(ah)), \
"rI" ((UDItype)(bh)), \
@@ -1447,8 +1447,8 @@ extern UDItype __umulsidi3 (USItype, USItype);
"sllx %3,32,%3\n\t" \
"add %1,%3,%1\n\t" \
"add %5,%2,%0" \
- : "=r" ((UDItype)(wh)), \
- "=&r" ((UDItype)(wl)), \
+ : "=r" (wh), \
+ "=&r" (wl), \
"=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4) \
: "r" ((UDItype)(u)), \
"r" ((UDItype)(v)) \
@@ -1461,16 +1461,16 @@ extern UDItype __umulsidi3 (USItype, USItype);
#if defined (__vax__) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("addl2 %5,%1\n\tadwc %3,%0" \
- : "=g" ((USItype) (sh)), \
- "=&g" ((USItype) (sl)) \
+ : "=g" (sh)), \
+ "=&g" (sl) \
: "%0" ((USItype) (ah)), \
"g" ((USItype) (bh)), \
"%1" ((USItype) (al)), \
"g" ((USItype) (bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("subl2 %5,%1\n\tsbwc %3,%0" \
- : "=g" ((USItype) (sh)), \
- "=&g" ((USItype) (sl)) \
+ : "=g" (sh)), \
+ "=&g" (sl) \
: "0" ((USItype) (ah)), \
"g" ((USItype) (bh)), \
"1" ((USItype) (al)), \
diff --git a/sunrpc/Makefile b/sunrpc/Makefile
index a79a7195..64ba0869 100644
--- a/sunrpc/Makefile
+++ b/sunrpc/Makefile
@@ -97,6 +97,12 @@ CFLAGS-pmap_rmt.c += -fexceptions
CFLAGS-clnt_perr.c += -fexceptions
CFLAGS-openchild.c += -fexceptions
+ifeq ($(with-clang),yes)
+CFLAGS-clnt_udp.c += -Wno-unknown-warning-option
+CFLAGS-key_call.c += -Wno-parentheses-equality
+CFLAGS-svc_unix.c += -Wno-gnu-variable-sized-type-not-at-end
+endif
+
$(objpfx)tst-getmyaddr: $(common-objpfx)linkobj/libc.so
$(objpfx)tst-xdrmem: $(common-objpfx)linkobj/libc.so
$(objpfx)tst-xdrmem2: $(common-objpfx)linkobj/libc.so
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 2ebe7901..2a7adac5 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -831,13 +831,28 @@ extern void _dl_dprintf (int fd, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)))
attribute_hidden;
#else
+#if defined(__clang__)
+#include <stdarg.h>
+#endif
__attribute__ ((always_inline, __format__ (__printf__, 2, 3)))
static inline void
_dl_dprintf (int fd, const char *fmt, ...)
{
+#if defined(__clang__)
+ /* In the absence of __builtin_va_arg_pack, use varargs macros to construct a
+ direct call to the stdio function that __dprintf eventually gets to. This
+ is not a robust hack, will break if stdio changes much. */
+ extern int _IO_vdprintf (int d, const char *format, va_list arg);
+ va_list arg;
+
+ va_start (arg, fmt);
+ _IO_vdprintf (fd, fmt, arg);
+ va_end (arg);
+#else
/* Use local declaration to avoid includign <stdio.h>. */
extern int __dprintf(int fd, const char *format, ...) attribute_hidden;
__dprintf (fd, fmt, __builtin_va_arg_pack ());
+#endif
}
#endif
diff --git a/sysdeps/i386/i686/Makefile b/sysdeps/i386/i686/Makefile
index 31104278..35e0d2fd 100644
--- a/sysdeps/i386/i686/Makefile
+++ b/sysdeps/i386/i686/Makefile
@@ -1,6 +1,7 @@
# So that we can test __m128's alignment
stack-align-test-flags += -msse
+ifeq ($(with-clang),no)
CFLAGS-.o += -Wa,-mtune=i686
CFLAGS-.os += -Wa,-mtune=i686
CFLAGS-.op += -Wa,-mtune=i686
@@ -10,3 +11,4 @@ ASFLAGS-.o += -Wa,-mtune=i686
ASFLAGS-.os += -Wa,-mtune=i686
ASFLAGS-.op += -Wa,-mtune=i686
ASFLAGS-.oS += -Wa,-mtune=i686
+endif
diff --git a/sysdeps/ieee754/float128/Makeconfig b/sysdeps/ieee754/float128/Makeconfig
index a493ff1d..99ae5e07 100644
--- a/sysdeps/ieee754/float128/Makeconfig
+++ b/sysdeps/ieee754/float128/Makeconfig
@@ -1,4 +1,4 @@
# Include this earlier so it can be used earlier in Makefiles,
# and sysdep/ makefiles.
-float128-fcts = yes
+float128-fcts = $(enable-float128)
float64x-alias-fcts = yes
diff --git a/sysdeps/ieee754/float128/Makefile b/sysdeps/ieee754/float128/Makefile
index 571a8418..70bb3ac4 100644
--- a/sysdeps/ieee754/float128/Makefile
+++ b/sysdeps/ieee754/float128/Makefile
@@ -1,3 +1,4 @@
+ifeq ($(enable-float128),yes)
ifeq ($(subdir),stdlib)
routines += float1282mpn strfromf128
routines += strtof128 strtof128_l strtof128_nan mpn2float128
@@ -10,3 +11,4 @@ endif
ifeq ($(subdir),wcsmbs)
routines += wcstof128_l wcstof128 wcstof128_nan
endif
+endif # enable-float128
diff --git a/sysdeps/ieee754/ldbl-96/Makefile b/sysdeps/ieee754/ldbl-96/Makefile
index 1618f8ef..5da732db 100644
--- a/sysdeps/ieee754/ldbl-96/Makefile
+++ b/sysdeps/ieee754/ldbl-96/Makefile
@@ -22,3 +22,9 @@ ifeq ($(have-ssp),yes)
CFLAGS-test-sinl-pseudo.c += -fstack-protector-all
endif
endif # $(subdir) == math
+
+ifeq ($(with-clang),yes)
+CFLAGS-strtold_l.c += -Wno-expansion-to-defined
+CFLAGS-strtof_l.c += -Wno-expansion-to-defined
+CFLAGS-strtod_l.c += -Wno-expansion-to-defined
+endif
diff --git a/sysdeps/nptl/Makefile b/sysdeps/nptl/Makefile
index edeaed8a..2c130777 100644
--- a/sysdeps/nptl/Makefile
+++ b/sysdeps/nptl/Makefile
@@ -25,3 +25,7 @@ endif
ifeq ($(subdir),posix)
CFLAGS-confstr.c += -DLIBPTHREAD_VERSION='"NPTL $(version)"'
endif
+
+ifeq ($(with-clang),yes)
+CFLAGS-jmp-unwind.c += -Wno-uninitialized
+endif
diff --git a/sysdeps/wordsize-64/Makefile b/sysdeps/wordsize-64/Makefile
index 2fa93475..bb16f6d1 100644
--- a/sysdeps/wordsize-64/Makefile
+++ b/sysdeps/wordsize-64/Makefile
@@ -1,3 +1,8 @@
ifeq ($(subdir),misc)
tests += tst-writev
endif
+
+ifeq ($(with-clang),yes)
+CFLAGS-strtol.c += -Wno-incompatible-library-redeclaration
+CFLAGS-strtoul.c += -Wno-incompatible-library-redeclaration
+endif
diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
index 6cf70833..a1a4669d 100644
--- a/sysdeps/x86/Makefile
+++ b/sysdeps/x86/Makefile
@@ -10,6 +10,10 @@ sysdep_headers += sys/platform/x86.h bits/platform/x86.h
CFLAGS-dl-get-cpu-features.os += $(rtld-early-cflags)
CFLAGS-get-cpuid-feature-leaf.o += $(no-stack-protector)
+ifeq ($(with-clang),yes)
+CFLAGS-dl-get-cpu-features.c += -Wno-unknown-attributes -Wno-unused-function
+endif
+
tests += tst-get-cpu-features tst-get-cpu-features-static \
tst-cpu-features-cpuinfo tst-cpu-features-cpuinfo-static \
tst-cpu-features-supports tst-cpu-features-supports-static
@@ -89,6 +93,10 @@ endif
ifeq ($(subdir),string)
sysdep_routines += cacheinfo
+ifeq ($(with-clang),yes)
+CFLAGS-cacheinfo.c += -Wno-unknown-attributes -Wno-unused-function
+endif
+
tests += \
tst-memchr-rtm \
tst-memcmp-rtm \
diff --git a/sysdeps/x86/bits/floatn.h b/sysdeps/x86/bits/floatn.h
index 34a6fdc8..fd530220 100644
--- a/sysdeps/x86/bits/floatn.h
+++ b/sysdeps/x86/bits/floatn.h
@@ -21,6 +21,8 @@
#include <features.h>
+#define capture(sym, val) extern int sym[val]
+
/* Defined to 1 if the current compiler invocation provides a
floating-point type with the IEEE 754 binary128 format, and this
glibc includes corresponding *f128 interfaces for it. The required
@@ -55,6 +57,9 @@
#ifndef __ASSEMBLER__
+capture(i_have_float128, __HAVE_FLOAT128);
+capture(i_have_distinct_float128, __HAVE_DISTINCT_FLOAT128);
+
/* Defined to concatenate the literal suffix to be used with _Float128
types, if __HAVE_FLOAT128 is 1. */
# if __HAVE_FLOAT128
@@ -86,6 +91,19 @@ typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
typedef __float128 _Float128;
# endif
+#if defined __clang__
+
+#define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ())
+#define __builtin_inff128() ((_Float128) __builtin_inf ())
+#define __builtin_nanf128(x) ((_Float128) __builtin_nan (x))
+#define __builtin_nansf128(x) ((_Float128) __builtin_nans (x))
+
+#define __builtin_copysignf128(x,y) ((_Float128) __builtin_copysign ((double)(x),(double)(y)))
+#define __builtin_fabsf128(x) ((_Float128) __builtin_fabs ((double)(x)))
+#define __builtin_signbitf128(x) (__builtin_signbit (x))
+
+#else /* GCC */
+
/* __builtin_huge_valf128 doesn't exist before GCC 7.0. */
# if !__GNUC_PREREQ (7, 0)
# define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ())
@@ -112,8 +130,14 @@ typedef __float128 _Float128;
# define __builtin_signbitf128 __signbitf128
# endif
+#endif /* clang or GCC */
+
# endif
+#if !__HAVE_FLOAT128 && defined __clang__
+typedef long double _Float128;
+#endif
+
#endif /* !__ASSEMBLER__. */
#include <bits/floatn-common.h>
diff --git a/sysdeps/x86/fpu/math-barriers.h b/sysdeps/x86/fpu/math-barriers.h
index cbe665a4..1b9fea9c 100644
--- a/sysdeps/x86/fpu/math-barriers.h
+++ b/sysdeps/x86/fpu/math-barriers.h
@@ -19,7 +19,7 @@
#ifndef X86_MATH_BARRIERS_H
#define X86_MATH_BARRIERS_H 1
-#ifdef __SSE2_MATH__
+#if defined(__SSE2_MATH__) && !defined(__clang__)
# define math_opt_barrier(x) \
({ __typeof(x) __x; \
if (sizeof (x) <= sizeof (double) \
diff --git a/sysdeps/x86_64/multiarch/Makefile b/sysdeps/x86_64/multiarch/Makefile
index 04477858..6be44fe2 100644
--- a/sysdeps/x86_64/multiarch/Makefile
+++ b/sysdeps/x86_64/multiarch/Makefile
@@ -88,6 +88,40 @@ CFLAGS-varshift.c += -msse4
CFLAGS-strcspn-c.c += -msse4
CFLAGS-strpbrk-c.c += -msse4
CFLAGS-strspn-c.c += -msse4
+
+ifeq ($(with-clang),yes)
+CFLAGS-strcspn.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strchr.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strcpy.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strcmp.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strcat.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strlen.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strspn.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strstr.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strnlen.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strncmp.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strncpy.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strncat.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strrchr.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strpbrk.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-stpcpy.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-stpncpy.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-memcpy.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-memcmp.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-memchr.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-memrchr.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-memmove.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-memset.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-memcmpeq.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-mempcpy.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strcasecmp.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strcasecmp_l.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strncase.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strncase_l.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-strchrnul.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-rawmemchr.c += -Wno-unknown-attributes -Wno-unused-function
+endif
+
endif
ifeq ($(subdir),wcsmbs)
@@ -118,10 +152,33 @@ sysdep_routines += wmemcmp-sse4 wmemcmp-ssse3 wmemcmp-c \
wmemchr-evex \
wmemcmp-evex-movbe \
wmemchr-evex-rtm
+
+ifeq ($(with-clang),yes)
+CFLAGS-wcschr.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-wcslen.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-wcscmp.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-wcscpy.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-wcsncmp.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-wcsnlen.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-wcsrchr.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-wmemcmp.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-wmemchr.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-wmemset.c += -Wno-unknown-attributes -Wno-unused-function
+endif
+
endif
ifeq ($(subdir),debug)
sysdep_routines += memcpy_chk-nonshared mempcpy_chk-nonshared \
memmove_chk-nonshared memset_chk-nonshared \
wmemset_chk-nonshared
+
+ifeq ($(with-clang),yes)
+CFLAGS-memcpy_chk.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-memmove_chk.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-mempcpy_chk.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-memset_chk.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-wmemset_chk.c += -Wno-unknown-attributes -Wno-unused-function
+endif
+
endif
diff --git a/time/Makefile b/time/Makefile
index 470275b9..0850fd57 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -102,6 +102,12 @@ CFLAGS-nanosleep.c += -fexceptions -fasynchronous-unwind-tables
# Don't warn about Y2k problem in strftime format string.
CFLAGS-test_time.c += -Wno-format
+ifeq ($(with-clang),yes)
+CFLAGS-clock_nanosleep.c += -Wno-shift-negative-value
+CFLAGS-time.c += -Wno-unknown-attributes -Wno-unused-function
+CFLAGS-gettimeofday.c += -Wno-unknown-attributes -Wno-unused-function
+endif
+
tst-getdate-ENV= DATEMSK=datemsk TZDIR=${common-objpfx}timezone/testdata
test_time-ARGS= EST5EDT CST
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
index df9a85f4..7ab0d6b6 100644
--- a/wcsmbs/Makefile
+++ b/wcsmbs/Makefile
@@ -103,6 +103,12 @@ CFLAGS-isoc99_fwscanf.c += -fexceptions
CFLAGS-isoc99_vwscanf.c += -fexceptions
CFLAGS-isoc99_vfwscanf.c += -fexceptions
+ifeq ($(with-clang),yes)
+CFLAGS-wcstold_l.c += -Wno-expansion-to-defined
+CFLAGS-wcstod_l.c += -Wno-expansion-to-defined
+CFLAGS-wcstof_l.c += -Wno-expansion-to-defined
+endif
+
CPPFLAGS += $(libio-mtsafe)
# We need to find the default version of strtold_l in stdlib.
--
2.34.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment