@@ -53,6 +53,15 @@ AC_DEFUN([WITH_SAVE_ENV],
5353[ RESTORE_ENV]
5454) dnl
5555
56+ dnl The libraries passed to the linker exactly once.
57+ dnl
58+ dnl This is needed for WASI/WASM as symbols should be defined at most once.
59+ dnl Modules sharing a common static library must add the latter here and
60+ dnl to "MODULE_<NAME>_RULE_LDFLAGS" instead of "MODULE_<NAME>_LDFLAGS"
61+ dnl as otherwise the library gets duplicated when linking the interpreter.
62+ UNIQMODLIBS=
63+ AC_SUBST ( [ UNIQMODLIBS] )
64+
5665dnl PY_CHECK_FUNC(FUNCTION, [INCLUDES], [AC_DEFINE-VAR])
5766AC_DEFUN ( [ PY_CHECK_FUNC] ,
5867[ AS_VAR_PUSHDEF ( [ py_var] , [ ac_cv_func_$1 ] )
@@ -7961,10 +7970,12 @@ PY_STDLIB_MOD_SIMPLE([unicodedata])
79617970# ##############################################################################
79627971# Cryptographic primitives
79637972LIBHASHLIB_INTERNAL_CFLAGS="-I\$(srcdir)/Modules/_hashlib"
7964- LIBHASHLIB_INTERNAL_LDFLAGS ="-lm \$(LIBHASHLIB_INTERNAL_A)"
7973+ LIBHASHLIB_INTERNAL_RULE_LDFLAGS ="-lm \$(LIBHASHLIB_INTERNAL_A)"
79657974LIBHASHLIB_INTERNAL="\$(LIBHASHLIB_INTERNAL_HEADERS) \$(LIBHASHLIB_INTERNAL_A)"
7975+ UNIQMODLIBS="$UNIQMODLIBS \$(LIBHASHLIB_INTERNAL_A)"
79667976
79677977AC_SUBST ( [ LIBHASHLIB_INTERNAL_CFLAGS] )
7978+ AC_SUBST ( [ LIBHASHLIB_INTERNAL_RULE_LDFLAGS] )
79687979AC_SUBST ( [ LIBHASHLIB_INTERNAL] )
79697980
79707981# ##############################################################################
@@ -8103,9 +8114,15 @@ dnl The EXTNAME is the name of the extension module being built.
81038114AC_DEFUN ( [ PY_HACL_CREATE_MODULE] , [
81048115 AS_VAR_PUSHDEF ( [ v] , [ [ LIBHACL_] [ $1 ] [ _LDFLAGS] ] )
81058116 AS_VAR_SET ( [ v] , [ [ LIBHACL_] [ $1 ] [ _LIB_${LIBHACL_LDEPS_LIBTYPE}] ] )
8117+ # LDFLAGS will not contain the internal library helper as it could
8118+ # be duplicated when eventually linking the interpreter.
8119+ #
8120+ # Instead, it will be part of the UNIQMODLIBS variable which will
8121+ # then be available as any other "core" features but without being
8122+ # part of the Include/ directory.
81068123 PY_STDLIB_MOD([ $2 ] , [ $3 ] , [ ] ,
81078124 [ $LIBHACL_CFLAGS $LIBHASHLIB_INTERNAL_CFLAGS] ,
8108- [ \$($v) $LIBHASHLIB_INTERNAL_LDFLAGS ] )
8125+ [ \$($v)] )
81098126 AS_VAR_POPDEF ( [ v] )
81108127] )
81118128
@@ -8185,9 +8202,16 @@ PY_STDLIB_MOD([_zstd], [], [test "$have_libzstd" = yes],
81858202dnl OpenSSL bindings
81868203PY_STDLIB_MOD([ _ssl] , [ ] , [ test "$ac_cv_working_openssl_ssl" = yes] ,
81878204 [ $OPENSSL_INCLUDES] , [ $OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $OPENSSL_LIBS] )
8205+
8206+ # LDFLAGS will not contain the internal library helper as it could
8207+ # be duplicated when eventually linking the interpreter.
8208+ #
8209+ # Instead, it will be part of the UNIQMODLIBS variable which will
8210+ # then be available as any other "core" features but without being
8211+ # part of the Include/ directory.
81888212PY_STDLIB_MOD([ _hashlib] , [ ] , [ test "$ac_cv_working_openssl_hashlib" = yes] ,
81898213 [ $OPENSSL_INCLUDES $LIBHASHLIB_INTERNAL_CFLAGS] ,
8190- [ $OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $LIBCRYPTO_LIBS $LIBHASHLIB_INTERNAL_LDFLAGS ] )
8214+ [ $OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $LIBCRYPTO_LIBS] )
81918215
81928216dnl test modules
81938217PY_STDLIB_MOD([ _testcapi] ,
0 commit comments