Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5113a98

Browse filesBrowse files
committed
remove statically linked libraries for HACL* implementation
1 parent ac1180f commit 5113a98
Copy full SHA for 5113a98

File tree

Expand file treeCollapse file tree

5 files changed

+79
-29
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+79
-29
lines changed

‎Makefile.pre.in

Copy file name to clipboardExpand all lines: Makefile.pre.in
+59-17Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,13 @@ ENSUREPIP= @ENSUREPIP@
227227
# Internal static libraries
228228
LIBMPDEC_A= Modules/_decimal/libmpdec/libmpdec.a
229229
LIBEXPAT_A= Modules/expat/libexpat.a
230-
LIBHACL_BLAKE2_A= Modules/_hacl/libHacl_Hash_Blake2.a
231-
LIBHACL_HMAC_A= Modules/_hacl/libHacl_HMAC.a
232230
LIBHACL_CFLAGS=@LIBHACL_CFLAGS@
233231
LIBHACL_SIMD128_FLAGS=@LIBHACL_SIMD128_FLAGS@
234232
LIBHACL_SIMD256_FLAGS=@LIBHACL_SIMD256_FLAGS@
235233
LIBHACL_SIMD128_OBJS=@LIBHACL_SIMD128_OBJS@
234+
LIBHACL_SIMD128_SRCS=$(LIBHACL_SIMD128_OBJS:.o=.c)
236235
LIBHACL_SIMD256_OBJS=@LIBHACL_SIMD256_OBJS@
236+
LIBHACL_SIMD256_SRCS=$(LIBHACL_SIMD256_SRCS:.o=.c)
237237

238238
# Module state, compiler flags and linker flags
239239
# Empty CFLAGS and LDFLAGS are omitted.
@@ -657,18 +657,32 @@ LIBEXPAT_HEADERS= \
657657
##########################################################################
658658
# hashlib's HACL* library
659659

660+
LIBHACL_MD5_SRCS= \
661+
Modules/_hacl/Hacl_Hash_MD5.c
660662
LIBHACL_MD5_OBJS= \
661663
Modules/_hacl/Hacl_Hash_MD5.o
662664

665+
LIBHACL_SHA1_SRCS= \
666+
Modules/_hacl/Hacl_Hash_SHA1.c
663667
LIBHACL_SHA1_OBJS= \
664668
Modules/_hacl/Hacl_Hash_SHA1.o
665669

670+
LIBHACL_SHA2_SRCS= \
671+
Modules/_hacl/Hacl_Hash_SHA2.c
666672
LIBHACL_SHA2_OBJS= \
667673
Modules/_hacl/Hacl_Hash_SHA2.o
668674

675+
LIBHACL_SHA3_SRCS= \
676+
Modules/_hacl/Hacl_Hash_SHA3.c
669677
LIBHACL_SHA3_OBJS= \
670678
Modules/_hacl/Hacl_Hash_SHA3.o
671679

680+
LIBHACL_BLAKE2_SRCS= \
681+
Modules/_hacl/Hacl_Hash_Blake2s.c \
682+
Modules/_hacl/Hacl_Hash_Blake2b.c \
683+
Modules/_hacl/Lib_Memzero0.c \
684+
$(LIBHACL_SIMD128_SRCS) \
685+
$(LIBHACL_SIMD256_SRCS)
672686
LIBHACL_BLAKE2_OBJS= \
673687
Modules/_hacl/Hacl_Hash_Blake2s.o \
674688
Modules/_hacl/Hacl_Hash_Blake2b.o \
@@ -1460,7 +1474,25 @@ $(LIBEXPAT_A): $(LIBEXPAT_OBJS)
14601474
# Build HACL* static libraries for hashlib and HACL* HMAC.
14611475
#
14621476
# The contents of libHacl_Blake2.a vary depending on whether we
1463-
# have the ability to compile vectorized versions
1477+
# have the ability to compile vectorized versions.
1478+
#
1479+
# The HACL* modules are dynamically compiled and linked with the
1480+
# corresponding CPython built-in modules on demand, depending on
1481+
# whether the module is built or not. Since HMAC however requires
1482+
# them to be built, we need rules that are always enabled and that
1483+
# are not overwritten by those automatically deduced by makesetup.
1484+
1485+
Modules/_hacl/Hacl_Hash_MD5.o: $(srcdir)/Modules/_hacl/Hacl_Hash_MD5.c $(LIBHACL_MD5_HEADERS)
1486+
$(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_MD5.c
1487+
1488+
Modules/_hacl/Hacl_Hash_SHA1.o: $(srcdir)/Modules/_hacl/Hacl_Hash_SHA1.c $(LIBHACL_SHA1_HEADERS)
1489+
$(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_SHA1.c
1490+
1491+
Modules/_hacl/Hacl_Hash_SHA2.o: $(srcdir)/Modules/_hacl/Hacl_Hash_SHA2.c $(LIBHACL_SHA2_HEADERS)
1492+
$(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_SHA2.c
1493+
1494+
Modules/_hacl/Hacl_Hash_SHA3.o: $(srcdir)/Modules/_hacl/Hacl_Hash_SHA3.c $(LIBHACL_SHA3_HEADERS)
1495+
$(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_SHA3.c
14641496

14651497
Modules/_hacl/Hacl_Hash_Blake2s.o: $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2s.c $(LIBHACL_BLAKE2_HEADERS)
14661498
$(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2s.c
@@ -1483,20 +1515,12 @@ Modules/_hacl/Hacl_Hash_Blake2b_Simd256_universal2.o: $(srcdir)/Modules/_hacl/Ha
14831515
Modules/_hacl/Lib_Memzero0.o: $(srcdir)/Modules/_hacl/Lib_Memzero0.c $(LIBHACL_BLAKE2_HEADERS)
14841516
$(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Lib_Memzero0.c
14851517

1486-
$(LIBHACL_BLAKE2_A): $(LIBHACL_BLAKE2_OBJS)
1487-
-rm -f $@
1488-
$(AR) $(ARFLAGS) $@ $(LIBHACL_BLAKE2_OBJS)
1489-
14901518
Modules/_hacl/Hacl_HMAC.o: $(srcdir)/Modules/_hacl/Hacl_HMAC.c $(LIBHACL_HMAC_HEADERS)
14911519
$(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_HMAC.c
14921520

14931521
Modules/_hacl/Hacl_Streaming_HMAC.o: $(srcdir)/Modules/_hacl/Hacl_Streaming_HMAC.c $(LIBHACL_HMAC_HEADERS)
14941522
$(CC) -Wno-unused-variable -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Streaming_HMAC.c
14951523

1496-
$(LIBHACL_HMAC_A): $(LIBHACL_HMAC_OBJS)
1497-
-rm -f $@
1498-
$(AR) $(ARFLAGS) $@ $(LIBHACL_HMAC_OBJS)
1499-
15001524
# create relative links from build/lib.platform/egg.so to Modules/egg.so
15011525
# pybuilddir.txt is created too late. We cannot use it in Makefile
15021526
# targets. ln --relative is not portable.
@@ -3270,12 +3294,30 @@ MODULE__DECIMAL_DEPS=$(srcdir)/Modules/_decimal/docstrings.h @LIBMPDEC_INTERNAL@
32703294
MODULE__ELEMENTTREE_DEPS=$(srcdir)/Modules/pyexpat.c @LIBEXPAT_INTERNAL@
32713295
MODULE__HASHLIB_DEPS=$(srcdir)/Modules/hashlib.h
32723296
MODULE__IO_DEPS=$(srcdir)/Modules/_io/_iomodule.h
3273-
MODULE__MD5_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_MD5_HEADERS) $(srcdir)/Modules/_hacl/Hacl_Hash_MD5.c
3274-
MODULE__SHA1_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA1_HEADERS) $(srcdir)/Modules/_hacl/Hacl_Hash_SHA1.c
3275-
MODULE__SHA2_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA2_HEADERS) $(srcdir)/Modules/_hacl/Hacl_Hash_SHA2.c
3276-
MODULE__SHA3_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA3_HEADERS) $(srcdir)/Modules/_hacl/Hacl_Hash_SHA3.c
3277-
MODULE__BLAKE2_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_BLAKE2_HEADERS) $(LIBHACL_BLAKE2_A)
3278-
MODULE__HMAC_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_HMAC_HEADERS) $(LIBHACL_HMAC_A)
3297+
MODULE__MD5_DEPS= \
3298+
$(srcdir)/Modules/hashlib.h \
3299+
$(LIBHACL_MD5_HEADERS) \
3300+
$(LIBHACL_MD5_OBJS)
3301+
MODULE__SHA1_DEPS= \
3302+
$(srcdir)/Modules/hashlib.h \
3303+
$(LIBHACL_SHA1_HEADERS) \
3304+
$(LIBHACL_SHA1_OBJS)
3305+
MODULE__SHA2_DEPS= \
3306+
$(srcdir)/Modules/hashlib.h \
3307+
$(LIBHACL_SHA2_HEADERS) \
3308+
$(LIBHACL_SHA2_OBJS)
3309+
MODULE__SHA3_DEPS= \
3310+
$(srcdir)/Modules/hashlib.h \
3311+
$(LIBHACL_SHA3_HEADERS) \
3312+
$(LIBHACL_SHA3_OBJS)
3313+
MODULE__BLAKE2_DEPS= \
3314+
$(srcdir)/Modules/hashlib.h \
3315+
$(LIBHACL_BLAKE2_HEADERS) \
3316+
$(LIBHACL_BLAKE2_OBJS)
3317+
MODULE__HMAC_DEPS= \
3318+
$(srcdir)/Modules/hashlib.h \
3319+
$(LIBHACL_HMAC_HEADERS) \
3320+
$(LIBHACL_HMAC_OBJS)
32793321
MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h $(srcdir)/Modules/addrinfo.h $(srcdir)/Modules/getaddrinfo.c $(srcdir)/Modules/getnameinfo.c
32803322
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
32813323
MODULE__TESTCAPI_DEPS=$(srcdir)/Modules/_testcapi/parts.h $(srcdir)/Modules/_testcapi/util.h

‎Modules/Setup.stdlib.in

Copy file name to clipboardExpand all lines: Modules/Setup.stdlib.in
+11-7Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,17 @@
7777
@MODULE_READLINE_TRUE@readline readline.c
7878

7979
# hashing builtins, can be disabled with --without-builtin-hashlib-hashes
80-
@MODULE__MD5_TRUE@_md5 md5module.c -I$(srcdir)/Modules/_hacl/include _hacl/Hacl_Hash_MD5.c -D_BSD_SOURCE -D_DEFAULT_SOURCE
81-
@MODULE__SHA1_TRUE@_sha1 sha1module.c -I$(srcdir)/Modules/_hacl/include _hacl/Hacl_Hash_SHA1.c -D_BSD_SOURCE -D_DEFAULT_SOURCE
82-
@MODULE__SHA2_TRUE@_sha2 sha2module.c -I$(srcdir)/Modules/_hacl/include _hacl/Hacl_Hash_SHA2.c -D_BSD_SOURCE -D_DEFAULT_SOURCE
83-
@MODULE__SHA3_TRUE@_sha3 sha3module.c -I$(srcdir)/Modules/_hacl/include _hacl/Hacl_Hash_SHA3.c -D_BSD_SOURCE -D_DEFAULT_SOURCE
84-
@MODULE__BLAKE2_TRUE@_blake2 blake2module.c -I$(srcdir)/Modules/_hacl/include Modules/_hacl/libHacl_Hash_Blake2.a -D_BSD_SOURCE -D_DEFAULT_SOURCE
85-
86-
@MODULE__HMAC_TRUE@_hmac hmacmodule.c
80+
# HACL* dependencies are compiled separately, but they should be linked
81+
# against the module when needed. In order for the extension module to
82+
# be correctly linked, we should however specify which *.o will be used
83+
# (but for which no Makefile rule will be auto-generated).
84+
@MODULE__MD5_TRUE@_md5 md5module.c -I$(srcdir)/Modules/_hacl/include $(LIBHACL_MD5_OBJS)
85+
@MODULE__SHA1_TRUE@_sha1 sha1module.c -I$(srcdir)/Modules/_hacl/include $(LIBHACL_SHA1_OBJS)
86+
@MODULE__SHA2_TRUE@_sha2 sha2module.c -I$(srcdir)/Modules/_hacl/include $(LIBHACL_SHA2_OBJS)
87+
@MODULE__SHA3_TRUE@_sha3 sha3module.c -I$(srcdir)/Modules/_hacl/include $(LIBHACL_SHA3_OBJS)
88+
@MODULE__BLAKE2_TRUE@_blake2 blake2module.c -I$(srcdir)/Modules/_hacl/include $(LIBHACL_BLAKE2_OBJS)
89+
90+
@MODULE__HMAC_TRUE@_hmac hmacmodule.c $(LIBHACL_HMAC_OBJS)
8791

8892
############################################################################
8993
# XML and text

‎Modules/makesetup

Copy file name to clipboardExpand all lines: Modules/makesetup
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ set -e
4444
# - for each variable definition found in Setup, insert the definition
4545
# before the comment 'Definitions added by makesetup'
4646

47+
remove_extension() {
48+
root=`dirname "$1"`
49+
echo $root/`basename "$1" $2`
50+
}
51+
4752
# Loop over command line options
4853
usage='
4954
usage: makesetup [-s srcdir] [-l libdir] [-c config.c.in] [-m Makefile.pre]
@@ -140,6 +145,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
140145
'*shared*') doconfig=no; continue;;
141146
'*disabled*') doconfig=disabled; continue;;
142147
esac
148+
objs=
143149
srcs=
144150
cpps=
145151
libs=
@@ -180,6 +186,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
180186
\$\(*_LIBS\)) libs="$libs $arg";;
181187
\$\(*_LDFLAGS\)) libs="$libs $arg";;
182188
\$\(*_RPATH\)) libs="$libs $arg";;
189+
\$\(*_OBJS\)) objs="$objs $arg";;
183190
\$*) libs="$libs $arg"
184191
cpps="$cpps $arg";;
185192
*.*) echo 1>&2 "bad word $arg in $line"
@@ -224,7 +231,6 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
224231
case $noobjects in
225232
yes) continue;;
226233
esac
227-
objs=''
228234
for src in $srcs
229235
do
230236
case $src in

‎configure

Copy file name to clipboardExpand all lines: configure
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎configure.ac

Copy file name to clipboardExpand all lines: configure.ac
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7923,9 +7923,7 @@ AC_SUBST([LIBHACL_SIMD256_OBJS])
79237923
dnl HMAC builtin library does not need OpenSSL for now. In the future
79247924
dnl we might want to rely on OpenSSL EVP/NID interface or implement
79257925
dnl our own for algorithm resolution.
7926-
PY_STDLIB_MOD([_hmac], [], [],
7927-
[$LIBHACL_CFLAGS],
7928-
[$LIBHACL_CFLAGS Modules/_hacl/libHacl_HMAC.a])
7926+
PY_STDLIB_MOD([_hmac], [], [], [$LIBHACL_CFLAGS], [$LIBHACL_CFLAGS])
79297927

79307928
PY_STDLIB_MOD([_ctypes],
79317929
[], [test "$have_libffi" = yes],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.