Skip to content
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
75 changes: 0 additions & 75 deletions .nanvix/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,81 +49,6 @@
DOCKER_WORKSPACE_PATH = "/mnt/workspace"


def toolchain_paths(
toolchain: str | Path,
sysroot: str | Path,
) -> dict[str, Path]:
"""Return resolved paths to toolchain binaries and libraries."""
tc = Path(toolchain)
sr = Path(sysroot)
return {
"cc": tc / "bin" / f"{TOOLCHAIN_TRIPLET}-gcc",
"cxx": tc / "bin" / f"{TOOLCHAIN_TRIPLET}-g++",
"ld": tc / "bin" / f"{TOOLCHAIN_TRIPLET}-ld",
"ar": tc / "bin" / f"{TOOLCHAIN_TRIPLET}-ar",
"ranlib": tc / "bin" / f"{TOOLCHAIN_TRIPLET}-ranlib",
"strip": tc / "bin" / f"{TOOLCHAIN_TRIPLET}-strip",
"build_python": tc / "bin" / "python3",
"libc": tc / f"{TOOLCHAIN_TRIPLET}" / "lib" / "libc.a",
"libm": tc / f"{TOOLCHAIN_TRIPLET}" / "lib" / "libm.a",
"libposix": sr / "lib" / "libposix.a",
"libz": sr / "lib" / "libz.a",
"libsqlite3": sr / "lib" / "libsqlite3.a",
"libssl": sr / "lib" / "libssl.a",
"libcrypto": sr / "lib" / "libcrypto.a",
"liblzma": sr / "lib" / "liblzma.a",
"libnvx_crt0": sr / "lib" / "libnvx_crt0.a",
}


def configure_env(toolchain: str | Path, sysroot: str | Path) -> dict[str, str]:
"""Return the environment dict for ./configure.

NOTE: This helper is currently unused; the actual cpython build invokes
``make -f Makefile.nanvix`` which has its own inline CONFIGURE_ENV. This
function is kept in sync so a future caller does not pick up stale link
flags. See ``Makefile.nanvix`` for the authoritative comment block
explaining the ``--whole-archive`` / ``--export-dynamic`` /
``--allow-multiple-definition`` rationale.
"""
tp = toolchain_paths(toolchain, sysroot)
sr = Path(sysroot)
return {
"CC": str(tp["cc"]),
"CXX": str(tp["cxx"]),
"LD": str(tp["ld"]),
"AR": str(tp["ar"]),
"RANLIB": str(tp["ranlib"]),
"CFLAGS": (
f"-O3 -fomit-frame-pointer -fno-unwind-tables "
f"-fno-asynchronous-unwind-tables -I{sr}/include"
),
"CFLAGS_NODIST": "-fno-semantic-interposition",
"LDFLAGS": (
f"-L{sr}/lib -T{sr}/lib/user.ld "
f"-Wl,--allow-multiple-definition -no-pie "
f"-Wl,--export-dynamic -Wl,--no-dynamic-linker"
),
"LIBS": (
f"-Wl,--whole-archive {tp['libnvx_crt0']} {tp['libposix']} "
f"{tp['libc']} {tp['libm']} "
f"-lstdc++ -lgcc -Wl,--no-whole-archive "
f"-Wl,--start-group "
f"-lsqlite3 -lz -lbz2 -llzma -Wl,--end-group"
),
"LIBSQLITE3_LIBS": f"-L{sr}/lib -lsqlite3",
"LIBSQLITE3_CFLAGS": f"-I{sr}/include",
"ZLIB_LIBS": f"-L{sr}/lib -lz",
"ZLIB_CFLAGS": f"-I{sr}/include",
"BZIP2_LIBS": f"-L{sr}/lib -lbz2",
"BZIP2_CFLAGS": f"-I{sr}/include",
"LIBLZMA_LIBS": f"-L{sr}/lib -llzma",
"LIBLZMA_CFLAGS": f"-I{sr}/include",
"LIBFFI_LIBS": f"-L{sr}/lib -lffi",
"LIBFFI_CFLAGS": f"-I{sr}/include",
}


def configure_opts(
build_python: str | Path,
libc: str | Path,
Expand Down
25 changes: 19 additions & 6 deletions .nanvix/setup_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,15 @@ class SetupEntry(NamedTuple):
# their own _hacl translation units rather than linking a shared
# libHacl_Hash_*.a -- same shape as upstream.
SetupEntry(
name="_asyncio",
name="_decimal",
linkage=Linkage.SHARED,
tokens=("_asynciomodule.c",),
tokens=("_decimal/_decimal.c",),
section_header=(
"Modules with bundled-in-cpython C deps. Each .so bundles "
"its own vendored .a, matching upstream cpython's default "
"./configure behavior."
),
),
SetupEntry(name="_datetime", linkage=Linkage.SHARED, tokens=("_datetimemodule.c",)),
SetupEntry(
name="_decimal", linkage=Linkage.SHARED, tokens=("_decimal/_decimal.c",)
),
SetupEntry(name="pyexpat", linkage=Linkage.SHARED, tokens=("pyexpat.c",)),
SetupEntry(name="_elementtree", linkage=Linkage.SHARED, tokens=("_elementtree.c",)),
SetupEntry(
Expand Down Expand Up @@ -268,6 +264,23 @@ class SetupEntry(NamedTuple):
"_blake2/blake2s_impl.c",
),
),
# ---------------- POSIX syscall wrappers + concurrency primitives ---
#
# No external or bundled C deps -- these are thin POSIX/syscall
# wrappers plus _asyncio / _datetime, all matching upstream
# Modules/Setup.stdlib.in's "Modules with some UNIX dependencies"
# grouping. libc / libm symbols (if any) resolve against
# python.elf .dynsym at dlopen time via --export-dynamic.
SetupEntry(
name="_asyncio",
linkage=Linkage.SHARED,
tokens=("_asynciomodule.c",),
section_header=(
"POSIX syscall wrappers + _asyncio / _datetime "
"(no external or bundled deps)."
),
),
SetupEntry(name="_datetime", linkage=Linkage.SHARED, tokens=("_datetimemodule.c",)),
SetupEntry(name="select", linkage=Linkage.SHARED, tokens=("selectmodule.c",)),
SetupEntry(name="_socket", linkage=Linkage.SHARED, tokens=("socketmodule.c",)),
SetupEntry(
Expand Down
10 changes: 1 addition & 9 deletions Makefile.nanvix
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ ifdef CONFIG_NANVIX
LIBC := $(DOCKER_TOOLCHAIN_PATH)/i686-nanvix/lib/libc.a
LIBM := $(DOCKER_TOOLCHAIN_PATH)/i686-nanvix/lib/libm.a
LIBPOSIX := $(DOCKER_SYSROOT_PATH)/lib/libposix.a
LIBZ := $(DOCKER_SYSROOT_PATH)/lib/libz.a
LIBSQLITE3 := $(DOCKER_SYSROOT_PATH)/lib/libsqlite3.a
LIBSSL := $(DOCKER_SYSROOT_PATH)/lib/libssl.a
LIBCRYPTO := $(DOCKER_SYSROOT_PATH)/lib/libcrypto.a
# libnvx_crt0 ships the executable startup symbols (`_do_start`, `_start`,
# `c_trampoline`). It must be present in the Nanvix sysroot ahead of this
# cpython build; the existence check below fails loudly when it is not.
Expand All @@ -102,10 +98,6 @@ ifdef CONFIG_NANVIX
LIBC := $(NANVIX_TOOLCHAIN)/i686-nanvix/lib/libc.a
LIBM := $(NANVIX_TOOLCHAIN)/i686-nanvix/lib/libm.a
LIBPOSIX := $(abspath $(NANVIX_HOME))/lib/libposix.a
LIBZ := $(abspath $(NANVIX_HOME))/lib/libz.a
LIBSQLITE3 := $(abspath $(NANVIX_HOME))/lib/libsqlite3.a
LIBSSL := $(abspath $(NANVIX_HOME))/lib/libssl.a
LIBCRYPTO := $(abspath $(NANVIX_HOME))/lib/libcrypto.a
LIBNVX_CRT0 := $(abspath $(NANVIX_HOME))/lib/libnvx_crt0.a
BUILD_PYTHON := $(NANVIX_TOOLCHAIN)/bin/python3
endif
Expand Down Expand Up @@ -258,7 +250,7 @@ CONFIGURE_OPTS = \
ac_cv_func_getsockname=yes \
ac_cv_func_inet_aton=no \
ac_cv_func_inet_ntoa=yes \
ac_cv_func_inet_pton=no
ac_cv_func_inet_pton=yes

# Marker file to track if configure has been run
CONFIGURED_MARKER = .nanvix-configured
Expand Down
Loading