Greetings,
I updated my MacOS 10.7.5 machine to 10.12.6. My gpc installation is still on my hard drive. I'm trying to get it to work. No luck so far. I know that Gale and others have listed what needs to be fixed in order to compile GPC on MacOS 10.12. Is it possible to install and run Adriaan's 10.6 binaries on 10.12?
Yours, Kevan
Hello Again,
I have a partial answer to my own question. The compiler installed from Adriaan's 10.6 installer launches and runs on MacOS 10.12. It produces text file assembly code with the -S option. But the assembler it calls is the default "/usr/bin/as", which is Intel 64-bit. When we install command-line utilities on MacOS 10.12 (which is initiated when you first try to run "gcc", so far as I can tell), we get these:
/Library/Developer/CommandLineTools/usr/libexec/as/arm/as /Library/Developer/CommandLineTools/usr/libexec/as/i386/as /Library/Developer/CommandLineTools/usr/libexec/as/x86_64/as
I used gpc to create assembler files, then assembled these with the i386 assembler to get object code that I later linked with gcc into a dynamic library with the MaOS10.6 SDK and the GPC libraries. So I can generate the dynamic library my main application requires. But I have not yet figured out how to compile a stand-alone executable "hello world" program from a pascal source file.
Is there a way to pass into GPC the path of the assembler it should use? I am splitting the compile and assembly and link into three steps, and somewhere in there, I'm losing the definition of the "main" function required by the linker for the stand-alone executable.
Yours, Kevan
Kevan Hashemi wrote:
Greetings,
I updated my MacOS 10.7.5 machine to 10.12.6. My gpc installation is still on my hard drive. I'm trying to get it to work. No luck so far. I know that Gale and others have listed what needs to be fixed in order to compile GPC on MacOS 10.12. Is it possible to install and run Adriaan's 10.6 binaries on 10.12?
Yours, Kevan
I know nothing about MacOS btw, but have you tried the "--automake" switch? Maybe a generic 'main' is brought in by the gcc linker?
Regards, Peter
Hello Again,
Failure to produce a stand-alone executable turns out to be a simple oversight on my part: I forgot to link to the main object when making the program. Apologies.
So, I now have GPC fully-functional on MacOS 10.12.6, but the odd step I have to take is to avoid using the default Clang editor and instead use this one:
kevan$ /Library/Developer/CommandLineTools/usr/libexec/as/i386/as -v Apple Inc version cctools-898, GNU assembler version 1.38
This file has "modified" date April 12, 2017, so it's certainly not one I had lying around before my update.
Also: when I call gcc, it turns out I'm calling the linker installed with the latest version of Xcode:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
If there's a way to tell gpc to use the gnu assembler directly, I can omit the intermediate -S assembler step in my Makefile, which would be nice. But I'm up and running now, which is a great relief. I set aside a week to figure this out, and it took only a day.
Yours, Kevan
Peter wrote:
I know nothing about MacOS btw, but have you tried the "--automake" switch? Maybe a generic 'main' is brought in by the gcc linker?
Regards, Peter
Gpc mailing list Gpc@gnu.de https://www.g-n-u.de/mailman/listinfo/gpc
On Jul 25, 2017, at 6:37 AM, Kevan Hashemi hashemi@brandeis.edu wrote:
Hello Again,
Failure to produce a stand-alone executable turns out to be a simple oversight on my part: I forgot to link to the main object when making the program. Apologies.
So, I now have GPC fully-functional on MacOS 10.12.6, but the odd step I have to take is to avoid using the default Clang editor and instead use this one:
kevan$ /Library/Developer/CommandLineTools/usr/libexec/as/i386/as -v Apple Inc version cctools-898, GNU assembler version 1.38
This file has "modified" date April 12, 2017, so it's certainly not one I had lying around before my update.
Also: when I call gcc, it turns out I'm calling the linker installed with the latest version of Xcode:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
If there's a way to tell gpc to use the gnu assembler directly, I can omit the intermediate -S assembler step in my Makefile, which would be nice. But I'm up and running now, which is a great relief. I set aside a week to figure this out, and it took only a day.
I think the gcc approved way of doing that is to is to use an external specs-file with the -specs=specs-file gcc/gpc command line parameter option to override the built-in assembler invoking driver spec.
I've never tried it so take the following with a big grain of salt.
First start off by seeing what the current built-in specs look like with gpc -dumpspecs
In the resulting output, there is an "*invoke_as:" spec which looks to be a promising avenue to override using the system default "as" assembler tool (i.e., the default Clang assembler) with the desired GNU assembler.
If I got it right from spec file from an old Mac OS gpc346u4 build project, the spec you're looking for looks like:
*invoke_as: %{!S:-o %|.s | as %(asm_options) %m.s %A }
Copy that into a new file that you'll use for the -specs= parameter option. In the new file, change the "as" in the "as %(asm_options) %m.s %A }" line to the full path specified GNU assembler you want invoked for assembling - since you say it works try "/Library/Developer/CommandLineTools/usr/libexec/as/i386/as" (without the quote marks) so the full changed line is:
/Library/Developer/CommandLineTools/usr/libexec/as/i386/as %(asm_options) %m.s %A }
Hopefully something like that will do the deed. If it does and since you're working with a pre gcc 4 version, there appears to be a fairly easy way to hack the gpc installation so you don't have to keep using the -specs= parameter option.
Gale Paeper gpaeper@empirenet.com
Dear Gale,
I think the gcc approved way of doing that is to is to use an external specs-file with the -specs=specs-file gcc/gpc command line parameter option to override the built-in assembler invoking driver spec.
My gpc is using this specs file by default:
/Developer/Pascal/gpc346u4/lib/gcc/i386-apple-darwin10/3.4.6/specs
First start off by seeing what the current built-in specs look like with gpc -dumpspecs
gpc -dumpspecs > specs
produces a local specs file identical to the default one, and containing exactly this line, even unto the space before "as".
*invoke_as: %{!S:-o %|.s | as %(asm_options) %m.s %A }
I can change the default specs file to point to my GNU assembler, or the new file, or a small file containing only the above, which is nice.
Copy that into a new file that you'll use for the -specs= parameter option.
That works. Thank you.
By the way: I tried to move the clang assembler and insert a symbolic link to the GNU assembler in its place. But OS 10.12.6 won't let me do anything to /usr/bin/as. Not even as root.
Best Wishes, Kevan