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?
Peter --- peter.schorn@acm.org
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
Gale Paeper wrote:
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.
Actually I had installed the patch Gale mentioned and actually there is a problem. For some reason under 10.5.2 the symbol __sysctl is not found but sysctl works. I therefore replaced __sysctl by sysctl in the patch and the build now proceeds to a new kind of problem:
...
../.././xgpc -B../.././ -L../.. -I../rts --automake --executable-file-name -W -Wall -Wmissing-prototypes -Wmissing-declarations -g -DENABLE_CHECKING -DENABLE_ASSERT_CHECKING --executable-path=. --unit-path=/Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/rts --unit-path=/Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/units "/Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/utils/binobj.pas" can't find atom for N_GSYM stabs Gpc_input:G(0,2) in ../../libgpc.a(files.o) can't find atom for N_GSYM stabs Gpc_output:G(0,2) in ../../libgpc.a(files.o)
... more "can't find atom ..." ...
../.././xgpc -B../.././ -L../.. -I../rts --automake --executable-file-name -W -Wall -Wmissing-prototypes -Wmissing-declarations -g -DENABLE_CHECKING -DENABLE_ASSERT_CHECKING --executable-path=. --unit-path=/Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/rts --unit-path=/Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/units -I. -I "/Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p" "/Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/utils/gpidump.pas" /Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/utils/gpidump.pas: In procedure `Flags': /Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/utils/gpidump.pas:439: error: undeclared identifier `FUNCTION_TYPE' (first use in this routine)
... more syntax errors
/Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/utils/gpidump.pas: In procedure `ProcessFile': /Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/utils/gpidump.pas:1315: error: syntax error before `Close' make[3]: *** [gpidump] Error 1 make[2]: *** [pascal.utils] Error 2 make[1]: *** [stage1_build] Error 2 make: *** [bootstrap] Error 2
Any ideas what could be the problem?
Peter Schorn --- peter.schorn@acm.org
Peter Schorn wrote:
Actually I had installed the patch Gale mentioned and actually there is a problem. For some reason under 10.5.2 the symbol __sysctl is not found but sysctl works. I therefore replaced __sysctl by sysctl in the patch and the build now proceeds to a new kind of problem:
Will look at it but can't do that today - in a day or two.
Regards,
Adriaan van Os
On Mar 15, 2008, at 12:01 AM, Peter Schorn wrote:
Gale Paeper wrote:
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.
Actually I had installed the patch Gale mentioned and actually there is a problem. For some reason under 10.5.2 the symbol __sysctl is not found but sysctl works. I therefore replaced __sysctl by sysctl in the patch and the build now proceeds to a new kind of problem:
That one I think is new with 10.5.2. Since Adriaan's supplied trampoline patch doesn't use __sysctl, I'm curious as to where the symbol __sysctl occurrence is located.
...
../.././xgpc -B../.././ -L../.. -I../rts --automake --executable- file-name -W -Wall -Wmissing-prototypes -Wmissing-declarations -g - DENABLE_CHECKING -DENABLE_ASSERT_CHECKING --executable-path=. -- unit-path=/Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/rts -- unit-path=/Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/units "/ Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/utils/binobj.pas" can't find atom for N_GSYM stabs Gpc_input:G(0,2) in ../../libgpc.a (files.o) can't find atom for N_GSYM stabs Gpc_output:G(0,2) in ../../libgpc.a (files.o)
I encountered that one while trying to build the PPC 64 bit version of the static libgpc. Stabs format debugging symbols don't work/ aren't supportrf for the PPC64 [or 64 bit Mach-O ?] target. The fix is to turn off debugging symbol generation while building PPC64 PPC64 [or 64 bit Mach-O ?] targets.
The modification I made to Adriaan's build-on command file script was:
# build and install a 64-bit static libgpc
pushd gcc/p/rts make clean # make CFLAGS="-O2 -m64" make CFLAGS="-g0 -O2 -m64" sudo cp libgpc.a /Developer/Pascal/gpc412u1/lib/gcc/powerpc-apple- darwin8/4.1.2/ppc64/ popd
I also encountered problems trying to build the PPC64 dynanic libgpc in the linking stag. Since, your probably going to encounter that problem also, the modification I made to Adriaan's build-on command file script was:
# build and install a 64-bit dynamic libgpc
pushd gcc/p/rts make clean GPCSOLIBNAME=libgpc-gpc412u1.dylib # override GPCSOLIBOPTIONS to add -m64 to get ppc64 archecture linking make GPCSOLIBNAME=libgpc-gpc412u1.dylib GPCSOLIBOPTIONS="-m64 - dynamiclib -dylib_install_name,libgpc-gpc412u1.dylib" WITH_SHARED=yes TARGET_MACHO=1 CFLAGS="-O2 -g0 -m64" sudo lipo /usr/lib/libgpc-gpc412u1.dylib libgpc-gpc412u1.dylib - create -output /usr/lib/libgpc-gpc412u1.dylib popd cd ..
Note: The above two modified build command are from the build-on- powerpc-10-4.command file. Since your building on Intel, you'll need to make adjustments for cross-compiler compilimg.
... more "can't find atom ..." ...
../.././xgpc -B../.././ -L../.. -I../rts --automake --executable- file-name -W -Wall -Wmissing-prototypes -Wmissing-declarations -g - DENABLE_CHECKING -DENABLE_ASSERT_CHECKING --executable-path=. -- unit-path=/Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/rts -- unit-path=/Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/units - I. -I "/Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p" "/Users/ peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/utils/gpidump.pas" /Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/utils/gpidump.pas: In procedure `Flags': /Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/utils/gpidump.pas: 439: error: undeclared identifier `FUNCTION_TYPE' (first use in this routine)
The FUNCTION_TYPE declaration comes from the tree.inc file. That file gets autogenerated by the mk-t-inc shell script during the GPC building process. Check the build directory and see if a tree.inc is generated. The path to the file should be /build/gcc/p/utils/tree.inc.
Gale Paeper gpaeper@empirenet.com
Gale Paeper wrote:
Actually I had installed the patch Gale mentioned and actually there is a problem. For some reason under 10.5.2 the symbol __sysctl is not found but sysctl works. I therefore replaced __sysctl by sysctl in the patch and the build now proceeds to a new kind of problem:
That one I think is new with 10.5.2. Since Adriaan's supplied trampoline patch doesn't use __sysctl, I'm curious as to where the symbol __sysctl occurrence is located.
Yes, there may be a mix-up. The old trampoline patch *did* use __sysctl
# 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-3.4.5-orig/gcc/config/i386/darwin.h gcc-3.4.5/gcc/config/i386/darwin.h --- gcc-3.4.5-orig/gcc/config/i386/darwin.h 2005-12-15 17:41:52.000000000 +0100 +++ gcc-3.4.5/gcc/config/i386/darwin.h 2005-12-17 15:31:03.000000000 +0100 @@ -137,3 +140,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); \ +}
but it was changed for Mac OS X 10.5 *not* to use __sysctl, as follows
# 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) # later modified by Geoffrey Keating # 2006-09-27 Geoffrey Keating geoffk@apple.com # avoid use of __sysctl on Darwin # see http://gcc.gnu.org/ml/gcc-patches/2006-09/msg01277.html # 20070922, and then backported to gcc-3.4.5 by Adriaan van Os gpc@microbizz.nl
diff -ur gcc-3.4.5-orig/gcc/config/i386/darwin.h gcc-3.4.5/gcc/config/i386/darwin.h --- gcc-3.4.5-orig/gcc/config/i386/darwin.h 2004-08-23 20:03:13.000000000 +0200 +++ gcc-3.4.5/gcc/config/i386/darwin.h 2007-09-23 13:22:24.000000000 +0200 @@ -137,3 +140,42 @@ } \ 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. + + Unfortunately it is not possible to make this namespace-clean. + + 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 getpagesize (void); \ + static int size; \ + static long mask; \ + \ + char *page, *end; \ + \ + if (size == 0) \ + { \ + size = getpagesize(); \ + mask = ~((long) size - 1); \ + } \ + \ + page = (char *) (((long) addr) & mask); \ + end = (char *) ((((long) (addr + (TARGET_64BIT ? 48 : 40))) & mask) + size); \ + \ + /* 7 == PROT_READ | PROT_WRITE | PROT_EXEC */ \ + (void) mprotect (page, end - page, 7); \ +}
Regards,
Adriaan van Os
some status below
Adriaan van Os wrote:
Gale Paeper wrote:
Actually I had installed the patch Gale mentioned and actually there is a problem. For some reason under 10.5.2 the symbol __sysctl is not found but sysctl works. I therefore replaced __sysctl by sysctl in the patch and the build now proceeds to a new kind of problem:
That one I think is new with 10.5.2. Since Adriaan's supplied trampoline patch doesn't use __sysctl, I'm curious as to where the symbol __sysctl occurrence is located.
Yes, there may be a mix-up. The old trampoline patch *did* use __sysctl
[... patches omitted ... ]
I can confirm that using the latest patch (which btw is also included in gcc 4.2.3 and 4.3.0 solves the original sysctl problem for latest gpc (gpc-20070904.tar.bz2) based on gcc 3.4.5 and based on 4.1.2.
Unfortunately I the build of "make bootstrap" terminates prematurely with
... (based on gcc 3.4.5) /Users/peterschorn/projects/gpc3/gcc-3.4.5/gcc/p/utils/gpidump.pas:1185: error: undeclared identifier `RTL_EXPR' (first use in this routine) make[3]: *** [gpidump] Error 1 make[2]: *** [pascal.utils] Error 2 make[1]: *** [stage1_build] Error 2 make: *** [bootstrap] Error 2
resp.
... (based on gcc 4.1.2) /Users/peterschorn/projects/gpc4/gcc-4.1.2/gcc/p/utils/gpidump.pas:1315: error: syntax error before `Close' make[3]: *** [gpidump] Error 1 make[2]: *** [pascal.utils] Error 2 make[1]: *** [stage1_build] Error 2 make: *** [bootstrap] Error 2
In the build based on gcc 3.4.5. there is no mention of the "can't find atom ..." I saw in 4.1.2. so probably this is not related to the problem leading to the issue.
I then looked at gpidump.pas and interestingly enough the error messages are actually justified since the generated - now I'm looking whether the 10.5.2 supplied sed has an issue ...
Peter --- peter.schorn@acm.org
The problem is solved - I can now successfully build a working gpc (cross) compiler on Intel Mac OS X 10.5.2. The following items did the trick:
1) A sysctl-free patch for __enable_execute_stack (Thanks to Adriaan and Gale for helping on this one)
2) Using sed 4.1.4. instead of the Apple supplied version of sed (maybe it would help to add an sed check in mk-t-inc).
Peter --- peter.schorn@acm.org
Peter Schorn wrote:
The problem is solved - I can now successfully build a working gpc (cross) compiler on Intel Mac OS X 10.5.2. The following items did the trick:
- A sysctl-free patch for __enable_execute_stack (Thanks to Adriaan and
Gale for helping on this one)
- Using sed 4.1.4. instead of the Apple supplied version of sed (maybe
it would help to add an sed check in mk-t-inc).
Good to hear so.
The build script included with the sources at my website automatically installs a GNU sed (the sed that comes with Mac OS X is a BSD sed).
Regards,
Adriaan van Os
Peter Schorn wrote:
- Using sed 4.1.4. instead of the Apple supplied version of sed (maybe
it would help to add an sed check in mk-t-inc).
Which sed feature or invocation is problematic actually? I tried not to use any GNU sed specific feature in this script.
To check it, I just tried with minised, and it works fine. Could you send me or point me to the source code of Apple's sed? (I don't use Mac OS, but given the source, I could probably try it under Linux.) When I know what doesn't work, I might be able to amend the script.
Frank
Frank Heckenbach wrote:
Peter Schorn wrote:
- Using sed 4.1.4. instead of the Apple supplied version of sed (maybe
it would help to add an sed check in mk-t-inc).
Which sed feature or invocation is problematic actually? I tried not to use any GNU sed specific feature in this script.
I will follow up with that.
To check it, I just tried with minised, and it works fine. Could you send me or point me to the source code of Apple's sed? (I don't use Mac OS, but given the source, I could probably try it under Linux.) When I know what doesn't work, I might be able to amend the script.
Darwin source can be found at http://www.opensource.apple.com/darwinsource/, e.g. http://www.opensource.apple.com/darwinsource/tarballs/apsl/text_cmds-68.tar.gz (free registration is required) or (if that's a problem) http://www.microbizz.nl/text_cmds-68.tar.gz
Regards,
Adriaan van Os
Adriaan van Os wrote:
Frank Heckenbach wrote:
Peter Schorn wrote:
- Using sed 4.1.4. instead of the Apple supplied version of sed
(maybe it would help to add an sed check in mk-t-inc).
Which sed feature or invocation is problematic actually? I tried not to use any GNU sed specific feature in this script.
I will follow up with that.
The gcc/p/utils/tree.inc created with the darwin system-installed sed ends with:
SN (gpc_type_PObjectType) SN (inoutres_variable_node) SN (null_pseudo_const_node)}
{$endif}
It doesn't have any of the
DEFTREECODE (ERROR_MARK, "error_mark", 'x', 0) DEFTREECODE (IDENTIFIER_NODE, "identifier_node", 'x', 0) ..... DEFTREECODE (RANGE_CHECK_EXPR, "range_check_expr", 'e', 3) DEFTREECODE (IO_RANGE_CHECK_EXPR, "io_range_check_expr", 'e', 3) #endif
that popup after rebuilding with gnu-sed-4.1.4 installed.
Also, there is the following problem when using the darwin system-installed sed
rm -rf p/docdemos ../../gcc-3.4.6/gcc/p/script/mkdir-p p/docdemos ../../gcc-3.4.6/gcc/p/script/extract-doc-demos -o p/docdemos ../../gcc-3.4.6/gcc/p/doc/*.texi ../../gcc-3.4.6/gcc/p/doc/generated/*.texi ../../gcc-3.4.6/gcc/p/doc/en/*.texi
Sorry, I could not find a non-crippled version of `sed' (one that understands regular expressions, in particular `|'). If or when you have installed one, e.g., GNU sed, available from ftp://ftp.gnu.org/pub/gnu/sed/ please install it as `sed', `gsed', or point the environment variable `SED' to it, and re-run.
This script needs a good sed to extract the demo programs from the GPC Manual. You can continue now and skip the installation of these demos.
Press ENTER to continue without docdemos; ^C to abort.
Regards,
Adriaan van Os
Adriaan van Os wrote:
To check it, I just tried with minised, and it works fine. Could you send me or point me to the source code of Apple's sed? (I don't use Mac OS, but given the source, I could probably try it under Linux.) When I know what doesn't work, I might be able to amend the script.
Darwin source can be found at http://www.opensource.apple.com/darwinsource/, e.g. http://www.opensource.apple.com/darwinsource/tarballs/apsl/text_cmds-68.tar.gz (free registration is required) or (if that's a problem) http://www.microbizz.nl/text_cmds-68.tar.gz
The last link gives me a zero-length file.
Adriaan van Os wrote:
Frank Heckenbach wrote:
Peter Schorn wrote:
- Using sed 4.1.4. instead of the Apple supplied version of sed
(maybe it would help to add an sed check in mk-t-inc).
Which sed feature or invocation is problematic actually? I tried not to use any GNU sed specific feature in this script.
I will follow up with that.
The gcc/p/utils/tree.inc created with the darwin system-installed sed ends with:
SN (gpc_type_PObjectType) SN (inoutres_variable_node) SN (null_pseudo_const_node)}
{$endif}
It doesn't have any of the
DEFTREECODE (ERROR_MARK, "error_mark", 'x', 0) DEFTREECODE (IDENTIFIER_NODE, "identifier_node", 'x', 0) ..... DEFTREECODE (RANGE_CHECK_EXPR, "range_check_expr", 'e', 3) DEFTREECODE (IO_RANGE_CHECK_EXPR, "io_range_check_expr", 'e', 3) #endif
that popup after rebuilding with gnu-sed-4.1.4 installed.
So it's the last "sed" invocation in the script that fails.
There may be a missing semicolon. At least I thought sed requires a ";" (or newline) before "}", and some examples I've just checked seem to suggest so, so I'm a bit surprised GNU sed works without it.
Otherwise I don't see any of the typical problems I've had with other seds here.
--- p/utils/mk-t-inc.orig Sat Apr 19 03:03:24 2008 +++ p/utils/mk-t-inc Sat Apr 19 03:03:57 2008 @@ -72,5 +72,5 @@ cat "$GCCDIR/tree.def" echo 'DEFTREECODE (LAST_AND_UNUSED_C_TREE_CODE, "unused", '"'x', 0)" sed -e '/#ifdef EGCS/,${/#ifdef EGCS/d;/#else/,/#endif/d;}' "$GCCDIR/p/p-tree.def" -} | sed -ne ':loop;/\$/{N;b loop};/^DEFTREECODE/{s,/*.**/,,;s/["'"'"']x["'"'"'].*/'"'x', 0)/;p;};/^#/p" +} | sed -ne ':loop;/\$/{N;b loop;};/^DEFTREECODE/{s,/*.**/,,;s/["'"'"']x["'"'"'].*/'"'x', 0)/;p;};/^#/p" } > "$2" || { rm -f "$2"; false; }
Also, there is the following problem when using the darwin system-installed sed rm -rf p/docdemos ../../gcc-3.4.6/gcc/p/script/mkdir-p p/docdemos [...]
For docdemos that's expected, as the extraction script needs full regex features. But docdemos are not essential for building GPC, so it lets you skip this step.
Frank
Frank Heckenbach wrote:
Darwin source can be found at http://www.opensource.apple.com/darwinsource/, e.g. http://www.opensource.apple.com/darwinsource/tarballs/apsl/text_cmds-68.tar.gz (free registration is required) or (if that's a problem) http://www.microbizz.nl/text_cmds-68.tar.gz
The last link gives me a zero-length file.
Oops, fixed that now.
Regards,
Adriaan van Os
Adriaan van Os wrote:
Frank Heckenbach wrote:
Darwin source can be found at http://www.opensource.apple.com/darwinsource/, e.g. http://www.opensource.apple.com/darwinsource/tarballs/apsl/text_cmds-68.tar.gz (free registration is required) or (if that's a problem) http://www.microbizz.nl/text_cmds-68.tar.gz
The last link gives me a zero-length file.
Oops, fixed that now.
Thanks. -- Apparently it doesn't like ";" after labels and branches, and wants a newline. So try this:
--- p/utils/mk-t-inc.orig Sun Apr 20 15:38:25 2008 +++ p/utils/mk-t-inc Sun Apr 20 15:41:16 2008 @@ -72,6 +72,11 @@ cat "$GCCDIR/tree.def" echo 'DEFTREECODE (LAST_AND_UNUSED_C_TREE_CODE, "unused", '"'x', 0)" sed -e '/#ifdef EGCS/,${/#ifdef EGCS/d;/#else/,/#endif/d;}' "$GCCDIR/p/p-tree.def" -} | sed -ne ':loop;/\$/{N;bloop;};/^DEFTREECODE/{s,/*.**/,,;s/["'"'"']x["'"'"'].*/'"'x', 0)/;p;}" +} | sed -ne ':loop + /\$/{ + N + bloop + } + /^DEFTREECODE/{s,/*.**/,,;s/["'"'"']x["'"'"'].*/'"'x'"', 0)/;p;}'
} > "$2" || { rm -f "$2"; false; }
I noticed, by the way, another peculiarity of the Darwin system sed. GNU-sed 4.1.5 doesn't build, GNU-sed 4.1.4 does ! So, you need to build and install GNU-sed 4.1.4, before you can build GNU-sed 4.1.5.
I don't know. You could try reporting this to the GNU sed developers. It might be an equally "trivial" issue ...
Frank
Frank Heckenbach wrote:
Thanks. -- Apparently it doesn't like ";" after labels and branches, and wants a newline. So try this:
--- p/utils/mk-t-inc.orig Sun Apr 20 15:38:25 2008 +++ p/utils/mk-t-inc Sun Apr 20 15:41:16 2008 @@ -72,6 +72,11 @@ cat "$GCCDIR/tree.def" echo 'DEFTREECODE (LAST_AND_UNUSED_C_TREE_CODE, "unused", '"'x', 0)" sed -e '/#ifdef EGCS/,${/#ifdef EGCS/d;/#else/,/#endif/d;}' "$GCCDIR/p/p-tree.def" -} | sed -ne ':loop;/\$/{N;bloop;};/^DEFTREECODE/{s,/*.**/,,;s/["'"'"']x["'"'"'].*/'"'x', 0)/;p;}" +} | sed -ne ':loop
/\\$/{
N
bloop
}
/^DEFTREECODE/{s,/\*.*\*/,,;s/["'"'"']x["'"'"'].*/'"'x'"', 0)/;p;}'
} > "$2" || { rm -f "$2"; false; }
This fixes the problem, thanks.
To apply, I had to change the patch to
--- p/utils/mk-t-inc-orig 2008-04-21 07:37:57.000000000 +0200 +++ p/utils/mk-t-inc 2008-04-21 07:39:08.000000000 +0200 @@ -72,5 +72,10 @@ cat "$GCCDIR/tree.def" echo 'DEFTREECODE (LAST_AND_UNUSED_C_TREE_CODE, "unused", '"'x', 0)" sed -e '/#ifdef EGCS/,${/#ifdef EGCS/d;/#else/,/#endif/d;}' "$GCCDIR/p/p-tree.def" -} | sed -ne ':loop;/\$/{N;b loop};/^DEFTREECODE/{s,/*.**/,,;s/["'"'"']x["'"'"'].*/'"'x', 0)/;p;};/^#/p" +} | sed -ne ':loop + /\$/{ + N + bloop + } + /^DEFTREECODE/{s,/*.**/,,;s/["'"'"']x["'"'"'].*/'"'x'"', 0)/;p;}' } > "$2" || { rm -f "$2"; false; }
Regards,
Adriaan van Os
Thanks. -- Apparently it doesn't like ";" after labels and branches, and wants a newline. So try this:
--- p/utils/mk-t-inc.orig Sun Apr 20 15:38:25 2008 +++ p/utils/mk-t-inc Sun Apr 20 15:41:16 2008 @@ -72,6 +72,11 @@ cat "$GCCDIR/tree.def" echo 'DEFTREECODE (LAST_AND_UNUSED_C_TREE_CODE, "unused", '"'x', 0)" sed -e '/#ifdef EGCS/,${/#ifdef EGCS/d;/#else/,/#endif/d;}' "$GCCDIR/p/p-tree.def" -} | sed -ne ':loop;/\$/{N;bloop;};/^DEFTREECODE/{s,/*.**/,,;s/["'"'"']x["'"'"'].*/'"'x', 0)/;p;}" +} | sed -ne ':loop
/\\$/{
N
bloop
}
/^DEFTREECODE/{s,/\*.*\*/,,;s/["'"'"']x["'"'"'].*/'"'x'"', 0)/;p;}'
} > "$2" || { rm -f "$2"; false; }
This fixes the problem, thanks.
That's what I thought -- but there still is a problem. The tree.inc created with the patched p/utils/mk-t-inc and the Darwin system-sed doesn't have any #ifdef GCC_xx conditions and this results in duplicate symbols:
"/Users/adriaan/gnu/gpc/gpc346u3/gcc-3.4.6/gcc/p/utils/mk-t-inc" "/Users/adriaan/gnu/gpc/gpc346u3/gcc-3.4.6/gcc" "tree.inc" ../.././xgpc -B../.././ -L../.. -I../rts --automake --executable-file-name -W -Wall -Wmissing-prototypes -Wmissing-declarations -g --executable-path=. --unit-path=/Users/adriaan/gnu/gpc/gpc346u3/gcc-3.4.6/gcc/p/rts --unit-path=/Users/adriaan/gnu/gpc/gpc346u3/gcc-3.4.6/gcc/p/units -I. -I "/Users/adriaan/gnu/gpc/gpc346u3/gcc-3.4.6/gcc/p" "/Users/adriaan/gnu/gpc/gpc346u3/gcc-3.4.6/gcc/p/utils/gpidump.pas" /Users/adriaan/gnu/gpc/gpc346u3/gcc-3.4.6/gcc/p/utils/gpidump.pas: In procedure `ProcessFile': /Users/adriaan/gnu/gpc/gpc346u3/gcc-3.4.6/gcc/p/utils/gpidump.pas:45: error: redeclaration of `In_expr' /Users/adriaan/gnu/gpc/gpc346u3/gcc-3.4.6/gcc/p/utils/gpidump.pas:45: error: previous declaration /Users/adriaan/gnu/gpc/gpc346u3/gcc-3.4.6/gcc/p/utils/gpidump.pas:45: error: redeclaration of `Operator_decl' /Users/adriaan/gnu/gpc/gpc346u3/gcc-3.4.6/gcc/p/utils/gpidump.pas:45: error: previous declaration
Here is the diff for tree.inc
--- tree-ok.inc 2008-04-21 08:13:44.000000000 +0200 +++ tree-bad.inc 2008-04-21 07:55:53.000000000 +0200 @@ -1,4 +1,4 @@ -{ Generated automatically by /Users/adriaan/gnu/gpc/gpc346u2/gcc-3.4.6/gcc/p/utils/mk-t-inc for GCC version 3.4.6. } +{ Generated automatically by /Users/adriaan/gnu/gpc/gpc346u3/gcc-3.4.6/gcc/p/utils/mk-t-inc for GCC version 3.4.6. } { DO NOT CHANGE THIS FILE MANUALLY! }
{$ifndef GCC_VERSION_SET} @@ -265,7 +265,6 @@ DEFTREECODE (SWITCH_EXPR, "switch_expr", 'e', 2) DEFTREECODE (EXC_PTR_EXPR, "exc_ptr_expr", 'e', 0) DEFTREECODE (LAST_AND_UNUSED_C_TREE_CODE, "unused", 'x', 0) -#ifdef GCC_4_0 DEFTREECODE (OPERATOR_DECL, "operator_decl", tcc_declaration, 0) DEFTREECODE (INTERFACE_NAME_NODE, "interface_name_node", tcc_exceptional, 3) DEFTREECODE (IMPORT_NODE, "import_node", tcc_exceptional, 4) @@ -277,10 +276,7 @@ DEFTREECODE (RANGE_CHECK_EXPR, "range_check_expr", tcc_expression, 3) DEFTREECODE (IO_RANGE_CHECK_EXPR, "io_range_check_expr", tcc_expression, 3) DEFTREECODE (IN_EXPR, "in_expr", tcc_binary, 2) -#ifdef GCC_4_1 DEFTREECODE (PASCAL_SET_CONSTRUCTOR, "pascal_set_constructor", tcc_expression, 1) -#endif -#else DEFTREECODE (OPERATOR_DECL, "operator_decl", 'd', 0) DEFTREECODE (INTERFACE_NAME_NODE, "interface_name_node", 'x', 0) DEFTREECODE (IMPORT_NODE, "import_node", 'x', 0) @@ -291,4 +287,3 @@ DEFTREECODE (SYMDIFF_EXPR, "symdiff_expr", '2', 2) DEFTREECODE (RANGE_CHECK_EXPR, "range_check_expr", 'e', 3) DEFTREECODE (IO_RANGE_CHECK_EXPR, "io_range_check_expr", 'e', 3) -#endif
Regards,
Adriaan van Os
Adriaan van Os wrote:
This fixes the problem, thanks.
That's what I thought -- but there still is a problem. The tree.inc created with the patched p/utils/mk-t-inc and the Darwin system-sed doesn't have any #ifdef GCC_xx conditions and this results in duplicate symbols:
Sorry, there was a part missing. Try this:
--- mk-t-inc.orig Mon Apr 21 15:50:47 2008 +++ mk-t-inc Mon Apr 21 16:08:09 2008 @@ -71,6 +71,14 @@ { cat "$GCCDIR/tree.def" echo 'DEFTREECODE (LAST_AND_UNUSED_C_TREE_CODE, "unused", '"'x', 0)" - sed -e '/#ifdef EGCS/,${/#ifdef EGCS/d;/#else/,/#endif/d;}' "$GCCDIR/p/p-tree.def" -} | sed -ne ':loop;/\$/{N;b loop};/^DEFTREECODE/{s,/*.**/,,;s/["'"'"']x["'"'"'].*/'"'x', 0)/;p;};/^#/p" + sed -e '/#ifdef EGCS/,${/#ifdef EGCS/d;/#else/,/#endif/d;}' "$GCCDIR/p/p-tree.def" +} | sed -ne ':loop + /\$/{ + N + s/\\n// + b loop + } + /^#(.*)/s//{$\1}/p + /^DEFTREECODE/{s,/*.**/,,;s/["'"'"']x["'"'"'].*/'"'x'"', 0)/;p;}' + } > "$2" || { rm -f "$2"; false; }
Frank
Frank Heckenbach wrote:
Sorry, there was a part missing. Try this:
--- mk-t-inc.orig Mon Apr 21 15:50:47 2008 +++ mk-t-inc Mon Apr 21 16:08:09 2008 @@ -71,6 +71,14 @@ { cat "$GCCDIR/tree.def" echo 'DEFTREECODE (LAST_AND_UNUSED_C_TREE_CODE, "unused", '"'x', 0)"
- sed -e '/#ifdef EGCS/,${/#ifdef EGCS/d;/#else/,/#endif/d;}' "$GCCDIR/p/p-tree.def"
-} | sed -ne ':loop;/\$/{N;b loop};/^DEFTREECODE/{s,/*.**/,,;s/["'"'"']x["'"'"'].*/'"'x', 0)/;p;};/^#/p"
- sed -e '/#ifdef EGCS/,${/#ifdef EGCS/d;/#else/,/#endif/d;}' "$GCCDIR/p/p-tree.def"
+} | sed -ne ':loop
/\\$/{
N
s/\\\n//
b loop
}
/^#\(.*\)/s//{$\1}/p
/^DEFTREECODE/{s,/\*.*\*/,,;s/["'"'"']x["'"'"'].*/'"'x'"', 0)/;p;}'
} > "$2" || { rm -f "$2"; false; }
That works, thanks.
Regards,
Adriaan van Os
Frank Heckenbach wrote:
So it's the last "sed" invocation in the script that fails.
There may be a missing semicolon. At least I thought sed requires a ";" (or newline) before "}", and some examples I've just checked seem to suggest so, so I'm a bit surprised GNU sed works without it.
Otherwise I don't see any of the typical problems I've had with other seds here.
--- p/utils/mk-t-inc.orig Sat Apr 19 03:03:24 2008 +++ p/utils/mk-t-inc Sat Apr 19 03:03:57 2008 @@ -72,5 +72,5 @@ cat "$GCCDIR/tree.def" echo 'DEFTREECODE (LAST_AND_UNUSED_C_TREE_CODE, "unused", '"'x', 0)" sed -e '/#ifdef EGCS/,${/#ifdef EGCS/d;/#else/,/#endif/d;}' "$GCCDIR/p/p-tree.def" -} | sed -ne ':loop;/\$/{N;b loop};/^DEFTREECODE/{s,/*.**/,,;s/["'"'"']x["'"'"'].*/'"'x', 0)/;p;};/^#/p" +} | sed -ne ':loop;/\$/{N;b loop;};/^DEFTREECODE/{s,/*.**/,,;s/["'"'"']x["'"'"'].*/'"'x', 0)/;p;};/^#/p" } > "$2" || { rm -f "$2"; false; }
This doesn't seem to make a difference for creating p/utils/tree.inc with the Darwin system sed.
I noticed, by the way, another peculiarity of the Darwin system sed. GNU-sed 4.1.5 doesn't build, GNU-sed 4.1.4 does ! So, you need to build and install GNU-sed 4.1.4, before you can build GNU-sed 4.1.5.
Regards,
Adriaan van Os