- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33.3k
Closed
Labels
OS-wasibuildThe build process and cross-buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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:
Lines 4 to 12 in eb50cd3
| #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:
cpython/Parser/tokenizer/file_tokenizer.c
Lines 1 to 9 in 01481f2
| #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
Metadata
Metadata
Assignees
Labels
OS-wasibuildThe build process and cross-buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error