jgravelle-google created this revision. Herald added a subscriber: jfb. Current WebAssembly implementations use musl libc, which writes to signgam in its lgamma functions. We want the rest of the builtins to be const under -fno-math-errno, so overwrite lgamma's builtin definitions to be never-const.
https://reviews.llvm.org/D29736 Files: include/clang/Basic/BuiltinsWebAssembly.def Index: include/clang/Basic/BuiltinsWebAssembly.def =================================================================== --- include/clang/Basic/BuiltinsWebAssembly.def +++ include/clang/Basic/BuiltinsWebAssembly.def @@ -16,9 +16,21 @@ // The format of this database matches clang/Basic/Builtins.def. +#if defined(BUILTIN) && !defined(LIBBUILTIN) +# define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) BUILTIN(ID, TYPE, ATTRS) +#endif + // Note that current_memory is not "c" (readnone) because it must be sequenced // with respect to grow_memory calls. BUILTIN(__builtin_wasm_current_memory, "z", "n") BUILTIN(__builtin_wasm_grow_memory, "zz", "n") +// Redeclaring lgamma from Builtins.def as non-const to allow for POSIX +// compatibility. Specifically lgamma writes to a user-visible global, signgam, +// that is available in POSIX-compliant libcs. +LIBBUILTIN(lgamma, "dd", "fn", "math.h") +LIBBUILTIN(lgammaf, "ff", "fn", "math.h") +LIBBUILTIN(lgammal, "LdLd", "fn", "math.h") + #undef BUILTIN +#undef LIBBUILTIN
Index: include/clang/Basic/BuiltinsWebAssembly.def =================================================================== --- include/clang/Basic/BuiltinsWebAssembly.def +++ include/clang/Basic/BuiltinsWebAssembly.def @@ -16,9 +16,21 @@ // The format of this database matches clang/Basic/Builtins.def. +#if defined(BUILTIN) && !defined(LIBBUILTIN) +# define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) BUILTIN(ID, TYPE, ATTRS) +#endif + // Note that current_memory is not "c" (readnone) because it must be sequenced // with respect to grow_memory calls. BUILTIN(__builtin_wasm_current_memory, "z", "n") BUILTIN(__builtin_wasm_grow_memory, "zz", "n") +// Redeclaring lgamma from Builtins.def as non-const to allow for POSIX +// compatibility. Specifically lgamma writes to a user-visible global, signgam, +// that is available in POSIX-compliant libcs. +LIBBUILTIN(lgamma, "dd", "fn", "math.h") +LIBBUILTIN(lgammaf, "ff", "fn", "math.h") +LIBBUILTIN(lgammal, "LdLd", "fn", "math.h") + #undef BUILTIN +#undef LIBBUILTIN
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits