Gcc multilib mac os

Gcc multilib mac os

Target makefile fragments can set these Makefile variables.

Compiler flags to use when compiling libgcc2.c .

A list of source file names to be compiled or assembled and inserted into libgcc.a .

Special flags used when compiling crtstuff.c . See Initialization.

Special flags used when compiling crtstuff.c for shared linking. Used if you use crtbeginS.o and crtendS.o in EXTRA-PARTS . See Initialization.

For some targets, invoking GCC in different ways produces objects that cannot be linked together. For example, for some targets GCC produces both big and little endian code. For these targets, you must arrange for multiple versions of libgcc.a to be compiled, one for each set of incompatible options. When GCC invokes the linker, it arranges to link in the right version of libgcc.a , based on the command line options used.

The MULTILIB_OPTIONS macro lists the set of options for which special versions of libgcc.a must be built. Write options that are mutually incompatible side by side, separated by a slash. Write options that may be used together separated by a space. The build procedure will build all combinations of compatible options.

For example, if you set MULTILIB_OPTIONS to ‘ m68000/m68020 msoft-float ’, Makefile will build special versions of libgcc.a using the following sets of options: -m68000 , -m68020 , -msoft-float , ‘ -m68000 -msoft-float ’, and ‘ -m68020 -msoft-float ’.

If MULTILIB_OPTIONS is used, this variable specifies the directory names that should be used to hold the various libraries. Write one element in MULTILIB_DIRNAMES for each element in MULTILIB_OPTIONS . If MULTILIB_DIRNAMES is not used, the default value will be MULTILIB_OPTIONS , with all slashes treated as spaces.

MULTILIB_DIRNAMES describes the multilib directories using GCC conventions and is applied to directories that are part of the GCC installation. When multilib-enabled, the compiler will add a subdirectory of the form prefix / multilib before each directory in the search path for libraries and crt files.

For example, if MULTILIB_OPTIONS is set to ‘ m68000/m68020 msoft-float ’, then the default value of MULTILIB_DIRNAMES is ‘ m68000 m68020 msoft-float ’. You may specify a different value if you desire a different set of directory names.

Sometimes the same option may be written in two different ways. If an option is listed in MULTILIB_OPTIONS , GCC needs to know about any synonyms. In that case, set MULTILIB_MATCHES to a list of items of the form ‘ option=option ’ to describe all relevant synonyms. For example, ‘ m68000=mc68000 m68020=mc68020 ’.

Sometimes when there are multiple sets of MULTILIB_OPTIONS being specified, there are combinations that should not be built. In that case, set MULTILIB_EXCEPTIONS to be all of the switch exceptions in shell case syntax that should not be built.

For example the ARM processor cannot execute both hardware floating point instructions and the reduced size THUMB instructions at the same time, so there is no need to build libraries with both of these options enabled. Therefore MULTILIB_EXCEPTIONS is set to:

Sometimes when there are only a few combinations are required, it would be a big effort to come up with a MULTILIB_EXCEPTIONS list to cover all undesired ones. In such a case, just listing all the required combinations in MULTILIB_REQUIRED would be more straightforward.

The way to specify the entries in MULTILIB_REQUIRED is same with the way used for MULTILIB_EXCEPTIONS , only this time what are required will be specified. Suppose there are multiple sets of MULTILIB_OPTIONS and only two combinations are required, one for ARMv7-M and one for ARMv7-R with hard floating-point ABI and FPU, the MULTILIB_REQUIRED can be set to:

Читайте также:  Автозапуск гаджетов windows 10

The MULTILIB_REQUIRED can be used together with MULTILIB_EXCEPTIONS . The option combinations generated from MULTILIB_OPTIONS will be filtered by MULTILIB_EXCEPTIONS and then by MULTILIB_REQUIRED .

Sometimes it is desirable to reuse one existing multilib for different sets of options. Such kind of reuse can minimize the number of multilib variants. And for some targets it is better to reuse an existing multilib than to fall back to default multilib when there is no corresponding multilib. This can be done by adding reuse rules to MULTILIB_REUSE .

A reuse rule is comprised of two parts connected by equality sign. The left part is the option set used to build multilib and the right part is the option set that will reuse this multilib. Both parts should only use options specified in MULTILIB_OPTIONS and the equality signs found in options name should be replaced with periods. An explicit period in the rule can be escaped by preceding it with a backslash. The order of options in the left part matters and should be same with those specified in MULTILIB_REQUIRED or aligned with the order in MULTILIB_OPTIONS . There is no such limitation for options in the right part as we don’t build multilib from them.

MULTILIB_REUSE is different from MULTILIB_MATCHES in that it sets up relations between two option sets rather than two options. Here is an example to demo how we reuse libraries built in Thumb mode for applications built in ARM mode:

Before the advent of MULTILIB_REUSE , GCC select multilib by comparing command line options with options used to build multilib. The MULTILIB_REUSE is complementary to that way. Only when the original comparison matches nothing it will work to see if it is OK to reuse some existing multilib.

Sometimes it is desirable that when building multiple versions of libgcc.a certain options should always be passed on to the compiler. In that case, set MULTILIB_EXTRA_OPTS to be the list of options to be used for all builds. If you set this, you should probably set CRTSTUFF_T_CFLAGS to a dash followed by it.

If MULTILIB_OPTIONS is used, this variable specifies a list of subdirectory names, that are used to modify the search path depending on the chosen multilib. Unlike MULTILIB_DIRNAMES , MULTILIB_OSDIRNAMES describes the multilib directories using operating systems conventions, and is applied to the directories such as lib or those in the LIBRARY_PATH environment variable. The format is either the same as of MULTILIB_DIRNAMES , or a set of mappings. When it is the same as MULTILIB_DIRNAMES , it describes the multilib directories using operating system conventions, rather than GCC conventions. When it is a set of mappings of the form gccdir = osdir , the left side gives the GCC convention and the right gives the equivalent OS defined location. If the osdir part begins with a ‘ ! ’, GCC will not search in the non-multilib directory and use exclusively the multilib directory. Otherwise, the compiler will examine the search path for libraries and crt files twice; the first time it will add multilib to each directory in the search path, the second it will not.

For configurations that support both multilib and multiarch, MULTILIB_OSDIRNAMES also encodes the multiarch name, thus subsuming MULTIARCH_DIRNAME . The multiarch name is appended to each directory name, separated by a colon (e.g. ‘ ../lib32:i386-linux-gnu ’).

Each multiarch subdirectory will be searched before the corresponding OS multilib directory, for example ‘ /lib/i386-linux-gnu ’ before ‘ /lib/../lib32 ’. The multiarch name will also be used to modify the system header search path, as explained for MULTIARCH_DIRNAME .

Читайте также:  Atom editor mac os

This variable specifies the multiarch name for configurations that are multiarch-enabled but not multilibbed configurations.

The multiarch name is used to augment the search path for libraries, crt files and system header files with additional locations. The compiler will add a multiarch subdirectory of the form prefix / multiarch before each directory in the library and crt search path. It will also add two directories LOCAL_INCLUDE_DIR / multiarch and NATIVE_SYSTEM_HEADER_DIR / multiarch ) to the system header search path, respectively before LOCAL_INCLUDE_DIR and NATIVE_SYSTEM_HEADER_DIR .

MULTIARCH_DIRNAME is not used for configurations that support both multilib and multiarch. In that case, multiarch names are encoded in MULTILIB_OSDIRNAMES instead.

More documentation about multiarch can be found at https://wiki.debian.org/Multiarch.

Unfortunately, setting MULTILIB_EXTRA_OPTS is not enough, since it does not affect the build of target libraries, at least not the build of the default multilib. One possible work-around is to use DRIVER_SELF_SPECS to bring options from the specs file as if they had been passed in the compiler driver command line. However, you don’t want to be adding these options after the toolchain is installed, so you can instead tweak the specs file that will be used during the toolchain build, while you still install the original, built-in specs . The trick is to set SPECS to some other filename (say specs.install ), that will then be created out of the built-in specs, and introduce a Makefile rule to generate the specs file that’s going to be used at build time out of your specs.install .

These are extra flags to pass to the C compiler. They are used both when building GCC, and when compiling things with the just-built GCC. This variable is deprecated and should not be used.

Источник

Mac OS X: Install GCC Compiler with Xcode

I have Mac OS X Mountain Lion. I need to compile a few apps and Perl modules. I already installed Xcode from app store but I’m unable to find gcc compiler or make command. How do I install gcc on Mac OS X 10.8.x?

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Mac OS X Mountain Lion
Est. reading time Depends on the internet speed

Xcode includes command line development tools such as gcc and friends.

Step #1: Install Xcode on a Apple Mac OS X

First, make sure Xcode is installed. If it is not installed on OS X, visit app store and install Xcode.

Fig.01: Make sure Xcode developer tools are install OS X

Step #2: Install gcc/LLVM compiler on OS X

Once installed, open Xcode and visit:

Xcode menu > Preferences > Downloads > choose » Command line tools » > Click » Install » button:

Fig.02: Installing gcc compiler on Mac OS X

Step #3: Verification

Open a terminal app and type the following commands:
$ gcc —version
$ whereis gcc
$ whereis make
Sample outputs:

Fig.03: Verify gcc compiler installation on Mountain Lion OS X

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

Testing sample “Hello world” C program

Create a text file called a.c as follows using a text editor such as vi or cat command:

To compile, enter:
$ make a
Run it as follows:
$ ./a
Sample outputs:

Fig.04: Compiling and running sample “Hello world” C program on Mountain Lion 10.8.4

See also

And, there you have it, the gcc version 4.2.1 installed and working correctly on the latest version of Mac OS X 10.8.4. In Apple’s version of GCC, both cc and gcc are actually symbolic links to the llvm-gcc compiler. Similarly, c++ and g++ are links to llvm-g++. For more information and examples see the following man pages:

$ man gcc $ man make

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

There is no need to install huge xcode consumes gigabytes of disk space (if you are not a apple developer), just go to the apple’s developer page and download the “command line tool for xcode” package and install it, that would be just sufficient.

Isn’t GCC is LLVM with GCC support and many automake, m4 etc… project is not enable to build.

thank u very very very much you are really clever

THANK YOU SO MUCH. Everything else I tried didn’t seem to work. Finally this did.

Thank you very much. It worked.

I installed the Xcode Command Line Tools, and when I try to find gcc in the terminal
tell me this:

asaffeldman$ $gcc –version
-bash: –version: command not found

with 2 dashes and no $ in front of it
hope it helps!

Clear , efficient , thanks !

I have GCC 4.8.1 with x86, x86_64 and PPC on Lion with ObjC, C/C++11, Fortan, Ada Go support.
And now I can compile PHP, WxWidgets, QT and many other source without problems like on Apple Clang vesion. In xcode too.
Gcc builded with llvm-gcc-4.2.

i m doing the c programming on terminal my keyword is not highlited by compiler,
strstr function is not working why plz resolve my problm

hi
when I typed make a I got this message:
make: *** No rule to make target `a’. Stop.

please help me.
Thanks.

I got the same error when I didn’t spell the filename with the exact case.

Hi , I installed xcode and command line tools just as you said but when I try the command gcc –version I get this error
Error: could not stat active Xcode path ‘/Volumes/Xcode/Xcode.app/Contents/Developer’. (No such file or directory)

Is my xCode in the wrong place? It’s installed and under Applications, please help

I AM GETTING THIS ERROR IN XCODE WHILE I AM BUILDING A PROGRAM IN C++

I don’t have the Command Line option in my preference. Help!

Источник

Читайте также:  Ноутбук msi не запускается windows
Оцените статью