how does compilation work exactly on os x - gcc

I just started getting into LLVM and clang compilers and the whole thing. I am following the book "Getting started with llvm core libraries". I was under the impression that OS X comes bundled with llvm. However it seems that is not the case. I need to install llvm separately to get command line tools like llc or lli.
So my question is, when I do a "clang" to compile my c/c++ code, what backend does the work of creating the machine code ? My installation shows commands like llvm-gcc and llvm-g++ . Does it mean that it uses gcc internally for creating machine code? And do i need to brew install llvm to switch completely to llvm ?

If you just want clang, and plan to do mostly high-level language development (C, C++, ObjC), then I recommend installing the Xcode command line tools. You can get those from https://developer.apple.com/downloads/index.action?name=for%20Xcode (or you can install all of Xcode if you prefer).
If you want lower-level tools like llc, then my recommendation is brew, as you suggest.
If you're goal is just Mac development, then Xcode is the better solution. If your goal is working on LLVM, then brew is the better answer (or pull the sources and build it yourself).
If you want both on the same machine, I'd recommend not installing the command line tools. Just install Xcode and LLVM. Then you can run the Xcode versions using xcrun without colliding with your LLVM installation.
clang doesn't use llvm-gcc as a backend. It includes LLVM. llvm-gcc is a modified version of GCC that integrates with the LLVM backend, which allows programs that expect GCC-specific features to work with LLVM.

Related

Run or use GCC without install

Can I use GCC for e.g GCC4.0.3 without installation
In my macOS I have installed Clang xcode , and GCC from Homebrew
In my Linux they are installed as well
But I want to use GCC (Specially older version) besides most updated version
Like NVM that manage Node version and it lets you install many nodejs with different version on your system
I want to use GCC4 specially for science and compiling Old FORTRAN to make my Source codes run and see the results
In new OS both macOS and Linux when you install gcc it will install most updated and that is not useful for old fortran or old codes.
So In my solution i think its better to use gcc without install or even install gcc to custom directory folder and copy the codes in that directory and compile them but not to install as wide system and make incompatibility with default GCC and CLANG on system
Thanks in advance

How to disable Apple's LLVM on mac

I started to learn about Mix IDE and the thing is that, while compiling the Mix IDE, it keeps failing to compile source in the package. So I've done some search and it turns out that I need to use old version llvm. So I installed llvm37 using home-brew and there was no problem while installing it. The only problem is that when I type
clang --version
it keeps returning the following result.
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Therefore, I need to know how to disable the default LLVM and use the one I installed with Homebrew. Any idea?
You have several options:
Modifying PATH
Put Homebrew's binary path before everything else:
export PATH=/usr/local/bin:$PATH
Uninstalling Xcode command line tools
This will remove the command line tools that are delivered along Xcode.
sudo /Developer/Library/uninstall-devtools --mode=all
If you installed the command line tools without Xcode, see this question. Please be aware that Homebrew might depend on some of those tools and may cease to function! I did not test it.
Setting the desired compiler
This is the cleanest solution. Tell the Mix IDE's build system which compiler to use. Since I do not know which build system Mix IDE uses, I cannot tell you how to do that. Some build systems honor the CC, CXX and CPP environment variables, so it may work setting those to the clang binary installed with Homebrew.

Desperately trying to build open source tools (octave) on a Mac 10.6 Snow Leopard (involves Xcode, gcc, fink)

The ironic thing is that all this used to work on my Mac, but Apple no longer supports 10.5.8, so I was forced to update to Snow Leopard, 10.6. And everything broke (thank you Apple).
On the surface, it seems simple. Build an open source package like octave under Snow Leopard (Mac OS X 10.6)
Apple has made this difficult, to say the least. They no longer download XCode for older operating systems unless you are a paid developer. My Macbook pro 2.16Ghz cannot load Lion, so that option is not available.
My old fink doesn't work because it was old. In order to build a new one, I need Xcode 3.2, which I can't get (see above).
I downloaded a free gcc 4.2, and it works fine.
So in order to try to build octave, it's the old style gnu install:
./configure
make
make install
./configure fails because there is no fortran installed. That's a special case because the install of gcc didn't include fortran. So a fallback would be building a complete gcc which I have done in the past.
downloaded gcc 4.9:
gcc-4.9-20130728
inside, gcc49
gcc can't build because it needs the three subsidiary packages gmp, mpfr and mpc
I am now trying to build these, so that I can bootstrap a complete gcc build, but in the meantime, is there any simpler way to bootstrap these things? I find it hard to understand why no binaries are available for:
fink
octave
which would solve part of my current problems.
You can still get XCode. You just have to be registered on Apple Developer, but you do not have to pay for the license. You then download it through the Mac App store, or you can get a link that opens it in the App store here. Finally, you have to install the command line tools from within Xcode. These can be found under the Components tab of the Download Preferences panel.
Let me know if that does not help. My iMac running 10.6 is currently in for repairs, so I am on my 10.7 laptop and cannot test all the specifics yet.

How to build GCC 4.7 on Windows?

How to build GCC 4.7 on Windows?
You are not finding instructions on how to do this because you cannot natively use gcc in Windows. Your options are either to use gcc through Cygwin [installation instructions] or install the MinGW port [installation instructions].
You can also find links to these projects on the Installing GCC: Binaries page.
Well, gcc 4.7 has not yet been released (it will be released in a few months, i.e. spring 2012).
If your system is Windows then I am sorry for you, Linux is so much better :-) More seriously, you should search for cygwin gcc. I cannot help you in that case.
What did you try? Building GCC (even on Linux) is not an easy task. Some hints (which I guess are also relevant to cygwin & windows).
Always configure and build the compiler in a build tree outside of the source tree. (this is a common mistake).
take care of the many dependencies (and their versions), like the Parma Polyhedra Library, Cloog, etc ...
some features of GCC are not available on Windows. In particular plugins.
I would suppose that installing the binary of an older variant of cygwin gcc (and all the related packages) will help.
But really, I know nothing about Windows. And if you really want a very recent GCC and you cannot install Linux (or build GCC cygwin), you might perhaps consider running Linux in an emulator or virtual machine.

OpenCV with CUDA on Mac OS 10.6.7

I'm trying to build OpenCV 2.2 with CUDA on my mac (using Mac OS 10.6.7 and Xcode 4). I followed the instructions on the opencv wiki, but it doesn't seem to work.
First of all, I can't find the NPP for the 3.2 version of the CUDA toolkit. I've tried then using the 4.0 version (even though it is not yet stable). The structure of the NPP directories is completely different than that assumed by the CMake script shipped with OpenCV. I've tried adapting it so that that it would find the NPP.
Apparently it had worked, except that when I build OpenCV on Xcode, I generate every library except gpu.
Has someone tried and was successful when trying to build OpenCV with CUDA on Mac OSX?
Thanks,
Renan
install cuda 4
then go to...
$ cd /developer/gpu computing/
build samples and libs.....
$ make
$ open /OpenCV-2.3.0/modules/gpu/CMakeLists.txt
go to line #48 and comment out this if statement....
//if (APPLE)
//set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;-fno-finite-math-only;")
//endif()
now you should be able to compile gpu libs.
basically your getting rid of the 3.2 no NPP exception.
you could enable exceptions like this....
if (APPLE)
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;/EHsc-;")
endif()
my gnu tests where faster negating the apple statement.

Resources