Repository navigation
browseros: wasm32-unknown-linux-musl の Linux として名乗る - #5
Open
nakedtatsuya wants to merge 2 commits into
Open
nakedtatsuya wants to merge 2 commits into
nakedtatsuya wants to merge 2 commits into
Conversation
configure の名乗りを wasm32-wasip1 から wasm32-unknown-linux-musl(BrowserOS の Linux)へ移すための直し。 - platform triplet は wasm32-linux-musl(拡張は .cpython-313-wasm32-linux-musl.so)。スレッドで名前を分けない - wheel の platform タグは browseros-<ABI の版>-wasm32。版は configure の BROWSEROS_ABI で受け取り、sysconfig の 変数にする(Android の API level と同じ役) - call trampoline は Linux の wasm32 でも組む。ctypes の引数の上限は __wasm__ で判定する - _posixsubprocess の C の実装は fork の無い OS では組まない(Lib/_posixsubprocess.py が posix_spawn で起こす) - subprocess の posix_spawn の道は、sys.platform ではなく「fork が無く posix_spawn がある」で選ぶ
glibc の ldconfig の表(-p)は musl に無く、BrowserOS の共有ライブラリは ELF でもないので、gcc・ld に聞く道でも
見つからない。threadpoolctl のように find_library("c") で libc を引いて dl_iterate_phdr を呼ぶものが、何も
見つけられなくなる。LD_LIBRARY_PATH と multiarch の置き場を直に探す(Alpine の CPython の直しと同じ考え)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
browser-python の CPython の名乗りを、configure の
--host=wasm32-wasip1からwasm32-unknown-linux-musl(BrowserOS の Linux)に移します。BrowserOS の土台の仕様(Progate/packages の docs/foundation/spec.md の 10)のとおりにするための変更です。sys.platformはlinuxwasm32-linux-musl(拡張は.cpython-313-wasm32-linux-musl.so)sysconfig.get_platform()はbrowseros-<世界の ABI の版>-wasm32(wheel のタグはbrowseros_2_wasm32)What was changed
Misc/platform_triplet.c: wasm32 の Linux はwasm32-linux-muslにしました。世界はいつもスレッド版なので、-threadsで名前を分けません。BROWSEROS_ABIを configure の変数で受け取り、sysconfig の変数にしました。Lib/sysconfig/__init__.py: wasm32 の Linux でBROWSEROS_ABIがあれば、browseros-<版>-wasm32を返すようにしました(Android がandroid_<API level>_<arch>を返すのと同じ役)。ビルドのホストの python は、sysconfig の値を書き出す前にここを通るので、wasm32 の Linux で走っているときだけ確かめます。Python/wasi_trampoline.c)を、Linux の wasm32 でも組むようにしました。_posixsubprocessの C の実装は fork(vfork)で子を起こすので、fork の無い OS では組みません。代わりにLib/_posixsubprocess.py(posix_spawn)を使います。Modules/_ctypes/ctypes.h: 引数の上限を__wasi__ではなく__wasm__で判定するようにしました。Lib/subprocess.py: posix_spawn の道を、sys.platform == "wasi"ではなく「fork が無く posix_spawn がある」で選ぶようにしました。multiprocessing と_browseros_subprocessのコメントも合わせました。Tools/build/regen-configure.sh(決まった版の autoconf のコンテナ)で作り直しました。WASI の筋に向けた前の直し(mmap・fcntl・termios を組む、
--enable-wasm-dynamic-linkingを受け付けるなど)は、Linux の筋では効かないので残っていても害はありません。この PR では触っていません。確かめたこと
Progate/packages の browser-python の
build-wasm.mjs --coreを、この fork の作業コピー(BROWSER_PYTHON_CPYTHON_SOURCE)で走らせました。python313.zipが組めた。_sysconfigdata__linux_wasm32-linux-musl.pyの値が次のとおりになった。MACHDEP:linuxMULTIARCH:wasm32-linux-muslSOABI:cpython-313-wasm32-linux-muslEXT_SUFFIX:.cpython-313-wasm32-linux-musl.soBROWSEROS_ABI:2🤖 Generated with Claude Code