On Mar 14, 2008, at 12:23 PM, Peter Schorn wrote:
I'm trying to build the latest gpc (gpc-20070904.tar.bz2) with Adriaan's patches on a Macintosh OS X 10.5.2. with Intel.
I configure with ../gcc-4.1.2/configure --enable-languages=pascal,c --enable- threads=posix --prefix=/Developer/Pascal/gpc412
but the "make bootstrap" fails with
Undefined symbols: "___sysctl", referenced from: ___enable_execute_stack in _enable_execute_stack_s.o ld: symbol(s) not found /usr/bin/libtool: internal link edit command failed make[3]: *** [libgcc_s.dylib] Error 1 make[2]: *** [libgcc.a] Error 2 make[1]: *** [stage1_build] Error 2 make: *** [bootstrap] Error 2
What am I missing?
I think you're missing the trampoline patch. I'm not sure what avenue I got it from Adriaan, but below is the trampoline patch that Adriaan and I ended up using in our attempts to get a gcc-4.1.2 based gpc-20070904 Mac OS X compiler built. Note: Last time I checked there's no fix for the back-end bug affecting the usability for production work for the Mac OS X gcc-4.1.2 based gpc-20070904 GPC build.
# Waldek Hebisch hebisch@math.uni.wroc.pl & Adriaan van Os gpc@microbizz.nl # Fix trampolines on i386-apple-darwin, by making the stack executable (see # http://www.gnu-pascal.de/crystal/gpc/en/mail12945.html and # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959)
diff -urN gcc-4.1.2-orig/gcc/config/i386/darwin.h gcc-4.1.2/gcc/ config/i386/darwin.h --- gcc-4.1.2-orig/gcc/config/i386/darwin.h 2005-11-15 05:55:12.000000000 +0100 +++ gcc-4.1.2/gcc/config/i386/darwin.h 2007-09-04 14:33:56.000000000 +0200 @@ -145,3 +148,50 @@ } \ else fprintf (FILE, "\tcall mcount\n"); \ } while (0) + + +/* Attempt to turn on execute permission for the stack. This may be + used by INITIALIZE_TRAMPOLINE of the target needs it (that is, + if the target machine can change execute permissions on a page). + + There is no way to query the execute permission of the stack, so + we always issue the mprotect() call. + + Note that we go out of our way to use namespace-non-invasive calls + here. Unfortunately, there is no libc-internal name for mprotect(). + + Also note that no errors should be emitted by this code; it is considered + dangerous for library calls to send messages to stdout/stderr. */ + +#define ENABLE_EXECUTE_STACK \ +extern void __enable_execute_stack (void *); \ +void \ +__enable_execute_stack (void *addr) \ +{ \ + extern int mprotect (void *, size_t, int); \ + extern int __sysctl (int *, unsigned int, void *, size_t *, \ + void *, size_t); \ + \ + static int size; \ + static long mask; \ + \ + char *page, *end; \ + \ + if (size == 0) \ + { \ + int mib[2]; \ + size_t len; \ + \ + mib[0] = 6; /* CTL_HW */ \ + mib[1] = 7; /* HW_PAGESIZE */ \ + len = sizeof (size); \ + (void) __sysctl (mib, 2, &size, &len, NULL, 0); \ + mask = ~((long) size - 1); \ + } \ + \ + page = (char *) (((long) addr) & mask); \ + end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \ + \ + /* 7 == PROT_READ | PROT_WRITE | PROT_EXEC */ \ + (void) mprotect (page, end - page, 7); \ +}
Gale Paeper gpaeper@empirenet.com