Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BLD: clean up incorrect-but-hardcoded define for strtold_l check. #24979

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

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions numpy/_core/feature_detection_locale.h

This file was deleted.

46 changes: 14 additions & 32 deletions numpy/_core/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -255,37 +255,6 @@ foreach filefunc_maybe: optional_file_funcs
endif
endforeach

# Optional locale function
have_strtold_l = cc.has_function('strtold_l', include_directories: inc_curdir,
prefix:'''
#include <stdlib.h>
#include <xlocale.h>
#include "feature_detection_locale.h"
''')
if not have_strtold_l
# Retry with locale.h, seems to vary across Linux distros
have_strtold_l = cc.has_function('strtold_l', include_directories: inc_curdir,
prefix:'''
#include <stdlib.h>
#include <locale.h>
#include "feature_detection_locale.h"
''')
endif
if have_strtold_l
cdata.set10('HAVE_STRTOLD_L', true)
else
# FIXME: this is wrong! the HAVE_ define should not exist, or it'll be
# interpreted as the function being available (true/false does nothing, see
# note on HAVE_ defines higher up). This is necessary though in order to make
# the Linux CI job pass. So either the check is wrong somehow, or this
# function is not available in CI. For the latter there is a fallback path,
# but that is broken because we don't have the exact long double
# representation checks.
if cc.get_argument_syntax() != 'msvc'
cdata.set10('HAVE_STRTOLD_L', false)
endif
endif

# Other optional functions
optional_misc_funcs = [
'backtrace',
Expand All @@ -303,7 +272,7 @@ endforeach
# SSE headers only enabled automatically on amd64/x32 builds
optional_headers = [
'features.h', # for glibc version linux
'xlocale.h', # see GH#8367
'xlocale.h', # removed in glibc 2.26, but may still be useful - see gh-8367
'dlfcn.h', # dladdr
'execinfo.h', # backtrace
'libunwind.h', # backtrace for LLVM/Clang using libunwind
Expand All @@ -315,6 +284,19 @@ foreach header: optional_headers
endif
endforeach

# Optional locale function - GNU-specific
_strtold_prefix = '''
#define _GNU_SOURCE
#include <locale.h>
#include <stdlib.h>
'''
if cdata.get('HAVE_XLOCALE_H', 0) == 1
_strtold_prefix += '#include <xlocale.h>'
endif
if cc.has_function('strtold_l', include_directories: inc_curdir, prefix: _strtold_prefix)
cdata.set10('HAVE_STRTOLD_L', true)
endif

# Optional compiler attributes
# TODO: this doesn't work with cc.has_function_attribute, see
# https://github.com/mesonbuild/meson/issues/10732
Expand Down
3 changes: 3 additions & 0 deletions numpy/_core/src/common/numpyos.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

#include "npy_pycompat.h"

#if defined(HAVE_STRTOLD_L) && !defined(_GNU_SOURCE)
# define _GNU_SOURCE
#endif
#include <locale.h>
#include <stdio.h>

Expand Down