macosgcccompiler-errorsclanggforth

How can I stop Apple’s compiler Clang impersonating GCC?


I’m trying to install the bleeding edge version of Gforth according to this page.

My question is not about the details of installation, but about how to stop Clang conflicting with the GNU compiler GCC (executable gcc).

There are many questions in Stack Overflow about this issue, and I added some of them at the end.

I have a bug report filed here and I tried their suggestions as well, but nothing worked. They cannot reproduce the problem, because Gforth compiles fine in their system. So the issue is with my Mac, not with Gforth.

I’m on macOS v14.2 (Sonoma), Intel

My GCC executable is in this location:

/usr/local/bin/gcc-14

Xcode and Developers tools are installed.

These are the commands I issued:

  1. Clone from Git and create the gforth directory

    git clone https://git.savannah.gnu.org/git/gforth/

  2. cd to the gforth directory

  3. Run the script ./install-deps.sh

    The script ended with

    [...]

     Installing /Users/a/gforth/local/bin/ccache-swig-forth
     /usr/bin/install -c -d /Users/a/gforth/local/bin
     /usr/bin/install -c -m 755 ccache-swig /Users/a/gforth/local/bin/`echo ccache-swig | sed 's&$&-forth&'`
     Installation complete
     /usr/bin/sudo
     (base) a@Ahmet-MacBook-Air gforth
    
  4. Run ./autogen.sh

    This ends with

    [...]

     glibtoolize: Consider adding '-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
     configure.ac:1419: warning: The macro 'AC_HEADER_STDC' is obsolete.
     configure.ac:1419: You should run autoupdate.
     ./lib/autoconf/headers.m4:663: AC_HEADER_STDC is expanded from...
     configure.ac:1419: the top level
     (base) a@Ahmet-MacBook-Air gforth %
    
  5. Run ./configure

    This ends with:

     *** Config summary: Warnings exist ***
    
     texi2html not found, HTML document won't be built.
     swig not found.
     Swig without -forth feature, library interfaces will not be generated.
     (base) a@Ahmet-MacBook-Air gforth %
    
  6. Run make

    This stopped here

     xcode-select: Failed to locate 'm4', requesting installation of command line developer tools.
     make: *** [prim.b] Error 72
    

    A message appeared asking to download the developer tools. (It was already installed several times!)

    The m4 folder is already in the gforth directory. It contains eight .m4 files.

  7. I downloaded the developer tools, entered make again, and I got this:

    (base) a@Ahmet-MacBook-Air gforth % make

    Output:

     zsh: parse error near `a@Ahmet-MacBook-Air'
    
  8. I ran ./configure again, and I got:

     *** Config summary: Warnings exist ***
    
     texi2html not found, HTML document won't be built.
     swig not found.
     Swig without -forth feature, library interfaces will not be generated.
     (base) a@Ahmet-MacBook-Air gforth %
    
  9. I ran make again, and I got this:

     (base) a@Ahmet-MacBook-Air gforth % make
     xcode-select: Failed to locate 'm4', requesting installation of command line developer tools.
     make: *** [prim.b] Error 72
     (base) a@Ahmet-MacBook-Air gforth %
    
  10. I tried the last step sudo make install, and I got:

    (base) a@Ahmet-MacBook-Air gforth % sudo make install
    Password:
    
    xcode-select: Failed to locate 'm4', requesting installation of command line developer tools.
    
    make: *** [prim.b] Error 72
    
    (base) a@Ahmet-MacBook-Air gforth %
    

Some of the questions that I tried were:

My question on Super User before I realized that the issue was related to Clang.


Solution

  • You ran ./configure without telling it which compiler to use. Issue ./configure --help to learn how to do this.

    Configure is not picking up your /usr/local version of GCC.