Skip to content

Building the math module fails on FreeBSD: sinpi, cospi and tanpi are not declared in math.h #154136

Description

@serhiy-storchaka

Bug report

Building main on FreeBSD (tested 15.1-RELEASE) fails since gh-150534:

./Modules/mathmodule.c:566:24: error: call to undeclared function 'sinpi'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration]

FreeBSD's libm exports cospi, sinpi and tanpi, but math.h declares them only for C23. CPython compiles with -std=c11 and defines _POSIX_C_SOURCE/_XOPEN_SOURCE, which reduces header visibility to C11. The link-only AC_CHECK_FUNCS test still finds the symbols and defines HAVE_SINPI etc., so compiling Modules/mathmodule.c fails. Linux is unaffected because glibc's _GNU_SOURCE implies _ISOC23_SOURCE.

The fix is to define _ISOC23_SOURCE, the feature-test macro both FreeBSD and glibc honor: the declarations become visible and the native libm implementations are actually used (FreeBSD's tanpi(0.25) returns exactly 1.0).

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.16new features, bugs and security fixesbuildThe build process and cross-buildextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions