Skip to content

gh-131876: use extern storage for _hashlib helper functions #137301

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

Closed
wants to merge 8 commits into from
Closed
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
8 changes: 8 additions & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ srcdir= @srcdir@
VPATH= @srcdir@
abs_srcdir= @abs_srcdir@
abs_builddir= @abs_builddir@
UNIQMODLIBS= @UNIQMODLIBS@


CC= @CC@
Expand Down Expand Up @@ -3381,21 +3382,28 @@ MODULE__CTYPES_MALLOC_CLOSURE=@MODULE__CTYPES_MALLOC_CLOSURE@
MODULE__DECIMAL_DEPS=$(srcdir)/Modules/_decimal/docstrings.h @LIBMPDEC_INTERNAL@
MODULE__ELEMENTTREE_DEPS=$(srcdir)/Modules/pyexpat.c @LIBEXPAT_INTERNAL@
MODULE__HASHLIB_DEPS=@LIBHASHLIB_INTERNAL@
MODULE__HASHLIB_RULE_LDFLAGS=@LIBHASHLIB_INTERNAL_RULE_LDFLAGS@
MODULE__IO_DEPS=$(srcdir)/Modules/_io/_iomodule.h

# HACL*-based cryptographic primitives
MODULE__MD5_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_MD5_HEADERS) $(LIBHACL_MD5_LIB_@LIBHACL_LDEPS_LIBTYPE@)
MODULE__MD5_LDEPS=$(LIBHACL_MD5_LIB_@LIBHACL_LDEPS_LIBTYPE@)
MODULE__MD5_RULE_LDFLAGS=@LIBHASHLIB_INTERNAL_RULE_LDFLAGS@
MODULE__SHA1_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_SHA1_HEADERS) $(LIBHACL_SHA1_LIB_@LIBHACL_LDEPS_LIBTYPE@)
MODULE__SHA1_LDEPS=$(LIBHACL_SHA1_LIB_@LIBHACL_LDEPS_LIBTYPE@)
MODULE__SHA1_RULE_LDFLAGS=@LIBHASHLIB_INTERNAL_RULE_LDFLAGS@
MODULE__SHA2_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_SHA2_HEADERS) $(LIBHACL_SHA2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
MODULE__SHA2_LDEPS=$(LIBHACL_SHA2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
MODULE__SHA2_RULE_LDFLAGS=@LIBHASHLIB_INTERNAL_RULE_LDFLAGS@
MODULE__SHA3_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_SHA3_HEADERS) $(LIBHACL_SHA3_LIB_@LIBHACL_LDEPS_LIBTYPE@)
MODULE__SHA3_LDEPS=$(LIBHACL_SHA3_LIB_@LIBHACL_LDEPS_LIBTYPE@)
MODULE__SHA3_RULE_LDFLAGS=@LIBHASHLIB_INTERNAL_RULE_LDFLAGS@
MODULE__BLAKE2_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_BLAKE2_HEADERS) $(LIBHACL_BLAKE2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
MODULE__BLAKE2_LDEPS=$(LIBHACL_BLAKE2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
MODULE__BLAKE2_RULE_LDFLAGS=@LIBHASHLIB_INTERNAL_RULE_LDFLAGS@
MODULE__HMAC_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_HMAC_HEADERS) $(LIBHACL_HMAC_LIB_@LIBHACL_LDEPS_LIBTYPE@)
MODULE__HMAC_LDEPS=$(LIBHACL_HMAC_LIB_@LIBHACL_LDEPS_LIBTYPE@)
MODULE__HMAC_RULE_LDFLAGS=@LIBHASHLIB_INTERNAL_RULE_LDFLAGS@

MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h $(srcdir)/Modules/addrinfo.h $(srcdir)/Modules/getaddrinfo.c $(srcdir)/Modules/getnameinfo.c
MODULE__SSL_DEPS=$(srcdir)/Modules/_ssl.h $(srcdir)/Modules/_ssl/cert.c $(srcdir)/Modules/_ssl/debughelpers.c $(srcdir)/Modules/_ssl/misc.c $(srcdir)/Modules/_ssl_data_111.h $(srcdir)/Modules/_ssl_data_300.h $(srcdir)/Modules/socketmodule.h
Expand Down
4 changes: 2 additions & 2 deletions Modules/_hashlib/hashlib_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* The symbol is exported for '_hashlib' and HACL*-based extension modules.
*/
PyAPI_FUNC(int)
extern int
_Py_hashlib_data_argument(PyObject **res, PyObject *data, PyObject *string);

/*
Expand All @@ -25,7 +25,7 @@ _Py_hashlib_data_argument(PyObject **res, PyObject *data, PyObject *string);
*
* The symbol is exported for '_hashlib' and HACL*-based extension modules.
*/
PyAPI_FUNC(int)
extern int
_Py_hashlib_get_buffer_view(PyObject *obj, Py_buffer *view);

/*
Expand Down
6 changes: 4 additions & 2 deletions Modules/makesetup
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
SHAREDMODS=
OBJS=
LIBS=
UNIQMODLIBS=
LOCALLIBS=
BASELIBS=
while read line
Expand Down Expand Up @@ -276,7 +277,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
;;
esac
rule="$file: $objs \$(MODULE_${mods_upper}_LDEPS)"
rule="$rule; \$(BLDSHARED) $objs $libs \$(LIBPYTHON) -o $file"
rule="$rule; \$(BLDSHARED) $objs $libs \$(MODULE_${mods_upper}_RULE_LDFLAGS) \$(LIBPYTHON) -o $file"
echo "$rule" >>$rulesf
done
done
Expand All @@ -290,7 +291,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
yes) BASELIBS=$LIBS;;
*) LOCALLIBS=$LIBS;;
esac
LIBS='$(LOCALMODLIBS) $(BASEMODLIBS)'
LIBS='$(LOCALMODLIBS) $(BASEMODLIBS) $(UNIQMODLIBS)'
DEFS="BASEMODLIBS=$BASELIBS$NL$DEFS"
DEFS="LOCALMODLIBS=$LOCALLIBS$NL$DEFS"

Expand Down Expand Up @@ -332,6 +333,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
echo "s%_MODDISABLED_NAMES_%$DISABLED%" >>$sedf
echo "s%_MODOBJS_%$OBJS%" >>$sedf
echo "s%_MODLIBS_%$LIBS%" >>$sedf
echo "s%_UNIQMODLIBS_%$UNIQMODLIBS%" >>$sedf
echo "/Definitions added by makesetup/r $sedr" >>$sedf
sed -f $sedf $makepre >Makefile
cat $rulesf >>Makefile
Expand Down
1 change: 1 addition & 0 deletions PCbuild/_hashlib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\Modules\_hashopenssl.c" />
<ClCompile Include="..\Modules\_hashlib\hashlib_buffer.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Modules\_hashlib\hashlib_buffer.h" />
Expand Down
3 changes: 3 additions & 0 deletions PCbuild/_hashlib.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<ClCompile Include="..\Modules\_hashopenssl.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Modules\_hashlib\hashlib_buffer.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\PC\python_nt.rc">
Expand Down
Loading
Loading