mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Remove wildcard from Python build config
It's important for build performance to use := rather than = notation so that $(wildcard foo/*) isn't a lazily evaluated lambda. In the case of Python where we need a lot of tuning and excludes, it should help to spell things out a bit more to just not use wildcard for now.
This commit is contained in:
parent
53b9f83e1c
commit
10aade69e3
8 changed files with 257 additions and 1306 deletions
184
third_party/python/Python/dynload_aix.c
vendored
184
third_party/python/Python/dynload_aix.c
vendored
|
@ -1,184 +0,0 @@
|
|||
|
||||
/* Support for dynamic loading of extension modules */
|
||||
|
||||
#include "Python.h"
|
||||
#include "importdl.h"
|
||||
|
||||
#include <errno.h> /* for global errno */
|
||||
#include <string.h> /* for strerror() */
|
||||
#include <stdlib.h> /* for malloc(), free() */
|
||||
#include <sys/ldr.h>
|
||||
|
||||
|
||||
#ifdef AIX_GENUINE_CPLUSPLUS
|
||||
#include <load.h>
|
||||
#define aix_load loadAndInit
|
||||
#else
|
||||
#define aix_load load
|
||||
#endif
|
||||
|
||||
|
||||
extern char *Py_GetProgramName(void);
|
||||
|
||||
typedef struct Module {
|
||||
struct Module *next;
|
||||
void *entry;
|
||||
} Module, *ModulePtr;
|
||||
|
||||
const char *_PyImport_DynLoadFiletab[] = {".so", NULL};
|
||||
|
||||
static int
|
||||
aix_getoldmodules(void **modlistptr)
|
||||
{
|
||||
ModulePtr modptr, prevmodptr;
|
||||
struct ld_info *ldiptr;
|
||||
char *ldibuf;
|
||||
int errflag, bufsize = 1024;
|
||||
unsigned int offset;
|
||||
char *progname = Py_GetProgramName();
|
||||
|
||||
/*
|
||||
-- Get the list of loaded modules into ld_info structures.
|
||||
*/
|
||||
if ((ldibuf = malloc(bufsize)) == NULL) {
|
||||
PyErr_SetString(PyExc_ImportError, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
while ((errflag = loadquery(L_GETINFO, ldibuf, bufsize)) == -1
|
||||
&& errno == ENOMEM) {
|
||||
free(ldibuf);
|
||||
bufsize += 1024;
|
||||
if ((ldibuf = malloc(bufsize)) == NULL) {
|
||||
PyErr_SetString(PyExc_ImportError, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (errflag == -1) {
|
||||
PyErr_SetString(PyExc_ImportError, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
-- Make the modules list from the ld_info structures.
|
||||
*/
|
||||
ldiptr = (struct ld_info *)ldibuf;
|
||||
prevmodptr = NULL;
|
||||
do {
|
||||
if (strstr(progname, ldiptr->ldinfo_filename) == NULL &&
|
||||
strstr(ldiptr->ldinfo_filename, "python") == NULL) {
|
||||
/*
|
||||
-- Extract only the modules belonging to the main
|
||||
-- executable + those containing "python" as a
|
||||
-- substring (like the "python[version]" binary or
|
||||
-- "libpython[version].a" in case it's a shared lib).
|
||||
*/
|
||||
offset = (unsigned int)ldiptr->ldinfo_next;
|
||||
ldiptr = (struct ld_info *)((char*)ldiptr + offset);
|
||||
continue;
|
||||
}
|
||||
if ((modptr = (ModulePtr)malloc(sizeof(Module))) == NULL) {
|
||||
PyErr_SetString(PyExc_ImportError, strerror(errno));
|
||||
while (*modlistptr) {
|
||||
modptr = (ModulePtr)*modlistptr;
|
||||
*modlistptr = (void *)modptr->next;
|
||||
free(modptr);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
modptr->entry = ldiptr->ldinfo_dataorg;
|
||||
modptr->next = NULL;
|
||||
if (prevmodptr == NULL)
|
||||
*modlistptr = (void *)modptr;
|
||||
else
|
||||
prevmodptr->next = modptr;
|
||||
prevmodptr = modptr;
|
||||
offset = (unsigned int)ldiptr->ldinfo_next;
|
||||
ldiptr = (struct ld_info *)((char*)ldiptr + offset);
|
||||
} while (offset);
|
||||
free(ldibuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
aix_loaderror(const char *pathname)
|
||||
{
|
||||
|
||||
char *message[1024], errbuf[1024];
|
||||
PyObject *pathname_ob = NULL;
|
||||
PyObject *errbuf_ob = NULL;
|
||||
int i,j;
|
||||
|
||||
struct errtab {
|
||||
int errNo;
|
||||
char *errstr;
|
||||
} load_errtab[] = {
|
||||
{L_ERROR_TOOMANY, "too many errors, rest skipped."},
|
||||
{L_ERROR_NOLIB, "can't load library:"},
|
||||
{L_ERROR_UNDEF, "can't find symbol in library:"},
|
||||
{L_ERROR_RLDBAD,
|
||||
"RLD index out of range or bad relocation type:"},
|
||||
{L_ERROR_FORMAT, "not a valid, executable xcoff file:"},
|
||||
{L_ERROR_MEMBER,
|
||||
"file not an archive or does not contain requested member:"},
|
||||
{L_ERROR_TYPE, "symbol table mismatch:"},
|
||||
{L_ERROR_ALIGN, "text alignment in file is wrong."},
|
||||
{L_ERROR_SYSTEM, "System error:"},
|
||||
{L_ERROR_ERRNO, NULL}
|
||||
};
|
||||
|
||||
#define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1)
|
||||
|
||||
PyOS_snprintf(errbuf, sizeof(errbuf), "from module %.200s ", pathname);
|
||||
|
||||
if (!loadquery(L_GETMESSAGES, &message[0], sizeof(message))) {
|
||||
ERRBUF_APPEND(strerror(errno));
|
||||
ERRBUF_APPEND("\n");
|
||||
}
|
||||
for(i = 0; message[i] && *message[i]; i++) {
|
||||
int nerr = atoi(message[i]);
|
||||
for (j=0; j < Py_ARRAY_LENGTH(load_errtab); j++) {
|
||||
if (nerr == load_errtab[j].errNo && load_errtab[j].errstr)
|
||||
ERRBUF_APPEND(load_errtab[j].errstr);
|
||||
}
|
||||
while (Py_ISDIGIT(Py_CHARMASK(*message[i]))) message[i]++ ;
|
||||
ERRBUF_APPEND(message[i]);
|
||||
ERRBUF_APPEND("\n");
|
||||
}
|
||||
errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */
|
||||
pathname_ob = PyUnicode_FromString(pathname);
|
||||
errbuf_ob = PyUnicode_FromString(errbuf);
|
||||
PyErr_SetImportError(errbuf_ob, NULL, pathname);
|
||||
Py_DECREF(pathname_ob);
|
||||
Py_DECREF(errbuf_ob);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
dl_funcptr _PyImport_FindSharedFuncptr(const char *prefix,
|
||||
const char *shortname,
|
||||
const char *pathname, FILE *fp)
|
||||
{
|
||||
dl_funcptr p;
|
||||
|
||||
/*
|
||||
-- Invoke load() with L_NOAUTODEFER leaving the imported symbols
|
||||
-- of the shared module unresolved. Thus we have to resolve them
|
||||
-- explicitly with loadbind. The new module is loaded, then we
|
||||
-- resolve its symbols using the list of already loaded modules
|
||||
-- (only those that belong to the python executable). Get these
|
||||
-- with loadquery(L_GETINFO).
|
||||
*/
|
||||
|
||||
static void *staticmodlistptr = NULL;
|
||||
|
||||
if (!staticmodlistptr)
|
||||
if (aix_getoldmodules(&staticmodlistptr) == -1)
|
||||
return NULL;
|
||||
p = (dl_funcptr) aix_load((char *)pathname, L_NOAUTODEFER, 0);
|
||||
if (p == NULL) {
|
||||
aix_loaderror(pathname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
66
third_party/python/Python/dynload_hpux.c
vendored
66
third_party/python/Python/dynload_hpux.c
vendored
|
@ -1,66 +0,0 @@
|
|||
|
||||
/* Support for dynamic loading of extension modules */
|
||||
|
||||
#include "dl.h"
|
||||
#include <errno.h>
|
||||
|
||||
#include "Python.h"
|
||||
#include "importdl.h"
|
||||
|
||||
#if defined(__hp9000s300)
|
||||
#define FUNCNAME_PATTERN "_%.20s_%.200s"
|
||||
#else
|
||||
#define FUNCNAME_PATTERN "%.20s_%.200s"
|
||||
#endif
|
||||
|
||||
const char *_PyImport_DynLoadFiletab[] = {SHLIB_EXT, NULL};
|
||||
|
||||
dl_funcptr _PyImport_FindSharedFuncptr(const char *prefix,
|
||||
const char *shortname,
|
||||
const char *pathname, FILE *fp)
|
||||
{
|
||||
dl_funcptr p;
|
||||
shl_t lib;
|
||||
int flags;
|
||||
char funcname[258];
|
||||
|
||||
flags = BIND_FIRST | BIND_DEFERRED;
|
||||
if (Py_VerboseFlag) {
|
||||
flags = BIND_FIRST | BIND_IMMEDIATE |
|
||||
BIND_NONFATAL | BIND_VERBOSE;
|
||||
printf("shl_load %s\n",pathname);
|
||||
}
|
||||
lib = shl_load(pathname, flags, 0);
|
||||
/* XXX Chuck Blake once wrote that 0 should be BIND_NOSTART? */
|
||||
if (lib == NULL) {
|
||||
char buf[256];
|
||||
PyObject *pathname_ob = NULL;
|
||||
PyObject *buf_ob = NULL;
|
||||
PyObject *shortname_ob = NULL;
|
||||
|
||||
if (Py_VerboseFlag)
|
||||
perror(pathname);
|
||||
PyOS_snprintf(buf, sizeof(buf), "Failed to load %.200s",
|
||||
pathname);
|
||||
buf_ob = PyUnicode_FromString(buf);
|
||||
shortname_ob = PyUnicode_FromString(shortname);
|
||||
pathname_ob = PyUnicode_FromString(pathname);
|
||||
PyErr_SetImportError(buf_ob, shortname_ob, pathname_ob);
|
||||
Py_DECREF(buf_ob);
|
||||
Py_DECREF(shortname_ob);
|
||||
Py_DECREF(pathname_ob);
|
||||
return NULL;
|
||||
}
|
||||
PyOS_snprintf(funcname, sizeof(funcname), FUNCNAME_PATTERN,
|
||||
prefix, shortname);
|
||||
if (Py_VerboseFlag)
|
||||
printf("shl_findsym %s\n", funcname);
|
||||
if (shl_findsym(&lib, funcname, TYPE_UNDEFINED, (void *) &p) == -1) {
|
||||
shl_unload(lib);
|
||||
p = NULL;
|
||||
}
|
||||
if (p == NULL && Py_VerboseFlag)
|
||||
perror(funcname);
|
||||
|
||||
return p;
|
||||
}
|
111
third_party/python/Python/dynload_next.c
vendored
111
third_party/python/Python/dynload_next.c
vendored
|
@ -1,111 +0,0 @@
|
|||
|
||||
/* Support for dynamic loading of extension modules on Mac OS X
|
||||
** All references to "NeXT" are for historical reasons.
|
||||
*/
|
||||
|
||||
#include "Python.h"
|
||||
#include "importdl.h"
|
||||
|
||||
#include <mach-o/dyld.h>
|
||||
|
||||
const char *_PyImport_DynLoadFiletab[] = {".so", NULL};
|
||||
|
||||
/*
|
||||
** Python modules are Mach-O MH_BUNDLE files. The best way to load these
|
||||
** is each in a private namespace, so you can load, say, a module bar and a
|
||||
** module foo.bar. If we load everything in the global namespace the two
|
||||
** initbar() symbols will conflict.
|
||||
** However, it seems some extension packages depend upon being able to access
|
||||
** each others' global symbols. There seems to be no way to eat our cake and
|
||||
** have it, so the USE_DYLD_GLOBAL_NAMESPACE define determines which behaviour
|
||||
** you get.
|
||||
*/
|
||||
|
||||
#ifdef USE_DYLD_GLOBAL_NAMESPACE
|
||||
#define LINKOPTIONS NSLINKMODULE_OPTION_BINDNOW|NSLINKMODULE_OPTION_RETURN_ON_ERROR
|
||||
#else
|
||||
#define LINKOPTIONS NSLINKMODULE_OPTION_BINDNOW| \
|
||||
NSLINKMODULE_OPTION_RETURN_ON_ERROR|NSLINKMODULE_OPTION_PRIVATE
|
||||
#endif
|
||||
dl_funcptr _PyImport_FindSharedFuncptr(const char *prefix,
|
||||
const char *shortname,
|
||||
const char *pathname, FILE *fp)
|
||||
{
|
||||
dl_funcptr p = NULL;
|
||||
char funcname[258];
|
||||
NSObjectFileImageReturnCode rc;
|
||||
NSObjectFileImage image;
|
||||
NSModule newModule;
|
||||
NSSymbol theSym;
|
||||
const char *errString;
|
||||
char errBuf[512];
|
||||
|
||||
PyOS_snprintf(funcname, sizeof(funcname), "_%.20s_%.200s", prefix, shortname);
|
||||
|
||||
#ifdef USE_DYLD_GLOBAL_NAMESPACE
|
||||
if (NSIsSymbolNameDefined(funcname)) {
|
||||
theSym = NSLookupAndBindSymbol(funcname);
|
||||
p = (dl_funcptr)NSAddressOfSymbol(theSym);
|
||||
return p;
|
||||
}
|
||||
#endif
|
||||
rc = NSCreateObjectFileImageFromFile(pathname, &image);
|
||||
switch(rc) {
|
||||
default:
|
||||
case NSObjectFileImageFailure:
|
||||
case NSObjectFileImageFormat:
|
||||
/* for these a message is printed on stderr by dyld */
|
||||
errString = "Can't create object file image";
|
||||
break;
|
||||
case NSObjectFileImageSuccess:
|
||||
errString = NULL;
|
||||
break;
|
||||
case NSObjectFileImageInappropriateFile:
|
||||
errString = "Inappropriate file type for dynamic loading";
|
||||
break;
|
||||
case NSObjectFileImageArch:
|
||||
errString = "Wrong CPU type in object file";
|
||||
break;
|
||||
case NSObjectFileImageAccess:
|
||||
errString = "Can't read object file (no access)";
|
||||
break;
|
||||
}
|
||||
if (errString == NULL) {
|
||||
newModule = NSLinkModule(image, pathname, LINKOPTIONS);
|
||||
if (newModule == NULL) {
|
||||
int errNo;
|
||||
const char *fileName, *moreErrorStr;
|
||||
NSLinkEditErrors c;
|
||||
NSLinkEditError( &c, &errNo, &fileName, &moreErrorStr );
|
||||
PyOS_snprintf(errBuf, 512, "Failure linking new module: %s: %s",
|
||||
fileName, moreErrorStr);
|
||||
errString = errBuf;
|
||||
}
|
||||
}
|
||||
if (errString != NULL) {
|
||||
PyErr_SetString(PyExc_ImportError, errString);
|
||||
return NULL;
|
||||
}
|
||||
#ifdef USE_DYLD_GLOBAL_NAMESPACE
|
||||
if (!NSIsSymbolNameDefined(funcname)) {
|
||||
/* UnlinkModule() isn't implemented in current versions, but calling it does no harm */
|
||||
/* NSUnLinkModule(newModule, FALSE); removed: causes problems for ObjC code */
|
||||
PyErr_Format(PyExc_ImportError,
|
||||
"Loaded module does not contain symbol %.200s",
|
||||
funcname);
|
||||
return NULL;
|
||||
}
|
||||
theSym = NSLookupAndBindSymbol(funcname);
|
||||
#else
|
||||
theSym = NSLookupSymbolInModule(newModule, funcname);
|
||||
if ( theSym == NULL ) {
|
||||
/* NSUnLinkModule(newModule, FALSE); removed: causes problems for ObjC code */
|
||||
PyErr_Format(PyExc_ImportError,
|
||||
"Loaded module does not contain symbol %.200s",
|
||||
funcname);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
p = (dl_funcptr)NSAddressOfSymbol(theSym);
|
||||
return p;
|
||||
}
|
14
third_party/python/Python/strdup.c
vendored
14
third_party/python/Python/strdup.c
vendored
|
@ -1,14 +0,0 @@
|
|||
/* strdup() replacement (from stdwin, if you must know) */
|
||||
|
||||
#include "pgenheaders.h"
|
||||
|
||||
char *
|
||||
strdup(const char *str)
|
||||
{
|
||||
if (str != NULL) {
|
||||
char *copy = malloc(strlen(str) + 1);
|
||||
if (copy != NULL)
|
||||
return strcpy(copy, str);
|
||||
}
|
||||
return NULL;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue