mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-05 10:48:29 +00:00
Fix breakages in Linux-only build modes
- compile.com now polyfills -march=native which gcc/clang removed - Guarantee zero Windows code is linked into non-Windows binaries - MODE=tinylinux binaries are now back to being as tiny as ~4kb - Improve the runtime's stack allocation / alignment hack - GitHub Actions now tests Linux modes for assurance
This commit is contained in:
parent
0e4c828a8e
commit
3dc86ce154
32 changed files with 283 additions and 104 deletions
2
third_party/lua/lunix.c
vendored
2
third_party/lua/lunix.c
vendored
|
@ -205,7 +205,7 @@ int LuaUnixSysretErrno(lua_State *L, const char *call, int olderr) {
|
|||
struct UnixErrno *ep;
|
||||
int i, unixerr, winerr;
|
||||
unixerr = errno;
|
||||
winerr = GetLastError();
|
||||
winerr = IsWindows() ? GetLastError() : 0;
|
||||
if (!IsTiny() && !(0 < unixerr && unixerr < (!IsWindows() ? 4096 : 65536))) {
|
||||
WARNF("errno should not be %d", unixerr);
|
||||
}
|
||||
|
|
5
third_party/python/Lib/ntpath.py
vendored
5
third_party/python/Lib/ntpath.py
vendored
|
@ -664,10 +664,7 @@ def commonpath(paths):
|
|||
try:
|
||||
# GetFinalPathNameByHandle is available starting with Windows 6.0.
|
||||
# Windows XP and non-Windows OS'es will mock _getfinalpathname.
|
||||
if sys.getwindowsversion()[:2] >= (6, 0):
|
||||
_getfinalpathname = posix._getfinalpathname
|
||||
else:
|
||||
raise ImportError
|
||||
_getfinalpathname = posix._getfinalpathname
|
||||
except (AttributeError, ImportError, OSError):
|
||||
# On Windows XP and earlier, two files are the same if their absolute
|
||||
# pathnames are the same.
|
||||
|
|
|
@ -946,6 +946,10 @@ os__getfinalpathname(PyObject *module, PyObject *arg)
|
|||
PyObject *return_value = NULL;
|
||||
PyObject *path;
|
||||
|
||||
if (!IsWindows()) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
if (!PyArg_Parse(arg, "U:_getfinalpathname", &path)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -1037,6 +1041,9 @@ os__getvolumepathname_impl(PyObject *module, PyObject *path);
|
|||
static PyObject *
|
||||
os__getvolumepathname(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
if (!IsWindows()) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"path", NULL};
|
||||
static _PyArg_Parser _parser = {"U:_getvolumepathname", _keywords, 0};
|
||||
|
|
6
third_party/python/Python/errors.c
vendored
6
third_party/python/Python/errors.c
vendored
|
@ -4,6 +4,7 @@
|
|||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nt/enum/formatmessageflags.h"
|
||||
|
@ -11,6 +12,7 @@
|
|||
#include "libc/nt/memory.h"
|
||||
#include "libc/nt/process.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/dictobject.h"
|
||||
|
@ -589,6 +591,10 @@ PyObject *PyErr_SetExcFromWindowsErrWithFilenameObjects(
|
|||
PyObject *message;
|
||||
PyObject *args, *v;
|
||||
uint32_t err = (uint32_t)ierr;
|
||||
if (!IsWindows()) {
|
||||
PyErr_SetString(PyExc_SystemError, "this is not windows");
|
||||
return 0;
|
||||
}
|
||||
if (err==0) err = GetLastError();
|
||||
len = FormatMessage(
|
||||
/* Error API error */
|
||||
|
|
5
third_party/python/Python/sysmodule.c
vendored
5
third_party/python/Python/sysmodule.c
vendored
|
@ -1032,6 +1032,11 @@ sys_getwindowsversion(PyObject *self)
|
|||
void *verblock;
|
||||
uint32_t verblock_size;
|
||||
|
||||
if (!IsWindows()) {
|
||||
PyErr_SetString(PyExc_SystemError, "this is not windows");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ver.dwOSVersionInfoSize = sizeof(ver);
|
||||
if (!GetVersionEx(&ver))
|
||||
return PyErr_SetFromWindowsErr(0);
|
||||
|
|
4
third_party/sqlite3/zipfile.c
vendored
4
third_party/sqlite3/zipfile.c
vendored
|
@ -1420,8 +1420,8 @@ static int zipfileGetMode(
|
|||
** Both (const char*) arguments point to nul-terminated strings. Argument
|
||||
** nB is the value of strlen(zB). This function returns 0 if the strings are
|
||||
** identical, ignoring any trailing '/' character in either path. */
|
||||
static int zipfileComparePath(const char *zA, const char *zB, int nB){
|
||||
int nA = (int)strlen(zA);
|
||||
static int zipfileComparePath(const char *zA, const char *zB, size_t nB){
|
||||
size_t nA = strlen(zA);
|
||||
if( nA>0 && zA[nA-1]=='/' ) nA--;
|
||||
if( nB>0 && zB[nB-1]=='/' ) nB--;
|
||||
if( nA==nB && memcmp(zA, zB, nA)==0 ) return 0;
|
||||
|
|
2
third_party/xxhash/xxh_x86dispatch.c
vendored
2
third_party/xxhash/xxh_x86dispatch.c
vendored
|
@ -82,10 +82,12 @@ extern "C" {
|
|||
# define XXH_X86DISPATCH_ALLOW_AVX
|
||||
#endif
|
||||
|
||||
#if 0 /* [jart] be quiet */
|
||||
#if defined(__AVX__) && !defined(XXH_X86DISPATCH_ALLOW_AVX)
|
||||
# error "Error: if xxh_x86dispatch.c is compiled with AVX enabled, the resulting binary will crash on sse2-only cpus !! " \
|
||||
"If you nonetheless want to do that, please enable the XXH_X86DISPATCH_ALLOW_AVX build variable"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __has_include
|
||||
# define XXH_HAS_INCLUDE(header) __has_include(header)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue