ATARI MiNT cross-compiler for Mac OS X

Based on the latest m68k-atari-mint cross-compiler work of Vincent Rivière (who is providing cygwin binaries on his site), I have built the gcc cross-compiler with his patches on my computer (Intel iMac, Mac OS 10.7) and make them available here for other Mac OS X users.
The old description on how to build the cross-compiler yourself has been moved here.

If you want to build the cross-compiler yourself, you can checkout the Git repository with my scripts.

The cross-compiler must be installed into the directory /opt/cross-mint. This directory can be created using the following Terminal commands (which require administrator privileges):

  sudo mkdir -p /opt/cross-mint
  sudo chown $USER /opt/cross-mint

After this initial setup, the binaries can be extracted (with your standard user) using the following command:

  tar xvzf m68k-cross-mint-bin-darwin-x86_64-20200621.tgz --directory /opt/

To avoid macOS complaining about unknown binaries, use the following command to clear the quarantine flag:

  xattr -d -r com.apple.quarantine /opt/cross-mint

Cross-compiler binary

For simplicity only a single "all included" package m68k-cross-mint is provided here which runs on Apple Silicon based Apple Computers.

Please send me your feedback if you have any problems with the setup or installation.

Previous binary releases can be found here:

Using the cross-compiler

After installation, you should create/modify your bash profile by enhancing ~/.zprofile with the following lines:

# m68k-atari-mint cross compiler
export PATH=$PATH:/opt/cross-mint/bin
export MANPATH=$MANPATH:/opt/cross-mint/share/man

This allows you to use the cross-compiler using m68k-atari-mint-gcc (or any other tool of it) and query its man pages.

The following simple "hello world" example can be compiled for TOS using the command: m68k-atari-mint-gcc hello.c -o hello.tos This creates a hello.tos application which can be run on a TOS compatible system (for example under MacAranym).

#include <stdio.h>

int main(int argc, char* argv[])
{
    puts("Hello, world !");
    return 0;
}

Using the cross-compiler with Xcode 5

If you really want to use the cross-compiler from within Xcode (=not going down to the most basic Terminal level or using a Terminal based build system with make), you have to build a Xcode plugin to drive the compilation of the C files.
To do this, follow these steps:

  1. Download the GCC plugin from here: https://code.google.com/p/xcode-gcc-plugin/downloads/list. (No harm should come from this file, as it is a textual description of GCC 4.5 and its options.)

  2. Create a directory ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins and put the extracted GCC 4.5.xcplugin into this directory.

  3. Open the GCC 4.5.xcplugin using the context action to show the content of this package/bundle. Drill down to the Contents/Info.plist file and edit it using your preferred editor.
    Add the following lines at the end of the Info.plist file:

        <key>DVTPlugInCompatibilityUUIDs</key>
        <array>
            <string>63FC1C47-140D-42B0-BB4D-A10B2D225574</string>
            <string>37B30044-3B14-46BA-ABAA-F01000C27B63</string>
            <string>640F884E-CE55-4B40-87C0-8869546CAB7A</string>
            <string>A2E4D43F-41F4-4FB9-BB94-7177011C9AED</string>
        </array>

    The codes shown above have to be amended everytime a new major version of Xcode is released, otherwise the plugin will not be activated during start-up of Xcode!

  4. Start-up Xcode and open your preferred project (choose "OS X > Applications > Command Line Tool" if you have nothing else to test).
    Go to the project settings and you should find now under "Build Settings > Build Options" a choice for GCC 4.5 as shown below:

    GCC compiler appearing in Xcode

    If you choose this compiler and build the project, the compilation will still fail with an error:

    Can't exec '/Applications/Xcode.app/Contents/Developer/usr/bin/gcc-4.5' (No such file or directory)
  5. Go back to the package content of the GCC 4.5.xcplugin into the Resources/GCC 4.5.xcspec file.
    Here we have to adjust the variable "ExecPath" to be the path and name to our cross-compiler.

        ExecPath = "/opt/cross-mint/bin/m68k-atari-mint-gcc";
  6. If you go restart Xcode now again and try to build with your cross-compiler, you will probably end up with some unsupported options:

    The error message Unrecognized command line option '-mmacosx-version-min=10.9' means that you are targeting the OS X 10.9 system and you must change your project settings. Set the "OS X Deployment Target" to "Compiler Default".

    The error message Unrecognized command line option '-Wshorten-64-to-32' means that you have an unsupported option enabled. Go to the project "Build settings" and use the search widget to find the reason by searching for "shorten". Disable the option "Implicit Conversion to 32 Bit Type" which turns up by this search.

    The error message Target system does not support the "dwarf-2" debug format is related to the "Debug Information Format" (where we can only select "DWARF" and "DWARF with dSYM File" and the option "Generate Debug Symbols" = "Yes".
    To solve this we have to "hack" the compiler specs again, which will be done as part of the next step.

  7. Reopen the Resources/GCC 4.5.xcspec file from within the xcplugin file and adjust the following values:

    Remove unnecessary architectures (as our cross-compiler cannot handle more than 1):

        Architectures = (
            i386,
        );

    Adjust the following boolean flags:

        SupportsHeadermaps = No;
        "DashIFlagAcceptsHeadermaps" = No;
        SupportsIsysroot = No;
        SupportsZeroLink = No;
        "SupportsPredictiveCompilation" = No;
        "SupportsSeparateUserHeaderPaths" = No;
        "SupportsSymbolSeparation" = No;
        "SupportsMacOSXDeploymentTarget" = No;
        "SupportsMacOSXMinVersionFlag" = No;
        "UseCPlusPlusCompilerDriverWhenBundlizing" = No;

    Looking for the following section, we are going to adjust the GCC default debugging format:

               Name = "GCC_DEBUG_INFORMATION_FORMAT";
                Type = Enumeration;
                AllowedValues = (
                    stabs,
                    dwarf,
                    "dwarf-with-dsym",
                );
                CommandLineArgs = {
                    dwarf = (
                        "-gdwarf-2",
                    );
                    "dwarf-with-dsym" = (
                        "-gdwarf-2",
                    );
                    "<<otherwise>>" = ();
                };
                DefaultValue = "stabs";
                Condition = "$(GCC_GENERATE_DEBUGGING_SYMBOLS)";
                CommonOption = NO;

    There are many more options we could fiddle with or tune, but we want a quick result and therefore restart Xcode to test compilation of our Command Line Tool: Major compilation errors are now gone. Errors appear during Linking phase:

    m68k-atari-mint-gcc: error: x86_64: No such file or directory
    m68k-atari-mint-gcc: error: unrecognized option '-arch'
    Command /opt/cross-mint/bin/m68k-atari-mint-gcc failed with exit code 1
    
  8. We are now stuck at the linking phase and it seems as if Apple does not support choosing the linker from within a "Drop Down" menu or even overriding the linker specifications from within a "simple plugin" (as the "GCC 4.5.xcplugin" is). The only working way I have currently found, is to copy the CoreBuildTasks.xcplugin to your local plugin directory ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins and then modify the file Ld.xcspec in the Contents/Resources subdirectory and removing the -arch option:

        CommandLine = "[exec-path] [options] [special-args] @$(LINK_FILE_LIST_$(variant)_$(arch)) -o $(OutputPath)";
  9. After fixing the unsupported -arch option I was stuck at the following fatal error:

    collect2: ld terminated with signal 11 [Segmentation fault: 11]
    Command /opt/cross-mint/bin/m68k-atari-mint-gcc failed with exit code 1
    

    After more detailed analysis of the command line option which has been generated by Xcode to link the application, I concluded that there are more options which are not supported:

    -filelist: Disable the "Input file lists" handling completely by commenting the section.

    /*
            // Input file lists
            {   Name = __INPUT_FILE_LIST_PATH__;
                Type = Path;
                DefaultValue = "$(LINK_FILE_LIST_$(variant)_$(arch))";      // this is set up for us as a read-only property
                CommandLineFlag = "-filelist";
                IsInputDependency = Yes;
            },
    */

    -Xlinker ... -dependency_info: Disable the "Dependency Info file" handling:

        DependencyInfoFile = ""; //$(LD_DEPENDENCY_INFO_FILE)";
  10. Finally: YOU ARE DONE. The simple hello world command line tool should now be compiling using your cross-compiler.

    There are still a lot of options which could be modified (like the -isysroot which is still passed to our cross-compiler), but now you have more or less seen the major parts playing into the compilation and linking phases.
    If you have any questions or comments or an even better way to do all this. Please let me know.