-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix TI C28x (C2000, etc.) support #13681
base: master
Are you sure you want to change the base?
Conversation
Is it really needed to have some
just before setting |
It appears so, unfortunately. These are excerpts from the Makefile generated by TI's IDE for the C28x family that shows the order: ...
ORDERED_OBJS += \
"./i2c_ex3_external_loopback.obj" \
"./device/F2837xD_CodeStartBranch.obj" \
"./device/device.obj" \
"../2837xD_RAM_lnk_cpu1.cmd" \
"/Users/REDACTED/ti/C2000Ware_5_03_00_00/driverlib/f2837xd/driverlib/ccs/Debug/driverlib.lib" \
$(GEN_CMDS__FLAG) \
-llibc.a \
...
# Tool invocations
i2c_ex3_external_loopback.out: $(OBJS) $(CMD_SRCS) $(LIB_SRCS) $(GEN_CMDS)
@echo 'Building target: "$@"'
@echo 'Invoking: C2000 Linker'
"/Applications/ti/ccs1271/ccs/tools/compiler/ti-cgt-c2000_22.6.1.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 -Ooff --define=DEBUG --define=CPU1 --diag_suppress=10063 --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi -z -m"i2c_ex3_external_loopback.map" --heap_size=0x200 --stack_size=0x3F8 --warn_sections -i"/Applications/ti/ccs1271/ccs/tools/compiler/ti-cgt-c2000_22.6.1.LTS/lib" -i"/Applications/ti/ccs1271/ccs/tools/compiler/ti-cgt-c2000_22.6.1.LTS/include" --reread_libs --define=RAM --diag_wrap=off --display_error_number --xml_link_info="i2c_ex3_external_loopback_linkInfo.xml" --entry_point=code_start --rom_model -o "i2c_ex3_external_loopback.out" $(ORDERED_OBJS)
@echo 'Finished building target: "$@"'
@echo ' ' The compiler args must come before the flag to run the linker, Before I fully commit to yes on this, I'll try building a few examples with the linker args after the in files but this family of compilers is very particular about the order of things, so I don't think it will work. |
@jpakkane It appears including the linker args after the in files does work despite The compiler args still need to be included before |
Summary
The purpose of this PR is to enable building for TI C28x targets with Meson without workarounds and un-mesonic ways.
I've looked through the implementation of the support for TI C28x currently in Meson and it appears workarounds have been used to avoid dealing with these issues directly, like including the arg
-llibc.a
to the linker args in the cross file for the MSP430 and using linker command files that can include the runtime support library rather than doing it the Mesonic way.The existing support for TI C28x cross compilation (C2000, C6000, etc.) omits the compiler args that are required to be included in the linker command for TI C28x and formats the names of static libs incorrectly. An example that demonstrates the issue has been created as a repo with a Docker image.
Compiler args not included in linker command
For example, the arg
--abi=eabi
is needed when compiling source files but also when linking since libraries being linked in and linker scripts have logic that depend on the macros set by the compiler / linker. If this arg is not included as a compiler arg when running the linker with the-z
flag, linking fails since the linker fails to confirm the ABI is correct for everything and the wrong elements are included in some places since the ABI-related macros aren't set.A conditional has been added to the
generate_link()
method to populate the Ninja$ARGS
variable with the compiler args when generating the linking command.Static lib names are formatted incorrectly
When linking in static libraries, the TI C28x family of compilers requires the full name of the static library be included rather than just the name of the library with the preceding
lib
and suffix removed.Currently, for the static lib
libc.a
with a TI C28x compiler, Meson adds the flag-lc
, with which linking fails because the linker doesn't find the lib. Also, the runtime support libraries for this family use a suffix of.lib
withoutlib
prepended to the name. The format needed is-llibc.a
for the linking command to work. When linking in a specific runtime support library rather than thelibc.a
index library, the arg needed is like this,-lrts2800_fpu32_eabi.lib
.Meson's
find_library()
finds the lib but the linker fails to find it because of the format of the arg added by Meson.Using Meson's
find_library()
fails, however, when trying to use it to find the runtime support libraries since they have a suffix of.lib
and no prefix.../src/meson.build:91:16: ERROR: C static library 'rts2800_fpu32_eabi' not found
TODO solution here.
Details
Populating the compiler args for TI C28x 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.An exception has been added to the
generate_link()
method of the Ninja backend to populate the$ARGS
Ninja variable for the linking rule when the linker ID iscl2000
,cl6000
, orti
.Exception added to
generate_link()
.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.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.Exceptions added to format static lib names correctly
TODO
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.