mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 13:52:28 +00:00
Fix bugs in cosmocc toolchain
This change integrates e58abc1110b335a3341e8ad5821ad8e3880d9bb2 from https://github.com/ahgamut/musl-cross-make/ which fixes the issues we were having with our C language extension for symbolic constants. This change also performs some code cleanup and bug fixes to getaddrinfo(). It's now possible to compile projects like ncurses, readline and python without needing to patch anything upstream, except maybe a line or two. Pretty soon it should be possible to build a Linux distro on Cosmo.
This commit is contained in:
parent
22f81a8d50
commit
23e235b7a5
272 changed files with 3491 additions and 4350 deletions
|
@ -27,13 +27,13 @@
|
|||
│ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, │
|
||||
│ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/mpdecimal.h"
|
||||
#include "libc/math.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/basearith.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/bits.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/convolute.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/crt.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/mpalloc.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/mpdecimal.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/typearith.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/umodarith.h"
|
||||
/* clang-format off */
|
||||
|
@ -3450,7 +3450,7 @@ mpd_qdivint(mpd_t *q, const mpd_t *a, const mpd_t *b,
|
|||
_settriple(q, sign, 0, 0);
|
||||
return;
|
||||
}
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
if (mpd_iszerocoeff(b)) {
|
||||
if (mpd_iszerocoeff(a)) {
|
||||
|
|
|
@ -27,12 +27,12 @@
|
|||
│ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, │
|
||||
│ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/mem/mem.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/transpose.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/bits.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/constants.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/mpdecimal.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/transpose.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/typearith.h"
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -237,7 +237,7 @@ transpose_pow2(mpd_uint_t *matrix, mpd_size_t rows, mpd_size_t cols)
|
|||
}
|
||||
}
|
||||
else {
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ _mpd_divmod_pow10(mpd_uint_t *q, mpd_uint_t *r, mpd_uint_t v, mpd_uint_t exp)
|
|||
case 17: DIVMOD(q, r, v, 100000000000000000ULL); break;
|
||||
case 18: DIVMOD(q, r, v, 1000000000000000000ULL); break;
|
||||
case 19: DIVMOD(q, r, v, 10000000000000000000ULL); break;
|
||||
default: unreachable;
|
||||
default: __builtin_unreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
10
third_party/python/Modules/gcmodule.c
vendored
10
third_party/python/Modules/gcmodule.c
vendored
|
@ -48,6 +48,11 @@ PYTHON_PROVIDE("gc.isenabled");
|
|||
PYTHON_PROVIDE("gc.set_debug");
|
||||
PYTHON_PROVIDE("gc.set_threshold");
|
||||
|
||||
#ifdef unreachable
|
||||
#define __unreachable unreachable
|
||||
#undef unreachable
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
Reference Cycle Garbage Collection
|
||||
|
@ -73,11 +78,6 @@ PYTHON_PROVIDE("gc.set_threshold");
|
|||
|
||||
*/
|
||||
|
||||
#ifdef unreachable
|
||||
#define __unreachable unreachable
|
||||
#undef unreachable
|
||||
#endif
|
||||
|
||||
/* Get an object's GC head */
|
||||
#define AS_GC(o) ((PyGC_Head *)(o)-1)
|
||||
|
||||
|
|
12
third_party/python/Objects/dictobject.c
vendored
12
third_party/python/Objects/dictobject.c
vendored
|
@ -4,8 +4,8 @@
|
|||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/likely.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/likely.h"
|
||||
#include "libc/log/countbranch.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
|
@ -720,7 +720,7 @@ lookdict_index(PyDictKeysObject *k, Py_hash_t hash, Py_ssize_t index)
|
|||
return DKIX_EMPTY;
|
||||
}
|
||||
}
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -858,7 +858,7 @@ top:
|
|||
}
|
||||
}
|
||||
}
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
/* Specialized version for string-only keys */
|
||||
|
@ -931,7 +931,7 @@ lookdict_unicode(PyDictObject *mp, PyObject *key,
|
|||
return ix;
|
||||
}
|
||||
}
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
/* Faster version of lookdict_unicode when it is known that no <dummy> keys
|
||||
|
@ -995,7 +995,7 @@ lookdict_unicode_nodummy(PyDictObject *restrict mp, PyObject *restrict key,
|
|||
return ix;
|
||||
}
|
||||
}
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
/* Version of lookdict for split tables.
|
||||
|
@ -1061,7 +1061,7 @@ lookdict_split(PyDictObject *mp, PyObject *key,
|
|||
return ix;
|
||||
}
|
||||
}
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
int
|
||||
|
|
4
third_party/python/Python/ast.c
vendored
4
third_party/python/Python/ast.c
vendored
|
@ -4,12 +4,12 @@
|
|||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Include/ast.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/ast.h"
|
||||
#include "third_party/python/Include/boolobject.h"
|
||||
#include "third_party/python/Include/compile.h"
|
||||
#include "third_party/python/Include/complexobject.h"
|
||||
|
@ -741,7 +741,7 @@ num_stmts(const node *n)
|
|||
Py_FatalError(buf);
|
||||
}
|
||||
}
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
/* Transform the CST rooted at node * to the appropriate AST
|
||||
|
|
4
third_party/python/Python/ceval.c
vendored
4
third_party/python/Python/ceval.c
vendored
|
@ -5,6 +5,7 @@
|
|||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define PY_LOCAL_AGGRESSIVE
|
||||
#include "third_party/python/Include/ceval.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/likely.h"
|
||||
#include "libc/runtime/stack.h"
|
||||
|
@ -12,7 +13,6 @@
|
|||
#include "third_party/python/Include/boolobject.h"
|
||||
#include "third_party/python/Include/bytesobject.h"
|
||||
#include "third_party/python/Include/cellobject.h"
|
||||
#include "third_party/python/Include/ceval.h"
|
||||
#include "third_party/python/Include/classobject.h"
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/descrobject.h"
|
||||
|
@ -3623,7 +3623,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
|
|||
|
||||
/* This should never be reached. Every opcode should end with DISPATCH()
|
||||
or goto error. */
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
|
||||
error:
|
||||
COLD_LABEL;
|
||||
|
|
17
third_party/python/Python/getcopyright.c
vendored
17
third_party/python/Python/getcopyright.c
vendored
|
@ -4,8 +4,8 @@
|
|||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/intrin/cmpxchg.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/stdio/append.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "third_party/python/Include/pylifecycle.h"
|
||||
|
@ -22,19 +22,18 @@ All Rights Reserved.\\n\
|
|||
Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\\n\
|
||||
All Rights Reserved.\"");
|
||||
|
||||
extern const char kLegalNotices[];
|
||||
|
||||
const char *
|
||||
Py_GetCopyright(void)
|
||||
{
|
||||
const char *p;
|
||||
static bool once;
|
||||
static char *res;
|
||||
if (_cmpxchg(&once, 0, 1)) {
|
||||
appends(&res, "");
|
||||
for (p = *_weaken(kLegalNotices); *p; p += strlen(p) + 1) {
|
||||
appends(&res, p);
|
||||
if (!res) {
|
||||
char *r = 0;
|
||||
const char *p;
|
||||
appends(&r, "");
|
||||
for (p = __comment_start; *p; p += strlen(p) + 1) {
|
||||
appends(&r, p);
|
||||
}
|
||||
res = r;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ void dzd(const char *s, void *p, size_t n, size_t z) {
|
|||
} else if (z == 4) {
|
||||
x = ((const uint32_t *)p)[i];
|
||||
} else {
|
||||
unreachable;
|
||||
__builtin_unreachable();
|
||||
}
|
||||
appendd(&r, t, zleb64(t, x - y) - t);
|
||||
y = x;
|
||||
|
|
2
third_party/python/freeze.c
vendored
2
third_party/python/freeze.c
vendored
|
@ -48,6 +48,8 @@ main(int argc, char *argv[])
|
|||
PyObject *code = NULL, *marshalled = NULL;
|
||||
int is_bootstrap = 1;
|
||||
|
||||
ShowCrashReports();
|
||||
|
||||
if (argc == 2 && !strcmp(argv[1], "-n")) return 0;
|
||||
|
||||
if (argc != 3) {
|
||||
|
|
1
third_party/python/pyobj.c
vendored
1
third_party/python/pyobj.c
vendored
|
@ -714,6 +714,7 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
int ec;
|
||||
ShowCrashReports();
|
||||
timestamp.tv_sec = 1647414000; /* determinism */
|
||||
/* clock_gettime(CLOCK_REALTIME, ×tamp); */
|
||||
GetOpts(argc, argv);
|
||||
|
|
2
third_party/python/python.mk
vendored
2
third_party/python/python.mk
vendored
|
@ -4048,6 +4048,7 @@ THIRD_PARTY_PYTHON_FREEZE_DIRECTDEPS = \
|
|||
LIBC_STDIO \
|
||||
LIBC_MEM \
|
||||
LIBC_STR \
|
||||
LIBC_LOG \
|
||||
LIBC_STUBS \
|
||||
LIBC_SYSV \
|
||||
LIBC_X \
|
||||
|
@ -4086,7 +4087,6 @@ o/$(MODE)/third_party/python/chibicc.inc: \
|
|||
libc/mem/mem.h \
|
||||
libc/nexgen32e/kcpuids.h \
|
||||
libc/runtime/runtime.h \
|
||||
libc/runtime/symbolic.h \
|
||||
libc/stdio/stdio.h \
|
||||
libc/str/str.h \
|
||||
libc/str/unicode.h \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue