|
Symptom(s):
When you create a shared library linking libirc.a statically (for example using –i_static) and using –Bsymbolic your application gets stuck in an infinite loop in __intel_cpu_indicator_init.
Cause:
__intel_new_proc_init is linked into the executable (the a.out) since it is only called from main(). It initializes a global cpu data value variable "x". __intel_cpu_indicator_init is called from routines in the shared library (DSO) so it gets linked in there. It uses "x". Because -Bsymbolic prevents the DSO "x" from being preempted by the executable "x", the DSO has its own copy of "x" which never gets initialized so __intel_cpu_indicator_init goes into an infinite loop.
Solution:
This is a known issue that been resolved in 10.0 for both C/C++ and Fortran and in 9.1 starting with updates l_fc_c_9.1.040 and l_cc_c_9.1.045. The following workarounds can be applied for earlier compiler versions/updates.
See -Bsymbolic Can Cause Dangerous Side Effects for more information on the dangers of using -Bsymbolic.
Workarounds:
- Do not link libirc.a statically
icc my_func.c -o libmy_lib.so -Bsymbolic -shared
- Add libirc.a as one of the initial libraries to link in main
icc main.c -L. –lirc -lmy_lib -o main -i_static
- Make the symbols local with a version script by adding “-Xlinker --version-script -Xlinker version_script” to the link line. Where “version_script” looks like the following:
VERS_1.1 { local: _intel*; __intel*;};
This is done when the shared library (DSO) is built, not on every use of it.
Example Follows:
$ icc my_func.c -o libmy_lib.so [-Bsymbolic] -i_static -shared -Xlinker --version-script -Xlinker version_script $ icc main.c -L. -lmy_lib -o main -i_static $ cat version_script VERS_1.1 {local: _intel*;__intel*;};
For completeness, it is recommended you not use -Bsymbolic and instead do an nm on your library and all libraries that are linked in statically (can be found using the -dryrun compiler option) and make all of the symbols local that need to be that way.
This will also make your programs compile faster. Additionally, you could examine all of the interfaces of your source and add them as appropriate to various sections of the linker script. See "More Info on Linker Scripts" at the following location: http://sourceware.org/binutils/docs-2.18/ld/index.html
†

† This link will take you off of the Intel Web site. Intel does not control the content of the destination Web Site.
This applies to:
|