Fix TI C28x (C2000, etc.) support #13681
Open
+25
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The existing support for TI C28x cross compilation (C2000, C6000, etc.) produces the linker rule with the arguments in the incorrect order and omits the compiler args that are required to also be included in the linker command for TI C28x. An example that demonstrates the issue has been created as a repo with a Docker image.
An exception has been added to the
generate_dynamic_link_rules()
method of the Ninja backend to produce the rule with the args in the correct order for this linker. To populate the variables for the rule, an exception has also been added to thegenerate_link()
method.This is not the ideal way to do this but it works. Ideally, compilers and linkers would provide their own ordering of arguments to avoid hard-coding the order in the Ninja backend but I sought to fix the TI C28x support with minimal changes. A more durable solution would be to move the ordering of the elements of commands to the compiler and linker classes, so it gets injected into the generation of the rules.
Details
Generating the correct rule format for TI C28x linking
To produce the linking rule for TI C28x with the correct form, the
generate_dynamic_link_rules()
method of theNinjaBackend
class has been modified to switch forms when the linker ID iscl2000
,cl6000
, orti
.Original.
Exception added.
This exception produces the correct linker rule format for TI C28x.
This change, however, caused a bunch test failures because the
StaticLinker
class did not have aget_id()
method despite having anid
, so a method has been added that matches theDynamicLinker
class's method.Populating the $ARGS and $TI_C28X_STATIC_LIBS Ninja args in linking
I spent some time attempting to figure out how to get the compiler args into the
generate_link()
method but resorted to using the guts from thegenerate_compile_rules()
method ingenerate_link()
. I imagine there is a better way to do this but this got it working and I can go from here.Addition of method to get ID of static linkers
The changes initially caused many test failures due to the lack of the same method for getting the ID of dynamic linkers on the static linker base class. The same method,
get_id()
, has now been implemented on theStaticLinker
class, too, so the method can be used to identify the linker in places where the instance can be either type.Testing
All tests pass locally except a couple that appear related to my environment. I did not find unit tests for the Ninja backend methods but the CI is passing and I have verified this works successfully with a minimal cross build with C2000. I could provide a self-contained example as a Docker image, if needed, so the minimal example can be run by a reviewer.