GCC 4.7 on OS X Lion: cannot compute suffix of object files - osx-lion

I know this issue already discussed (include there), and no one time. But, unfortunately, I cannot solve this problem.
So, I have OS X Lion, i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1, and I try to build gcc-4.7.0.
First of all, I've already built this compiler on Debian GNU/Linux, so I was sure any problems will not be...
So, I read this GCC manual and I did all exactly as described:
cd gcc-4.7.0
./contrib/download_prerequisites
cd ..
mkdir gcc_build
cd gcc_build
/Users/dshevchenko/Downloads/gcc-4.7.0/configure --prefix=/Users/dshevchenko/Tools/GCC
make
So, MPC, MPFR and GMP was successfully downloaded, and ./configure was OK. But after few minutes after make I get this error:
checking for suffix of object files... configure: error:
in `/Users/dshevchenko/Downloads/gcc_build/x86_64-apple-darwin11.4.0/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
As I understand this can't be due error of dynamic linking with MPFR, MPC or GMP, because these libs was built inside of GCC source code tree.
In my ~/.bash_profile:
export DYLD_LIBRARY_PATH=/Users/dshevchenko/Tools/GCC/lib
Help me please, I'll be grateful for any advice.

Be sure you have the latest Xcode (4.4 at the time of this writing). There is a bug in the llvm compiler in some versions of Xcode (including 4.1, which I had). For Xcode 4.4, the command line tools must be downloaded from the Xcode preferences.

the follow solution helped me out:
$ export CC="gcc -D_FORTIFY_SOURCE=0”
$ $srcdir/configure ...
$ make
source: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50342

Related

swift build doesn't work

I'm trying to run Kitura project on XCode. I tried to follow instructions on this page ([https://github.com/IBM-Swift/Kitura/wiki/Building-your-Kitura-application-on-XCode]), however I failed with step 3 – run swift build -X. I get this error:
error: unable to invoke subcommand: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build (No such file or directory)
Looks like I have latest toolchain installed (see the screenshot below).
I also have both XCode 7.3.1 and XCode 8 beta. What would you suggest to solve that problem?
As Daniel mentioned above, Kitura right now requires use of the June 6 drop of the Swift Development toolchain. This toolchain can only be used with Xcode v7.3.1. The toolchain format changed between Xcode 7.x and newer Xcode 8 beta. When using the Xcode 8 beta with the new June 20 toolchain, there's another step that you need to do before you can run swift build from the command line.
From the command line, enter the following command:
$ sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer/
This command is necessary to inform Xcode where to find the required binaries and frameworks.
To switch it back, just use the same command but point it at non-beta version of Xcode:
$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer/
Using these commands will eliminate the error <unknown>:0: error: Swift does not support the SDK 'MacOSX10.11.sdk' error: exit(1): that you ran into.
The Xcode 8 beta will be required to be used for all future Swift.org toolchains unless otherwise specified.
As of this writing, Kitura only compiles with the 06-06 Swift Development toolchain so make sure you have that installed.
In addition the wiki was out of date, the generate Xcode project command got renamed to swift package generate-xcodeproj. I updated the wiki to reflect this change.
Try:
export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}"

Building Swift on CentOS

I am building Swift compiler from source on CentOS 6, and am running into a library issue. After fighting with the build script for a while I have got where running ./utils/build-script eventually gives:
+ /home/src/cmake-3.4.1-Linux-x86_64/bin/cmake --build /home/src/swift/build/Ninja-DebugAssert/cmark-linux-x86_64 -- all
ninja: no work to do.
llvm: using standard linker
+ cd /home/src/swift/build/Ninja-DebugAssert/llvm-linux-x86_64
+ /home/src/cmake-3.4.1-Linux-x86_64/bin/cmake -G Ninja -DCMAKE_C_COMPILER:PATH=clang -DCMAKE_CXX_COMPILER:PATH=clang++ '-DCMAKE_C_FLAGS= ' '-DCMAKE_CXX_FLAGS= ' -DCMAKE_BUILD_TYPE:STRING=Debug -DLLVM_ENABLE_ASSERTIONS:BOOL=TRUE -DLLVM_TOOL_SWIFT_BUILD:BOOL=NO '-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64' -DLLVM_INCLUDE_TESTS:BOOL=TRUE -LLVM_INCLUDE_DOCS:BOOL=TRUE -DCMAKE_INSTALL_PREFIX:PATH=/usr -DINTERNAL_INSTALL_PREFIX=local /home/src/swift/llvm
CMake Error at cmake/modules/CheckAtomic.cmake:36 (message):
Host compiler appears to require libatomic, but cannot find it.
Call Stack (most recent call first):
cmake/config-ix.cmake:296 (include)
CMakeLists.txt:403 (include)
-- Configuring incomplete, errors occurred!
See also "/home/src/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/CMakeFiles/CMakeOutput.log".
See also "/home/src/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/CMakeFiles/CMakeError.log".
./utils/build-script: command terminated with a non-zero exit status 1, aborting
(gcc-4.8.2 was what I compiled llvm with)
libatomic is there:
$ locate libatomic
/opt/gcc-4.8.2/lib64/libatomic.a
/opt/gcc-4.8.2/lib64/libatomic.la
/opt/gcc-4.8.2/lib64/libatomic.so
/opt/gcc-4.8.2/lib64/libatomic.so.1
/opt/gcc-4.8.2/lib64/libatomic.so.1.0.0
I just don't know how to tell the build system where to look. I have tried the usual CMAKE_LIBRARY_PATH (exporting on the command line - I am not sure if cmake works like the way LD_LIBRARY_PATH, LIBRARY_PATH work) but it can't seem to find it.
I also don't have root on the machine.
I had not tried building from source on CentOS 6 until I saw this question, but I have been able to build Swift 2.2 on CentOS 7.1 and Ubuntu 14.04, with partial success. A few things to think about:
You will need numerous dependencies required to build Swift, and unless
they happen to be already on the system, you will need root access to
install them.
Use -R flag with the build-script to create a release build.
Building in DebugAssert (the default) will require a lot of memory. In my case even 14 GB was not sufficient. A release build
can be done with about 6 GB.
As for your specific problem, it is related to Clang's dependency on GCC-related packages for headers and libraries. See, for example, Fedora 21 with clang, without gcc.
Even if you installed GCC 4.8.2 and adjusted the path to use gcc and g++ from 4.8.2, Clang may still be looking in the old GCC directories for headers and libraries. CMake first tries to compile a C++ test file that includes the header atomic, which does not exist in the old GCC. So, it then tries to link a C test program that uses the library libatomic, which again doesn't exist in the old GCC. You can see this by looking at llvm/cmake/modules/CheckAtomic.cmake mentioned by usr1234567. CMakeError.log and CMakeOutput.log can also provide valuable insight. BTW, when I was building Swift on CentOS 7.1, I didn't run into this problem because GCC 4.8.2 was used by Clang for headers and libraries and the atomic header was found, so the C++ file got compiled. However, had the libatomic check been done, it would have failed, because libatomic.so in the repository-provided 4.8.2 has INPUT ( <name of some non-existent file> ), so trying to link with libatomic errors out.
I'm sure there are various ways of dealing with this issue, but what solved the problem for me was setting the following environment variables, please adjust to your specific setup:
export CPLUS_INCLUDE_PATH=/opt/gcc-4.8.2/include/c++/4.8.2:/opt/gcc-4.8.2/include/c++/4.8.2/x86_64-unknown-linux-gnu
export LIBRARY_PATH=/opt/gcc-4.8.2/lib64:/opt/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Also make sure that your 4.8.2 version of libstdc++.so is available to the dynamic linker at runtime. Since you don't have root, do
export LD_LIBRARY_PATH=/opt/gcc-4.8.2/lib64
If you had root, you could use ldconfig.
Before you start building Swift, you may want to try building, using Clang, a simple C program linking it with libatomic (the code doesn't actually have to use any symbols from the lib) and a simple C++ program that includes the <atomic> header. When compiling the C++ program, use the -std=c++11 compiler flag. If the C++ program compiles successfully, then it is not necessary for the libatomic linking test to be successful.
Interestingly, the CMakeOutput.log file still did not report finding GCC 4.8.2 as a candidate GCC installation, but the configuration/build worked well past the error.
Hopefully this helps. Please let us know if you run into something else.
CheckAtomic.cmake seems to be part of LLVM. I found a file at Github and it tries to find '__atomic_fetch_add_4' from libatomic
check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC)
This fails for you. Check CMakeFiles/CMakeError.log to get more details why this test failed. Or try this line in a new project.

MATLAB can't see my C compiler to mex svmlib

I have 64-bit Mac, OS X 10.8.5, and I have xcode installed. I can also verify gcc works from the command line. When I type mex -setup I get
The options files available for mex are:
1: /Applications/MATLAB_R2013a.app/bin/mexopts.sh :
Template Options file for building MEX-files
0: Exit with no changes
This is unhelpful. And when I type make, with all of the relevant libsvm files in my folder of choice, I get
make
xcodebuild: error: SDK "macosx10.7" cannot be located.
xcrun: error: unable to find utility "clang", not a developer tool or in PATH
mex: compile of ' "libsvmread.c"' failed.
If make.m fails, please check README about detailed instructions.
Is anyone able to help me with this?
The quickest thing is to edit the mexopts.sh file directly, using your favorite text editor (you may need to do this with "Administrator Privileges"). The file:
/Applications/MATLAB_R2013a.app/bin/mexopts.sh
defines a bunch of paths and flags for invoking the C/C++ compiler on your system. It tends not to keep up with revisions to the MacOS.
On my system, I had to make the following changes:
lines 258-260
CC='gcc'
SDKROOT='/Developer/SDKs/MacOSX10.6.sdk'
MACOSX_DEPLOYMENT_TARGET='10.6'
line 273
CXX=g++
There will be many references to "CC=" in the file; you're looking for the ones that follow the line
maci64)
But the correct values for your system depend on which gcc/g++ you have and where they are installed. As you can see, I have the MacOS 10.6 Developer tools installed under /Develop. You will need an install of the Developer tools (XCode) - see
How to use/install gcc on Mac OS X 10.8 / Xcode 4.4
In more recent versions of the XCode tools, the path might look more like:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
But compiling MEX code with more recent versions of XCode might cause other problems - I had issues with char16_t, see:
MEX compile error: unknown type name 'char16_t'

Performance API on mac 10.8

Anyone tried to install papi(performance API) version 5.1.0 on the mac os 10.8 ? I am getting following errors on the make command.
zero_attach.c: In function ‘main’:
zero_attach.c:84: error: ‘PTRACE_ATTACH’ undeclared (first use in this function)
zero_attach.c:84: error: (Each undeclared identifier is reported only once
zero_attach.c:84: error: for each function it appears in.)
zero_attach.c:84: warning: passing argument 4 of ‘ptrace’ makes integer from pointer without a cast
zero_attach.c:117: error: ‘PTRACE_CONT’ undeclared (first use in this function)
The INSTALL.txt doesnt say anything on the mac os. Just says it can be installed no procedure given so i tried just the standard procedure mentioned.
On the main page of papi -> platform supported, it doesnt say about anything about mac os.
Do i need to install some drivers for this ? any help will be great..
I just installed the latest version of PAPI (5.3.0) on OS X v 10.9.1.
Following the instructions in the install file did the trick too!
wget http://icl.cs.utk.edu/projects/papi/downloads/papi-5.3.0.tar.gz
tar -xvf papi-5.3.0.tar.gz
cd papi-5.3.0/src
./configure
make
The only problem I encountered was with an undefined malloc.h, this is easily
fixed by either making a dummy malloc.h stub with
touch malloc.h
or copying a good malloc.h into the src directory
cp /System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/malloc.h .
Then you should be fine with:
make
./run_tests.sh
make install
Happy performance counting!
p.s. I did this with gcc-4.7.3 (installed with homebrew).

Opa build failure under OS X Lion

I've been wanting to get my hands dirty with Opa, but had been really feeling the lack of a REPL, which is my weapon of choice in coming to terms with a new language. Lo and behold, the Opa Blog mentioned a tool called opatop which appeared to be just that, but it doesn't seem to be included the standard Mac or Ubuntu distributions.
I trekked over to GitHub, grabbed the source, and started building, but I'm getting the same error mentioned here:
+ /opt/local/bin/ocamlopt.opt dynlink.cmxa unix.cmxa str.cmxa nums.cmxa -g threads.cmxa -thread -I +zip zip.cmxa -I +ocamlgraph graph.cmxa -I /opt/local/lib/ocaml/ulex ulexing.cmxa buildinfos.cmxa libbase.cmxa compilerlib.cmxa libtrx.cmxa opacapi.cmxa passlib.cmxa libqmlcompil.cmxa jslang.cmxa ocamllang.cmxa libbsl.cmxa libbsl/bslregister.cmx opalang.cmxa -o libbsl/bslregister.native
File "_none_", line 1, characters 0-1:
Error: Cannot find file dynlink.cmxa
Command exited with code 2.
I know next to nothing about OCaml development, but it looks like other files with the same extension in the relevant library directory are "OCaml native library files". Given that, is this just a library that wasn't included in the OCaml distribution I ended up with? The Mantis bug referenced in the link above makes it look as though there may be conflicting assumptions about build environments at work.
Regardless, can anyone offer any advice?
Thanks!
OCaml isn't built with native dynlink for Lion yet, so dynlink.cmxa doesn't exist under the default install.
The following patch will enable allow you to build it. From within the OCaml src dir, patch -p1 < PATH/TO/PATCH, and reinstall OCaml as appropriate.
This is for OCaml 3.12.1
--- a/configure 2011-07-04 14:15:01.000000000 -0700
+++ b/configure 2011-08-26 10:18:42.000000000 -0700
## -619,9 +619,9 ##
case "$host" in
*-*-cygwin*) natdynlink=true;;
i[3456]86-*-linux*) natdynlink=true;;
x86_64-*-linux*) natdynlink=true;;
- i[3456]86-*-darwin10.*)
+ i[3456]86-*-darwin1[01].*)
if test $arch64 == true; then
natdynlink=true
fi;;
i[3456]86-*-darwin[89]*) natdynlink=true;;
I have investigated Opa build under OS X Lion and have pushed 2 patches on opalang waiting for approval to solve main problems.
So when the patches will be available, this is my steps (as i remember) to make Opa work under Lion :
First, install necessary tools :
Install OS X Lion
Install Xcode 4
Install MacPorts
Install wget (macports)
Install coreutils (macports)
Install md5sha1sum (macports)
(I think that's all...)
Then compile Opa from source :
git clone https://github.com/MLstate/opalang.git
cd opalang
dependencies/installation_helper.sh --prefix ~/Opa
change your PATH in your ~/.profile : export PATH=~/Opa/bin:$PATH
re-source your .bashrc : source ~/.profile
./configure -prefix ~/Opa
make all install
Your new opa compiler should be in ~/Opa/bin :)