Skip to content

WASI build is broken on certain environments #110749

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

Closed
FFY00 opened this issue Oct 12, 2023 · 0 comments
Closed

WASI build is broken on certain environments #110749

FFY00 opened this issue Oct 12, 2023 · 0 comments
Labels
build The build process and cross-build OS-wasi type-bug An unexpected behavior, bug, or error

Comments

@FFY00
Copy link
Member

FFY00 commented Oct 12, 2023

Bug report

Bug description:

Building CPython main for WASI in quay.io/tiran/cpythonbuild:emsdk3 results in:

../../Parser/tokenizer/file_tokenizer.c:156:9: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        lseek(fd, (off_t)(pos > 0 ? pos - 1 : pos), SEEK_SET) == (off_t)-1) {
        ^
../../Parser/tokenizer/file_tokenizer.c:156:9: note: did you mean 'fseek'?
/opt/wasi-sdk/bin/../share/wasi-sysroot/include/stdio.h:95:5: note: 'fseek' declared here
int fseek(FILE *, long, int);
    ^
../../Parser/tokenizer/file_tokenizer.c:395:12: error: implicit declaration of function 'read' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    return read(b.fd, (void *)buf, size);
           ^
../../Parser/tokenizer/file_tokenizer.c:395:12: note: did you mean 'fread'?
/opt/wasi-sdk/bin/../share/wasi-sysroot/include/stdio.h:102:8: note: 'fread' declared here
size_t fread(void *__restrict, size_t, size_t, FILE *__restrict);
       ^
2 errors generated.

This seems to be due to GH-110684, which moved the unistd.h import to the top during the refactoring. The import is now happening before pyconfig.h is included, so HAVE_UNISTD_H may be undefined.

Old code:

#include "Python.h"
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "tokenizer.h" // struct tok_state
#include "errcode.h" // E_OK
#ifdef HAVE_UNISTD_H
# include <unistd.h> // read()
#endif

New code:

#ifdef HAVE_UNISTD_H
# include <unistd.h> // read()
#endif
#include "Python.h"
#include "pycore_call.h"
#include "pycore_import.h"
#include "pycore_fileutils.h"
#include "errcode.h"

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

@FFY00 FFY00 added type-bug An unexpected behavior, bug, or error build The build process and cross-build labels Oct 12, 2023
FFY00 added a commit to FFY00/cpython that referenced this issue Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build OS-wasi type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants