Problem building 9.4.7 on Fedora 36 (bytestring/cbits/is-valid-utf8.c)

Viktor Dukhovni ietf-dane at dukhovni.org
Tue Aug 8 15:33:52 UTC 2023


The build was failing, because rts/OSThreads.h via Rts.h from
libraries/bytestring/cbits/is-valid-utf8.c had no definition of
`clockid_t`.  This type is not exposed with _POSIX_C_SOURCE is
not defined to a sufficiently high value:

    SYNOPSIS
           #include <time.h>

           int clock_getres(clockid_t clockid, struct timespec *res);

           int clock_gettime(clockid_t clockid, struct timespec *tp);
           int clock_settime(clockid_t clockid, const struct timespec *tp);

           Link with -lrt (only for glibc versions before 2.17).

       Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

           clock_getres(), clock_gettime(), clock_settime():
               _POSIX_C_SOURCE >= 199309L

I quick-and-dirty work-around was:

--- a/libraries/bytestring/cbits/is-valid-utf8.c
+++ b/libraries/bytestring/cbits/is-valid-utf8.c
@@ -27,6 +27,10 @@ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 SUCH DAMAGE.
 */
+#undef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 200809L
+#undef _XOPEN_SOURCE
+#define _XOPEN_SOURCE   700
 #pragma GCC push_options
 #pragma GCC optimize("-O2")
 #include <stdbool.h>


There's surely a better solution.

-- 
    Viktor.


More information about the ghc-devs mailing list