-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile Python 2.7.2 with WASM #58
Comments
In file included from ../Modules/python.c:3: |
Where did you pull the source code from? |
The error persists because we are performing a cross-compilation, and Solution:Add the following line to #define PY_FORMAT_LONG_LONG "ll" |
I got the source code from here: https://www.python.org/downloads/release/python-272/ |
A lot of clues for things such as the one above should be in here: https://github.com/Lind-Project/lind_project/tree/main/tests/applications/python Python was the hardest app to build because its build process uses itself to package everything, but because we couldn't switch between native and Lind in the build process we had to compile a bunch of things by scratch. It would be cool to figure it out seemlessly this time but that may not be possible. |
This issue would be a good reference from my view |
Parser/pgen ../Grammar/Grammar ../Include/graminit.h ../Python/graminit.c |
The error occurred because the SolutionInspired by the Lind-NaCl compilation process, I followed these steps to resolve the issue:
|
../Modules/posixmodule.c:5873:21: error: use of undeclared identifier 'MAX_GROUPS' |
The error occurs because SolutionAdd the following line to the #define MAX_GROUPS 64 Explanation
|
../Modules/posixmodule.c:1800:11: error: call to undeclared function 'chflags'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] |
The error occurs because the function Solution: Disable
|
wasm-ld: error: unable to find library -lm |
This error happens because the linker ( SolutionTo resolve the issue, create a static /clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin/llvm-ar crs "/lind-wasm/glibc/sysroot/lib/wasm32-wasi/libm.a" Explanation
|
A little more progress on this:
|
I'm not sure about the zipimporter error but the PYTHONHOME/PYTHONPATH variables are env variables that need to be set. We did encounter this in lind-nacl. I think @Yaxuan-w knows what values they should be set to? |
I looked into the path that python is trying to load from, it turns out it is trying to load a file called |
I've discussed the readlink issue with Qianxi in part 2, and in the newest PR, I've added support for both readlink and readlinkat. Regarding the environment setup mentioned in part 3, here's the configuration I previously used: export LD_LIBRARY_PATH=/usr/local/python-gcc4/lib:/usr/local/pgsql/lib:$LD_LIBRARY_PATH
export PYTHONHOME="/usr/local/python-gcc4"
export PYTHONPATH="/usr/local/python-gcc4/lib/:/usr/local/python-gcc4/lib/python2.7/site-packages"
export PATH=/usr/local/python-gcc4/bin/:$PATH This setup is used for running:
This is the script I used to compile native-python: https://github.com/Lind-Project/lind_project/blob/alice-py-gcc4/tests/applications/python-native-gcc4/python-gcc4/bootstrap_native.sh From the error message Qianxi shared, part of the issue seems to be related to settings (e.g., os.py) and could potentially be resolved by adjusting the environment variables as shown above. From what I recall, the specific library files within lib-dynload (e.g., for math, datetime, etc.) are typically required at runtime for executing python code and I don't remember we used PYTHONHOME/PYTHONPATH in compilation. During the compilation process, I did not encounter any need to explicitly declare the lib-dynload path. In my setup, I completed the entire compilation process first, and only afterward created paths for config, site-packages, and lib-dynload. I'd prefer debugging from the perspective of reconfiguring the dependency env settings or figuring what's the current compilation stage (only a personal suggestion) |
The locale issue was because I forgot the compile crt1.c after merging fix-locale branch. So The next issue I encountered was from wasmtime, reporting that |
There are some other python builds with wasm floating around. May be worth checking them out to see if theyve changed anything. One that I came across is this which doesn't seem to be changing the source: https://github.com/emmatyping/python-wasm Are you building python with |
yes, I am using |
I looked into the code and I guess I have verified that what I said is exactly what is happening: The python-wasm builds is using python 3 instead of python 2, I am not sure if that's the reason they did not face such issue |
This blog post seems to be referencing what you're talking about: https://blog.pyodide.org/posts/function-pointer-cast-handling/ |
That's cool, I'll take a look at it later btw, after I bypassed
|
That's awesome! Almost there! |
I tried to use I have several thoughs about this. So, if I am understanding correctly,
These two strategies are not direct and general optimization to |
So previously I was able to run some simple python script like 1+1 with Next, I am getting another stack overflow error (call stack exhausted). But this time, it is because we have some infinite recursion: |
Great progress with this! Maybe open up a new issue for the math lib recursion and assign it to @robinyuan1002 |
I temporarily bypassed Next I am getting a weird issue from wasmtime reporting Btw, when running python without performing Asyncify transformation, we now got a python traceback error:
This is a pretty much expected error since we indeed do not have this file yet. I wonder how lind-nacl deals with this, like do python under lind-nacl has this file and how it is generated? @Yaxuan-w |
For the first Though I am still a little bit confused why the unoptimized version could yield |
There's a |
@qianxichen233 I've seen references to the "shadow stack" (sounds menacing!) like in this explanation: https://news.ycombinator.com/item?id=24220630 |
If you don't understand this, let me know. Using a shadow stack is a
somewhat uncommon technique in practice, but is fairly common in academia
…On Thu, Jan 9, 2025 at 12:47 PM Nicholas Renner ***@***.***> wrote:
@qianxichen233 <https://github.com/qianxichen233> I've seen references to
the "shadow stack" (sounds menacing!) like in this explanation:
https://news.ycombinator.com/item?id=24220630
—
Reply to this email directly, view it on GitHub
<#58 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGROD52COL7CMQGON75D4D2J2Y2DAVCNFSM6AAAAABSQZZUJKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOBQHEYTIMJYGY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
We now get this error. Looks like it has to do with uid. Do we have any clue for this?
|
Looks like it's because python tries to use |
We can create one for Python. Did we run into this before? This isn't a
big deal and many apps will have little things like this we need to do.
Justin
…On Thu, Jan 9, 2025 at 9:56 PM Qianxi Chen ***@***.***> wrote:
We now get this error. Looks like it has to do with uid. Do we have any
clue for this?
Traceback (most recent call last):
File "/usr/local/lib/python2.7/lib-dynload/site.py", line 563, in <module>
main()
File "/usr/local/lib/python2.7/lib-dynload/site.py", line 545, in main
known_paths = addusersitepackages(known_paths)
File "/usr/local/lib/python2.7/lib-dynload/site.py", line 278, in addusersitepackages
user_site = getusersitepackages()
File "/usr/local/lib/python2.7/lib-dynload/site.py", line 253, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/usr/local/lib/python2.7/lib-dynload/site.py", line 243, in getuserbase
USER_BASE = get_config_var('userbase')
File "/usr/local/lib/python2.7/lib-dynload/sysconfig.py", line 520, in get_config_var
return get_config_vars().get(name)
File "/usr/local/lib/python2.7/lib-dynload/sysconfig.py", line 424, in get_config_vars
_CONFIG_VARS['userbase'] = _getuserbase()
File "/usr/local/lib/python2.7/lib-dynload/sysconfig.py", line 182, in _getuserbase
return env_base if env_base else joinuser("~", ".local")
File "/usr/local/lib/python2.7/lib-dynload/sysconfig.py", line 169, in joinuser
return os.path.expanduser(os.path.join(*args))
File "/usr/local/lib/python2.7/lib-dynload/posixpath.py", line 260, in expanduser
userhome = pwd.getpwuid(os.getuid()).pw_dir
KeyError: 'getpwuid(): uid not found: 0'
Looks like it's because python tries to use /etc/passwd. Are we supposed
to have this file in lind?
—
Reply to this email directly, view it on GitHub
<#58 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGROD53I434RDAIAJIRMJD2J4ZHPAVCNFSM6AAAAABSQZZUJKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOBRGY2DANRUGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
This is the script we used before to load a bunch of config files including /etc/passwd: https://github.com/Lind-Project/lind_project/blob/main/src/scripts/base/load_confs.sh |
I tried to create |
That's amazing. This is a big step! Creating /etc/passwd in relation to the LINDROOT path doesn't work? That seems strange. |
We will create /etc/passwd manually in Lind by copy the file in |
We are currently attempting to compile Python version 2.7.2 with our Lind-WASM. We selected version 2.7.2 because it is the version used by Lind-NaCl, allowing for a fair comparison. I will also use this issue to track the compilation problems and document their solutions.
The text was updated successfully, but these errors were encountered: