[Vm-dev] [commit] r2484 - Move dialect-independence macros to sq.h
and use them on Mac OS.
commits at squeakvm.org
commits at squeakvm.org
Mon Aug 1 21:36:20 UTC 2011
Author: eliot
Date: 2011-08-01 14:36:19 -0700 (Mon, 01 Aug 2011)
New Revision: 2484
Modified:
branches/Cog/nscogbuild/unixbuild/HowToBuild
branches/Cog/platforms/Cross/vm/sq.h
branches/Cog/platforms/Cross/vm/sqSCCSVersion.h
branches/Cog/platforms/Mac OS/vm/sqMacMain.c
branches/Cog/platforms/Mac OS/vm/sqMacUnixCommandLineInterface.c
branches/Cog/platforms/unix/vm/sqUnixExternalPrims.c
branches/Cog/platforms/unix/vm/sqUnixMain.c
branches/Cog/unixbuild/HowToBuild
Log:
Move dialect-independence macros to sq.h and use them on Mac OS.
Format platforms/unix/vm/sqUnixExternalPrims.c so I can make sense of it and
hence avoid calling tryLoading with a null plugin. Update unix HowToBuilds
with info on avoiding gcc 3.4.x and -O2.
Modified: branches/Cog/nscogbuild/unixbuild/HowToBuild
===================================================================
--- branches/Cog/nscogbuild/unixbuild/HowToBuild 2011-07-31 22:48:45 UTC (rev 2483)
+++ branches/Cog/nscogbuild/unixbuild/HowToBuild 2011-08-01 21:36:19 UTC (rev 2484)
@@ -5,6 +5,8 @@
- How to build the Newspeak Cog VM on Unix
- Testing an external plugin has completely linked
- Compiling in 32-bit mode on a 64-bit linux
+ - Testing an external plugin has completely linked
+ - N.B. Please read: Optimization level and gcc version
How to build the Newspeak VM on Unix
-------------------------------
@@ -59,3 +61,13 @@
symbols, remake the plugin, capturing the link step and then supply
-Wl,--warn-unresolved-symbols -Wl,--no-allow-shlib-undefined
when manually repeating the link command
+
+
+Optimization level and gcc version
+----------------------------------
+There appear to be issues with 3.4.x gcc version on RedHat. In particular
+compiling the Newspeak VM with either of
+ gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)
+ gcc version 3.4.6 20060404 (Red Hat 3.4.6-10)
+using -O2 results in a VM that segfaults early in startup. For these compilers
+it is probably wise to use -O1, even though -O3 seems to work.
Modified: branches/Cog/platforms/Cross/vm/sq.h
===================================================================
--- branches/Cog/platforms/Cross/vm/sq.h 2011-07-31 22:48:45 UTC (rev 2483)
+++ branches/Cog/platforms/Cross/vm/sq.h 2011-08-01 21:36:19 UTC (rev 2484)
@@ -23,6 +23,18 @@
#define false 0
#define null 0 /* using "null" because nil is predefined in Think C */
+#if !defined(IMAGE_DIALECT_NAME)
+# if NewspeakVM
+# define IMAGE_DIALECT_NAME "Newspeak"
+# define DEFAULT_IMAGE_NAME "newspeak.image"
+# define IMAGE_ENV_NAME "NEWSPEAK_IMAGE"
+# else
+# define IMAGE_DIALECT_NAME "Squeak"
+# define DEFAULT_IMAGE_NAME "squeak.image"
+# define IMAGE_ENV_NAME "SQUEAK_IMAGE"
+# endif
+#endif
+
/* Pluggable primitives macros. */
/* Note: All pluggable primitives are defined as
Property changes on: branches/Cog/platforms/Cross/vm/sqSCCSVersion.h
___________________________________________________________________
Modified: checkindate
- Sun Jul 31 15:48:22 PDT 2011
+ Mon Aug 1 14:33:26 PDT 2011
Modified: branches/Cog/platforms/Mac OS/vm/sqMacMain.c
===================================================================
--- branches/Cog/platforms/Mac OS/vm/sqMacMain.c 2011-07-31 22:48:45 UTC (rev 2483)
+++ branches/Cog/platforms/Mac OS/vm/sqMacMain.c 2011-08-01 21:36:19 UTC (rev 2484)
@@ -130,7 +130,7 @@
gSqueakUIFlushSecondaryCleanupDelayMilliseconds=20,
gSqueakUIFlushSecondaryCheckForPossibleNeedEveryNMilliseconds=16,
gSqueakDebug=0;
-char gSqueakImageName[PATH_MAX] = "Squeak.image";
+char gSqueakImageName[PATH_MAX] = DEFAULT_IMAGE_NAME;
char gSqueakUntrustedDirectoryName[PATH_MAX] = "/foobar/tooBar/forSqueak/bogus/";
char gSqueakTrustedDirectoryName[PATH_MAX] = "/foobar/tooBar/forSqueak/bogus/";
CFStringRef gSqueakImageNameStringRef;
Modified: branches/Cog/platforms/Mac OS/vm/sqMacUnixCommandLineInterface.c
===================================================================
--- branches/Cog/platforms/Mac OS/vm/sqMacUnixCommandLineInterface.c 2011-07-31 22:48:45 UTC (rev 2483)
+++ branches/Cog/platforms/Mac OS/vm/sqMacUnixCommandLineInterface.c 2011-08-01 21:36:19 UTC (rev 2484)
@@ -250,7 +250,7 @@
printf(" %s [<option>...] -- [<argument>...]\n", argVec[0]);
printUsage();
printf("\nNotes:\n");
- printf(" <imageName> defaults to `Squeak.image'.\n");
+ printf(" <imageName> defaults to `" DEFAULT_IMAGE_NAME "'.\n");
printUsageNotes();
exit(1);
}
@@ -282,8 +282,8 @@
static void printUsageNotes(void)
{
printf(" If `-memory' is not specified then the heap will grow dynamically.\n");
- printf(" <argument>s are ignored, but are processed by the Squeak image.\n");
- printf(" The first <argument> normally names a Squeak `script' to execute.\n");
+ printf(" <argument>s are ignored, but are processed by the " IMAGE_DIALECT_NAME " image.\n");
+ printf(" The first <argument> normally names a " IMAGE_DIALECT_NAME " `script' to execute.\n");
printf(" Precede <arguments> by `--' to use default image.\n");
}
@@ -311,10 +311,12 @@
static void parseEnvironment(void)
{
- char *ev= 0;
+ char *ev;
- if ((ev= getenv("SQUEAK_IMAGE")))
- resolveWhatTheImageNameIs(ev);
- if ((ev= getenv("SQUEAK_MEMORY"))) gMaxHeapSize= strtobkm(ev);
- if ((ev= getenv("SQUEAK_PATHENC"))) setEncodingType(ev);
+ if ((ev= getenv(IMAGE_ENV_NAME)))
+ resolveWhatTheImageNameIs(ev);
+ if ((ev= getenv("SQUEAK_MEMORY")))
+ gMaxHeapSize= strtobkm(ev);
+ if ((ev= getenv("SQUEAK_PATHENC")))
+ setEncodingType(ev);
}
Modified: branches/Cog/platforms/unix/vm/sqUnixExternalPrims.c
===================================================================
--- branches/Cog/platforms/unix/vm/sqUnixExternalPrims.c 2011-07-31 22:48:45 UTC (rev 2483)
+++ branches/Cog/platforms/unix/vm/sqUnixExternalPrims.c 2011-08-01 21:36:19 UTC (rev 2484)
@@ -35,6 +35,7 @@
#endif
#include "sq.h" /* sqUnixConfig.h */
+#include "sqAssert.h"
#if (DEBUG)
# define DPRINTF(ARGS) fprintf ARGS
@@ -216,7 +217,8 @@
* moduleName and suffix. Answer the new module entry, or 0 if the shared
* library could not be loaded.
*/
-static void *tryLoading(char *dirName, char *moduleName)
+static void *
+tryLoading(char *dirName, char *moduleName)
{
static char *prefixes[]= { "", "lib", 0 };
static char *suffixes[]= { "", ".so", ".dylib", 0 };
@@ -224,33 +226,32 @@
char **prefix= 0, **suffix= 0;
for (prefix= prefixes; *prefix; ++prefix)
- for (suffix= suffixes; *suffix; ++suffix)
- {
- char libName[NAME_MAX + 32]; /* headroom for prefix/suffix */
- struct stat buf;
- int err;
- sprintf(libName, "%s%s%s%s", dirName, *prefix, moduleName, *suffix);
- if ((!(err= stat(libName, &buf))) && S_ISDIR(buf.st_mode))
- DPRINTF((stderr, "ignoring directory: %s\n", libName));
- else
- {
- DPRINTF((stderr, "tryLoading %s\n", libName));
- handle= dlopen(libName, RTLD_NOW | RTLD_GLOBAL);
- if (handle == 0)
- {
- if ((!err) && !(sqIgnorePluginErrors))
- fprintf(stderr, "ioLoadModule(%s):\n %s\n", libName, dlerror());
- }
- else
- {
-# if DEBUG
- printf("%s: loaded plugin `%s'\n", exeName, libName);
-# endif
- return handle;
- }
- }
- }
- return 0;
+ for (suffix= suffixes; *suffix; ++suffix) {
+ char libName[NAME_MAX + 32]; /* headroom for prefix/suffix */
+ struct stat buf;
+ int n;
+ n = sprintf(libName,"%s%s%s%s",dirName,*prefix,moduleName,*suffix);
+ assert(n >= 0 && n < NAME_MAX + 32);
+ if (!stat(libName, &buf)) {
+ if (S_ISDIR(buf.st_mode))
+ DPRINTF((stderr, "ignoring directory: %s\n", libName));
+ else {
+ DPRINTF((stderr, "tryLoading %s\n", libName));
+ handle= dlopen(libName, RTLD_NOW | RTLD_GLOBAL);
+ if (handle == 0) {
+ if (!sqIgnorePluginErrors)
+ fprintf(stderr, "ioLoadModule(%s):\n %s\n", libName, dlerror());
+ }
+ else {
+# if DEBUG
+ printf("%s: loaded plugin `%s'\n", exeName, libName);
+# endif
+ return handle;
+ }
+ }
+ }
+ }
+ return 0;
}
@@ -283,49 +284,44 @@
/* Find and load the named module. Answer 0 if not found (do NOT fail
* the primitive!).
*/
-void *ioLoadModule(char *pluginName)
+void *
+ioLoadModule(char *pluginName)
{
- void *handle= 0;
+ void *handle= 0;
- if ((pluginName == 0) || (pluginName[0] == '\0'))
- {
- handle= dlopen(0, RTLD_NOW | RTLD_GLOBAL);
- if (handle == 0)
- fprintf(stderr, "ioLoadModule(<intrinsic>): %s\n", dlerror());
- else
- {
- DPRINTF((stderr, "loaded: <intrinsic>\n"));
- return handle;
+ if (!pluginName || !*pluginName) {
+ if (!(handle= dlopen(0, RTLD_NOW | RTLD_GLOBAL))) {
+ fprintf(stderr, "ioLoadModule(<intrinsic>): %s\n", dlerror());
+ return 0;
+ }
+ DPRINTF((stderr, "loaded: <intrinsic>\n"));
+ return handle;
}
- }
- if (squeakPlugins)
- {
- char path[NAME_MAX];
- char c, *in= squeakPlugins, *out= path;
- while ((c= *in++))
- {
- if (c == '%' && ((*in == 'n') || (*in == 'N')))
- {
- ++in;
- strcpy(out, pluginName);
- out+= strlen(pluginName);
- }
- else
- *out++= c;
- }
- *out= '\0';
- DPRINTF((stderr, "ioLoadModule plugins = %s\n path = %s\n",
- squeakPlugins, path));
- if ((handle= tryLoading("", path)))
- return handle;
- if (!(out > path && *(out - 1) == '/')) {
- *out++= '/';
- *out= '\0';
+ if (squeakPlugins) {
+ char path[NAME_MAX];
+ char c, *in= squeakPlugins, *out= path;
+ while ((c= *in++)) {
+ if (c == '%' && ((*in == 'n') || (*in == 'N'))) {
+ ++in;
+ strcpy(out, pluginName);
+ out+= strlen(pluginName);
+ }
+ else
+ *out++= c;
+ }
+ *out= '\0';
+ DPRINTF((stderr, "ioLoadModule plugins = %s\n path = %s\n",
+ squeakPlugins, path));
+ if ((handle= tryLoading("", path)))
+ return handle;
+ if (!(out > path && *(out - 1) == '/')) {
+ *out++= '/';
+ *out= '\0';
+ }
+ if ((handle= tryLoading(path, pluginName)))
+ return handle;
}
- if ((handle= tryLoading(path, pluginName)))
- return handle;
- }
if (( handle= tryLoading( "./", pluginName))
|| (handle= tryLoadingPath("SQUEAK_PLUGIN_PATH", pluginName))
@@ -390,7 +386,6 @@
#endif
return 0;
}
-
#endif /* USE_SIMPLIFIED_PLUGIN_LOGIC */
/* Find a function in a loaded module. Answer 0 if not found (do NOT
Modified: branches/Cog/platforms/unix/vm/sqUnixMain.c
===================================================================
--- branches/Cog/platforms/unix/vm/sqUnixMain.c 2011-07-31 22:48:45 UTC (rev 2483)
+++ branches/Cog/platforms/unix/vm/sqUnixMain.c 2011-08-01 21:36:19 UTC (rev 2484)
@@ -1182,15 +1182,6 @@
if (documentName)
strcpy(shortImageName, documentName);
-#if NewspeakVM
-# define IMAGE_ENV_NAME "NEWSPEAK_IMAGE"
-# define IMAGE_DIALECT_NAME "Newspeak"
-# define DEFAULT_IMAGE_NAME "newspeak.image"
-#else
-# define IMAGE_ENV_NAME "SQUEAK_IMAGE"
-# define IMAGE_DIALECT_NAME "Squeak"
-# define DEFAULT_IMAGE_NAME "squeak.image"
-#endif
else if ((ev= getenv(IMAGE_ENV_NAME)))
strcpy(shortImageName, ev);
else
Modified: branches/Cog/unixbuild/HowToBuild
===================================================================
--- branches/Cog/unixbuild/HowToBuild 2011-07-31 22:48:45 UTC (rev 2483)
+++ branches/Cog/unixbuild/HowToBuild 2011-08-01 21:36:19 UTC (rev 2484)
@@ -6,6 +6,8 @@
- How to build the Cog Croquet VM on Unix
- Testing an external plugin has completely linked
- Compiling in 32-bit mode on a 64-bit linux
+ - Testing an external plugin has completely linked
+ - N.B. Please read: Optimization level and gcc version
Checking out sources
@@ -99,3 +101,13 @@
symbols, remake the plugin, capturing the link step and then supply
-Wl,--warn-unresolved-symbols -Wl,--no-allow-shlib-undefined
when manually repeating the link command
+
+
+Optimization level and gcc version
+----------------------------------
+There appear to be issues with 3.4.x gcc version on RedHat. In particular
+compiling the Newspeak VM with either of
+ gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)
+ gcc version 3.4.6 20060404 (Red Hat 3.4.6-10)
+using -O2 results in a VM that segfaults early in startup. For these compilers
+it is probably wise to use -O1, even though -O3 seems to work.
More information about the Vm-dev
mailing list