arichardson created this revision. arichardson added reviewers: efriedma, dim. Herald added subscribers: cfe-commits, krytarowski, sdardis, emaste.
On FreeBSD it is currently not possible to use the clang builtin headers to build the base system. The build will fail with the following error if I don't delete the std* headers from the clang install directory: /sources/freebsd-mips/include/stdio.h:72:19: error: redefinition of typedef 'va_list' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef __va_list va_list; ^ /home/alr48/cheri/output/sdk/lib/clang/7.0.0/include/stdarg.h:30:27: note: previous definition is here typedef __builtin_va_list va_list; /sources/freebsd-mips/sys/sys/_stdarg.h:46:11: error: 'va_start' macro redefined [-Werror,-Wmacro-redefined] #define va_start(ap, last) __builtin_va_start((ap), (last)) ^ /home/alr48/cheri/output/sdk/lib/clang/7.0.0/include/stdarg.h:35:9: note: previous definition is here #define va_start(ap, param) __builtin_va_start(ap, param) FreeBSD includes definitions of va_list, va_copy, etc in the <machine/stdarg.h> header and some files end up including both that header and <stdarg.h>. Only defining the va_* macros if they are not yet defined fixes the macro redefiniton issue and probably also makes sense for other operating systems. However, for the va_list typedef I can't think of a better solution than to also check for _VA_LIST_DECLARED and define it. Repository: rC Clang https://reviews.llvm.org/D44604 Files: lib/Headers/stdarg.h Index: lib/Headers/stdarg.h =================================================================== --- lib/Headers/stdarg.h +++ lib/Headers/stdarg.h @@ -26,22 +26,33 @@ #ifndef __STDARG_H #define __STDARG_H -#ifndef _VA_LIST +#if !defined(_VA_LIST) && !defined(_VA_LIST_DECLARED) typedef __builtin_va_list va_list; #define _VA_LIST +#define _VA_LIST_DECLARED /* FreeBSD */ #endif +#ifndef va_start #define va_start(ap, param) __builtin_va_start(ap, param) +#endif +#ifndef va_end #define va_end(ap) __builtin_va_end(ap) +#endif +#ifndef va_arg #define va_arg(ap, type) __builtin_va_arg(ap, type) +#endif /* GCC always defines __va_copy, but does not define va_copy unless in c99 mode * or -ansi is not specified, since it was not part of C90. */ +#ifndef __va_copy #define __va_copy(d,s) __builtin_va_copy(d,s) +#endif #if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L || !defined(__STRICT_ANSI__) +#ifndef va_copy #define va_copy(dest, src) __builtin_va_copy(dest, src) #endif +#endif #ifndef __GNUC_VA_LIST #define __GNUC_VA_LIST 1
Index: lib/Headers/stdarg.h =================================================================== --- lib/Headers/stdarg.h +++ lib/Headers/stdarg.h @@ -26,22 +26,33 @@ #ifndef __STDARG_H #define __STDARG_H -#ifndef _VA_LIST +#if !defined(_VA_LIST) && !defined(_VA_LIST_DECLARED) typedef __builtin_va_list va_list; #define _VA_LIST +#define _VA_LIST_DECLARED /* FreeBSD */ #endif +#ifndef va_start #define va_start(ap, param) __builtin_va_start(ap, param) +#endif +#ifndef va_end #define va_end(ap) __builtin_va_end(ap) +#endif +#ifndef va_arg #define va_arg(ap, type) __builtin_va_arg(ap, type) +#endif /* GCC always defines __va_copy, but does not define va_copy unless in c99 mode * or -ansi is not specified, since it was not part of C90. */ +#ifndef __va_copy #define __va_copy(d,s) __builtin_va_copy(d,s) +#endif #if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L || !defined(__STRICT_ANSI__) +#ifndef va_copy #define va_copy(dest, src) __builtin_va_copy(dest, src) #endif +#endif #ifndef __GNUC_VA_LIST #define __GNUC_VA_LIST 1
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits