GCC multilib

Compiler comes with different versions of the same library. This support is known as compiler multilib supports. The compiler will choose a specific version of the targeted library depending upon the compiler options used to build source code.

Let’s see how compiler manages this multilib support:

Find out compiler version

$ arm-none-linux-gnueabi-gcc --version
arm-none-linux-gnueabi-gcc (Sourcery CodeBench 2015.12-159) 5.2.0
Copyright (C) 2015 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.

 

Find out supported multilibs

$ arm-none-linux-gnueabi-gcc -print-multi-lib
.;
armv4t;@march=armv4t
vfp;@mfloat-abi=softfp
be;@mbig-endian
vfp-be;@mfloat-abi=softfp@mbig-endian
armv7-a-neon;@march=armv7-a@mfloat-abi=softfp@mfpu=neon
armv7-a-hard;@march=armv7-a@mfloat-abi=hard@mfpu=neon
thumb2;@mthumb@march=armv7-a
thumb2-be;@mthumb@march=armv7-a@mbig-endian
thumb2-neon;@mthumb@march=armv7-a@mfloat-abi=softfp@mfpu=neon

Let’s take a single line of the information shown by the compiler to understand what’s going on
armv4t;@march=armv4t

Compiler will use libraries from the armv4t folder if source code is compiled using -march=armv4t.

armv7-a-hard;@march=armv7-a@mfloat-abi=hard@mfpu=neon

Compiler will use libraries from armv7-a-hard folder if source code is compiled using -march=armv7-a -mfloat-abi=hard -mfpu=neon.

You can also find out directory using another trick:

$ arm-none-linux-gnueabi-gcc -print-multi-directory -march=armv4t
armv4t

$ arm-none-linux-gnueabi-gcc -print-multi-directory -march=armv7-a -mfloat-abi=hard -mfpu=neon
armv7-a-hard

$ arm-none-linux-gnueabi-gcc --print-multi-directory -mthumb -march=armv7e-m -mfloat-abi=softfp -mfpu=vfpv3-d16
vfp

There are some options supported by GCC to play with multi-lib. https://gcc.gnu.org/onlinedocs/gccint/Target-Fragment.html (Look for MULTILIB_)

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s