Main Content
Prevent Circular Data Dependencies with One-Pass or Single-Pass Linkers
Symptom: During a software build, a build error occurs; variables don't resolve correctly.
If your toolchain uses a one-pass or single-pass linker, prevent circular data
dependencies by adding the StartLibraryGroup
and
EndLibraryGroup
linker directives to the toolchain definition file. The
build process applies the grouping directives to model reference libraries
$(MODELREF_LIBS)
and user libraries $(LIBS)
.
For example, if the linker is like GNU gcc
, then the directives are
'-Wl,--start-group'
and '-Wl,--end-group'
, as shown
here:
% ------------------------------ % Linker % ------------------------------ tool = tc.getBuildTool('Linker'); tool.setName( 'GNU Linker'); tool.setCommand( 'gcc'); tool.setPath( ''); tool.setDirective( 'Library', '-l'); tool.setDirective( 'LibrarySearchPath', '-L'); tool.setDirective( 'OutputFlag', '-o'); tool.setDirective( 'Debug', '-g'); tool.addDirective( 'StartLibraryGroup', '-Wl,--start-group'); tool.addDirective( 'EndLibraryGroup', '-Wl,--end-group'); tool.setFileExtension( 'Executable', ''); tool.setFileExtension( 'Shared Library', '.so');