React Nativa he command pod install cause error in macOS - macos

I was tried install React Native following this guide https://kadikraman.github.io/react-native-v2/setup-rn in which redirected me to this guide https://reactnative.dev/docs/environment-setup and for a some reason i had to use the command pod install but this command show the follow error, I don't understand why do occur:
set -e
#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
set -e
PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}"
CURRENT_ARCH="${CURRENT_ARCH}"
if [ -z "$CURRENT_ARCH" ] || [ "$CURRENT_ARCH" == "undefined_arch" ]; then
# Xcode 10 beta sets CURRENT_ARCH to "undefined_arch", this leads to incorrect linker arg.
# it's better to rely on platform name as fallback because architecture differs between simulator and device
if [[ "$PLATFORM_NAME" == *"simulator"* ]]; then
CURRENT_ARCH="x86_64"
else
CURRENT_ARCH="armv7"
fi
fi
export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"
export CXX="$CC"
# Remove automake symlink if it exists
if [ -h "test-driver" ]; then
rm test-driver
fi
./configure --host arm-apple-darwin
# Fix build for tvOS
cat << EOF >> src/config.h
/* Add in so we have Apple Target Conditionals */
#ifdef __APPLE__
#include <TargetConditionals.h>
#include <Availability.h>
#endif
/* Special configuration for AppleTVOS */
#if TARGET_OS_TV
#undef HAVE_SYSCALL_H
#undef HAVE_SYS_SYSCALL_H
#undef OS_MACOSX
#endif
/* Special configuration for ucontext */
#undef HAVE_UCONTEXT_H
#undef PC_FROM_UCONTEXT
#if defined(__x86_64__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip
#elif defined(__i386__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip
#endif
EOF
# Prepare exported header include
EXPORTED_INCLUDE_DIR="exported/glog"
mkdir -p exported/glog
cp -f src/glog/log_severity.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-apple-darwin-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for arm-apple-darwin-gcc... /Library/Developer/CommandLineTools/usr/bin/cc -arch armv7 -isysroot
checking whether the C compiler works... no
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'
/Users/cristianpuentes/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing: Unknown `--is-lightweight' option
Try `/Users/cristianpuentes/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
configure: error: in `/Users/cristianpuentes/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6':
configure: error: C compiler cannot create executables
See `config.log' for more details```

Try to run
sudo xcode-select --switch /Applications/Xcode.app
Then run pod install again

Related

SPheno-4.0.5 make command not running (MacOS)

In my work I am using a Fortran based program called SPheno. Having SPheno-4.0.4 installed, I tried to install the new version SPheno-4.0.5, however, when selecting F90 = gfortran in the Makefile, just as I did on my working SPheno-4.0.4 version, it returns me the following error:
cd src ; /Library/Developer/CommandLineTools/usr/bin/make F90=gfortran version=400.00
gfortran -c -O -J../include -I../include -DGENERATIONMIXING -DONLYDOUBLE Control.F90
ar ../lib/libSPheno.a Control.o
/Library/Developer/CommandLineTools/usr/bin/ar: illegal option -- .
usage: ar -d [-TLsv] archive file ...
ar -m [-TLsv] archive file ...
ar -m [-abiTLsv] position archive file ...
ar -p [-TLsv] archive [file ...]
ar -q [-cTLsv] archive file ...
ar -r [-cuTLsv] archive file ...
ar -r [-abciuTLsv] position archive file ...
ar -t [-TLsv] archive [file ...]
ar -x [-ouTLsv] archive [file ...]
make[1]: *** [../lib/libSPheno.a(Control.o)] Error 1
make: *** [bin/SPheno] Error 2
What does this error even mean, and what do I have to change? I even tried to copy/paste the Makefile from SPheno-4.0.4, just to check.
In case it matters, when running the command gfortran -v it returns me:
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/11.2.0/libexec/gcc/x86_64-apple-darwin19/11.2.0/lto-wrapper
Target: x86_64-apple-darwin19
Configured with: ../configure --prefix=/usr/local/Cellar/gcc/11.2.0 --libdir=/usr/local/Cellar/gcc/11.2.0/lib/gcc/11 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran,d --program-suffix=-11 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-zstd=/usr/local/opt/zstd --with-pkgversion='Homebrew GCC 11.2.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --enable-libphobos --build=x86_64-apple-darwin19 --with-system-zlib --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Homebrew GCC 11.2.0)
The Makefile at play is the following:
# please put here your preferred F95/F2003 compiler
# the options in src/Makefile have been put for the
# cases NAG's nagfor, gfortran, g95, Lahey's lf95 and Intels ifort
# Please uncomment the corresponding line
# F90 = nagfor
F90 = gfortran
# F90 = g95
# F90 = lf95
# F90 = ifort
Model = src
version = 400.00
bin/SPheno:
cd ${Model} ; ${MAKE} F90=${F90} version=${version}
clean:
rm -f *.o *~ */*.o */*~
cleanall:
rm -f bin/SPheno lib/*.a *.o *~ */*.o */*~ include/*
.PHONY: bin/SPheno clean cleanall
The output means that make invoked this command:
ar ../lib/libSPheno.a Control.o
which runs the ar (archive) program and apparently wants to put the Control.o object into the ../lib/libSPheno.a archive. However, that command line is incorrect because there's supposed to be an option after the ar which tells it what operation to perform. This output:
/Library/Developer/CommandLineTools/usr/bin/ar: illegal option -- .
usage: ar -d [-TLsv] archive file ...
...
is printed by the ar program telling you that your invocation is invalid.
Then this line:
make[1]: *** [../lib/libSPheno.a(Control.o)] Error 1
is make telling you that the command it invoked (ar) to build the target ../lib/libSPheno.a(Control.o) failed, with error code 1.
Somewhere in the makefile you need to find the rule that is telling make to run the ar program. We can't tell you where it is; unfortunately your version of make is too old (Apple is notorious for shipping outdated and buggy versions of GNU utilities): newer versions would give you the line number of the rule in the makefile that failed.
Most likely the rule will refer to the variable $(AR) and maybe $(ARFLAGS) or something.

Installation of OpenSMILE 2.3.0

I am trying to configure OpenSMILE 2.3.0 on my Mac OS. Right now my only guess to why it's not working is that the Xcode syntax changed and OpenSMILE didn't catch up with it, so perhaps I need an older version of Xcode. Please let me know if it could be anything else.
I tried the suggestions from the other question (MacOS: configure: error: C compiler cannot create executables) and so far it has failed to configure still.
I tried downloading the latest Xcode command line tools to get the latest C compiler.
Command run:
bash buildStandalone.sh
Result:
- aclocal.
- autoconf.
- autoheader.
- automake.
- glibtoolize
- aclocal.
- autoconf.
- autoheader.
- automake.
- glibtoolize
./configure --without-portaudio --prefix=/Users/monica/music-emotion/opensmile-2.3.0/inst --enable-static --enable-shared=no
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/Users/monica/music-emotion/opensmile-2.3.0':
configure: error: C compiler cannot create executables
See `config.log' for more details
failed to configure openSMILE!
And config.log contains this:
## ----------- ##
## Core tests. ##
## ----------- ##
configure:2496: checking for a BSD-compatible install
configure:2564: result: /usr/bin/install -c
configure:2575: checking whether build environment is sane
configure:2630: result: yes
configure:2781: checking for a thread-safe mkdir -p
configure:2820: result: ./install-sh -c -d
configure:2827: checking for gawk
configure:2843: found /usr/local/bin/gawk
configure:2854: result: gawk
configure:2865: checking whether make sets $(MAKE)
configure:2887: result: yes
configure:2916: checking whether make supports nested variables
configure:2933: result: yes
configure:3110: checking for gcc
configure:3126: found /usr/bin/gcc
configure:3137: result: gcc
configure:3366: checking for C compiler version
configure:3375: gcc --version >&5
Apple clang version 11.0.0 (clang-1100.0.33.5)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
configure:3386: $? = 0
configure:3375: gcc -v >&5
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.5)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
configure:3386: $? = 0
configure:3375: gcc -V >&5
clang: error: unsupported option '-V -Wno-framework-include-private-from-public'
clang: error: no input files
configure:3386: $? = 1
configure:3375: gcc -qversion >&5
clang: error: unknown argument '-qversion', did you mean '--version'?
clang: error: no input files
configure:3386: $? = 1
configure:3406: checking whether the C compiler works
configure:3428: gcc -O2 -mfpmath=sse -msse2 -D__STATIC_LINK -DOPENSMILE_BUILD -DBUILD_SVMSMO -DBUILD_SVMSMO -DBUILD_LIBSVM -DBUILD_RNN -DBUILD_WITHOUT_EXPERIMENTAL -lrt -lm -lpthread -lc conftest.c >&5
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:3432: $? = 1
configure:3470: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "openSMILE"
| #define PACKAGE_TARNAME "opensmile"
| #define PACKAGE_VERSION "2.3.0"
| #define PACKAGE_STRING "openSMILE 2.3.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define PACKAGE "opensmile"
| #define VERSION "2.3.0"
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:3475: error: in `/Users/monica/music-emotion/opensmile-2.3.0':
configure:3477: error: C compiler cannot create executables
See `config.log' for more details
If you edit buildStandalone.sh as follows:
-export LDFLAGS="-lm -lpthread -lc"
+export LDFLAGS="-lrt -lm -lpthread -lc"
it should work. From what I can tell from elsewhere librt isn't need on OS-X.

Compilation errors for gcc 6.2

I have CentOS 7.2 1511 (gcc 4.8.5 20150623 (Red Hat 4.8.5-4)), and have been trying to compile gcc 6.2.0 as downloaded from gnu website. The following is the error I got:
checking for x86_64-pc-linux-gnu-gcc... /home/xxx/gcc-6.2.0/build/./gcc/xgcc -B/home/xxx/gcc-6.2.0/build/./gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/ -B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem /usr/local/x86_64-pc-linux-gnu/include -isystem /usr/local/x86_64-pc-linux-gnu/sys-include
checking for suffix of object files... configure: error: in `/home/xxx/gcc-6.2.0/build/x86_64-pc-linux-gnu/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[2]: *** [configure-stage1-target-libgcc] Error 1
make[2]: Leaving directory `/home/xxx/gcc-6.2.0/build'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/xxx/gcc-6.2.0/build'
make: *** [all] Error 2
And looking into the x86_64-pc-linux-gnu/libgcc/config.log file:
configure:3435: /home/xxx/gcc-6.2.0/build/./gcc/xgcc -B/home/xxx/gcc-6.2.0/build/./gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/ -B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem /usr/local/x86_64-pc-linux-gnu/include -isystem /usr/local/x86_64-pc-linux-gnu/sys-include -V >&5
xgcc: error: unrecognized command line option '-V'
xgcc: fatal error: no input files
compilation terminated.
configure:3446: $? = 1
configure:3435: /home/xxx/gcc-6.2.0/build/./gcc/xgcc -B/home/xxx/gcc-6.2.0/build/./gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/ -B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem /usr/local/x86_64-pc-linux-gnu/include -isystem /usr/local/x86_64-pc-linux-gnu/sys-include -qversion >&5
xgcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
xgcc: fatal error: no input files
compilation terminated.
What is happening here? I followed the procedure to "mkdir build;cd build" and then issued the configure command as below:
../configure --disable-multilib --enable-languages=c,c++ --with-system-zlib --with-default-libstdcxx-abi=gcc4-compatible
With slight variation in error from that of (thanks to Oleksandr Kravchuk):
Compilng libgcc xgcc error
here below are my solution:
--- tmp/gcc-6.2.0/libgcc/configure 2016-04-11 15:45:35.000000000 -0400
+++ gcc-6.2.0/libgcc/configure 2016-09-25 15:59:21.611181908 -0400
## -3426,26 +3426,26 ## See \`config.log' for more details." "$L
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
set X $ac_compile
ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
- { { ac_try="$ac_compiler $ac_option >&5"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_compiler $ac_option >&5") 2>conftest.err
- ac_status=$?
- if test -s conftest.err; then
- sed '10a\
-... rest of stderr output deleted ...
- 10q' conftest.err >conftest.er1
- cat conftest.er1 >&5
- rm -f conftest.er1 conftest.err
- fi
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }
-done
+#for ac_option in --version -v -V -qversion; do
+# { { ac_try="$ac_compiler $ac_option >&5"
+#case "(($ac_try" in
+# *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+# *) ac_try_echo=$ac_try;;
+#esac
+#eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+#$as_echo "$ac_try_echo"; } >&5
+# (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+# ac_status=$?
+# if test -s conftest.err; then
+# sed '10a\
+#... rest of stderr output deleted ...
+# 10q' conftest.err >conftest.er1
+# cat conftest.er1 >&5
+# rm -f conftest.er1 conftest.err
+# fi
+# $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+# test $ac_status = 0; }
+#done
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
So essentially I am just ignoring all the checks for "-qversion", "-V" and more. Moreover, later in the same configure script will give another "libisl" API not found error. Since I have I downloaded the libisl source code myself and compiled it to /usr/local/lib directly before, it seemed the gcc compilation is not picking up the new libraries.
Therefore I added "/usr/local/lib" line into the /etc/ld.so.conf file and did a "sudo ldconfig" thereafter.
Compilation proceeded to completion without error and testing seems good.
I ran into the "[stage1-bubble] Error" because I wasn't following the proper procedure for building and installing gcc. For example, I had done configure on the source directory.
Here's what worked for building and installing gcc 8.1.0 on CentOS 7:
Some pre-requisites first:
yum install gcc-c++
yum install libgcc.i686
yum install glibc-devel.i686
yum install epel-release
yum install lbzip2
yum install wget
yum install flex
Download, build and install:
wget ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-8.1.0/gcc-8.1.0.tar.xz
tar -xvf gcc-8.1.0.tar.xz
cd gcc-8.1.0
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-8.1.0/configure --prefix=$HOME/GCC-8.1.0 --enable-languages=c,c++
make -j 3
make install
On my virtual machine the build takes several hours, even with -j option to take advantage of extra CPU cores.
If there is a build failure, for example a missing dependency, it's a good idea to wipe clean the 'objdir' directory and run make again.
By the way, these steps also worked to build more recent code from the Git repository, obviously with some minor modifications.

gcc build error: Trouble closing elf file

I’m compiling GCC on Solaris x86 and got the following error:
Assembler: optimize.c
"/var/tmp//ccMndPR3.s", line 85111 : Trouble closing elf file
gmake[3]: *** [cp/optimize.o] Error 1
I downloaded MPC, GMP and MPFR and extracted them into GCC source directory as mpc,gmp and mpfr directories and configure GCC source with:
$ ../gcc-5.2.0.src/configure --prefix=$HOME/gcc-5.2.0 --enable-languages=c,c++
I used gmake for executing the compilation tasks.
$ gmake
The file mentioned in the error message doesn’t exist.
$ ls -l "/var/tmp//ccEtAJ5n.s"
/var/tmp//ccEtAJ5n.s: No such file or directory
$ ls -l "/var/tmp/ccEtAJ5n.s"
/var/tmp/ccEtAJ5n.s: No such file or directory
I’m not sure how this can happen.
The file system has plenty of room:
$ df -h /var/tmp
Filesystem size used avail capacity Mounted on
/dev/dsk/c0t0d0s6 99G 27G 71G 28% /var
$ uname -a
SunOS sbdsvrwm566 5.10 Generic_150401-20 i86pc i386 i86pc
the only error message in config.log is as follows:
configure:5091: g++ -o conftest -g -O2 -static-libstdc++ -static-libgcc conftest.cpp >&5
g++: unrecognized option `-static-libstdc++'
conftest.cpp:11:2: #error -static-libstdc++ not implemented
configure:5091: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h. */
|
| #if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
| #error -static-libstdc++ not implemented
| #endif
| int main() {}
the error apparently is due to the missing space between -static and -libstdc++. however, what is strange is none of the mentioned confdefs.h conftest.cpp exist either under the source or build directory or installed packages.
obviously the older gcc was used to compile the new gcc:
configure:4074: checking for gcc
configure:4090: found /usr/sfw/bin/gcc
configure:4101: result: gcc
configure:4330: checking for C compiler version
configure:4339: gcc --version >&5
gcc (GCC) 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ echo $PATH
/usr/ccs/bin:/usr/bin:/usr/sfw/bin:/usr/sbin:/usr/local/bin:/opt/SUNWspro/bin:/bin:/usr/bin:/usr/sbin:/usr/ucb:/bns/bin:/usr/openwin/bin:
$ echo $LD_LIBRARY_PATH
/opt/SUNWspro11/SUNWspro/prod/lib:/usr/local/lib:/usr/lib:/usr/lib/X11

How to build a cross-compiler for i386-apple-darwin target from x86_64-apple-darwin host?

Problem overview
I am trying to learn how to build a cross-compiler, specifically a version of GNU gcc 4.7.2 on a 64-bit Intel OS X host that targets i386-apple-darwin (32-bit Intel). However, I keep getting stuck on the same error:
...
checking for i386-apple-darwin-gcc... /Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/xgcc -B/Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/bin/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/lib/ -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/include -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/sys-include
checking for suffix of object files... configure: error: in `/Users/alexpreynolds/Developer/third-party/build-gcc/i386-apple-darwin/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[1]: *** [configure-target-libgcc] Error 1
make: *** [all] Error 2
Build process
I first build a version of GNU binutils which targets i386-apple-darwin, which is accessible to the GNU gcc build folder:
$ cd third-party
$ wget http://ftp.gnu.org/gnu/binutils/binutils-2.23.2.tar.bz2
$ tar xjvf binutils-2.23.2.tar.bz2
$ mkdir i386-apple-darwin
$ mkdir build-binutils && cd build-binutils
$ ../binutils-2.23.2/configure --target=i386-apple-darwin --prefix="/Users/alexpreynolds/Developer/third-party/i386-apple-gcc"
$ make all && make install
...
Then I try to build a targeted version of gcc as follows:
$ cd ..
$ pwd
/Users/alexpreynolds/Developer/third-party
$ wget http://ftp.gnu.org/pub/gnu/gcc/gcc-4.7.2/gcc-4.7.2.tar.bz2
$ tar xvjf gcc-4.7.2.tar.bz2
$ cd gcc-4.7.2
$ ./contrib/download_prerequisites
... /* this grabs GMP, MPC and MPFR dependencies */
$ cd ..
$ mkdir build-gcc && cd build-gcc
$ ../gcc-4.7.2/configure --target=i386-apple-darwin --prefix="/Users/alexpreynolds/Developer/Bedops/bedops/third-party/i386-apple-gcc"
$ make
...
After about 30 minutes of compiling stuff, it gets stuck with the error message shown above.
Error details
To track down the source of the error, here is a snippet of build-gcc/i386-apple-darwin/libgcc/config.log:
configure:3344: /Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/xgcc -B/Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/bin/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/lib/ -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/include -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/sys-include -V >&5
xgcc: error: unrecognized command line option '-V'
xgcc: fatal error: no input files
compilation terminated.
configure:3355: $? = 1
configure:3344: /Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/xgcc -B/Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/bin/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/lib/ -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/include -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/sys-include -qversion >&5
xgcc: error: unrecognized command line option '-qversion'
xgcc: fatal error: no input files
compilation terminated.
configure:3355: $? = 1
configure:3371: /Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/xgcc -B/Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/bin/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/lib/ -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/include -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/sys-include -o conftest -g -O2 conftest.c >&5
Assembler messages:
Fatal error: invalid listing option `r'
configure:3374: $? = 1
configure:3562: checking for suffix of object files
configure:3584: /Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/xgcc -B/Users/alexpreynolds/Developer/third-party/build-gcc/./gcc/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/bin/ -B/Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/lib/ -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/include -isystem /Users/alexpreynolds/Developer/third-party/i386-apple-gcc/i386-apple-darwin/sys-include -c -g -O2 conftest.c >&5
Assembler messages:
Fatal error: invalid listing option `r'
configure:3588: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL "http://www.gnu.org/software/libgcc/"
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:3602: error: in `/Users/alexpreynolds/Developer/third-party/build-gcc/i386-apple-darwin/libgcc':
configure:3605: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
The compiler I'm bootstrapping from
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin12/4.7.2/lto-wrapper
Target: x86_64-apple-darwin12
Configured with: ../gcc-4.7.2/configure --prefix=/opt/local --build=x86_64-apple-darwin12 --enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=/opt/local/lib/gcc47 --includedir=/opt/local/include/gcc47 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.7 --with-libiconv-prefix=/opt/local --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.7 --with-gxx-include-dir=/opt/local/include/gcc47/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-ppl=/opt/local --with-cloog=/opt/local --enable-cloog-backend=isl --disable-cloog-version-check --enable-stage1-checking --enable-lto --enable-libstdcxx-time --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --disable-ppl-version-check --with-pkgversion='MacPorts gcc47 4.7.2_2+universal'
Thread model: posix
gcc version 4.7.2 (MacPorts gcc47 4.7.2_2+universal)
Question
Is there a step I missed in setting up the build environment of coreutils or gcc such that this error results?
What else can I troubleshoot in trying to resolve this error? My Google searches on this error message are not bearing much fruit.
Changes
I changed the build script as follows:
#!/bin/bash -x
WORK_DIR=$PWD
INSTALL_DIR=$WORK_DIR/gcc-4.7.2-darwin
MIN_OSX_VERSION=10.5
if [ -d "$INSTALL_DIR" ]; then
echo "Directory $INSTALL_DIR already exists";
exit 1
fi
BINUTILS=binutils-2.23.2
TARBALL_BINUTILS=$BINUTILS.tar.bz2
URL_BINUTILS=http://ftp.gnu.org/gnu/binutils/$TARBALL_BINUTILS
SOURCE_BINUTILS_DIR=$WORK_DIR/$BINUTILS
BUILD_BINUTILS_DIR=$WORK_DIR/build-$BINUTILS
GCC=gcc-4.7.2
TARBALL_GCC=$GCC.tar.bz2
URL_GCC=http://ftp.gnu.org/pub/gnu/gcc/$GCC/$TARBALL_GCC
SOURCE_GCC_DIR=$WORK_DIR/$GCC
BUILD_GCC_DIR=$WORK_DIR/build-$GCC
curl -O $URL_BINUTILS
mkdir -p $SOURCE_BINUTILS_DIR
tar -xjvf $TARBALL_BINUTILS
rm $TARBALL_BINUTILS
mkdir -p $BUILD_BINUTILS_DIR
cd $BUILD_BINUTILS_DIR
$SOURCE_BINUTILS_DIR/configure --prefix=$INSTALL_DIR
make -j $(sysctl -n hw.availcpu) all CFLAGS='-Wno-error' && make install
find $INSTALL_DIR -name '*strip*' -delete
cd $WORK_DIR
curl -O $URL_GCC
mkdir -p $SOURCE_GCC_DIR
tar -xvjf $TARBALL_GCC
rm $TARBALL_GCC
cd $SOURCE_GCC_DIR
sed -i '' -e 's/wget/curl -O/g' $SOURCE_GCC_DIR/contrib/download_prerequisites
$SOURCE_GCC_DIR/contrib/download_prerequisites
cd $WORK_DIR
mkdir -p $BUILD_GCC_DIR
cd $BUILD_GCC_DIR
$SOURCE_GCC_DIR/configure --prefix=$INSTALL_DIR --enable-languages=c,c++
make -j $(sysctl -n hw.availcpu) CFLAGS="-mmacosx-version-min=$MIN_OSX_VERSION" && make install
find $INSTALL_DIR -name '*.a' -print0 | xargs -0 -n1 ranlib
rm -Rf $BUILD_GCC_DIR
rm -Rf $BUILD_BINUTILS_DIR
rm -Rf $SOURCE_GCC_DIR
rm -Rf $SOURCE_BINUTILS_DIR
The ranlib step was necessary due to numerous errors during the process of building a library.
To build an i386 binary, I had to do the following with my Makefile:
ARCH = i386
...
GCCDIR = ${PARTY3}/gcc-4.7.2-darwin
GCCBINDIR = ${GCCDIR}/bin
GCCLIBDIR = ${GCCDIR}/lib
GCCINCDIR = ${GCCDIR}/include
...
LIBCPP = libgcc_eh.a
LIBCXX = libstdc++.a
...
INCLUDES = -I${GCCINCDIR} ...
...
CC = ${GCCBINDIR}/gcc
CXX = ${GCCBINDIR}/g++
...
GCCCPPLIBPATH = ${GCCLIBDIR}/gcc/x86_64-apple-darwin12.3.0/4.7.2/${ARCH}/${LIBCPP}
GCCCXXLIBPATH = ${GCCLIBDIR}/${ARCH}/${LIBCXX}
...
FLAGS = ${SFLAGS} ${NONSTATICFLAGS} ${OBJS} -L${GCCLIBDIR} ...
...
run: dependencies
mkdir -p ${BIN} && ${CXX} -o ${BIN}/${PROG}_${ARCH} ${FLAGS} -static-libgcc -mmacosx-version-min=${MIN_OSX_VERSION} -arch ${ARCH} ... ${GCCCPPLIBPATH} ${GCCCXXLIBPATH} ${SOURCE1}
Summary of Makefile changes:
I had to add the -static-libgcc flag and leave out -static-libstdc++, which had no effect (except to cause the build to fail, until I ran ranlib on the static libraries, which fixed the build failure but had no effect on -static-libstdc++).
I added ${GCCCPPLIBPATH} and ${GCCCXXLIBPATH} to the run target, which each point to the static C anc C++ libraries libgcc_eh.a and libstdc++.a, respectively.
This allowed me to compile a working i386 (32-bit) binary, but the same GCC installation failed to build a working x86_64 (64-bit) binary.
After thinking about this a little, it occurs to me that by far the easiest solution would be to compile GCC for x86_64, and then to just pass -m32 when you wish to build for i386. Is that not sufficient for your needs for some reason? Building in this manner is dramatically simpler, and doesn't require any of the madness described below. Doing the following sequence of events results in a working compiler that will spit out i386 binaries when requested:
WORK_DIR=$PWD
INSTALL_DIR=$WORK_DIR/install
curl -O http://ftp.gnu.org/gnu/binutils/binutils-2.23.2.tar.bz2
tar xjvf binutils-2.23.2.tar.bz2
mkdir build-binutils && cd build-binutils
../binutils-2.23.2/configure --prefix=$INSTALL_DIR
make -j $(sysctl -n hw.availcpu) all CFLAGS='-Wno-error' && make install
find $INSTALL_DIR -name '*strip*' -delete
cd $WORK_DIR
curl -O http://ftp.gnu.org/pub/gnu/gcc/gcc-4.7.2/gcc-4.7.2.tar.bz2
tar xvjf gcc-4.7.2.tar.bz2
cd gcc-4.7.2
sed -i '' -e 's/wget/curl -O/g' ./contrib/download_prerequisites
./contrib/download_prerequisites
cd ..
mkdir build-gcc && cd build-gcc
../gcc-4.7.2/configure --prefix=$INSTALL_DIR --enable-languages=c,c++
make -j $(sysctl -n hw.availcpu) && make install
Once this completes you can see it in action like so:
mrowe#falcon:~/tmp$ cat > test.cpp
#include <iostream>
int main(int argc, char **argv) {
std::cerr << "Built with GCC 4.7" << std::endl;
return 0;
}
^D
mrowe#falcon:~/tmp$ ./install/bin/g++ -o test test.cpp
mrowe#falcon:~/tmp$ file test
test: Mach-O 64-bit executable x86_64
mrowe#falcon:~/tmp$ ./install/bin/g++ -m32 -static-libgcc -static-libstdc++ -o test test.cpp
mrowe#falcon:~/tmp$ file test
test: Mach-O executable i386
mrowe#falcon:~/tmp$ otool -L ./test
./test:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1192.0.0)
mrowe#falcon:~/tmp$ ./test
Built with GCC 4.7
mrowe#falcon:~/tmp$
If you see warnings like:
ignoring file …/4.7.2/i386/libgcc.a, file was built for archive which is not the architecture being linked (i386)
You can fix them by running ranlib on the static libraries:
find $INSTALL_DIR -name '*.a' -print0 | xargs -0 -n1 ranlib
Below is my attempt at helping you along the path you were attempting to follow. I don't think it's the ideal approach and it is fraught with problems.
The error you reported seeing is due to your GCC build trying to use the GNU assembler from binutils when the generated assembly is intended to be assembled with the GNU assembler from Apple's cctools. The dialect of assembly that is supported differs between the two as Apple's assembler diverged from the upstream GNU assembler many years ago.
All of the instructions I was able to find for building cctools were out of date so I experimented until I got something working. I did something close to the following:
curl -O http://opensource.apple.com/tarballs/cctools/cctools-829.tar.gz
tar xvzf cctools-829.tar.gz
cd cctools-829
You'll then need to patch two files in order to build without a dependency on LLVM:
diff -ru cctools-829/libstuff/lto.c cctools-829.modified/libstuff/lto.c
--- cctools-829/libstuff/lto.c 1969-12-31 16:00:00.000000000 -0800
+++ cctools-829.modified/libstuff/lto.c 2013-04-05 03:18:34.000000000 -0700
## -376,4 +376,18 ##
lto_dispose(mod);
}
+#else
+
+#include <stdlib.h>
+
+__private_extern__
+int
+is_llvm_bitcode(
+ struct ofile *ofile,
+ char *addr,
+ size_t size)
+{
+ return 0;
+}
+
#endif /* LTO_SUPPORT */
diff -ru cctools-829/misc/libtool.c cctools-829.modified/misc/libtool.c
--- cctools-829/misc/libtool.c 1969-12-31 16:00:00.000000000 -0800
+++ cctools-829.modified/misc/libtool.c 2013-04-05 03:20:21.000000000 -0700
## -1369,8 +1369,11 ##
}
}
}
- else if(ofiles[i].arch_type == OFILE_Mach_O ||
- ofiles[i].arch_type == OFILE_LLVM_BITCODE){
+ else if(ofiles[i].arch_type == OFILE_Mach_O
+#ifdef LTO_SUPPORT
+ || ofiles[i].arch_type == OFILE_LLVM_BITCODE
+#endif
+ ){
if(cmd_flags.ranlib == TRUE){
error("for architecture: %s file: %s is not an "
"archive (no processing done on this file)",
And then build:
make install USE_DEPENDENCY_FILE=NO BUILD_DYLIBS=NO LTO= TRIE= DSTROOT=../build-cctools
And install the necessary parts of by hand:
cd ..
cp build-cctools/usr/bin/as i386-apple-gcc/bin/i386-apple-darwin-as
cp build-cctools/usr/bin/as i386-apple-gcc/i386-apple-darwin/bin/as
cp build-cctools/usr/bin/lipo i386-apple-gcc/bin/i386-apple-darwin-lipo
cp build-cctools/usr/bin/lipo i386-apple-gcc/i386-apple-darwin/bin/lipo
cp build-cctools/usr/bin/strip i386-apple-gcc/bin/i386-apple-darwin-strip
cp build-cctools/usr/bin/strip i386-apple-gcc/i386-apple-darwin/bin/strip
If we then attempt to build GCC once more we'll discover that the build process is upset because our freshly-built assembler is unable to target x86_64. Since that doesn't seem relevant to what you're trying to achieve you can add the --disable-multilib argument to GCC's configure script to prevent it from trying that.
At this point I ran in to errors while attempting to build libgcc. These errors are because a suitable linker cannot be found, so I guess that now you'd need to download and build ld64 too.
And it's at this point that I've run out of time to make it any further. Good luck!

Resources