Skip to content

Commit cee94c4

Browse files
committed
update build configuration
1 parent ebbd6d8 commit cee94c4

File tree

8 files changed

+103
-24
lines changed

8 files changed

+103
-24
lines changed

Makefile.pre.in

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ ENSUREPIP= @ENSUREPIP@
227227
# Internal static libraries
228228
LIBMPDEC_A= Modules/_decimal/libmpdec/libmpdec.a
229229
LIBEXPAT_A= Modules/expat/libexpat.a
230+
LIBHASHLIB_INTERNAL_A=Modules/_hashlib/libhashlib.a
230231

231232
# HACL* build configuration
232233
LIBHACL_CFLAGS=@LIBHACL_CFLAGS@
@@ -761,6 +762,18 @@ LIBHACL_HMAC_HEADERS= \
761762
$(LIBHACL_BLAKE2_HEADERS) \
762763
$(LIBHACL_HEADERS)
763764

765+
##########################################################################
766+
# Internal library for cryptographic primitives
767+
768+
LIBHASHLIB_INTERNAL_OBJS= \
769+
Modules/_hashlib/hashlib_buffer.o \
770+
Modules/_hashlib/hashlib_fetch.o
771+
772+
LIBHASHLIB_INTERNAL_HEADERS= \
773+
Modules/_hashlib/hashlib_buffer.h \
774+
Modules/_hashlib/hashlib_fetch.h \
775+
Modules/_hashlib/hashlib_mutex.h
776+
764777
#########################################################################
765778
# Rules
766779

@@ -1511,6 +1524,20 @@ $(LIBEXPAT_A): $(LIBEXPAT_OBJS)
15111524
-rm -f $@
15121525
$(AR) $(ARFLAGS) $@ $(LIBEXPAT_OBJS)
15131526

1527+
##########################################################################
1528+
# '_hashlib', '_hmac' and HACL*-based modules helpers
1529+
LIBHASHLIB_INTERNAL_CFLAGS=@LIBHASHLIB_INTERNAL_CFLAGS@ $(PY_STDMODULE_CFLAGS) $(CCSHARED)
1530+
1531+
Modules/_hashlib/hashlib_buffer.o: Modules/_hashlib/hashlib_buffer.c $(LIBHASHLIB_INTERNAL_HEADERS) $(PYTHON_HEADERS)
1532+
$(CC) -I$(srcdir)/Modules/_hashlib -c $(LIBHASHLIB_INTERNAL_CFLAGS) -o $@ $(srcdir)/Modules/_hashlib/hashlib_buffer.c
1533+
1534+
Modules/_hashlib/hashlib_fetch.o: Modules/_hashlib/hashlib_fetch.c $(LIBHASHLIB_INTERNAL_HEADERS) $(PYTHON_HEADERS)
1535+
$(CC) -I$(srcdir)/Modules/_hashlib -c $(LIBHASHLIB_INTERNAL_CFLAGS) -o $@ $(srcdir)/Modules/_hashlib/hashlib_fetch.c
1536+
1537+
$(LIBHASHLIB_INTERNAL_A): $(LIBHASHLIB_INTERNAL_OBJS)
1538+
-rm -f $@
1539+
$(AR) $(ARFLAGS) $@ $(LIBHASHLIB_INTERNAL_OBJS)
1540+
15141541
##########################################################################
15151542
# HACL* library build
15161543
#
@@ -3353,21 +3380,21 @@ MODULE__CTYPES_TEST_DEPS=$(srcdir)/Modules/_ctypes/_ctypes_test_generated.c.h
33533380
MODULE__CTYPES_MALLOC_CLOSURE=@MODULE__CTYPES_MALLOC_CLOSURE@
33543381
MODULE__DECIMAL_DEPS=$(srcdir)/Modules/_decimal/docstrings.h @LIBMPDEC_INTERNAL@
33553382
MODULE__ELEMENTTREE_DEPS=$(srcdir)/Modules/pyexpat.c @LIBEXPAT_INTERNAL@
3356-
MODULE__HASHLIB_DEPS=$(srcdir)/Modules/hashlib.h
3383+
MODULE__HASHLIB_DEPS=@LIBHASHLIB_INTERNAL@
33573384
MODULE__IO_DEPS=$(srcdir)/Modules/_io/_iomodule.h
33583385

33593386
# HACL*-based cryptographic primitives
3360-
MODULE__MD5_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_MD5_HEADERS) $(LIBHACL_MD5_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3387+
MODULE__MD5_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_MD5_HEADERS) $(LIBHACL_MD5_LIB_@LIBHACL_LDEPS_LIBTYPE@)
33613388
MODULE__MD5_LDEPS=$(LIBHACL_MD5_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3362-
MODULE__SHA1_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA1_HEADERS) $(LIBHACL_SHA1_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3389+
MODULE__SHA1_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_SHA1_HEADERS) $(LIBHACL_SHA1_LIB_@LIBHACL_LDEPS_LIBTYPE@)
33633390
MODULE__SHA1_LDEPS=$(LIBHACL_SHA1_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3364-
MODULE__SHA2_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA2_HEADERS) $(LIBHACL_SHA2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3391+
MODULE__SHA2_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_SHA2_HEADERS) $(LIBHACL_SHA2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
33653392
MODULE__SHA2_LDEPS=$(LIBHACL_SHA2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3366-
MODULE__SHA3_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA3_HEADERS) $(LIBHACL_SHA3_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3393+
MODULE__SHA3_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_SHA3_HEADERS) $(LIBHACL_SHA3_LIB_@LIBHACL_LDEPS_LIBTYPE@)
33673394
MODULE__SHA3_LDEPS=$(LIBHACL_SHA3_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3368-
MODULE__BLAKE2_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_BLAKE2_HEADERS) $(LIBHACL_BLAKE2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3395+
MODULE__BLAKE2_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_BLAKE2_HEADERS) $(LIBHACL_BLAKE2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
33693396
MODULE__BLAKE2_LDEPS=$(LIBHACL_BLAKE2_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3370-
MODULE__HMAC_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_HMAC_HEADERS) $(LIBHACL_HMAC_LIB_@LIBHACL_LDEPS_LIBTYPE@)
3397+
MODULE__HMAC_DEPS=$(MODULE__HASHLIB_DEPS) $(LIBHACL_HMAC_HEADERS) $(LIBHACL_HMAC_LIB_@LIBHACL_LDEPS_LIBTYPE@)
33713398
MODULE__HMAC_LDEPS=$(LIBHACL_HMAC_LIB_@LIBHACL_LDEPS_LIBTYPE@)
33723399

33733400
MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h $(srcdir)/Modules/addrinfo.h $(srcdir)/Modules/getaddrinfo.c $(srcdir)/Modules/getnameinfo.c

PCbuild/_hashlib.vcxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@
100100
<ItemGroup>
101101
<ClCompile Include="..\Modules\_hashopenssl.c" />
102102
</ItemGroup>
103+
<ItemGroup>
104+
<ClInclude Include="..\Modules\_hashlib\hashlib.h" />
105+
<ClInclude Include="..\Modules\_hashlib\hashlib_buffer.h" />
106+
<ClInclude Include="..\Modules\_hashlib\hashlib_fetch.h" />
107+
<ClInclude Include="..\Modules\_hashlib\hashlib_mutex.h" />
108+
</ItemGroup>
103109
<ItemGroup>
104110
<ResourceCompile Include="..\PC\python_nt.rc" />
105111
</ItemGroup>

PCbuild/_hashlib.vcxproj.filters

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
<Filter>Resource Files</Filter>
1919
</ResourceCompile>
2020
</ItemGroup>
21-
</Project>
21+
</Project>

PCbuild/pythoncore.vcxproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,11 @@
447447
<PreprocessorDefinitions>HACL_CAN_COMPILE_VEC128;%(PreprocessorDefinitions)</PreprocessorDefinitions>
448448
<AdditionalOptions>/arch:AVX %(AdditionalOptions)</AdditionalOptions>
449449
</ClCompile>
450+
<ClCompile Include="..\Modules\_hashlib\hashlib_buffer.c" />
451+
<ClInclude Include="..\Modules\_hashlib\hashlib_buffer.h" />
452+
<ClCompile Include="..\Modules\_hashlib\hashlib_fetch.c" />
453+
<ClInclude Include="..\Modules\_hashlib\hashlib_fetch.h" />
454+
<ClInclude Include="..\Modules\_hashlib\hashlib_mutex.h" />
450455
<ClCompile Include="..\Modules\_heapqmodule.c" />
451456
<ClCompile Include="..\Modules\_json.c" />
452457
<ClCompile Include="..\Modules\_localemodule.c" />

PCbuild/pythoncore.vcxproj.filters

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,15 @@
255255
<ClInclude Include="..\Include\weakrefobject.h">
256256
<Filter>Include</Filter>
257257
</ClInclude>
258+
<ClInclude Include="..\Modules\_hashlib\hashlib_buffer.h">
259+
<Filter>Modules\_hashlib</Filter>
260+
</ClInclude>
261+
<ClInclude Include="..\Modules\_hashlib\hashlib_fetch.h">
262+
<Filter>Modules\_hashlib</Filter>
263+
</ClInclude>
264+
<ClInclude Include="..\Modules\_hashlib\hashlib_mutex.h">
265+
<Filter>Modules\_hashlib</Filter>
266+
</ClInclude>
258267
<ClInclude Include="..\Modules\_math.h">
259268
<Filter>Modules</Filter>
260269
</ClInclude>
@@ -971,6 +980,12 @@
971980
<ClCompile Include="..\Modules\_hacl\Hacl_Streaming_HMAC.c">
972981
<Filter>Modules</Filter>
973982
</ClCompile>
983+
<ClCompile Include="..\Modules\_hashlib\hashlib_buffer.c">
984+
<Filter>Modules\_hashlib</Filter>
985+
</ClCompile>
986+
<ClCompile Include="..\Modules\_hashlib\hashlib_fetch.c">
987+
<Filter>Modules\_hashlib</Filter>
988+
</ClCompile>
974989
<ClCompile Include="..\Modules\_heapqmodule.c">
975990
<Filter>Modules</Filter>
976991
</ClCompile>

Tools/c-analyzer/cpython/ignored.tsv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ Modules/_decimal/_decimal.c - signal_map_template -
238238
Modules/_decimal/_decimal.c - ssize_constants -
239239
Modules/_decimal/_decimal.c - INVALID_SIGNALDICT_ERROR_MSG -
240240
Modules/_elementtree.c - ExpatMemoryHandler -
241+
Modules/_hashlib/hashlib_fetch.h - _Py_hashlib_message_digest_NAMES -
241242
Modules/_hashopenssl.c - py_hashes -
242243
Modules/_hacl/Hacl_Hash_SHA1.c - _h0 -
243244
Modules/_hacl/Hacl_Hash_MD5.c - _h0 -

configure

Lines changed: 26 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7186,6 +7186,7 @@ SRCDIRS="\
71867186
Modules/_decimal \
71877187
Modules/_decimal/libmpdec \
71887188
Modules/_hacl \
7189+
Modules/_hashlib \
71897190
Modules/_io \
71907191
Modules/_multiprocessing \
71917192
Modules/_sqlite \
@@ -7956,6 +7957,15 @@ PY_STDLIB_MOD_SIMPLE([_codecs_tw])
79567957
PY_STDLIB_MOD_SIMPLE([_multibytecodec])
79577958
PY_STDLIB_MOD_SIMPLE([unicodedata])
79587959

7960+
###############################################################################
7961+
# Cryptographic primitives
7962+
LIBHASHLIB_INTERNAL_CFLAGS="-I\$(srcdir)/Modules/_hashlib"
7963+
LIBHASHLIB_INTERNAL_LDFLAGS="-lm \$(LIBHASHLIB_INTERNAL_A)"
7964+
LIBHASHLIB_INTERNAL="\$(LIBHASHLIB_INTERNAL_HEADERS) \$(LIBHASHLIB_INTERNAL_A)"
7965+
7966+
AC_SUBST([LIBHASHLIB_INTERNAL_CFLAGS])
7967+
AC_SUBST([LIBHASHLIB_INTERNAL])
7968+
79597969
###############################################################################
79607970
# HACL* compilation and linking configuration (contact: @picnixz)
79617971
#
@@ -8092,7 +8102,9 @@ dnl The EXTNAME is the name of the extension module being built.
80928102
AC_DEFUN([PY_HACL_CREATE_MODULE], [
80938103
AS_VAR_PUSHDEF([v], [[LIBHACL_][$1][_LDFLAGS]])
80948104
AS_VAR_SET([v], [[LIBHACL_][$1][_LIB_${LIBHACL_LDEPS_LIBTYPE}]])
8095-
PY_STDLIB_MOD([$2], [$3], [], [$LIBHACL_CFLAGS], [\$($v)])
8105+
PY_STDLIB_MOD([$2], [$3], [],
8106+
[$LIBHACL_CFLAGS $LIBHASHLIB_INTERNAL_CFLAGS],
8107+
[\$($v) $LIBHASHLIB_INTERNAL_LDFLAGS])
80968108
AS_VAR_POPDEF([v])
80978109
])
80988110

@@ -8173,7 +8185,8 @@ dnl OpenSSL bindings
81738185
PY_STDLIB_MOD([_ssl], [], [test "$ac_cv_working_openssl_ssl" = yes],
81748186
[$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $OPENSSL_LIBS])
81758187
PY_STDLIB_MOD([_hashlib], [], [test "$ac_cv_working_openssl_hashlib" = yes],
8176-
[$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $LIBCRYPTO_LIBS])
8188+
[$OPENSSL_INCLUDES $LIBHASHLIB_INTERNAL_CFLAGS],
8189+
[$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $LIBCRYPTO_LIBS $LIBHASHLIB_INTERNAL_LDFLAGS])
81778190

81788191
dnl test modules
81798192
PY_STDLIB_MOD([_testcapi],

0 commit comments

Comments
 (0)