Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

barracuda156

macrumors 68040
Original poster
Sep 3, 2021
3,073
1,842
I have bumped into a weird problem with gcc6 and gcc7, initially when gcc7 failed to build icu as universal (ppc+ppc64), and it turned out compiler itself is at fault.

As an example, identical HelloWorld is built correctly for ppc64 on 10.5.8 with Apple gcc, but fails when built with gcc7:

Code:
36-225:Dev svacchanda$ gcc-mp-7 -arch ppc HelloWorld.c -o HelloWorld
HelloWorld.c:2:1: warning: return type defaults to 'int' [-Wimplicit-int]
 main() {
 ^~~~
36-225:Dev svacchanda$ /Users/svacchanda/Dev/HelloWorld
hello, world
36-225:Dev svacchanda$ gcc-mp-7 -arch ppc64 HelloWorld.c -o HelloWorld
HelloWorld.c:2:1: warning: return type defaults to 'int' [-Wimplicit-int]
 main() {
 ^~~~
36-225:Dev svacchanda$ /Users/svacchanda/Dev/HelloWorld
Segmentation fault
36-225:Dev svacchanda$ file /Users/svacchanda/Dev/HelloWorld
/Users/svacchanda/Dev/HelloWorld: Mach-O 64-bit executable ppc64
36-225:Dev svacchanda$ gcc -arch ppc64 HelloWorld.c -o HelloWorld
36-225:Dev svacchanda$ /Users/svacchanda/Dev/HelloWorld
hello, world
36-225:Dev svacchanda$ file /Users/svacchanda/Dev/HelloWorld
/Users/svacchanda/Dev/HelloWorld: Mach-O 64-bit executable ppc64

32-bit binaries work normally. The same problem is observed with gcc6.

P. S. At the moment I confirm the issue for Macports versions of compilers. I am building gcc7 outside of Macports now to make sure whether the problem is inherent to compiler itself and not its configuration by Macports. I have opened the ticket: https://trac.macports.org/ticket/64260
 
Outside of Macports gcc7 doesn't even build universal, failing here:

Code:
libbackend.a main.o libcommon-target.a libcommon.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a libcommon.a ../libcpp/libcpp.a  -liconv ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a  -L/Users/svacchanda/Dev/gcc_all/gcc-7.5.0/build/./isl/.libs  -lisl -L/Users/svacchanda/Dev/gcc_all/gcc-7.5.0/build/./gmp/.libs -L/Users/svacchanda/Dev/gcc_all/gcc-7.5.0/build/./mpfr/src/.libs -L/Users/svacchanda/Dev/gcc_all/gcc-7.5.0/build/./mpc/src/.libs -lmpc -lmpfr -lgmp   -L./../zlib -lz
ld: bl out of range (-19165716 max is +/-16M) from type_lists_compatible_p(tree_node const*, tree_node const*, bool*, bool*) at 0x10126E7F0 in __text_cold of c/c-typeck.o to c_build_qualified_type(tree_node*, int, tree_node*, unsigned long) at 0x100027690 in __text of  c/c-typeck.o in type_lists_compatible_p(tree_node const*, tree_node const*, bool*, bool*) from c/c-typeck.o
collect2: error: ld returned 1 exit status
make[3]: *** [cc1] Error 1
make[3]: *** Waiting for unfinished jobs....
ld: bl out of range (-19486640 max is +/-16M) from toplev::main(int, char**) at 0x1012A8B40 in __text_startup of libbackend.a(toplev.o) to hash_table_higher_prime_index(unsigned long) at 0x1000135E0 in __text of  hash-table.o in toplev::main(int, char**) from libbackend.a(toplev.o)
collect2: error: ld returned 1 exit status
make[3]: *** [cc1obj] Error 1
ld: bl out of range (-19268260 max is +/-16M) from finalization_scalarizer(gfc_symbol*, gfc_symbol*, gfc_expr*, gfc_namespace*) at 0x10133EE80 in __text_cold of fortran/class.o to gfc_get_code(gfc_exec_op)      at 0x1000DEC10 in __text of  fortran/st.o in finalization_scalarizer(gfc_symbol*, gfc_symbol*, gfc_expr*, gfc_namespace*) from fortran/class.o
collect2: error: ld returned 1 exit status
make[3]: *** [f951] Error 1
ld: bl out of range (-19401504 max is +/-16M) from mark_inline_variable(tree_node*)      at 0x1013DABE0 in __text_cold of cp/decl.o to toplevel_bindings_p()     at 0x10015A0E0 in __text of  cp/name-lookup.o in mark_inline_variable(tree_node*)      from cp/decl.o
collect2: error: ld returned 1 exit status
make[3]: *** [cc1plus] Error 1
make[2]: *** [all-stage2-gcc] Error 2
make[1]: *** [stage2-bubble] Error 2
make: *** [all] Error 2
 
Outside of Macports gcc7 doesn't even build universal, failing here:

Code:
libbackend.a main.o libcommon-target.a libcommon.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a libcommon.a ../libcpp/libcpp.a  -liconv ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a  -L/Users/svacchanda/Dev/gcc_all/gcc-7.5.0/build/./isl/.libs  -lisl -L/Users/svacchanda/Dev/gcc_all/gcc-7.5.0/build/./gmp/.libs -L/Users/svacchanda/Dev/gcc_all/gcc-7.5.0/build/./mpfr/src/.libs -L/Users/svacchanda/Dev/gcc_all/gcc-7.5.0/build/./mpc/src/.libs -lmpc -lmpfr -lgmp   -L./../zlib -lz
ld: bl out of range (-19165716 max is +/-16M) from type_lists_compatible_p(tree_node const*, tree_node const*, bool*, bool*) at 0x10126E7F0 in __text_cold of c/c-typeck.o to c_build_qualified_type(tree_node*, int, tree_node*, unsigned long) at 0x100027690 in __text of  c/c-typeck.o in type_lists_compatible_p(tree_node const*, tree_node const*, bool*, bool*) from c/c-typeck.o
collect2: error: ld returned 1 exit status
make[3]: *** [cc1] Error 1
make[3]: *** Waiting for unfinished jobs....
ld: bl out of range (-19486640 max is +/-16M) from toplev::main(int, char**) at 0x1012A8B40 in __text_startup of libbackend.a(toplev.o) to hash_table_higher_prime_index(unsigned long) at 0x1000135E0 in __text of  hash-table.o in toplev::main(int, char**) from libbackend.a(toplev.o)
collect2: error: ld returned 1 exit status
make[3]: *** [cc1obj] Error 1
ld: bl out of range (-19268260 max is +/-16M) from finalization_scalarizer(gfc_symbol*, gfc_symbol*, gfc_expr*, gfc_namespace*) at 0x10133EE80 in __text_cold of fortran/class.o to gfc_get_code(gfc_exec_op)      at 0x1000DEC10 in __text of  fortran/st.o in finalization_scalarizer(gfc_symbol*, gfc_symbol*, gfc_expr*, gfc_namespace*) from fortran/class.o
collect2: error: ld returned 1 exit status
make[3]: *** [f951] Error 1
ld: bl out of range (-19401504 max is +/-16M) from mark_inline_variable(tree_node*)

By the way, these are typical linker problems. I got the same when trying to build gcc10 in Macports on 10A190 couple of days ago (apparently default system linker failed). That is, it is not exclusive to ppc64.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.