2

I am building the same library (TI GBM) in two different build environments (buildroot and Yocto). The binaries from Yocto work, but the binaries from buildroot fail due to a segmentation fault. I compared the makefiles generated by autoconfig in the two build systems and noticed differences in the LDFLAGS.

Yocto:

LDFLAGS =  -L/home/kyle/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/lib -Wl,-rpath-link,/home/kyle/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/lib -Wl,-O1 -Wl,--hash-style=gnu

Buildroot:

LDFLAGS = 

How is Yocto adding these new linker directives to the makefile?

user8908459
  • 537
  • 5
  • 24

3 Answers3

1

What is Yocto doing to introduce these new linker directives into the build?

LDFLAGS are the linker options, if you are familiar with gcc and other command line compiler front-ends, make will internally call gcc in this fashion (Assuming c++ here):

g++ CPPFLAGS CXXFLAGS SOURCE_CODE LDFLAGS LDADD

Here is an example of how it would look like with the LDFLAGS you indicated in Yocto:

g++ -Wall -g -O3 -o output myfiles... -L/home/kyle/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/lib -Wl,-rpath-link,/home/kyle/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/lib -Wl,-O1 -Wl,--hash-style=gnu

As for what the meaning of the value of LDFLAGS

-L/home/kyle/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/lib -Wl,-rpath-link,/home/kyle/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/lib -Wl,-O1 -Wl,--hash-style=gnu` 

It means that:

  • Search libraries in directory:

    /home/kyle/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/lib

  • dynamically link libraries in the path: /home/kyle/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/lib

Vicente Bolea
  • 1,409
  • 16
  • 39
1

How is Yocto adding these new linker directives to the makefile?

Yocto is not actively doing anything -- it is the configure script that does the work. Its whole purpose is to analyze the system on which it runs to identify required tools, figure out appropriate flags, and determine the presence or absence of various system facilities. Having done so, it (generally) creates one or more Makefiles for you by filling in templates included with the program source. One of the things it fills in is a value for the LDFLAGS variable.

How configure chooses the flags it does depends in part on how it is written, and in part on how it is run. You can specify some variables on the configure command line or via its environment, and you can affect others via command-line options. Some of these can have a cascading effect. For example, the particular choice of LDFLAGS in your yocto environment is likely related to the C or C++ compiler that was chosen.

John Bollinger
  • 160,171
  • 8
  • 81
  • 157
0

When the configure script is run, it saves the values of some particular variables in the environment into the Makefile. LDFLAGS is one of those variables, called "precious variables."

ptomato
  • 56,175
  • 13
  • 112
  • 165