bebbo / amiga-gcc

The GNU C-Compiler with Binutils and other useful tools for cross development for Amiga
GNU General Public License v2.0
312 stars 66 forks source link

Building on macOS 12.6.4 M2 MBP fails #336

Closed isoriano1968 closed 1 year ago

isoriano1968 commented 1 year ago

isoriano@M2-MBP:~$ CC=gcc-12 CXX=g++-12 gmake all SHELL=$(brew --prefix)/bin/bash NDK=3.2 PREFIX=/Users/isoriano/amiga-gcc

Build fails with:

/Users/isoriano/Sources/amiga-gcc/projects/gcc/gcc/graphite-isl-ast-to-gimple.c: In member function 'tree_node translate_isl_ast_to_gimple::gcc_expression_from_isl_expr_int(tree, isl_ast_expr)': /Users/isoriano/Sources/amiga-gcc/projects/gcc/gcc/graphite-isl-ast-to-gimple.c:349:3: error: 'isl_val_free' was not declared in this scope; did you mean 'isl_vec_free'? 349 | isl_val_free (val); | ^~~~ | isl_vec_free /Users/isoriano/Sources/amiga-gcc/projects/gcc/gcc/graphite-isl-ast-to-gimple.c: In function 'isl_ast_expr get_upper_bound(isl_ast_node)': /Users/isoriano/Sources/amiga-gcc/projects/gcc/gcc/graphite-isl-ast-to-gimple.c:752:11: error: 'isl_val_int_from_si' was not declared in this scope; did you mean 'isl_val_int_from_gmp'? 752 | isl_val_int_from_si (isl_ast_expr_get_ctx (for_cond), 1); | ^~~~~~~ | isl_val_int_from_gmp In file included from /Users/isoriano/Sources/amiga-gcc/projects/gcc/gcc/hash-table.h:236, from /Users/isoriano/Sources/amiga-gcc/projects/gcc/gcc/coretypes.h:348, from /Users/isoriano/Sources/amiga-gcc/projects/gcc/gcc/graphite-isl-ast-to-gimple.c:29: /Users/isoriano/Sources/amiga-gcc/projects/gcc/gcc/vec.h: In instantiation of 'bool vec<T, va_heap, vl_ptr>::reserve(unsigned int, bool) [with T = std::pair<gphi, gphi>]': /Users/isoriano/Sources/amiga-gcc/projects/gcc/gcc/vec.h:1515:3: required from 'T vec<T, va_heap, vl_ptr>::safe_push(const T&) [with T = std::pair<gphi, gphi>]' /Users/isoriano/Sources/amiga-gcc/projects/gcc/gcc/graphite-isl-ast-to-gimple.c:1881:38: required from here /Users/isoriano/Sources/amiga-gcc/projects/gcc/gcc/vec.h:1409:14: warning: 'void memcpy(void, const void, size_t)' writing to an object of type 'struct std::pair<gphi, gphi>' with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess] 1409 | memcpy (m_vec->address (), oldvec->address (), sizeof (T) oldsize); | ~^~~~~~~~~~~~~~~ In file included from /opt/homebrew/Cellar/gcc/12.2.0/include/c++/12/bits/stl_algobase.h:64, from /opt/homebrew/Cellar/gcc/12.2.0/include/c++/12/bits/stl_tree.h:63, from /opt/homebrew/Cellar/gcc/12.2.0/include/c++/12/map:60, from /Users/isoriano/Sources/amiga-gcc/projects/gcc/gcc/system.h:228, from /Users/isoriano/Sources/amiga-gcc/projects/gcc/gcc/graphite-isl-ast-to-gimple.c:28: /opt/homebrew/Cellar/gcc/12.2.0/include/c++/12/bits/stl_pair.h:185:12: note: 'struct std::pair<gphi, gphi*>' declared here 185 | struct pair | ^~~~ gmake[2]: [Makefile:1121: graphite-isl-ast-to-gimple.o] Error 1 gmake[2]: Leaving directory '/Users/isoriano/Sources/amiga-gcc/build-Darwin-m68k-amigaos/gcc/gcc' gmake[1]: [Makefile:4156: all-gcc] Error 2

isoriano1968 commented 1 year ago

Darwin M2-MBP.local 21.6.0 Darwin Kernel Version 21.6.0: Thu Mar 9 20:12:18 PST 2023; root:xnu-8020.240.18.700.8~1/RELEASE_ARM64_T8110 arm64

rrs42 commented 1 year ago

Just ran into this same issue on an Intel Mac running Ventura 13.3.1.

The problem looks like the homebrew package 'isl'. Installing gcc-12 brings in isl version 0.26 which is too new for the old version of gcc being used for the cross-compiler here. Fortunately there is still a compatible version in homebrew. This worked for me:

brew unlink isl
brew install isl@0.18
brew link isl@0.18

I was then able to compile gcc, and everything else compiled without drama.

bebbo commented 1 year ago

@isoriano1968 does this fix your issue?

isoriano1968 commented 1 year ago

Hi,

sorry for the late reply, indeed switching to isl@0.18 fixed the compiler compilation error.

gdb fails next:

gmake[3]: Leaving directory '/Users/isoriano/Sources/amiga-gcc/build-Darwin-m68k-amigaos/binutils/libbacktrace' gmake[2]: Leaving directory '/Users/isoriano/Sources/amiga-gcc/build-Darwin-m68k-amigaos/binutils/libbacktrace' gmake[2]: Entering directory '/Users/isoriano/Sources/amiga-gcc/build-Darwin-m68k-amigaos/binutils/gdb' CXX m2-exp.o m2-exp.c:163:13: error: expected identifier before numeric constant 163 | #define DOT 302 | ^~~ /Users/isoriano/Sources/amiga-gcc/projects/binutils/gdb/split-name.h:34:3: note: in expansion of macro 'DOT' 34 | DOT, | ^~~ m2-exp.c:163:13: error: expected '}' before numeric constant 163 | #define DOT 302 | ^~~ /Users/isoriano/Sources/amiga-gcc/projects/binutils/gdb/split-name.h:34:3: note: in expansion of macro 'DOT' 34 | DOT, | ^~~ In file included from /Users/isoriano/Sources/amiga-gcc/projects/binutils/gdb/symtab.h:39, from /Users/isoriano/Sources/amiga-gcc/projects/binutils/gdb/language.h:26, from /Users/isoriano/Sources/amiga-gcc/projects/binutils/gdb/m2-exp.y:42: /Users/isoriano/Sources/amiga-gcc/projects/binutils/gdb/split-name.h:28:1: note: to match this '{' 28 | { | ^ m2-exp.c:163:13: error: expected unqualified-id before numeric constant 163 | #define DOT 302 | ^~~ /Users/isoriano/Sources/amiga-gcc/projects/binutils/gdb/split-name.h:34:3: note: in expansion of macro 'DOT' 34 | DOT, | ^~~ /Users/isoriano/Sources/amiga-gcc/projects/binutils/gdb/split-name.h:37:1: error: expected declaration before '}' token 37 | }; | ^ /Users/isoriano/Sources/amiga-gcc/projects/binutils/gdb/symtab.h: In member function 'std::vector<std::basic_string_view > ada_lookup_name_info::split_name() const': /Users/isoriano/Sources/amiga-gcc/projects/binutils/gdb/symtab.h:138:64: error: 'UNDERSCORE' is not a member of 'split_style' 138 | return ::split_name (m_encoded_name.c_str (), split_style::UNDERSCORE); | ^~~~~~ /Users/isoriano/Sources/amiga-gcc/projects/binutils/gdb/symtab.h: In member function 'std::vector<std::basic_string_view > lookup_name_info::split_name(language) const': m2-exp.c:163:13: error: expected unqualified-id before numeric constant 163 | #define DOT 302 | ^~~ /Users/isoriano/Sources/amiga-gcc/projects/binutils/gdb/symtab.h:307:30: note: in expansion of macro 'DOT' 307 | style = split_style::DOT; | ^~~ gmake[2]: [Makefile:1897: m2-exp.o] Error 1 gmake[2]: Leaving directory '/Users/isoriano/Sources/amiga-gcc/build-Darwin-m68k-amigaos/binutils/gdb' gmake[1]: [Makefile:12865: all-gdb] Error 2 gmake[1]: Leaving directory '/Users/isoriano/Sources/amiga-gcc/build-Darwin-m68k-amigaos/binutils'

rrs42 commented 1 year ago

That error looks like the error you get when the old version of bison that ships with the MacOS command line developer tools is being used instead of a current version (Apple ships 2.3, Homebrew has 3.8.2 as of today.) This mentioned in the Mac OS build instructions, but misses the next error you're going to hit. a missing binary called 'makeinfo'. Homebrew provides it as part of the texinfo package but does not put in the path - you have to add the texinfo bin directory just like you do with bison.

I've been working on a script to capture all the junk required to build this on Mac OS. I've got it up on gist here.

bebbo commented 1 year ago

feel free to add this script via PR.

cfwdman commented 6 months ago

HI @bebbo and @rrs42, thanks to this issue I was able to get gcc build.

One thing I'd like to mention though with respect to isl: Installing isl@0.18 is made difficult due to "Error: isl@0.18 has been disabled because it is a versioned formula!".

gdb still fails with the two errors:

1) In file included from /Users/christoph.dohrmann/development/amiga-gcc/projects/binutils/gdb/m2-exp.y:42: In file included from /Users/christoph.dohrmann/development/amiga-gcc/projects/binutils/gdb/language.h:26: In file included from /Users/christoph.dohrmann/development/amiga-gcc/projects/binutils/gdb/symtab.h:39: /Users/christoph.dohrmann/development/amiga-gcc/projects/binutils/gdb/split-name.h:34:3: error: expected identifier DOT, ^ m2-exp.c:163:13: note: expanded from macro 'DOT'

define DOT 302

        ^

2) In file included from /Users/christoph.dohrmann/development/amiga-gcc/projects/binutils/gdb/m2-exp.y:42: In file included from /Users/christoph.dohrmann/development/amiga-gcc/projects/binutils/gdb/language.h:26: /Users/christoph.dohrmann/development/amiga-gcc/projects/binutils/gdb/symtab.h:307:23: error: expected unqualified-id style = split_style::DOT; ^ m2-exp.c:163:13: note: expanded from macro 'DOT'

define DOT 302

        ^

I've seen #355 but the description to handle DOT renaming does not sound "right"....