Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python defines __BSD_VISIBLE 1 in pyconfig.h #5113

Open
1 task done
teepean opened this issue Jan 5, 2025 · 8 comments
Open
1 task done

Python defines __BSD_VISIBLE 1 in pyconfig.h #5113

teepean opened this issue Jan 5, 2025 · 8 comments
Labels

Comments

@teepean
Copy link

teepean commented Jan 5, 2025

Description / Steps to reproduce the issue

  1. Install latest Python with pacman
  2. $ cat /usr/include/python3.12/pyconfig.h | grep BSD_VISIBLE
    #define __BSD_VISIBLE 1

Expected behavior

It should be:
$ cat /usr/include/python3.12/pyconfig.h | grep BSD_VISIBLE
/* #undef __BSD_VISIBLE */

Actual behavior

For some reason __BSD_VISIBLE is defined as 1 on MSYS2.

Verification

Windows Version

MINGW64_NT-10.0-27764

Are you willing to submit a PR?

No response

@teepean teepean added the bug label Jan 5, 2025
@Biswa96
Copy link
Member

Biswa96 commented Jan 5, 2025

Could you please provide the reasons why that constant should not be defined?

@teepean
Copy link
Author

teepean commented Jan 5, 2025

No other reason than it is undefined in earlier Cygwin versions.

$ cat /usr/include/python3.9/pyconfig.h | grep BSD_VISIBLE
/* #undef __BSD_VISIBLE */

@Biswa96
Copy link
Member

Biswa96 commented Jan 5, 2025

Does defining it cause any issue?

@teepean
Copy link
Author

teepean commented Jan 5, 2025

When compiling numpy and __BSD_VISIBLE is defined:

  [250/530] Compiling C object numpy/_core/libloops_comparison.dispatch.h_baseline.a.p/meson-generated_loops_comparison.dispatch.c.o
  [251/530] Compiling C++ object numpy/_core/libloops_trigonometric.dispatch.h_AVX2.a.p/src_umath_loops_trigonometric.dispatch.cpp.o
  FAILED: numpy/_core/libloops_trigonometric.dispatch.h_AVX2.a.p/src_umath_loops_trigonometric.dispatch.cpp.o
  c++ -Inumpy/_core/libloops_trigonometric.dispatch.h_AVX2.a.p -Inumpy/_core -I../numpy/_core -Inumpy/_core/include -I../numpy/_core/include -I../numpy/_core/src/common -I../numpy/_core/src/multiarray -I../numpy/_core/src/npymath -I../numpy/_core/src/umath -I../numpy/_core/src/highway -I/usr/include/python3.12 -I/home/Teemu/numpy-2.2.1/.mesonpy-yh8ftx2h/meson_cpu -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -msse -msse2 -msse3 -DNPY_INTERNAL_BUILD -DHAVE_NPY_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -fno-exceptions -fno-rtti -O3 -DNPY_HAVE_SSE2 -DNPY_HAVE_SSE -DNPY_HAVE_SSE3 -DNPY_HAVE_SSSE3 -DNPY_HAVE_SSE41 -DNPY_HAVE_POPCNT -DNPY_HAVE_SSE42 -DNPY_HAVE_AVX -DNPY_HAVE_F16C -DNPY_HAVE_FMA3 -DNPY_HAVE_AVX2 -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2 -maes -mpclmul -mbmi -mbmi2 -DNPY_MTARGETS_CURRENT=AVX2 -MD -MQ numpy/_core/libloops_trigonometric.dispatch.h_AVX2.a.p/src_umath_loops_trigonometric.dispatch.cpp.o -MF numpy/_core/libloops_trigonometric.dispatch.h_AVX2.a.p/src_umath_loops_trigonometric.dispatch.cpp.o.d -o numpy/_core/libloops_trigonometric.dispatch.h_AVX2.a.p/src_umath_loops_trigonometric.dispatch.cpp.o -c ../numpy/_core/src/umath/loops_trigonometric.dispatch.cpp
  In file included from /usr/include/python3.12/Python.h:12,
                   from ../numpy/_core/include/numpy/npy_common.h:5,
                   from ../numpy/_core/src/common/simd/simd.h:12,
                   from ../numpy/_core/src/umath/fast_loop_macros.h:15,
                   from ../numpy/_core/src/umath/loops_trigonometric.dispatch.cpp:1:
  /usr/include/python3.12/pyconfig.h:1898: warning: "__BSD_VISIBLE" redefined
   1898 | #define __BSD_VISIBLE 1
        |
  In file included from /usr/include/sys/config.h:5,
                   from /usr/include/_ansi.h:11,
                   from /usr/include/assert.h:9,
                   from ../numpy/_core/src/umath/fast_loop_macros.h:13:
  /usr/include/sys/features.h:265: note: this is the location of the previous definition
    265 | #define __BSD_VISIBLE           0
        |
  In file included from /usr/include/python3.12/pyport.h:202,
                   from /usr/include/python3.12/Python.h:38:
  /usr/include/sys/time.h:106:34: error: ‘u_int’ has not been declared
    106 | bintime_mul(struct bintime *_bt, u_int _x)
        |                                  ^~~~~
  [252/530] Compiling C++ object numpy/_core/libloops_trigonometric.dispatch.h_AVX512_SKX.a.p/src_umath_loops_trigonometric.dispatch.cpp.o
  FAILED: numpy/_core/libloops_trigonometric.dispatch.h_AVX512_SKX.a.p/src_umath_loops_trigonometric.dispatch.cpp.o
  c++ -Inumpy/_core/libloops_trigonometric.dispatch.h_AVX512_SKX.a.p -Inumpy/_core -I../numpy/_core -Inumpy/_core/include -I../numpy/_core/include -I../numpy/_core/src/common -I../numpy/_core/src/multiarray -I../numpy/_core/src/npymath -I../numpy/_core/src/umath -I../numpy/_core/src/highway -I/usr/include/python3.12 -I/home/Teemu/numpy-2.2.1/.mesonpy-yh8ftx2h/meson_cpu -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++17 -O3 -msse -msse2 -msse3 -DNPY_INTERNAL_BUILD -DHAVE_NPY_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -fno-exceptions -fno-rtti -O3 -DNPY_HAVE_SSE2 -DNPY_HAVE_SSE -DNPY_HAVE_SSE3 -DNPY_HAVE_SSSE3 -DNPY_HAVE_SSE41 -DNPY_HAVE_POPCNT -DNPY_HAVE_SSE42 -DNPY_HAVE_AVX -DNPY_HAVE_F16C -DNPY_HAVE_FMA3 -DNPY_HAVE_AVX2 -DNPY_HAVE_AVX512F -DNPY_HAVE_AVX512F_REDUCE -DNPY_HAVE_AVX512CD -DNPY_HAVE_AVX512_SKX -DNPY_HAVE_AVX512VL -DNPY_HAVE_AVX512BW -DNPY_HAVE_AVX512DQ -DNPY_HAVE_AVX512BW_MASK -DNPY_HAVE_AVX512DQ_MASK -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2 -maes -mpclmul -mbmi -mbmi2 -mno-mmx -mavx512f -mavx512cd -mavx512vl -mavx512bw -mavx512dq -DNPY_MTARGETS_CURRENT=AVX512_SKX -MD -MQ numpy/_core/libloops_trigonometric.dispatch.h_AVX512_SKX.a.p/src_umath_loops_trigonometric.dispatch.cpp.o -MF numpy/_core/libloops_trigonometric.dispatch.h_AVX512_SKX.a.p/src_umath_loops_trigonometric.dispatch.cpp.o.d -o numpy/_core/libloops_trigonometric.dispatch.h_AVX512_SKX.a.p/src_umath_loops_trigonometric.dispatch.cpp.o -c ../numpy/_core/src/umath/loops_trigonometric.dispatch.cpp
  In file included from /usr/include/python3.12/Python.h:12,
                   from ../numpy/_core/include/numpy/npy_common.h:5,
                   from ../numpy/_core/src/common/simd/simd.h:12,
                   from ../numpy/_core/src/umath/fast_loop_macros.h:15,
                   from ../numpy/_core/src/umath/loops_trigonometric.dispatch.cpp:1:
  /usr/include/python3.12/pyconfig.h:1898: warning: "__BSD_VISIBLE" redefined
   1898 | #define __BSD_VISIBLE 1
        |
  In file included from /usr/include/sys/config.h:5,
                   from /usr/include/_ansi.h:11,
                   from /usr/include/assert.h:9,
                   from ../numpy/_core/src/umath/fast_loop_macros.h:13:
  /usr/include/sys/features.h:265: note: this is the location of the previous definition
    265 | #define __BSD_VISIBLE           0
        |
  In file included from /usr/include/python3.12/pyport.h:202,
                   from /usr/include/python3.12/Python.h:38:
  /usr/include/sys/time.h:106:34: error: ‘u_int’ has not been declared
    106 | bintime_mul(struct bintime *_bt, u_int _x)
        |                                  ^~~~~
  [253/530] Compiling C object numpy/_core/libloops_comparison.dispatch.h_AVX2.a.p/meson-generated_loops_comparison.dispatch.c.o

When it is undefined:

  [248/530] Compiling C++ object numpy/_core/libloops_trigonometric.dispatch.h_baseline.a.p/src_umath_loops_trigonometric.dispatch.cpp.o
  [249/530] Compiling C object numpy/_core/libloops_unary_fp_le.dispatch.h_SSE41.a.p/meson-generated_loops_unary_fp_le.dispatch.c.o

@Biswa96
Copy link
Member

Biswa96 commented Jan 5, 2025

There is a mingw numpy package https://packages.msys2.org/base/mingw-w64-python-numpy. msys python is used for bootstrapping purposes.

@teepean
Copy link
Author

teepean commented Jan 5, 2025

I am aware of MinGW packages but I got the idea to use MSYS2 as a Cygwin replacement.

@jeremyd2019
Copy link
Member

That's odd, it looks like __BSD_VISIBLE was defined to 1 unconditionally in configure.ac, git blame traces it back to 2003. Recently, there was a commit that touched that line that quoted things from autoconf, perhaps that fixed it so that it is now actually defined?

@jeremyd2019
Copy link
Member

I think this is a bug with numpy, it should be including Python.h before any system header (such as assert.h) to make sure the feature macros are all set as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants